Last active
April 29, 2021 02:46
-
-
Save DeveloperWil/7375d48560a8b9602d14fde51efe39e0 to your computer and use it in GitHub Desktop.
WooCommerce: Order Notification to Amazon Echo
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
function zpd_wc_order_to_alexa( $payload, $resource, $resource_id, $id){ | |
if( $id == 1) { // webhook ID is 1 | |
// Get an instance of the WC_Order object (same as before) | |
$order = wc_get_order( $resource_id ); | |
$payload[ 'accessCode' ] = ZPD_NOTIFYME_SECRET_API_KEY; | |
$payload[ 'notification'] = 'There is a new ' . $order->get_status() . ' order'; | |
$payload[ 'notification'] .= ' on the ' . get_bloginfo( 'name' ) . ' website'; | |
$payload[ 'notification'] .= ' from ' . $order->get_billing_first_name() . ' ' . $order->get_billing_last_name() . '.'; | |
} | |
return $payload; | |
} | |
add_filter( 'woocommerce_webhook_payload', 'zpd_wc_order_to_alexa', 8, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment