craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
226 stars 170 forks source link

[4.x]: Setting address condition based on country field for shipping zone is not working #2861

Closed Stalex89 closed 2 years ago

Stalex89 commented 2 years ago

What happened?

Description

According to the documentation, the country condition can be set by setting the "Country" rule to "is one of" and type+selecting the country (it should typeahead the county in the input).

However, the actual field differs from the documentation. Instead, there are four options for the Country rule: 1) equals 2) begins with 3) ends with 4) contains

If I select "equals" and type for example "Netherlands", it doesn't autosuggest country (not a typeahead input) and you type country name "as you type it".

When I set the shipping address in the order, hit the "Update order" button and try to select the shipping rule, I don't see the shipping methods based on the country condition.

Steps to reproduce

  1. Set the store location to some address in the Netherlands
  2. Create a shipping zone based on the country condition (for example, Netherlands)
  3. Create a shipping method with a shipping rule for shipping only inside Netherlands (add "Netherlands" zone filtering condition)
  4. Make an order with the shipping address in the Netherlands, then click on "Update order" button to update shipping address
  5. Try to select the shipping method created before

Expected behavior

You should be able to select the shipping method based on country conditional rule

Actual behavior

The shipping method is not present in the selection list

Screenshots:

Screenshot 2022-06-22 at 10 24 02 Screenshot 2022-06-22 at 10 23 44 Screenshot 2022-06-22 at 10 24 35 Screenshot 2022-06-22 at 10 25 05 Screenshot 2022-06-22 at 10 25 15

If I remove the address condition for the shipping zone, all shipping methods will appear in the selection list:

Screenshot 2022-06-22 at 10 26 10

Craft CMS version

Craft Pro 4.0.5

Craft Commerce version

4.0.3

PHP version

8.0.20

Operating system and version

Linux 3.10.0-962.3.2.lve1.5.64.el7.x86_64

Database type and version

MySQL 10.2.44

Image driver and version

GD 8.0.20

Installed plugins and versions

Mollie for Craft Commerce | 4.0.0 Navigation | 2.0.2 Redactor | 3.0.0 Redirects | 4.0.1 SEOmatic | 4.0.2 Super Table | 3.0.0-beta.6 Typed link field | 2.1.3-rc

lukeholder commented 2 years ago

It looks like you're referencing a custom field called 'country':

I don't have a country custom field and see this:

CleanShot 2022-06-22 at 21 51 38@2x

it looks like the custom field name is conflicting with the build in address field name. You will need to rename the custom field to fix it quickly, in the future we will need to disallow custom fields with those names.

Stalex89 commented 2 years ago

@lukeholder Thank you for the answer, idd custom field with the same name overrides the default field from the dropdown, I changed the name of the custom field and the default one appeared back:

Screenshot 2022-06-22 at 16 43 23

Would be nice tho to keep both of fields in the dropdown (maybe differentiate by unique field handle) Anyway thank you for clarifying!