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.

  • Søren Erland Vestø 19 posts 42 karma points
    Aug 31, 2012 @ 11:08
    Søren Erland Vestø
    0

    Default shipping method

    I would like to have a default shipping method selected from the moment I put a product in the basket.

    In my "Add to basket"-macro I run the following code:

    if ( !SiteContext.Current.OrderContext.HasBasket )
    {
        var newbasket = SiteContext.Current.OrderContext.NewBasket(catalog.PriceGroup.Currency);
    
        // Select default shipment method
        var shippingMethod = SiteContext.Current.OrderContext.GetAvailableShippingMethods().FirstOrDefault();
        TransactionLibrary.EditShipmentInformation("shipping", "", "", "", "", "", "", "", "", "", "", "", "", Country.All().First().CountryId);
        newbasket.PurchaseOrder.CreateShipment(shippingMethod, newbasket.PurchaseOrder.GetShippingAddress("shipping"), true);
    }
    
    var basket = SiteContext.Current.OrderContext.GetBasket();
    
    var order = SiteContext.Current.OrderContext.GetBasket().PurchaseOrder;
    var orderline = order.AddProduct(catalog, product, quantity, true);
    
    var shipment = basket.PurchaseOrder.Shipments.First();
    shipment.AddOrderLine(orderline);
    
    PipelineFactory.Create<PurchaseOrder>("basket").Execute(basket.PurchaseOrder);
    TransactionLibrary.ExecuteBasketPipeline();
    
    Upon inspection of the basket the ShippingMethod seems to be chosen and the shipping fee is correct. BUT it seems to discount the entire fee (screenshot of PurchaseOrder watch window):
    How do I correctly programatically choose a default shipment method AND get the fee included in basket total?
  • Søren Spelling Lund 1797 posts 2786 karma points
    Sep 03, 2012 @ 15:02
    Søren Spelling Lund
    0

    Per default we roll out a default marketing campaign which provides free shipping for orders over a certain amount. Disable that under the Marketing node and the discount will disappear upon rerunning the basket pipeline.

  • Søren Erland Vestø 19 posts 42 karma points
    Sep 03, 2012 @ 15:24
    Søren Erland Vestø
    0

    Only place I hadn't looked. :-)

    Perfect, thank you.

Please Sign in or register to post replies

Write your reply to:

Draft