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
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 25854
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
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Posts: 25854
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. Alle Rechte vorbehalten
Durch die Nutzung dieser Website stimme ich zu, dass Cookies zur optimalen Gestaltung der Website sowie zur Analyse der Nutzung der Website verwendet werden. Weiterführende Informationen finden Sie hier. OK, einverstanden.