Coupon description (title) on invoice

[ad_1]

Hi everyone, I’m trying to set the used coupon code on the Invoice. I’ve a custom template for the invoices. Whit this code I get the coupon on the invoice, works great:

add_action( 'wpo_wcpdf_after_order_details', 'wpo_wcpdf_add_coupon_code_and_description', 10, 2 );
function wpo_wcpdf_add_coupon_code_and_description ($template_type, $order) {
	if( $coupon_items = $order->get_coupons() ) {
		foreach ( $coupon_items as $coupon_item ) {
			$coupon = new WC_Coupon( $coupon_item->get_code() );
			empty( $coupon->get_description() ) ? printf ( '<p><strong>%s</strong></p>', $coupon->get_code() ) : printf ( '<p><strong>%s:</strong> %s</p>', $coupon->get_code(), $coupon->get_description() );
		}
	}
}

But; when I want to export invoices in bulk. I get an error:

Cannot redeclare wpo_wcpdf_add_coupon_code_and_description() (previously declared in /subdomains/…./woocommerce/pdf/mb/invoice.php:175) in /subdomains/…./woocommerce/pdf/mb/invoice.php on line 175

Can someone help me adjust the code?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer