Check if cart is empty in plugin

  • Posts: 217
  • Thank you received: 4
9 years 8 months ago #192854

-- 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.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
9 years 8 months ago #192858

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.

  • Posts: 217
  • Thank you received: 4
9 years 8 months ago #192946

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.

  • Posts: 13201
  • Thank you received: 2322
9 years 8 months ago #193082

Hi,

To check the content of the old cart, you can do:

$cartClass = hikashop_get('class.cart');
$oldCart = $cartClass->get();
if(!empty($oldCart)){
  //...
}

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

  • Posts: 217
  • Thank you received: 4
9 years 8 months ago #193170

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