Seems that the default ship method display in OPC is ALWAYS a dropdown field.
Does anyone have code to change this display to radio buttons and show all options available to the customer in a single view?
EITHER THAT or a handy way to have the ShipMethods obey the order set in the Admin controls? We believe we're losing orders because the first shipping price displayed is too expensive.... we need to show customers better pricing on shipping.
Thanks!
Steve
GetShipMethods -- Sorting in OPC
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: GetShipMethods -- Sorting in OPC
Interested in this as well.
-
- Commodore (COMO)
- Posts: 436
- Joined: Tue May 07, 2013 1:59 pm
Re: GetShipMethods -- Sorting in OPC
Disclaimer: I don't use OPC and I haven't tried this, it is just an educated guess. Using GOLD R12.
In OPC.aspx.cs, after building the rateQuotes collection on line 508:
add a line to sort rateQuotes from lowest to highest:
To get the order specified in Admin, you'd have to get the corresponding record from the ShipMethods table and look at the OrderBy field to put them in the correct order.
Another option, if you have the source, is to modify the QuoteForShipment method in \Services\ShipRateQuoteCalculator.cs to sort it's shipMethods list on the OrderBy field before looping through them.
In OPC.aspx.cs, after building the rateQuotes collection on line 508:
Code: Select all
ICollection<ShipRateQuote> rateQuotes = shippingCalculator.QuoteForShipment(shipment);
Code: Select all
rateQuotes.OrderBy(q => q.TotalRate)
Another option, if you have the source, is to modify the QuoteForShipment method in \Services\ShipRateQuoteCalculator.cs to sort it's shipMethods list on the OrderBy field before looping through them.
Jay
Re: GetShipMethods -- Sorting in OPC
Hello Jay --
I appreciate the effort, but that doesn't appear to be working.
I've tested on the OPC pages, but the page breaks when attempting to load.
I wasn't sure if this was placed correctly -- You had entered on line 509, in the "recalculate" section... as if this should only have triggered when the basket changes. We want this when the list of rates first populates...
Any additional thoughts?
I appreciate the effort, but that doesn't appear to be working.
I've tested on the OPC pages, but the page breaks when attempting to load.
I wasn't sure if this was placed correctly -- You had entered on line 509, in the "recalculate" section... as if this should only have triggered when the basket changes. We want this when the list of rates first populates...
Any additional thoughts?
-
- Commodore (COMO)
- Posts: 436
- Joined: Tue May 07, 2013 1:59 pm
Re: GetShipMethods -- Sorting in OPC
Sorry, I forgot the semi-colon at the end of the line of code I posted.
I figured it probably used the same code to calculate the rates on first load and when the basket changes.
I hadn't tried it before, but I tried the unchanged OPC page on my test server now, and when the page loaded, the shipping options were already listed in the drop down according to the order I have defined in Admin. So I'm not sure why they are in a different order for you.
I also tried adding the line of code I posted above (with the semi-colon ), except using OrderByDescending, to see if the order changed (my Admin-defined order already produced a list from lowest to highest). I did not get an error, but the order didn't change either. So my suggestion is probably doesn't work.
I figured it probably used the same code to calculate the rates on first load and when the basket changes.
I hadn't tried it before, but I tried the unchanged OPC page on my test server now, and when the page loaded, the shipping options were already listed in the drop down according to the order I have defined in Admin. So I'm not sure why they are in a different order for you.
I also tried adding the line of code I posted above (with the semi-colon ), except using OrderByDescending, to see if the order changed (my Admin-defined order already produced a list from lowest to highest). I did not get an error, but the order didn't change either. So my suggestion is probably doesn't work.
Jay
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: GetShipMethods -- Sorting in OPC
I have the bullet list change working but I use bootstrap responsive which I do not think uses the same checkout files.