---- dataentry integration ---- type : integration # do not change this line supports-foxycart-version-from : 2.0 # Minimum required FoxyCart version for this to work supports-foxycart-version-to : # Last FoxyCart version that supports this (leave empty if unknown) systems : google # the system(s) that the integration is for, separated with commas if more than one name : Google Customer Reviews (Survey Opt-In) # the name of the integration description : Add the Survey Opt-In display to your receipt for Google Customer Reviews tags_tags : customer reviews # tags, separated by commas. don't include the "system" here. date_dt : # the date in YYYY-MM-DD format version : # if you have a version for your code, enter it here developer_url : # if you'd like a link back to your site, stick it here ---- ====== Google Customer Reviews (Survey Opt-In) ====== //**Please note:**// The code on this page is submitted by members of the FoxyCart community, and may not verified by FoxyCart.com LLC in any way, shape, or form. Please double check the code before installing. If you need help with it please [[http://forum.foxycart.com/|post in our forum]], but if we cannot offer assistance (due to unfamiliarity with this particular system or language) we apologize in advance. ===== Adding Google Customer Reviews to your Foxy store ===== ==== Requirements ==== * **Customer Reviews enabled on your Google Merchant Account** - [[https://support.google.com/merchants/answer/7188525?hl=en|review their documentation here]] for completing that. * **A custom subdomain for your Foxy Store** - The Opt-In Survey will also only display on your approved/validated domains. As such, your Foxy store will need to use a custom subdomain (like ''secure.yourstore.com''), rather than on our standard FoxyCart subdomain (like ''yourstore.foxycart.com''). ==== Add the integration code to your website ==== Once you have it enabled for your account - you'll then need to add some code to your store. Head to the "configuration" section of your store's Foxy administration, and if it isn't already enabled, enable the "Add custom header and footer code to your templates" option. Within the "footer" textarea, paste the following code: {% if context == "receipt" %} {% set gtin = [] %} {% for item in items %} {% for option in item.options %} {% if option.class == "gtin" %} {% set gtin = gtin|merge(['{"gtin":"' ~ option.value ~ '"}']) %} {% endif %} {% endfor %} {% endfor %} {% endif %} In the code above, make sure you update the ''MERCHANT_ID'' text with your own Google Merchant ID, which you can get from the Google Merchant Center. You may also need to modify the estimated delivery date value. The code above defaults to setting it to be 1 week after the transaction date. If you need to provide a different estimated delivery date, you will want to edit this portion of the code: ''%%"+7 day"%%''. For example, if you estimate delivery within 5 days, you would make it ''%%"+5 day"%%''. ==== Supporting product reviews with GTINs ==== The survey opt-in also allows for supporting product reviews, which requires that you pass GTIN (Global Trade Item Numbers) for each of your products. The code above does support passing the GTIN, and just require that you set a custom option to each of your product with a name of ''gtin''. For example, in a link like ''>in=123456789'' or in a form like ''%%%%''. You can [[https://support.google.com/merchants/answer/6219078?hl=en|use this page]] to find GTINs for your products. ==== Using product code instead of a custom product option for gtin ==== If you specify the ''gtin'' value as your product ''code'' already, you can use a modified version of the code to use the ''code'' you're passing. Specifically, replace this portion of the code: {% set gtin = [] %} {% for item in items %} {% for option in item.options %} {% if option.class == "gtin" %} {% set gtin = gtin|merge(['{"gtin":"' ~ option.value ~ '"}']) %} {% endif %} {% endfor %} {% endfor %} With this version: {% set gtin = [] %} {% for item in items %} {% set gtin = gtin|merge(['{"gtin":"' ~ item.code ~ '"}']) %} {% endfor %}