Created
June 6, 2012 16:29
-
-
Save cornelisonc/2883084 to your computer and use it in GitHub Desktop.
Ecwid Notification Script
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
This is the script I am using to construct custom order notifications using the Ecommerce platform Ecwid. |
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
<?php | |
//Store specific variables for the URL | |
$secretKey = "YourSecretKey"; | |
$storeId = YourNumericalStoreId; | |
//This is declaring variables for the notification mail function | |
$subject = "Notification Subject"; | |
$mailheader = "From: someone@yourwebpage.com \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("https://app.ecwid.com/api/v1/".$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); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ohhhhh damn, this gist totally just saved my bacon.