Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Mar 13, 2013 @ 14:47
    Marc Love (uSkinned.net)
    0

    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

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Mar 13, 2013 @ 16:06
    Marc Love (uSkinned.net)
    100

    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;
    }

Please Sign in or register to post replies

Write your reply to:

Draft