Order total (price) does not updates, afeter order has beed eddited (add/remove products)
I'm currently working on the project where we have custom admin part which should do changes in user order (add/remove order lines).
I try this:
UCommerce.EntitiesV2.PurchaseOrder order = UCommerce.EntitiesV2.PurchaseOrder.Get(int.Parse(orderId)); var ol = order.OrderLines.Single(x => x.Sku == sku); order.RemoveOrderLine(ol); order.Save();
what do you mean click to save button ? I told I do not use ucommerce admin, I have own admin side with possibility edite orders. but after edititng order in this custom admin side, order total has wrong value.
Could you provide me how can I add/remove orderlines without current basket and then recalculate order total?
My admin part (for your understanding how it looks like):
I did:
Basket bask = SiteContext.Current.OrderContext.GetBasket(true);
//previos line for having some basket, without basket Library.ExecuteBasketPipeline(); does not work
Product product = Product.All().FirstOrDefault(x => x.Sku == sku);
order.AddProduct(product.PriceGroupPrices.ToList()[0].PriceGroup, product, 1);
Library.ExecuteBasketPipeline();
order.Save();
but after that in ucommerce admin I see:
the total price of added products is 0, how I can solve it, plz help me ?
If you want to create the order manually you can provide the context to the basket pipeline manually as well:
var order = SiteContext.Current.OrderContext.GetBasket(true).PurchaseOrder; var basketPipeline = PipelineFactory.Create<PurchaseOrder>("Basket"); basketPipeline.Execute(order);
Order total (price) does not updates, afeter order has beed eddited (add/remove products)
I'm currently working on the project where we have custom admin part which should do changes in user order (add/remove order lines).
I try this:
but this code does not add anything to order.
I tried to add some basket:
but after that in ucommerce admin (not my custom admin) I can see that order total does not update.
If I add this line without basket:
it returns error;
How can I add/remove orderlines and update order total without current member and without basket (in custom admin part).
or how can I create member basket for admin, or how can I get user basket?
Thx!
Hi Sergio, i'm not sure what you're trying to achieve here.
Baskets and orders are the same thing. Basket can be searched by using the search node.
You can add or remove order lines out of the box.
What version of uCommerce are you using?
The green button adds an orderline and the red crosses on each order line will remove them. You don't need custom code for that.
Hi Morten Skjoldager , thx for quick answer!
I use uCommerce v6.
I need to remove/add products outside of ucommerce admin.
Could you give me source code, how can I get basket by memberId (I do not have logedin member) or by order?
I have just figured out that I can get basket by:
but after thet I can't exequteYou cannot set current basket inside the backend in that way. It is handeled by a querystring.
You should not execute basket pipeline in the backend. There's a save order pipeline for that, that will fire when you click the save button.
You can get an order by looking at the MemberId of the customer on the order. But you will get multiple orders. Something like this:
PurchaseOrder.Where(x => x.Customer.MemberId == memberId).ToList(); You should then redirect the backend to have the right id:
/umbraco/uCommerce/orders/EditOrder.aspx?id={the_id_you_want_to_redirect_to}
what do you mean click to save button ? I told I do not use ucommerce admin, I have own admin side with possibility edite orders. but after edititng order in this custom admin side, order total has wrong value.
Could you provide me how can I add/remove orderlines without current basket and then recalculate order total?
My admin part (for your understanding how it looks like):
I did:
but after that in ucommerce admin I see:
the total price of added products is 0, how I can solve it, plz help me ?
Hi Sergio,
If you want to create the order manually you can provide the context to the basket pipeline manually as well:
This should update the totals for you.
is working on a reply...