Problem with Cart ID on new Cart...

  • Posts: 23
  • Thank you received: 0
13 years 7 months ago #13423

Hi everybody, Hi Nicolas!
Got this problem... from this code:

$cartClass = hikashop::get('class.cart');

if(!($cartClass->hasCart())){
$cartClass->initCart();
}

$currentCartId = $cartClass->cart->cart_id;



Well, if I have to instance a new cart, entering the IF clause, I get an ID (for example: 230)
while if a Cart already exist, for example the second time I add a product to the cart i created before, I get the ID + 1 (for example: 231).
From the third time on I get always the "right" ID that is the same as the second (for example: 231)

Any ideas??!
Cheers

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 7 months ago #13472

Hi,

I don't understand why you have such code ?

There is no such code in hikashop.

We never initialize the cart from the outside of the cart class because when we call the update function of that class to add/modify a product in it, the cart is initialized automatically.

you should not have the code:
if(!($cartClass->hasCart())){
$cartClass->initCart();
}

but just:
$cartClass->initCart();

like in the update function.

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

Time to create page: 0.059 seconds
Powered by Kunena Forum