Support » Plugin: Print Invoice & Delivery Notes for WooCommerce » Include Coupon Codes on Invoice

  • Hi there…

    I love this plugin, and I was trying to show the Coupons Codes used on the Invoices. I read a couple of previous post regarding the same subject, I used the code supplied but it doesn’t work for me.

    This is the actual code that should show the Coupon Codes on the Invoice, but again, it doesn’t work for me. Is there anything I can do???

    function example_custom_order_fields( $fields, $order ) {
        $new_fields = array();
    	
    	$coupon_codes = $order->get_coupon_codes();
        
    	$coupons_string = '';
    	
    	foreach($coupon_codes as $coupon){
    		$coupons_string .= $coupon.', ';
    	}
    	
    	$new_fields[0] = array( 
                'label' => 'Coupon Code(s)',
                'value' => $coupons_string
        );
        
        return array_merge( $fields, $new_fields );
    }
    add_filter( 'wcdn_order_info_fields', 'example_custom_order_fields', 10, 2 );
Viewing 1 replies (of 1 total)
  • Plugin Support Upendra Kapse

    (@wpupen)

    Hello,

    Apologies for the delay on this.

    I just tried the code snippet that you have posted on my end again and it worked fine, it will add the coupon code in the Invoice like this: https://prnt.sc/1efcz8j

    Please make sure that you add this code snippet either in the functions.php file of your child theme or you can also add it as a snippet using the Code Snippets plugin.

    Kind Regards,
    Upendra,

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.