Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ecwid Notification Script
This is the script I am using to construct custom order notifications using the Ecommerce platform Ecwid.
//Store specific variables for the URL
$secretKey = "YourSecretKey";
$storeId = YourNumericalStoreId;
//This is declaring variables for the notification mail function
$subject = "Notification Subject";
$mailheader = "From: \r\n";
//This will save the unique order ID in a variable to construct the URL for the JSON request
$newOrderNumber = $_POST['order_id'];
//This will send a request to return this specific order's detailed information as JSON
$thisOrder = GetJsonFeed("".$storeId."/orders?secure_auth_key=".$secretKey."&order=".$newOrderNumber);
//These variables access the parsed JSON stored in $thisOrder. To look for more variables, add in Ecwid's identifier in the last [''].
$custEmail = $thisOrder['orders'][0]['customerEmail'];
$custFirstName = $thisOrder['orders'][0]['customerName'];
//The message sent out in the email. You can use any information stored in $thisOrder.
$message = "
Dear $custFirstName,
Your order number is $newOrderNumber.
Let us know if you have any questions!";
//Sends the custom notification to the customer
mail($custEmail, $subject, $message, $mailheader) or die("Error!");
//Helper Function to deal with the JSON
function GetJsonFeed($url)
$response = file_get_contents($url);
return json_decode($response, true);

This comment has been minimized.

Copy link
Owner Author

@cornelisonc cornelisonc commented Jul 23, 2012

Ohhhhh damn, this gist totally just saved my bacon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.