Last active
September 28, 2022 04:51
-
-
Save pogla/87956792db6ff33ff3e5db03eb5a7bc0 to your computer and use it in GitHub Desktop.
Pushover for WooCommerce - Add order coupon codes to message
This file contains hidden or 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_filter( | |
'wc_pushover_notify_new_order', | |
function ( $args ) { | |
$order = wc_get_order( $args['order_id'] ); | |
if ( ! $order ) { | |
return $args; | |
} | |
$order_coupons = $order->get_items( 'coupon' ); | |
if ( ! $order_coupons ) { | |
return $args; | |
} | |
$args['message'] .= sprintf( | |
' (%s)', | |
implode( | |
',', | |
array_map( | |
function ( $el ) { | |
return $el->get_code(); | |
}, | |
$order_coupons | |
) | |
) | |
); | |
return $args; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment