Support » Plugin: WooCommerce Print Invoice & Delivery Note » Hook to show Coupon Code on Invoice

  • I think I am close?

    I am trying to show the “coupon code” used underneath the “Cart Discount” amount row on the invoice.

    function my_custom_order_fields( $fields, $order ) {
        $new_fields = array();
        if( get_post_meta( $order->id, 'woocommerce_coupon_code', true ) ) {
            $new_fields['woocommerce_coupon_code'] = array(
                'label' => 'Coupon Code 1',
                'value' => get_post_meta( $order->id, 'woocommerce_coupon_code', true )
        return array_merge( $fields, $new_fields );
    add_filter( 'wcdn_order_info_fields', 'my_custom_order_fields', 10, 2 );

Viewing 6 replies - 1 through 6 (of 6 total)
  • Bozz


    Great plugin! I’m very much interested in sorting out a solution to this myself, or better yet seeing the coupon code printed automatically on the default templates.

    I am so close!!! I think I just need a few small edits!! Can anyone point me in the right direction ?

    Thanks! What a great plugin! 5 stars!

    Still trying to get this to show up. I just updated to the latest release, but still no “coupon code” on PDF invoice, just the $dollar amount…

    Has anyone managed to do this yet? Really need to show coupon code on the packing slip!

    Ok, here is what I did to accomplish this.

    ** disclaimer ** There is much better ways to achieve this. This is very straight forward using the “template” method

    Made a template in your theme folder ( copied the one in the plugin folder )


    All I added was a quick query to grab the “coupon code” if it exists:

    At the end of the <table> I inserted this code:

    <?php 	if( $order->get_used_coupons() ) {
    $coupons_count = count( $order->get_used_coupons() );
    echo '<div style="padding:5px; background-color: #eaeaea;"><h4 style="margin-top:10px;">' . __('Coupons used') . ' (' . $coupons_count . ')</h4>';
    echo '<p><strong>' . __('Coupons used') . ':</strong> ';
    $i = 1;
    $coupons_list = '';
    foreach( $order->get_used_coupons() as $coupon) {
    $coupons_list .= $coupon;
    if( $i < $coupons_count )
    $coupons_list .= ', ';
    echo '<p style="padding:4px;"><strong>Coupons used (' . $coupons_count . ') :</strong> ' . $coupons_list . '</p></div>';
    } // endif get_used_coupons ?>

    Now it works perfect!! Just the way I want it to!

    Hi Guys,

    i am not quiet sure where to put which part of this plugin!

    I want to show the discount codes on my woocommerce invoices.

    Can anyone explain it to me? thx in advance

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Hook to show Coupon Code on Invoice’ is closed to new replies.