Title: Coupon Code
Last modified: December 10, 2018

---

# Coupon Code

 *  Resolved [creoadmin](https://wordpress.org/support/users/creoadmin/)
 * (@creoadmin)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/coupon-code-12/)
 * How can I make it so that if a coupon is used it shows up on either the packing
   slip or invoice?
    Thanks!

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/coupon-code-12/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/coupon-code-12/page/2/?output_format=md)

 *  Plugin Contributor [kluver](https://wordpress.org/support/users/kluver/)
 * (@kluver)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/coupon-code-12/#post-10977950)
 * Hi [@creoadmin](https://wordpress.org/support/users/creoadmin/),
 * You can add used coupons with a small code snippet:
 *     ```
       //Add used coupons to PDFs
       add_action( 'wpo_wcpdf_after_order_details', 'wpo_wcpdf_coupons_used', 10, 2 );
       function wpo_wcpdf_coupons_used ($template_type, $order) {
       	if( $used_coupons = $order->get_used_coupons() ) {
       		$coupons_list = implode(', ', $used_coupons);
       		echo '<h4>' . __('Coupons used') . '</h4>';
       		echo '<p>' . $coupons_list . '</p>';
       	}
       }
       ```
   
 * This code snippet should be placed in the functions.php of your child theme. 
   If you haven’t worked with code snippets or functions.php please read this: [How to use filters](https://docs.wpovernight.com/general/how-to-use-filters/)
 *  Thread Starter [creoadmin](https://wordpress.org/support/users/creoadmin/)
 * (@creoadmin)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/coupon-code-12/#post-10978668)
 * This is amazing and works PERFECTLY!!!
 * One more request, is there a way to include the order notes on the packing slips/
   invoices?
 * THANK YOU for your amazing support!
 *  Plugin Contributor [kluver](https://wordpress.org/support/users/kluver/)
 * (@kluver)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/coupon-code-12/#post-10979076)
 * Hi [@creoadmin](https://wordpress.org/support/users/creoadmin/),
 * Sure, please read the following guide: [Displaying the order notes](https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/displaying-order-notes/)
 * Thanks for the compliment and if you haven’t already, we would really appreciate
   a good review. 🙂
 *  Thread Starter [creoadmin](https://wordpress.org/support/users/creoadmin/)
 * (@creoadmin)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11553224)
 * I am so sorry to be reopening this thread, but I can no longer see what coupon
   codes have been used on my packing slips.
 * Also, you gave me a custom code to list user roles on my packing slips and that
   has stopped working too. Here is what you said for that:
    add_action( ‘wpo_wcpdf_after_order_data’,‘
   wpo_wcpdf_print_user_role’, 10, 2 ); function wpo_wcpdf_print_user_role ($template_type,
   $order) { if ($template_type == ‘packing-slip’) { $user = $order->get_user();
   if ( $user && in_array( ‘gold_level_membership’, (array) $user->roles ) ) { ?
   > <tr class=”user-role”> <th>User role:</th> <td>Gold Level</td> </tr> <?php }
   else { ?> <tr class=”user-role”> <th>User role:</th> <td>Customer</td> </tr> 
   <?php } } }
 * Any ideas as to what happened that caused these to stop working? THANK YOU for
   all of your help!!
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11553978)
 * None of these filters have changed, so unless you made changes to the template
   files, they should still work.
    Where did you put those code snippets exactly?
   Can you verify that they are still enabled/executed?
 *  [jodiekieliszewski](https://wordpress.org/support/users/jodiekieliszewski/)
 * (@jodiekieliszewski)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11557043)
 * HI, is there a way I could modify the code snippet to show which affiliate an
   order was placed through on the invoice?THank you!
 *  Plugin Contributor [kluver](https://wordpress.org/support/users/kluver/)
 * (@kluver)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11559437)
 * Hi [@jodiekieliszewski](https://wordpress.org/support/users/jodiekieliszewski/),
 * Is this data stored in the order? If so you could retrieve it following this 
   guide: [Displaying a custom field](https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/displaying-a-custom-field/#with-a-template-action-hook)
 *  Thread Starter [creoadmin](https://wordpress.org/support/users/creoadmin/)
 * (@creoadmin)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11559998)
 * I did verify that they are still executed. They are running in the Code Snippets
   plugin. 🙂
 *  Plugin Contributor [kluver](https://wordpress.org/support/users/kluver/)
 * (@kluver)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11560672)
 * Hi [@creoadmin](https://wordpress.org/support/users/creoadmin/),
 * Have you made recent changes to your packing slip template? If the action hooks
   are still there and your filters are executed there should be no reason why they
   wouldn’t work.
 *  [jodiekieliszewski](https://wordpress.org/support/users/jodiekieliszewski/)
 * (@jodiekieliszewski)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11561300)
 * [@kluver](https://wordpress.org/support/users/kluver/)
    There is a column on 
   woocommerce orders which shows the referral number, if the order was referred
   by an affiliate.
 * If you click on the referral number, the affiliate’s id is stored with all other
   order data in the custom field box. This is how it identifies the affiliate
 * :”affiliate_id”;i:11;
 * I did add the store toolkit plugin, and I don’t see any meta data identifying
   the affiliate with the order. It appears that the only place that I can see affiliate
   id or username is through the AffiliateWP plugin.
 * Any advice is greatly appreciated.
    Thank you, Jodie
 *  [jodiekieliszewski](https://wordpress.org/support/users/jodiekieliszewski/)
 * (@jodiekieliszewski)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11561853)
 * The referral id is also available under order notes.
 *  Thread Starter [creoadmin](https://wordpress.org/support/users/creoadmin/)
 * (@creoadmin)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11561913)
 * [@kluver](https://wordpress.org/support/users/kluver/) I am so confused why they
   stopped working! I haven’t made any recent changes to my packing slips template.
   They stopped working when I installed a new theme. That could be the problem?
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11563701)
 * [@creoadmin](https://wordpress.org/support/users/creoadmin/) if you switch back
   to the old theme, do the snippets start working again?
    Checking if the code 
   is still in Code Snippets is not a sure way to determine it is being executed,
   a better way would be a snippet without any conditions, if this doesn’t show ‘
   TEST’ anywhere on the invoice or packing slip it’s not executed:
 *     ```
       add_action( 'wpo_wcpdf_after_order_details', 'wpo_wcpdf_test_filter', 10, 2 );
       function wpo_wcpdf_test_filter ($template_type, $order) {
           echo "TEST";
       }
       ```
   
 * You may also want to double check that the snippet in Code Snippets is set to“
   Run snippet everywhere”.
 * [@jodiekieliszewski](https://wordpress.org/support/users/jodiekieliszewski/),
   I recommend contacting the WP Affiliate support to get help with this. Here’s
   a base code snippet that with the right information they should be able to help
   you further with:
 *     ```
       add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_delivery_date', 10, 2 );
       function wpo_wcpdf_delivery_date ( $template_type, $order ) {
           // example order meta
           $meta_key = '_meta_key';
           $order_meta = $order->get_meta($meta_key);
           ?>
           <tr class="order-meta">
               <th>Order Meta:</th>
               <td><?php echo $order_meta; ?></td>
           </tr>
           <?php
   
           // example user meta, check if we have a user ID first
           if ( $user_id = $order->get_user_id() ):
               $meta_key = 'user_meta_key';
               $user_meta = get_user_meta( $user_id, $meta_key, true );
               ?>
               <tr class="user-meta">
                   <th>User Meta:</th>
                   <td><?php echo $user_meta; ?></td>
               </tr>
               <?php
           endif;
       }
       ```
   
 * If you need more help with this, please open a new thread on this support forum,
   otherwise this original thread becomes too confusing with two different, unrelated
   topics!
 *  Thread Starter [creoadmin](https://wordpress.org/support/users/creoadmin/)
 * (@creoadmin)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11582292)
 * We are definitely narrowing the problem! I added a new snippet with that test
   code and TEST appeared nowhere on the packing slip. But, I have verified that
   the snippets are activated everywhere.
 * [https://leggingavenue.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-9.43.55-PM.png](https://leggingavenue.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-9.43.55-PM.png)
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [7 years ago](https://wordpress.org/support/topic/coupon-code-12/#post-11583101)
 * Are you sure you are using this very plugin, “WooCommerce PDF Invoices & Packing
   Slips” and not another plugin? Are you using the Simple template (check under
   _WooCommerce > PDF Invoices > General > Select a template_)?

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/coupon-code-12/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/coupon-code-12/page/2/?output_format=md)

The topic ‘Coupon Code’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-pdf-invoices-packing-slips/assets/icon-256x256.
   png?rev=2189942)
 * [PDF Invoices & Packing Slips for WooCommerce](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/)

 * 19 replies
 * 4 participants
 * Last reply from: [Ewout](https://wordpress.org/support/users/pomegranate/)
 * Last activity: [6 years, 12 months ago](https://wordpress.org/support/topic/coupon-code-12/page/2/#post-11606807)
 * Status: resolved