Different email heading based on shipping methods in Woocommerce












1














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





























    1














    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



























      1












      1








      1


      1





      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















      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















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 at 4:15









      LoicTheAztec

      84.2k136095




      84.2k136095










      asked Nov 21 at 3:39









      Matt Nath

      204




      204
























          1 Answer
          1






          active

          oldest

          votes


















          1














          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',
          autoActivateHeartbeat: false,
          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
          });


          }
          });














          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









          1














          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
















          1














          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














          1












          1








          1






          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

          84.2k136095




          84.2k136095








          • 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


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


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

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'