I've created a webhook in the Shopify admin as order creation by using following url:
https://a.klaviyo.com/api/track?token=<public_api_key>
After that, I use the Klaviyo API to receive the webhook data and store it as an event in Klaviyo with the Shopify metafield value as a custom property:
$url = 'https://a.klaviyo.com/api/track';
$data = array(
'token' => $public_api_key,
'event' => 'Order Placed',
'customer_properties' => array(
'$email' => '{{ order.email }}'
),
'properties' => array(
'Order ID' => '{{ order.order_number }}',
'Order Total' => '{{ order.total_price }}',
'Shopify Metafield' => '{{ order.metafields.custom.promise_date }}'
)
);
$data_string = http_build_query(array('data' => json_encode($data)));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
'Content-Length: ' . strlen($data_string)
));
$result = curl_exec($ch);
curl_close($ch);
What I want is that the metafield 'promise_date' should have in the order event property list:
and then I want to show the ‘promise_date’ value in the email template.
What did I do wrong? Any help would be appreciated, thanks in advance!
Best answer by Brian Turcotte
View original