- Posts: 217
- Thank you received: 4
How to get cart count in php module
- FilipHradil
-
Topic Author
- Offline
Less
More
7 years 11 months ago #298897
by FilipHradil
How to get cart count in php module was created by FilipHradil
-- HikaShop version -- : 4.0.
-- Joomla version -- : 3.8.13
Hello,
on my website I developed with your help simple module that says coun of products in cart:
But after update of Hikashop it doesn't work anymore. Please, could you tell how to get variable with cart count in custom module?
I know it can be done with your plugin, but for my needs I need this solution.
Thank you in advance for your time!
-- Joomla version -- : 3.8.13
Hello,
on my website I developed with your help simple module that says coun of products in cart:
Code:
$cartClass = hikashop_get('class.cart');
$oldCart = $cartClass->get();
if(!empty($oldCart)){
.....
}
But after update of Hikashop it doesn't work anymore. Please, could you tell how to get variable with cart count in custom module?
I know it can be done with your plugin, but for my needs I need this solution.
Thank you in advance for your time!
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
7 years 11 months ago #298915
by Mohamed Thelji
Replied by Mohamed Thelji on topic How to get cart count in php module
Hello,
You'll just have to calculate product quantity in the $oldCart->cart_products variable, using the following code will probably do the job :
Kind regards,
Mohamed Thelji.
You'll just have to calculate product quantity in the $oldCart->cart_products variable, using the following code will probably do the job :
Code:
$cartClass = hikashop_get('class.cart');
$oldCart = $cartClass->get(0);
$cart_count = 0;
if(!empty($oldCart)){
foreach($oldCart->cart_products as $cart_product){
$cart_count += $cart_product->cart_product_quantity;
}
}
echo 'cart count : '. $cart_count;
Kind regards,
Mohamed Thelji.
Please Log in or Create an account to join the conversation.
- FilipHradil
-
Topic Author
- Offline
Less
More
- Posts: 217
- Thank you received: 4
7 years 11 months ago - 7 years 11 months ago #298952
by FilipHradil
Replied by FilipHradil on topic How to get cart count in php module
Hello,
Thank you.
I only add this code from old extension:
Is that okay?
And it works!
Thank you,
Filip
Thank you.
I only add this code from old extension:
Code:
$hikashopHelper = rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_hikashop'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php';
if(!file_exists($hikashopHelper) || !include_once($hikashopHelper))
return;
And it works!
Thank you,
Filip
Last edit: 7 years 11 months ago by Jerome. Reason: [code] tag is nice
Please Log in or Create an account to join the conversation.
7 years 11 months ago #298954
by nicolas
Replied by nicolas on topic How to get cart count in php module
Hi,
Yes it's ok !
Yes it's ok !
Please Log in or Create an account to join the conversation.
Time to create page: 0.173 seconds