Continue shopping: What's wrong with my logic

  • Posts: 139
  • Thank you received: 1
10 years 7 months ago #150871

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

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.

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.

  • Posts: 13201
  • Thank you received: 2322
10 years 7 months ago #150905

Hi,

To diplay the button only when the cart is empty, you can just use this if condition:

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.065 seconds
Powered by Kunena Forum