1999 Posts in 530 Topics by 433 members
E-Commerce Modules
SilverStripe Forums » E-Commerce Modules » Removing all products from Shopping Card
Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.
Moderators: martimiz, Nicolaas, Howard, Sean, Ryan M., biapar, Willr, Ingo, Jedateach, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 882 Views |
-
Removing all products from Shopping Card

1 August 2009 at 3:38am Last edited: 3 August 2009 10:14pm
Hello
I've got small issue,
I'm preparing my Shopping Card for selling only one product variation in one time.
My product page is only a holder and I don't have there any code like "adding product to" or "remove product from" Shopping Card, just only adding product variations, so I've got there only links like:product_name/addVariation/ID-product-variation
after clicking link like that, product variation is added to Shopping Card and customer is redirected to checkout . I've added at the end of function addVariation() this code :
Director::redirect('checkout/');Before doing that, I want to make sure, Shopping Card is empty, so I've tried to add some code at the beginning of this function.
I've checked :
ShoppingCart::clear();
Product_OrderItem::removeallLink();
ShoppingCart::remove_all_items();
ShoppingCart::remove_all_modifiers();But without any positive results. If I go back on other product variations, and I put it on Shopping Card, at checkout page I've got another position, not just the last one.
Could somebody help me and tell me, which function I need to use in this case, to make sure, I have just one product Variation on the checkout page? I don't understand some of this code from ecommerce module, so any reply will be very helpfull for me.
-
Re: Removing all products from Shopping Card

4 August 2009 at 11:01pm Last edited: 4 August 2009 11:01pm
Hmmmm.
Is it really so complicated, that nobody can't answer for my question? ;-)
-
Re: Removing all products from Shopping Card

4 September 2009 at 10:56pm
Could anybody help me with this issue?
-
Re: Removing all products from Shopping Card

4 September 2009 at 11:06pm
Not tested, but maybe it works if you add :
self::clear();
in ShoppingCart.php function add_new_item()
static function add_new_item(OrderItem $item) {
$itemsTableIndex = self::items_table_name();
self::clear(); //added
if($serializedItems = Session::get($itemsTableIndex)) {
foreach($serializedItems as $itemIndex => $serializedItem) {
if($serializedItem != null) {
$unserializedItem = unserialize($serializedItem);
if($unserializedItem->hasSameContent($item)) return self::add_item($itemIndex, $item->getQuantity());
}
}
}
self::set_item($item->getProductID(), $item);
} -
Re: Removing all products from Shopping Card

5 September 2009 at 12:44am
Well, it could be good idea, for me it should be worked, but nothing changed.
I don't know why this ShoppingCard::clear() function doesn't work in any way. For example, I've still got two ProductVariaton items from two different products in the checkout.
If I go back and change Product Variation items from one product, it's replacing the first one item, but another product variation is still in the basket.It's very, very strange, and I don't know, why it's happening in this way and what wrong I'm doing.
Thanks for help Martijn.
| 882 Views | ||
|
Page:
1
|
Go to Top |


