Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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?
the 'update product stock' shouldnt be there. when i try and edit the question i get an xslt error :-(
worked it out. I had to comment out this line from the basket.config
<!--<value>${Basket.ApplyAwards}</value>-->
Thanks for following up with the answer here.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
using PercentOffOrderTotalAward in cart.xslt
Im trying to write an xslt function that can apply a 10% discount to the order total when called:
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?
the 'update product stock' shouldnt be there. when i try and edit the question i get an xslt error :-(
worked it out. I had to comment out this line from the basket.config
<!--<value>${Basket.ApplyAwards}</value>-->
Thanks for following up with the answer here.
is working on a reply...