Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeveloperWil/7375d48560a8b9602d14fde51efe39e0 to your computer and use it in GitHub Desktop.
Save DeveloperWil/7375d48560a8b9602d14fde51efe39e0 to your computer and use it in GitHub Desktop.
WooCommerce: Order Notification to Amazon Echo
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