Display content in email

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #10866
    bart
    Participant

      Hey Olly,

      I use the wppizza-order-email-html.php to confirm the order. Now I would like to have the content to be displayed below each product in the email as well.

      How do i do this ? I assume I can’t just post “<?php the_content(); ?>” as there is no reference to this one product?

      Thanks in advance.

      <?php
      /***allow filtering of items (sort, add categories and whatnot)****/
      $order_items = apply_filters('wppizza_emailhtml_filter_items', $order_items, 'htmlemail');
      foreach($order_items as $itemKey=>$item){
      /***allow action per item - probably to use in conjunction with filter above****/
      do_action('wppizza_emailhtml_item', $item, $htmlEmailStyle);
      /**added 2.10.2*/
      /**construct the markup display of this item**/
      $itemMarkup=array();
      $itemMarkup['trtd']			='<tr><td style="'.$htmlEmailStyle['mailPadding']['2x15'].'">';
      $itemMarkup['quantity']		=''.$item['quantity'].'x ';
      $itemMarkup['name']			=''.$item['name'].' ';
      $itemMarkup['size']			=''.$item['size'].' ';
      $itemMarkup['price']		='['.$currency_left.''.$item['price'].''.$currency_right.']';
      $itemMarkup['tdtd']			='</td><td>';
      $itemMarkup['price_total']	=''.$currency_left.''.$item['pricetotal'].''.$currency_right.'';
      $itemMarkup['tdtr']			='</td></tr>';
      if($item['additional_info']!=''){
      $itemMarkup['additionalinfo']='<tr><td colspan="2" style="'.$htmlEmailStyle['mailPadding']['0x15x15x30'].';font-size:90%">'. $item['additional_info'].'</td></tr>';
      }
      /**************************************************************************************************
      [added filter for customisation  v2.10.2]
      if you wish to customise the output, i would suggest you use the filter below in
      your functions.php instead of editing this file (or a copy thereof in your themes directory)
      /**************************************************************************************************/
      $itemMarkup = apply_filters('wppizza_filter_htmlemail_item_markup', $itemMarkup, $item, $itemKey, $options['order']);
      /**output markup**/
      echo''.implode("",$itemMarkup).'';
      ?>
      #10874
      Olly
      Admin & Mod

        >assume I can’t just post…
        you would be correct

        but you can use $item['postId'] to then get the content for that post id (or anything else you want to get for that id)

        #10875
        Olly
        Admin & Mod

          PS: BTW, i would suggest you also use the filter “wppizza_filter_htmlemail_item_markup” though instead of editing the template directly

          #10885
          bart
          Participant

            Olly I am always stoked about your quick replies. Respect 🙂

            I have added the filter to the functions.php file however not sure how to actually use it. I dont have an extra page or something to setup the email? (right?)

            Thanks again.

            Regards,
            Bart

            #10886
            bart
            Participant

              Hey Olly, so far I have tried but failed to pull the content from the product. My coding isnt great at all.

              <?php
              /***allow filtering of items (sort, add categories and whatnot)****/
              $order_items = apply_filters('wppizza_emailhtml_filter_items', $order_items, 'htmlemail');
              foreach($order_items as $itemKey=>$item){
              /***allow action per item - probably to use in conjunction with filter above****/
              do_action('wppizza_emailhtml_item', $item, $htmlEmailStyle);
              /**added 2.10.2*/
              /**construct the markup display of this item**/
              $itemMarkup=array();
              $itemMarkup['trtd']			='<tr><td style="'.$htmlEmailStyle['mailPadding']['2x15'].'">';
              $itemMarkup['quantity']		=''.$item['quantity'].'x ';
              $itemMarkup['name']			=''.$item['name'].' ';
              $itemMarkup['size']			=''.$item['size'].' ';
              $itemMarkup['price']		='['.$currency_left.''.$item['price'].''.$currency_right.']';
              $itemMarkup['tdtd']			='</td><td>';
              $itemMarkup['price_total']	=''.$currency_left.''.$item['pricetotal'].''.$currency_right.'';
              $itemMarkup['tdtr']			='</td></tr>';
              $itemMarkup['trtd']			='<tr><td>';
              $itemMarkup['postId']		=['postid'];
              $itemMarkup['tdtr']			='</td></tr>';
              if($item['additional_info']!=''){
              $itemMarkup['additionalinfo']='<tr><td colspan="2" style="'.$htmlEmailStyle['mailPadding']['0x15x15x30'].';font-size:90%">'. $item['additional_info'].'</td></tr>';
              }
              /**************************************************************************************************
              [added filter for customisation  v2.10.2]
              if you wish to customise the output, i would suggest you use the filter below in
              your functions.php instead of editing this file (or a copy thereof in your themes directory)
              /**************************************************************************************************/
              $itemMarkup = apply_filters('wppizza_filter_htmlemail_item_markup', $itemMarkup, $item, $itemKey, $options['order']);
              /**output markup**/
              echo''.implode("",$itemMarkup).'';
              ?>
              #10887
              bart
              Participant

                I changed back to the original code and found when ordering, this shows up above the email:
                % @%% @%% @%% @%

                It looks like its three symbols for each ordered product (in this case 4 products)

                The only thing that I changed is adding the filter.

                #10895
                Olly
                Admin & Mod

                  >I changed back to the original code …
                  never change/edit corefiles. your changes will get lost with the next update

                  >The only thing that I changed is adding the filter.

                  doesnt look like it to me. you are supposed to add a filter and function that goes with it in your themes functions.php, not editing what is in the plugin

                  #10896
                  Olly
                  Admin & Mod

                    also, what is this supposed to do ? $itemMarkup['postId']=['postid'];

                    #10897
                    Olly
                    Admin & Mod

                      anyway , you should do something along these lines (in your themes functions.php)

                      function my_extra_markup( $itemMarkup, $item, $itemKey, $options) {
                      /* get content of post */
                      $content=get_post( $item['postId']);
                      /* add content to markup */
                      $itemMarkup['content']='<tr><td colspan="2">'.$content->post_content.'</td></tr>';
                      return $itemMarkup;
                      }
                      add_filter('wppizza_filter_htmlemail_item_markup', 'my_extra_markup', 10, 4);	
                      #10970
                      bart
                      Participant

                        What I did was copy paste the email .php to the theme folder so I could edit the layout.

                        I tried adding the filter and then make it show up through the php form but no succes. When i add this filter. What exactly do i put in the php ?

                        #10972
                        Olly
                        Admin & Mod

                          >What exactly do i put in the php ?

                          nothing (assuming you are talking ab out the template …..emails.php

                          you add and use the filter in your themes’ functions php as required

                          #11082
                          bart
                          Participant

                            Hey Olli, I’ve added the filter to the functions.php, and put the original wppizza-order-email-html.php file back to make sure not to have any mistakes, but it doesnt display the content below each product, or anywhere.

                            #11083
                            Olly
                            Admin & Mod

                              i edited the example code a little bit.
                              try that

                              #11139
                              bart
                              Participant

                                Absolutely great!! works perfect !

                              Viewing 14 posts - 1 through 14 (of 14 total)
                              • The topic ‘Display content in email’ is closed to new replies.