My client
is going to be using voucher codes. I need to be able to apply
these in conjunction with other offers which I can do using the ‘Allow
additional discounts if this discount is awarded’ checkbox.
My issue is
that there is going to be a lot of different voucher codes offering different
percentages off the order total. I don’t want users to be able to apply more
than one voucher code to their basket so I need to check if any other voucher
codes have been applied to the basket before the voucher code is applied.
Applying Voucher Codes to Basket
My client is going to be using voucher codes. I need to be able to apply these in conjunction with other offers which I can do using the ‘Allow additional discounts if this discount is awarded’ checkbox.
My issue is that there is going to be a lot of different voucher codes offering different percentages off the order total. I don’t want users to be able to apply more than one voucher code to their basket so I need to check if any other voucher codes have been applied to the basket before the voucher code is applied.
Is there a quick way I can do this in code?
Cheers,
Marc
Sorted for now with a bit of a hack, check if campaign already applied starting with the word voucher, if found wont apply again:
Basket basket = SiteContext.Current.OrderContext.GetBasket();
PurchaseOrder order = basket.PurchaseOrder;
int liPreviousDiscountCount = order.Discounts.Count();
ICollection<Discount> discounts = order.Discounts.Where(x => x.CampaignItemName.ToLower().StartsWith("voucher")).ToList();
Boolean lbDiscountAdded = false;
if (!discounts.Any())
{
MarketingLibrary.AddVoucher(txtVoucherCode.Text);
TransactionLibrary.ExecuteBasketPipeline();
lbDiscountAdded = order.Discounts.Count() > liPreviousDiscountCount;
}
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.