This post has been edited by Panthr: 28 July 2010 - 09:43 AM
Page 1 of 1
Editing cart items
#1
Posted 28 July 2010 - 09:17 AM
Is there a way I can edit the cart items through PHP? Change quantity, postpone, remove, etc.
#2
Posted 28 July 2010 - 09:50 AM
Sure there is.
Shop_Cart::remove_item($key, $cart_name = 'main')
Shop_Cart::set_quantity($key, $value, $cart_name = 'main')
Shop_Cart::change_postpone_status($values, $cart_name = 'main')
You should have a look at shop_cart.php in the modules/shop/classes - folder. To make use of them, you could set up a custom module and write some functions that can be accessed from the frontend via ajax-requests.
Best regards
Hauke
Shop_Cart::remove_item($key, $cart_name = 'main')
Shop_Cart::set_quantity($key, $value, $cart_name = 'main')
Shop_Cart::change_postpone_status($values, $cart_name = 'main')
You should have a look at shop_cart.php in the modules/shop/classes - folder. To make use of them, you could set up a custom module and write some functions that can be accessed from the frontend via ajax-requests.
Best regards
Hauke
#4
Posted 29 July 2010 - 01:00 AM
Yes, that is true. It think it would be a good idea, though. It would make the API more complete!
#5
Posted 29 July 2010 - 02:15 AM
Hi, guys!
Hauke, thanks a lot for the help. It was the Release Day today and I had no chance to process the support queries. But you managed without me :-) I will add the Shop_Cart methods to the documentation.
Thank you!
Hauke, thanks a lot for the help. It was the Release Day today and I had no chance to process the support queries. But you managed without me :-) I will add the Shop_Cart methods to the documentation.
Thank you!
#6
Posted 29 July 2010 - 10:10 AM
I was doing some coding, and stumbled across a couple of bugs with Shop_Cart::find_by_product_sku():
/modules/shop/classes/shop_cart.php line 61: Need to add $cart_name = 'main'
Line 68: Change $items to $item
Which brings about another question: is find_by_product_sku() the best way to find a specific product in a cart?
/modules/shop/classes/shop_cart.php line 61: Need to add $cart_name = 'main'
Line 68: Change $items to $item
Which brings about another question: is find_by_product_sku() the best way to find a specific product in a cart?
This post has been edited by Panthr: 29 July 2010 - 10:13 AM
#7
Posted 29 July 2010 - 03:07 PM
Hi!
There was a bug in the find_by_product_sku method. We added this method only recently and nobody actually used it before. I just fixed the bug and published the update.
As you may know LemonStand supports multiple shopping carts, so the second (optional) argument of the find_by_product_sku method is the cart_name. The default cart name is "main" and you can omit this parameter if you do not use multiple carts.
Yes, this method is the best for finding products in the cart. Please note that it returns an array of Shop_CartItem objects, not a single object. This is because there could be different cart items which correspond to a single product. For example, if there is a t-shirt with 2 color options - blue and red. There will be 2 items in the cart, referring to a single product, but with different options.
Thank you
There was a bug in the find_by_product_sku method. We added this method only recently and nobody actually used it before. I just fixed the bug and published the update.
As you may know LemonStand supports multiple shopping carts, so the second (optional) argument of the find_by_product_sku method is the cart_name. The default cart name is "main" and you can omit this parameter if you do not use multiple carts.
Yes, this method is the best for finding products in the cart. Please note that it returns an array of Shop_CartItem objects, not a single object. This is because there could be different cart items which correspond to a single product. For example, if there is a t-shirt with 2 color options - blue and red. There will be 2 items in the cart, referring to a single product, but with different options.
Thank you
Share this topic:
Page 1 of 1

Help














