Empty shipping address

Created on 28 May 2024, 12 months ago
Updated 1 June 2024, 11 months ago

Problem/Motivation

We face a scenario when the shipping address is empty on the checkout review step even though a user entered a valid address.

The issue happens because Commerce API stores the shipping profile in the "shipping_information" base field. When the order is saved, the empty shipping profile stored there at this point is saved as well, overriding the saved non-empty profile.

Steps to reproduce

* Install Commerce Shipping and Commerce API module.
* On the checkout order information step, uncheck the "My billing information is the same as my shipping information" checkbox.
* Enter shipping address.
* Make sure the shipping rates are recalculated.
* Enter other data (like card data and billing address).
* Proceed to the checkout Review step.
* See the shipping address is empty.

Proposed resolution

The suggestion is to load the latest version of the order before saving it.

🐛 Bug report
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

🇨🇾Cyprus alex.bukach

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @alex.bukach
  • 🇮🇱Israel jsacksick

    hm... I'm not sure why you're bringing up Commerce API here? Could you be a little bit more specific? Are you manipulating the same order via the API and via the regular fullstack checkout at the same time?

  • Issue was unassigned.
  • Status changed to Needs review 12 months ago
  • 🇨🇾Cyprus alex.bukach

    @jsacksick, Commerce API is a dependency of Commerce Cart Flyout .

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 5.7
    last update 12 months ago
    160 pass
  • 🇮🇱Israel jsacksick

    @jsacksick, Commerce API is a dependency of Commerce Cart Flyout.

    No, Commerce Cart API is, not Commerce API.

    Also, your fix would set a precedent, if we start doing that here, we'd need similar "hacks"/workarounds in pretty much all other checkout panes... Except yeah, this one might be the only one saving the order at this stage.

  • 🇨🇾Cyprus alex.bukach

    Sorry, my fault @jsacksick, I have updated the issue description.

    I understand it might be not the best solution, however it's ShippingInformation pane that saves a shipping profile and then almost immediately saves a related order which in the case contains the shipping profile as well (though stale), and I cannot see any other way to hook into the process.

    The same solution was suggested in the " OrderVersionMismatchException caused by ShippingInformation.php unnecessarily saving the order ", however there were able to find more elegant solution. Can you see another way to fix it in the case?

  • 🇨🇾Cyprus alex.bukach

    @jsacksick sorry again, it is Commerce API that provides the base field, we do use it as well, and I am checking whether we still need it :)

  • Status changed to Closed: works as designed 11 months ago
  • 🇨🇾Cyprus alex.bukach

    @jsacksick, at currently our project uses only fields declared Commerce API's, so we can rework the code to uninstall it. However I believe Commerce API should not break commerce shipping functionality anyway. I have found other scenarios when shipping address is empty, and the attached patch does not fix them. Therefore I dig further and came to another solution I posted in an issue for Commerce API 🐛 Empty shipping address Needs review . Therefore I am closing this issue.

Production build 0.71.5 2024