Display cart button only when it has a product

23.10.2014 13:31
#1
Jobos1
Joomshopping forum user no avatar
Name: J
07.10.2014
Posts: 30
Quote
Display cart button only when it has a product

Hello!

I want to display a cart button, but only when there is already a product in the cart. How can I load this inside the index.php of my template file?

I found an entry in the web and tried already with

$countprod = count($this->products);

$jshopConfig = JSFactory::getConfig();

JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_jshopping/models');

$cart = JModelLegacy::getInstance('cart', 'jshop');
$cart->load("cart");

if ($countprod>0) {

// CART BUTTON SHOULD BE DISPLAYED

}

 
23.10.2014 15:15
#2
webdesigner
(Support Team)
User webdesigner
Name: Admin
05.08.2010
Posts: 16517
Quote
Aw: Display cart button only when it has a product

$jshopConfig = JSFactory::getConfig();

JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_jshopping/models');

$cart = JModelLegacy::getInstance('cart', 'jshop');
$cart->load("cart");

$countprod = count($cart->products);
if ($countprod>0) {

// CART BUTTON SHOULD BE DISPLAYED

}

 
23.10.2014 15:27
#3
Jobos1
Joomshopping forum user no avatar
Name: J
07.10.2014
Posts: 30
Quote
Aw: Display cart button only when it has a product

If I use this and open a page which is not a shop page, there is a big display issue; the half of the page is not loaded.

Only when I am on jshop pages it is loading correctly..

 
23.10.2014 16:23
#4
webdesigner
(Support Team)
User webdesigner
Name: Admin
05.08.2010
Posts: 16517
Quote
Aw: Display cart button only when it has a product

require_once (JPATH_SITE.'/components/com_jshopping/lib/factory.php');
require_once (JPATH_SITE.'/components/com_jshopping/lib/functions.php');
JSFactory::loadCssFiles();
JSFactory::loadLanguageFile();
$jshopConfig = JSFactory::getConfig();

.....
......

 
23.10.2014 19:19
#5
Jobos1
Joomshopping forum user no avatar
Name: J
07.10.2014
Posts: 30
Quote
Aw: Display cart button only when it has a product

Thank you very much, perfect!

 
Copyrights MAXXmarketing GmbH. All Rights Reserved