Preferred shipping method for a product

Posted by Community Admin on 05-Aug-2018 09:10

Preferred shipping method for a product

All Replies

Posted by Community Admin on 26-Jun-2012 00:00

Hi all,

I was wondering if it is possible to set a preferred (specific?!) shipping method per product? One of our customers offers a variety of products, which include some books (shippingcosts based on weight) and some boardgames (shippingcosts are fixed because of productsize).

At the moment a visitor who orders a copy of a boardgame will be presented with two different shippingmethods when in checkout; the weight-based method and the fixed-price method. Obviously a visitor will select the weight-based method, since it's cheaper than the fixed price. What should I do in this case?

Thanks already for reading this thread. I'm looking forward to any possible solution!

Regards,
Menno

Posted by Community Admin on 26-Jun-2012 00:00

Hey Menno,

Although there's a setting to change sort order for Shipping BackendViews (admin>> advanced>> shipping>> controls>> shippingbackenddefinition>> views>> Shippingbackendmaster> sort expression), unfortunately there isn't for FrontEnd. But even if there was, it wouldn't solve your problem...

By playing around with the shipping service you'll notice that you can't sort on 'ShippingPriceToDisplay' field and then still a percentage based value will only output the percentage, not the actual end cost.

(  The Firefox RESTClient plugin is awesome for this
1. login to your sitefinity backend (so your browser will be authenticated)
2. Click on the RESTClient icon and type in the url:  yoursitename/.../  

So the only option seemed left is to custom drop the payment methods in, 'manually' sorted and or 'filtered' by you. You could use a snippet like this to retrieve them: 
private void GetShippingOptions()
  var availableShippingMethods = new List<IShippingResponse>();
  
  foreach (var shippingCarrier in Config.Get<ShippingConfig>().ShippingCarrierProviders.Values.Where(x => x.IsActive))
  
    var carrierProvider = this.ShippingManager.GetShippingCarrierProvider(shippingCarrier.Name);
  
    ShippingResponseContext shippingContext = carrierProvider.GetServiceRates(this.GenerateShippingRequest());
    if (shippingContext.ShippingResponses != null)
    
      availableShippingMethods.AddRange(shippingContext.ShippingResponses);
    
  
  
  availableShippingMethods = availableShippingMethods.OrderBy(x => x.SortOrder).ToList();
  shippingMethodsList.DataSource = availableShippingMethods;
  shippingMethodsList.DataBind();

And then use 'ShippingPrice' to further filter out and sort them.
For instance "quantity|2|5|5" vs "fixedPercentage|||10" so they wouldn't even show up if the products in the order are from a specific type.

Jochem

This thread is closed