Remarkety socializes in providing companies that sells customized promotional products with the tools to display the final proof of the order item, inside a Remarkety campaign. That way, you can use Remarkety’s drag-and-drop editor for your post-order emails.
If your store implemented some unique functionality that modifies customer or order data, and you want to make sure Remarkety use the custom data instead of Magento's built-in fields, you can extend Remarkety's Magento plugin using a Magento observers and modify the data before it is passed to Remarkety.
This article assumes that you have a basic knowledge of Magento's observers mechanism.
The observers were added on plugin version 1.5.3.6 which can be downloaded here.
The following observer events are available:
- rm_order_data_webhook - modify order data before it is sent using a webhook in real time (should not have long running functionality here in order to prevent a slowdown of the checkout process).
- rm_order_data_sync - modify order data before it is sent using batch API in a background process.
- rm_customer_data_webhook - modify customer data before it is sent using a webhook in real time (should not have long running functionality here in order to prevent a slowdown of the checkout process and/or customer updates).
- rm_customer_data_sync - modify customer data before it is sent using batch API in a background process.
We have created a sample plugin that implements all the 4 observers with sample functionality. If you use the sample plugin please remove the unnecessary observers from these 2 files:
- app/code/community/Remarkety/Customize/etc/config.xml
- app/code/community/Remarkety/Customize/Model/observer.php
You can download the sample plugin here.
Sample 1 - Adding custom rewards points value to the customers' data
Implement these 2 events:
- rm_customer_data_webhook
- rm_customer_data_sync
The data passed to each observer is slightly different so it requires 2 different observer functions.
For the real-time webhook data, the observer method should look like this:
public function customerWebhookData(Varien_Event_Observer $event){
$varien_object = $event->getVarienObj();
$varien_object->setRewards([
'points' => 555
]);
return $this;
}
For the background sync data, the observer method should look like this:
public function customerSyncData(Varien_Event_Observer $event){
$varien_object = $event->getVarienObj();
$varien_object->setRewardsPoints(555);
return $this;
}
On these 2 examples we set the rewards points to a static value "555", but you should replace the value with a dynamic value from your custom implementation.
Sample 2 - Changing the image of the order items
Implement these 2 events:
- rm_order_data_webhook
- rm_order_data_sync
The data passed to each observer is slightly different so it requires 2 different observer functions.
For the real-time webhook data, the observer method should look like this:
public function orderWebhookData(Varien_Event_Observer $event){
$varien_object = $event->getVarienObj();
$order_id = $varien_object->getId();
$items = $varien_object->getLineItems();
foreach ($items as $key => $item){
$items[$key]['images'] = [
[
'src' => 'http://www.store.com/custom_image.png'
]
];
}
$varien_object->setLineItems($items);
return $this;
}
For the background sync data, the observer method should look like this:
public function orderSyncData(Varien_Event_Observer $event){
$varien_object = $event->getVarienObj();
$order_id = $varien_object->getIncrementId();
$items = $varien_object->getItems();
foreach ($items as $key => $item){
$items[$key]['base_image'] = 'http://www.store.com/custom_image.png';
$items[$key]['small_image'] = 'http://www.store.com/custom_image.png';
$items[$key]['thumbnail_image'] = 'http://www.store.com/custom_image.png';
}
$varien_object->setItems($items);
return $this;
}
On these 2 examples we set the order item image to a static image URL, but you should replace the value with a dynamic value from your custom implementation.
To learn more about how Remarkety can help improve the quality of your post-order emails, contact support@remarkety.com
Comments
0 comments