There seems to be a bug with trying to remove vouchers when clearing the users cart/basket.
Scenario
User adds a product to the cart/basket, then from within the cart applys a discount code/voucher. This gets applied and we can see it on the purchase order (And the discount for the order in the database).
The user then decides they don't want the product, so empties their basket. We now need to remove the discounts as well as the products. We are currently doing this to remove the discounts
foreach (var discount in discounts)
{
basket.PurchaseOrder.RemoveDiscount(discount);
}
basket.Save();
ExecuteBasketPipeline();
Using the debugger we can see the discounts are removed from the database once the basket.Save() method is called.
But after ExecuteBasketPipeline() they magically reappear BACK in the database (Back on the order too). We have the standard Basket pipeline config. And after trial and error of commenting out each line, we have narrowed it down to this pipeline task
ApplyAwards
If we comment this out then it works fine. BUT if we comment this out then we won't be able to use the marketing foundation for other campaigns that auto discount the order.
Slight tearing our hair out here... Especially as there is pretty much NO REAL documentation for this...
Thanks for the reply. I'll have a look at that now :)
We 'could' just abandon the basket and give them a new one. But we want the users to be able to also add a voucher, then remove it if they want. But it's rather clunky to make the user abandon/empty their cart to remove the voucher.
Unable To Clear Vouchers From Basket
There seems to be a bug with trying to remove vouchers when clearing the users cart/basket.
Scenario
User adds a product to the cart/basket, then from within the cart applys a discount code/voucher. This gets applied and we can see it on the purchase order (And the discount for the order in the database).
The user then decides they don't want the product, so empties their basket. We now need to remove the discounts as well as the products. We are currently doing this to remove the discounts
Using the debugger we can see the discounts are removed from the database once the basket.Save() method is called.
But after ExecuteBasketPipeline() they magically reappear BACK in the database (Back on the order too). We have the standard Basket pipeline config. And after trial and error of commenting out each line, we have narrowed it down to this pipeline task
ApplyAwards
If we comment this out then it works fine. BUT if we comment this out then we won't be able to use the marketing foundation for other campaigns that auto discount the order.
Slight tearing our hair out here... Especially as there is pretty much NO REAL documentation for this...
If my memory serves me right, vouchers are saved as orderproperties (can't test that right now). Try clearing that list too :)
Is there a reason why you are not giving the customer a new basket (to avoid the hassle of clearing all the parameters)?
Thanks for the reply. I'll have a look at that now :)
We 'could' just abandon the basket and give them a new one. But we want the users to be able to also add a voucher, then remove it if they want. But it's rather clunky to make the user abandon/empty their cart to remove the voucher.
Maybe this could solve that problem:
(uCommerceHelpers.CurrentHelper is custom incase you wonder. Just use SiteContext to grab the basket)
You were right. We cleared the voucherCodes property and it worked fine! Thanks :)
is working on a reply...