Skip to content

Instantly share code, notes, and snippets.

@rubendivall
Created May 2, 2019 19:18
Show Gist options
  • Save rubendivall/eab006fd8ff933c39d05afccbd195208 to your computer and use it in GitHub Desktop.
Save rubendivall/eab006fd8ff933c39d05afccbd195208 to your computer and use it in GitHub Desktop.
survey-opt-in-ps-17
{* Integrate the survey opt-in module Google Merchant Center for Prestashop 1.7
*
* STEP 1
* Add this code in your tpl file in themes/YOUR_THEME/templates/checkout/order-confirmation.tpl inside the block page_content_container -> {block name='page_content_container'}
*
* STEP 2
* Define your google Merchant ID in {assign var="merchant_id" value="YOUR_ID"}
* Define how many days your order will be deliveried {assign var="estimated_delivery_days" value="NUMBER_OF_DAYS"}
*
*
* by Ruben Divall @rubendivall http://www.rubendivall.com
* https://support.google.com/merchants/answer/7106244?hl=en&ref_topic=7105160
*}
{block name='conversion_pixel'}
{assign var="estimated_delivery_days" value="NUMBER_OF_DAYS"}
{assign var="merchant_id" value="YOUR_ID"}
<!-- BEGIN GCR Opt-in Module Code -->
{if !empty($merchant_id) && !empty($order.details.id) && !empty(Country::getIsoById($order.addresses.delivery.id_country))}
<script src="https://apis.google.com/js/platform.js?onload=renderOptIn" async defer></script>
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": {$merchant_id},
"order_id": "{$order.details.id}",
"email": "{$customer.email}",
"delivery_country": "{Country::getIsoById($order.addresses.delivery.id_country)|upper}",
"estimated_delivery_date": "{"+$estimated_delivery_days days"|date_format:"%Y-%m-%d"}",
"opt_in_style": "CENTER_DIALOG",
"products": [
{foreach $order.products as $item_product}
{
"gtin": "{if !empty({$item_product.product_ean13})}{$item_product.product_ean13}{/if}"
} {if !$item_product@last},{/if}
{/foreach}
]
});
});
}
</script>
<script>
window.___gcfg = {
lang: "{$language.iso_code|lower}"
};
</script>
{/if}
{/block}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment