Craft Commerce 2.0.2 Shipping Rule Names & Descriptions—How?












1















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!










share|improve this question

























  • I would also want to display the rule name together with description. Right now it only displays the method name.

    – Anders
    8 hours ago
















1















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!










share|improve this question

























  • I would also want to display the rule name together with description. Right now it only displays the method name.

    – Anders
    8 hours ago














1












1








1








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!










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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










2 Answers
2






active

oldest

votes


















2














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 %}





share|improve this answer































    2














    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 %}





    share|improve this answer

























      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
      });


      }
      });














      draft saved

      draft discarded


















      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









      2














      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 %}





      share|improve this answer




























        2














        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 %}





        share|improve this answer


























          2












          2








          2







          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 %}





          share|improve this answer













          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 %}






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 3 hours ago









          Luke HolderLuke Holder

          5,584723




          5,584723























              2














              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 %}





              share|improve this answer






























                2














                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 %}





                share|improve this answer




























                  2












                  2








                  2







                  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 %}





                  share|improve this answer















                  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 %}






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 3 hours ago

























                  answered 3 hours ago









                  Stephen CallenderStephen Callender

                  1578




                  1578






























                      draft saved

                      draft discarded




















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      サソリ

                      広島県道265号伴広島線

                      Setup Asymptote in Texstudio