Different email heading based on shipping methods in Woocommerce











up vote
1
down vote

favorite












So I want to send the same email with a slightly different heading in WooCommerce. It uses the argument $email_heading variable to hold the value of that current email heading so I figure a simple replacement would work. It doesn't. I could be completely missing the mark here any help is much appreciated.



I want it to say Your Order is ready for pickup when they choose local pickup and then the default value (stored the email settings of woocommerce) when any other shipping is chosen.



add_filter( "woocommerce_email_heading_customer_completed_order", 'HDM_woocommerce_email_header', 10, 2 );
function HDM_woocommerce_email_header( $email_heading, $email ) {
if ('customer_completed_order' == $email->id && $order->has_shipping_method('local_pickup') ){
$order_id = $order->get_id();
$email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
}
return $email_heading;
};









share|improve this question









New contributor




Matt Nath is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    1
    down vote

    favorite












    So I want to send the same email with a slightly different heading in WooCommerce. It uses the argument $email_heading variable to hold the value of that current email heading so I figure a simple replacement would work. It doesn't. I could be completely missing the mark here any help is much appreciated.



    I want it to say Your Order is ready for pickup when they choose local pickup and then the default value (stored the email settings of woocommerce) when any other shipping is chosen.



    add_filter( "woocommerce_email_heading_customer_completed_order", 'HDM_woocommerce_email_header', 10, 2 );
    function HDM_woocommerce_email_header( $email_heading, $email ) {
    if ('customer_completed_order' == $email->id && $order->has_shipping_method('local_pickup') ){
    $order_id = $order->get_id();
    $email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
    }
    return $email_heading;
    };









    share|improve this question









    New contributor




    Matt Nath is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      So I want to send the same email with a slightly different heading in WooCommerce. It uses the argument $email_heading variable to hold the value of that current email heading so I figure a simple replacement would work. It doesn't. I could be completely missing the mark here any help is much appreciated.



      I want it to say Your Order is ready for pickup when they choose local pickup and then the default value (stored the email settings of woocommerce) when any other shipping is chosen.



      add_filter( "woocommerce_email_heading_customer_completed_order", 'HDM_woocommerce_email_header', 10, 2 );
      function HDM_woocommerce_email_header( $email_heading, $email ) {
      if ('customer_completed_order' == $email->id && $order->has_shipping_method('local_pickup') ){
      $order_id = $order->get_id();
      $email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
      }
      return $email_heading;
      };









      share|improve this question









      New contributor




      Matt Nath is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      So I want to send the same email with a slightly different heading in WooCommerce. It uses the argument $email_heading variable to hold the value of that current email heading so I figure a simple replacement would work. It doesn't. I could be completely missing the mark here any help is much appreciated.



      I want it to say Your Order is ready for pickup when they choose local pickup and then the default value (stored the email settings of woocommerce) when any other shipping is chosen.



      add_filter( "woocommerce_email_heading_customer_completed_order", 'HDM_woocommerce_email_header', 10, 2 );
      function HDM_woocommerce_email_header( $email_heading, $email ) {
      if ('customer_completed_order' == $email->id && $order->has_shipping_method('local_pickup') ){
      $order_id = $order->get_id();
      $email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
      }
      return $email_heading;
      };






      php wordpress woocommerce email-notifications shipping-method






      share|improve this question









      New contributor




      Matt Nath is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Matt Nath is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited Nov 21 at 4:15









      LoicTheAztec

      80.2k125992




      80.2k125992






      New contributor




      Matt Nath is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Nov 21 at 3:39









      Matt Nath

      82




      82




      New contributor




      Matt Nath is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Matt Nath is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Matt Nath is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          There are some mistakes in your code like $email that is in fact $order. Also you are already targeting customer_completed_order in this composite hook, so you don't need it in your IF statement…



          So try instead:



          add_filter( "woocommerce_email_heading_customer_completed_order", 'custom_email_heading', 10, 2 );
          function custom_email_heading( $email_heading, $order ) {
          if ( $order->has_shipping_method('local_pickup') ){
          $email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
          }
          return $email_heading;
          }


          Code goes in function.php file of your active child theme (or active theme). Tested and works.






          share|improve this answer



















          • 1




            Oooh you seriously are the best! Thank you so much i was working on that for way too long.
            – Matt Nath
            Nov 22 at 1:12











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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
          });


          }
          });






          Matt Nath is a new contributor. Be nice, and check out our Code of Conduct.










           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404939%2fdifferent-email-heading-based-on-shipping-methods-in-woocommerce%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted










          There are some mistakes in your code like $email that is in fact $order. Also you are already targeting customer_completed_order in this composite hook, so you don't need it in your IF statement…



          So try instead:



          add_filter( "woocommerce_email_heading_customer_completed_order", 'custom_email_heading', 10, 2 );
          function custom_email_heading( $email_heading, $order ) {
          if ( $order->has_shipping_method('local_pickup') ){
          $email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
          }
          return $email_heading;
          }


          Code goes in function.php file of your active child theme (or active theme). Tested and works.






          share|improve this answer



















          • 1




            Oooh you seriously are the best! Thank you so much i was working on that for way too long.
            – Matt Nath
            Nov 22 at 1:12















          up vote
          0
          down vote



          accepted










          There are some mistakes in your code like $email that is in fact $order. Also you are already targeting customer_completed_order in this composite hook, so you don't need it in your IF statement…



          So try instead:



          add_filter( "woocommerce_email_heading_customer_completed_order", 'custom_email_heading', 10, 2 );
          function custom_email_heading( $email_heading, $order ) {
          if ( $order->has_shipping_method('local_pickup') ){
          $email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
          }
          return $email_heading;
          }


          Code goes in function.php file of your active child theme (or active theme). Tested and works.






          share|improve this answer



















          • 1




            Oooh you seriously are the best! Thank you so much i was working on that for way too long.
            – Matt Nath
            Nov 22 at 1:12













          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          There are some mistakes in your code like $email that is in fact $order. Also you are already targeting customer_completed_order in this composite hook, so you don't need it in your IF statement…



          So try instead:



          add_filter( "woocommerce_email_heading_customer_completed_order", 'custom_email_heading', 10, 2 );
          function custom_email_heading( $email_heading, $order ) {
          if ( $order->has_shipping_method('local_pickup') ){
          $email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
          }
          return $email_heading;
          }


          Code goes in function.php file of your active child theme (or active theme). Tested and works.






          share|improve this answer














          There are some mistakes in your code like $email that is in fact $order. Also you are already targeting customer_completed_order in this composite hook, so you don't need it in your IF statement…



          So try instead:



          add_filter( "woocommerce_email_heading_customer_completed_order", 'custom_email_heading', 10, 2 );
          function custom_email_heading( $email_heading, $order ) {
          if ( $order->has_shipping_method('local_pickup') ){
          $email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
          }
          return $email_heading;
          }


          Code goes in function.php file of your active child theme (or active theme). Tested and works.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 21 at 4:20

























          answered Nov 21 at 4:14









          LoicTheAztec

          80.2k125992




          80.2k125992








          • 1




            Oooh you seriously are the best! Thank you so much i was working on that for way too long.
            – Matt Nath
            Nov 22 at 1:12














          • 1




            Oooh you seriously are the best! Thank you so much i was working on that for way too long.
            – Matt Nath
            Nov 22 at 1:12








          1




          1




          Oooh you seriously are the best! Thank you so much i was working on that for way too long.
          – Matt Nath
          Nov 22 at 1:12




          Oooh you seriously are the best! Thank you so much i was working on that for way too long.
          – Matt Nath
          Nov 22 at 1:12










          Matt Nath is a new contributor. Be nice, and check out our Code of Conduct.










           

          draft saved


          draft discarded


















          Matt Nath is a new contributor. Be nice, and check out our Code of Conduct.













          Matt Nath is a new contributor. Be nice, and check out our Code of Conduct.












          Matt Nath is a new contributor. Be nice, and check out our Code of Conduct.















           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404939%2fdifferent-email-heading-based-on-shipping-methods-in-woocommerce%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

          Sphinx de Gizeh

          Dijon

          Guerrita