Skip to content

Instantly share code, notes, and snippets.

@pogla
Last active September 28, 2022 04:51
Show Gist options
  • Save pogla/87956792db6ff33ff3e5db03eb5a7bc0 to your computer and use it in GitHub Desktop.
Save pogla/87956792db6ff33ff3e5db03eb5a7bc0 to your computer and use it in GitHub Desktop.
Pushover for WooCommerce - Add order coupon codes to message
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