Problem/Motivation

When viewing an order summary (admin/commerce/orders/), the Shipping information box used to display the USPS shipping service, e.g. "USPS Ground Advantage". Now the shipping method doesn't show up at all, even though I have the shipping_method field enabled under "Manage display" with the "Shipping method" format. If I change the format from "Shipping method" to "Label", the value will appear in the order summary shipping information box, but "USPS Domestic" (the name of the shipping method) is displayed instead of "USPS Ground Advantage" (the name of the shipping service selected by the customer).

Steps to reproduce

View an order that includes a USPS shipment.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sah62 created an issue. See original summary.

rhovland’s picture

Confirming this bug.
This bug is because the service id saved on the shipment (which is saved from the rate) is stored as the "USPS product SKU" instead of the service's id.
I also encountered this in #3569266: ShippingService id of returned rates is missing the shipping method service id but I didn't realize that the rate id HAD to map to the service id for multiple things to work correctly.
This also broke our company's internal order import plugin because it couldn't find the service label because the IDs did not match.

Moving this to major because post production bugs have revealed how important the service id matching the services defined in the shipping method is.

rhovland’s picture

Status: Active » Needs work

Tested MR. Fixes the display, fixes the commerce_best_rate module, and fixes my custom order to XML exporter.

One problem unaddressed is that each service can have multiple rates associated with it. So if there are multiple rates returned for priority mail, only one of them is displayed. I don't know how this can be solved without enumerating all of the rates as services or changing how the shipping module handles rates/services.

sah62’s picture

I don't know how this can be solved without enumerating all of the rates as services or changing how the shipping module handles rates/services.

This may be worth exploring. One thing I noticed with the current patch for #3568335: Implement additional service filtering options is that my customers see and can select from all of the available USPS Priority Mail options. I don't support all of those options, and I'd very much prefer to limit customer confusion when it comes to shipping options. I'd like to expose, for example, only "USPS Priority Mail" without all of the other options.

rhovland’s picture

See #3569991: Provide guidance to site builders on categories and rate indicators about that. The issue you're having is what the filtering was meant to solve. Also the beta version of the module includes filtering, you don't need the patch anymore. The patch was incomplete too.

sah62’s picture

Thanks for the clarification! I just installed the beta release and manually made the change in your merge request from #3. I still don't see the customer-selected shipping method on my order summary. The shipment type displays all include an enabled shipping method field. Did I miss something?

rhovland’s picture

The existing orders have the wrong ids saved to the shipment so it can't resolve them. This only fixes the new ones after the change.
Both the SKU approach and the mail class approach will both fail when USPS decides to change the mail class names at a future date.

You'll find that all of the shipments from the 8.x-1.x version will not display the service either because the services don't exist anymore.

The shipping module should have saved the service label to shipments but was not designed to do so and assumed that shipping methods and their services would never change (that was an incorrect assumption).

tbkot made their first commit to this issue’s fork.

tbkot’s picture

Status: Needs work » Needs review

We cannot use only the "mailClass" for the service ID; it will remove all rates with the same mail class by the radios element because of duplicated value.

SKU is not efficient to be used as a service in the shipping method annotation, as it is always different, not only for combinations like mail class + facility + rate indicator, but also for prices, and it is practically impossible to define the list of services based on SKU. And we still need the SKU to be used in the shipping rate ID to have all possible radio buttons.

I combined the mail class and sku for the shipping service ID, and set the correct service (mail class) to the shipment on rate selection.

Would appreciate testing from anyone, so I can merge it.

rhovland’s picture

Status: Needs review » Reviewed & tested by the community

Great idea on adding the SKU to the rate but dropping it from the shipment service id.

I have tested this and confirm that it works. Multiple rates in the mailClass are returned as rates. Selecting one, the mailClass is written to the shipment and the service displays properly on the order summary page.

  • tbkot committed 8216f0ad on 2.x authored by rhovland
    fix: #3569675 Shipping Method Format Fails to Display on Order Summary...
tbkot’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.