- Posts: 23
- Thank you received: 0
Problem with Cart ID on new Cart...
- luciomonter
-
Topic Author
- Offline
Less
More
15 years 5 months ago #13423
by luciomonter
Problem with Cart ID on new Cart... was created by luciomonter
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
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.
15 years 5 months ago #13472
by nicolas
Replied by nicolas on topic Re: Problem with Cart ID on new Cart...
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.
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.144 seconds