Skip to content

[v4 -> v5] Get the relevant shipping zone from the calculated shipping method for a cart during checkout #3637

Answered by lukeholder
rob-c-baker asked this question in Q&A
Discussion options

You must be logged in to vote

My guess is your zone condition was migrated to the order shipping address zone condition builder?

if so, you will need to get the condition builder and loop over the conditions and find its zone condition value.

Something like this? (not tested)

{% set condition = rule.orderCondition.conditionRules|filter(item => item is instance of ('craft\\commerce\\elements\\conditions\\orders\\ShippingAddressZoneConditionRule'))|first %}

{% if condition %}
   
    Shipping zone IDs in this rule: {{ condition.getValues()|join(',') }} 
{% else %}
    {# No condition of the specified class was found #}
    <p>No ShippingAddressZoneConditionRule found.</p>
{% endif %}

in php something like this

$rule =…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rob-c-baker
Comment options

Answer selected by lukeholder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants