Craft Commerce 2.0.2 Shipping Rule Names & Descriptions—How?
I just noticed I had to update some templates after updating to the latest Commerce version (2.0.2).
How does one go about getting the method's rule description?
I currently have it set up to apply a rule based on geographical shipping location (like contiguous US states / Hawaii and Alaska / Russia / World / Oceania)—but {{ method.description }}
from within {% for handle, method in cart.availableShippingMethods %}
breaks the site.
Cheers!
craft3 plugin-craftcommerce2
add a comment |
I just noticed I had to update some templates after updating to the latest Commerce version (2.0.2).
How does one go about getting the method's rule description?
I currently have it set up to apply a rule based on geographical shipping location (like contiguous US states / Hawaii and Alaska / Russia / World / Oceania)—but {{ method.description }}
from within {% for handle, method in cart.availableShippingMethods %}
breaks the site.
Cheers!
craft3 plugin-craftcommerce2
I would also want to display the rule name together with description. Right now it only displays the method name.
– Anders
8 hours ago
add a comment |
I just noticed I had to update some templates after updating to the latest Commerce version (2.0.2).
How does one go about getting the method's rule description?
I currently have it set up to apply a rule based on geographical shipping location (like contiguous US states / Hawaii and Alaska / Russia / World / Oceania)—but {{ method.description }}
from within {% for handle, method in cart.availableShippingMethods %}
breaks the site.
Cheers!
craft3 plugin-craftcommerce2
I just noticed I had to update some templates after updating to the latest Commerce version (2.0.2).
How does one go about getting the method's rule description?
I currently have it set up to apply a rule based on geographical shipping location (like contiguous US states / Hawaii and Alaska / Russia / World / Oceania)—but {{ method.description }}
from within {% for handle, method in cart.availableShippingMethods %}
breaks the site.
Cheers!
craft3 plugin-craftcommerce2
craft3 plugin-craftcommerce2
edited 6 hours ago
Anders
asked 8 hours ago
AndersAnders
1939
1939
I would also want to display the rule name together with description. Right now it only displays the method name.
– Anders
8 hours ago
add a comment |
I would also want to display the rule name together with description. Right now it only displays the method name.
– Anders
8 hours ago
I would also want to display the rule name together with description. Right now it only displays the method name.
– Anders
8 hours ago
I would also want to display the rule name together with description. Right now it only displays the method name.
– Anders
8 hours ago
add a comment |
2 Answers
2
active
oldest
votes
calling
{% set methods = cart.availableShippingMethods %}
which is the same as calling:
{% set methods = craft.commerce.shippingMethods.getAvailableShippingMethods(cart) %}
the above returns an array of shipping method models, keyed by the shipping method handle.
to get the matching rule for each available method
{% for method in methods %}
{% set rule = method.getMatchingShippingRule(cart) %}
{% set price = method.getPriceForOrder(cart) %}
{% endfor %}
add a comment |
You have to can loop through the shipping rules for the shipping method.
{% for handle, method in cart.availableShippingMethods %}
{% if method.shippingRules|length %}
{% for shippingRule in method.shippingRules %}
{{ shippingRule.name }}
{{ shippingRule.description }}
{% endfor %}
{% endif %}
{% endfor %}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "563"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcraftcms.stackexchange.com%2fquestions%2f29280%2fcraft-commerce-2-0-2-shipping-rule-names-descriptions-how%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
calling
{% set methods = cart.availableShippingMethods %}
which is the same as calling:
{% set methods = craft.commerce.shippingMethods.getAvailableShippingMethods(cart) %}
the above returns an array of shipping method models, keyed by the shipping method handle.
to get the matching rule for each available method
{% for method in methods %}
{% set rule = method.getMatchingShippingRule(cart) %}
{% set price = method.getPriceForOrder(cart) %}
{% endfor %}
add a comment |
calling
{% set methods = cart.availableShippingMethods %}
which is the same as calling:
{% set methods = craft.commerce.shippingMethods.getAvailableShippingMethods(cart) %}
the above returns an array of shipping method models, keyed by the shipping method handle.
to get the matching rule for each available method
{% for method in methods %}
{% set rule = method.getMatchingShippingRule(cart) %}
{% set price = method.getPriceForOrder(cart) %}
{% endfor %}
add a comment |
calling
{% set methods = cart.availableShippingMethods %}
which is the same as calling:
{% set methods = craft.commerce.shippingMethods.getAvailableShippingMethods(cart) %}
the above returns an array of shipping method models, keyed by the shipping method handle.
to get the matching rule for each available method
{% for method in methods %}
{% set rule = method.getMatchingShippingRule(cart) %}
{% set price = method.getPriceForOrder(cart) %}
{% endfor %}
calling
{% set methods = cart.availableShippingMethods %}
which is the same as calling:
{% set methods = craft.commerce.shippingMethods.getAvailableShippingMethods(cart) %}
the above returns an array of shipping method models, keyed by the shipping method handle.
to get the matching rule for each available method
{% for method in methods %}
{% set rule = method.getMatchingShippingRule(cart) %}
{% set price = method.getPriceForOrder(cart) %}
{% endfor %}
answered 3 hours ago
Luke HolderLuke Holder
5,584723
5,584723
add a comment |
add a comment |
You have to can loop through the shipping rules for the shipping method.
{% for handle, method in cart.availableShippingMethods %}
{% if method.shippingRules|length %}
{% for shippingRule in method.shippingRules %}
{{ shippingRule.name }}
{{ shippingRule.description }}
{% endfor %}
{% endif %}
{% endfor %}
add a comment |
You have to can loop through the shipping rules for the shipping method.
{% for handle, method in cart.availableShippingMethods %}
{% if method.shippingRules|length %}
{% for shippingRule in method.shippingRules %}
{{ shippingRule.name }}
{{ shippingRule.description }}
{% endfor %}
{% endif %}
{% endfor %}
add a comment |
You have to can loop through the shipping rules for the shipping method.
{% for handle, method in cart.availableShippingMethods %}
{% if method.shippingRules|length %}
{% for shippingRule in method.shippingRules %}
{{ shippingRule.name }}
{{ shippingRule.description }}
{% endfor %}
{% endif %}
{% endfor %}
You have to can loop through the shipping rules for the shipping method.
{% for handle, method in cart.availableShippingMethods %}
{% if method.shippingRules|length %}
{% for shippingRule in method.shippingRules %}
{{ shippingRule.name }}
{{ shippingRule.description }}
{% endfor %}
{% endif %}
{% endfor %}
edited 3 hours ago
answered 3 hours ago
Stephen CallenderStephen Callender
1578
1578
add a comment |
add a comment |
Thanks for contributing an answer to Craft CMS Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcraftcms.stackexchange.com%2fquestions%2f29280%2fcraft-commerce-2-0-2-shipping-rule-names-descriptions-how%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I would also want to display the rule name together with description. Right now it only displays the method name.
– Anders
8 hours ago