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.

  • Phil Crowe 192 posts 256 karma points
    Oct 01, 2012 @ 15:08
    Phil Crowe
    0

    using PercentOffOrderTotalAward in cart.xslt

    Im trying to write an xslt function that can apply a 10% discount to the order total when called:

     public void AddVoucherCode(string voucherCode, string orderGuid)
            {
                PercentOffOrderTotalAward percentOffTotal = new PercentOffOrderTotalAward()
                {
                    Name = "Voucher Discount",
                    PercentOff = 10.00M
                };
                List<PurchaseOrder> orderList = PurchaseOrder.All().ToList();
                PurchaseOrder currentOrder = null;
                foreach (PurchaseOrder order in orderList)
                {
                    if (order.OrderGuid.ToString() == orderGuid)
                    {
                        currentOrder = order;
                        //update product stock
                        foreach (OrderLine orderLine in order.OrderLines)
                        {
                            string pSku = orderLine.Sku;
                            Product product = Product.All().Where(x => x.Sku == pSku && x.ParentProductId == null).Single();
                            //save the updates quantity for this product 
                            product["InventoryOnHand"].Value = (Convert.ToInt32(product["InventoryOnHand"].Value) - orderLine.Quantity).ToString();
                            //Response.Write("sku: " + product.Sku + " qu: " + product["InventoryOnHand"].Value);
                        }
                        break;
                    }
                }
                List<OrderLine> purchaseOrderLines = new List<OrderLine>();
                foreach (OrderLine line in currentOrder.OrderLines)
                {
                    purchaseOrderLines.Add(line);
                }
                //percentOffTotal.Apply(currentOrder, purchaseOrderLines);
            }

    I get an object reference not set to an instance of object error when i try to apply the discount. is this the correct way to apply?


  • Phil Crowe 192 posts 256 karma points
    Oct 01, 2012 @ 15:21
    Phil Crowe
    0

    the 'update product stock' shouldnt be there. when i try and edit the question i get an xslt error :-(

  • Phil Crowe 192 posts 256 karma points
    Oct 01, 2012 @ 18:22
    Phil Crowe
    1

    worked it out. I had to comment out this line from the basket.config

     

    <!--<value>${Basket.ApplyAwards}</value>-->

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 10, 2012 @ 08:51
    Søren Spelling Lund
    0

    Thanks for following up with the answer here.

Please Sign in or register to post replies

Write your reply to:

Draft