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?
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.
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:
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.
Only place I hadn't looked. :-)
Perfect, thank you.
is working on a reply...