Skip to main content

Continue shopping: What's wrong with my logic

More
12 years 5 months ago #150871 by abasel
I want to add a continue shopping button when the cart is empty. I found the place in Product > Cart that I think does this ie
Code:
if(empty($desc) && $desc != '0'){ $this->params->set('msg',$emptyText);

I then added the custom code that does the job fine but alas is shows the button weather or not the $emptyText is displayed. I would have thought that as it is nested in the if statement that appears to control the display of "The Cart is empty" that it would only appear when that does, and not all the time.

Code:
if(empty($desc) && $desc != '0'){ $this->params->set('msg',$emptyText); $config =& hikashop_config(); $continueShopping = $config->get('continue_shopping', ''); if(!empty($continueShopping)) { global $Itemid; $url_itemid=''; if(!empty($Itemid)){ $url_itemid='&Itemid='.$Itemid; } if(strpos($continueShopping,'Itemid') === false) { if(strpos($continueShopping,'index.php?') !== false) { $continueShopping .= $url_itemid; } } if(!preg_match('#^https?://#',$continueShopping)) $continueShopping = JURI::base().ltrim($continueShopping,'/'); echo '<div style="float: right;">'.$this->cart->displayButton(JText::_('CONTINUE_SHOPPING'),'continue_shopping',$this->params,JRoute::_($continueShopping),'window.location=\''.JRoute::_($continueShopping).'\';return false;','id="hikashop_checkout_shopping_button"').'</div>'; } }

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #150905 by Xavier
Hi,

To diplay the button only when the cart is empty, you can just use this if condition:
Code:
if(empty($this->rows)){ // display the button }
The following user(s) said Thank You: abasel

Please Log in or Create an account to join the conversation.

Time to create page: 0.161 seconds
Powered by Kunena Forum