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.

  • sergio 10 posts 50 karma points
    Jul 07, 2014 @ 17:53
    sergio
    0

    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();

    but this code does not add anything to order.

    I tried to add some basket:

    Basket bask = SiteContext.Current.OrderContext.GetBasket(true);

    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:

    Library.ExecuteBasketPipeline();

    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!

  • Morten Skjoldager 440 posts 1499 karma points
    Jul 08, 2014 @ 09:39
    Morten Skjoldager
    0

    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.

  • sergio 10 posts 50 karma points
    Jul 08, 2014 @ 10:29
    sergio
    0

    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:

    UCommerce.EntitiesV2.PurchaseOrder order = UCommerce.EntitiesV2.PurchaseOrder.Get(int.Parse(orderId));
    Basket b = new Basket(order);
     but after thet I can't exequte
    Library.ExecuteBasketPipeline();


    So I also have to set it as current basket
    SiteContext.Current.OrderContext
  • Morten Skjoldager 440 posts 1499 karma points
    Jul 08, 2014 @ 12:36
    Morten Skjoldager
    0

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

  • sergio 10 posts 50 karma points
    Jul 08, 2014 @ 12:45
    sergio
    0

    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 ?

     

     

  • Søren Spelling Lund 1797 posts 2786 karma points
    Aug 12, 2014 @ 11:58
    Søren Spelling Lund
    0

    Hi Sergio,

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

    This should update the totals for you.

Please Sign in or register to post replies

Write your reply to:

Draft