Skip to main content

Check if cart is empty in plugin

More
11 years 6 months ago #192854 by FilipHradil
-- HikaShop version -- : 2.3.5

Hello,

please I need to check if a cart is empty in my plugin (onBeforeCartUpdate)
I tried everything but I didn't succeed.

Many thanks!
Filip

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

More
11 years 6 months ago #192858 by Jerome
Hi,

www.hikashop.com/support/support/documen...l#onBeforeCartUpdate

As you can see in the documentation, the $cart contains the future new cart.
So if you want the old cart, the best is to load it using the $cartClass ; like calling "$cartClass->loadCart()"

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

More
11 years 6 months ago #192946 by FilipHradil
Thank you!
So how can I check number of items in cart, or whether is empty?
Thanks

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

More
11 years 6 months ago #193082 by Xavier
Hi,

To check the content of the old cart, you can do:
Code:
$cartClass = hikashop_get('class.cart'); $oldCart = $cartClass->get(); if(!empty($oldCart)){ //... }

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

More
11 years 6 months ago #193170 by FilipHradil
Hello Xavier,

that is exacly what I needed.
Thanks you!

Filip

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

Time to create page: 0.170 seconds
Powered by Kunena Forum