[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?