GetShipMethods -- Sorting in OPC

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

GetShipMethods -- Sorting in OPC

Post by sfeher » Mon Jun 18, 2018 12:05 am

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

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: GetShipMethods -- Sorting in OPC

Post by compunerdy » Mon Jun 18, 2018 2:25 am

Interested in this as well.

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: GetShipMethods -- Sorting in OPC

Post by jguengerich » Mon Jun 18, 2018 7:35 am

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:

Code: Select all

ICollection<ShipRateQuote> rateQuotes = shippingCalculator.QuoteForShipment(shipment);
add a line to sort rateQuotes from lowest to highest:

Code: Select all

rateQuotes.OrderBy(q => q.TotalRate)
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.
Jay

sfeher
Captain (CAPT)
Captain (CAPT)
Posts: 220
Joined: Fri Jun 04, 2004 1:58 pm
Location: Steubenville, Ohio

Re: GetShipMethods -- Sorting in OPC

Post by sfeher » Mon Jun 18, 2018 1:11 pm

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?

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: GetShipMethods -- Sorting in OPC

Post by jguengerich » Tue Jun 19, 2018 8:09 am

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.
Jay

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: GetShipMethods -- Sorting in OPC

Post by compunerdy » Thu Jun 28, 2018 11:31 am

I have the bullet list change working but I use bootstrap responsive which I do not think uses the same checkout files.

Post Reply