Skip to content

Remove shipping methods if there aren't any in API return #4192

@EmilsM

Description

@EmilsM

Current behavior

When you have e.g. 1 shipping method, and it has only allowed countries, when switching to a country that doesn't have any shipping methods, thee previous methods do not go away.

Expected behavior

There would be no shipping methods to choose from.

Steps to reproduce the issue

(Using Magento 2).
Set a shipping method to have Only Specific Countries
Choose The Specific country in Vue Storefront checkout
Choose a country that is not in the specified list

Repository

Can you handle fixing this bug by yourself?

  • YES
  • [] NO

Which Release Cycle state this refers to? Info for developer.

Pick one option.

  • [x ] This is a bug report for test version on https://test.storefrontcloud.io - In this case Developer should create branch from develop branch and create Pull Request 2. Feature / Improvement back to develop.
  • This is a bug report for current Release Candidate version on https://next.storefrontcloud.io - In this case Developer should create branch from release branch and create Pull Request 3. Stabilisation fix back to release.
  • This is a bug report for current Stable version on https://demo.storefrontcloud.io and should be placed in next stable version hotfix - In this case Developer should create branch from hotfix or master branch and create Pull Request 4. Hotfix back to hotfix.

Additional information

I checked the current master branch, the issue is still there, in this line of code:
core/modules/cart/store/actions/methodsActions.ts

The updateShippingMethods needs to be change from:
async updateShippingMethods ({ dispatch }, { shippingMethods }) { if (shippingMethods.length > 0) { const newShippingMethods = shippingMethods.map(method => ({ ...method, is_server_method: true })) await dispatch('checkout/replaceShippingMethods', newShippingMethods, { root: true }) } },
to
async updateShippingMethods ({ dispatch }, { shippingMethods }) { const newShippingMethods = shippingMethods.map(method => ({ ...method, is_server_method: true })) await dispatch('checkout/replaceShippingMethods', newShippingMethods, { root: true }) },

This is only a bug report, I won't make a PR for this. Maybe someone in the community wants to make one!: )

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2: ImportantPriority mark - still high ;)QA approved after mergeTesters will add this label after positive check on merged changesbugBug reports

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions