-
-
Save ConradGalli/8424026 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_email_after_order_table', 'add_payment_method_to_admin_new_order', 15, 2 ); | |
/** | |
* Add used coupons to the order confirmation email | |
* | |
*/ | |
function add_payment_method_to_admin_new_order( $order, $is_admin_email ) { | |
if ( $is_admin_email ) { | |
if( $order->get_used_coupons() ) { | |
$coupons_count = count( $order->get_used_coupons() ); | |
echo '<h4>' . __('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 .= ', '; | |
$i++; | |
} | |
echo '<p><strong>Coupons used (' . $coupons_count . ') :</strong> ' . $coupons_list . '</p>'; | |
} // endif get_used_coupons | |
} // endif $is_admin_email | |
} | |
add_action( 'woocommerce_admin_order_data_after_billing_address', 'custom_checkout_field_display_admin_order_meta', 10, 1 ); | |
/** | |
* Add used coupons to the order edit page | |
* | |
*/ | |
function custom_checkout_field_display_admin_order_meta($order){ | |
if( $order->get_used_coupons() ) { | |
$coupons_count = count( $order->get_used_coupons() ); | |
echo '<h4>' . __('Coupons used') . ' (' . $coupons_count . ')</h4>'; | |
echo '<p><strong>' . __('Coupons used') . ':</strong> '; | |
$i = 1; | |
foreach( $order->get_used_coupons() as $coupon) { | |
echo $coupon; | |
if( $i < $coupons_count ) | |
echo ', '; | |
$i++; | |
} | |
echo '</p>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment