0

I'm new to this, sorry. So let's say I'm trying to fill in dynamic values in the Google survey code explained here https://support.google.com/merchants/answer/7106244?hl=en&ref_topic=7105160#example

This post mentions a few of the fields How to insert Google Merchant Review JS code in WooCommerce Order Complete page

But what about the others, like shipping date and country code? How can those be dynamically filled in?

Would shipping country be shipping_country, so then <?php echo $shipping_country; ?> ?

What about delivery date, how is that put in? I see there are ways to calculate shipping dates (such as this), but we have multiple shipping options (local pick up, free over $200 and flat rates based on location). Is there a simple way to just pull this info from what the user selects?

Tried to look here, and other docs, but didn't find anything related to shipping https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/

This is what it wants to fill in:

<!-- BEGIN GCR Opt-in Module Code -->
<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({
            // REQUIRED
            "merchant_id": "MERCHANT_ID",
            "order_id": "ORDER_ID",
            "email": "CUSTOMER_EMAIL",
            "delivery_country": "COUNTRY_CODE",
            "estimated_delivery_date": "YYYY-MM-DD",
            // OPTIONAL
            "products":[{"gtin":"GTIN1"}, {"gtin":"GTIN2">}],
            "opt_in_style": "OPT_IN_STYLE"
        });
    });
}
</script>
EhsanT
  • 2,077
  • 3
  • 27
  • 31
joycegrace
  • 29
  • 3
  • "_Would shipping country be shipping_country, so then `` ?_". Yes indeed, as you can see in the example you shared you have access to the `$order_id` and then also to the `$order`. So then you get `$shipping_country = $order->get_shipping_country();'`, etc... – 7uc1f3r May 16 '20 at 22:59
  • see: https://stackoverflow.com/questions/22843504/how-to-get-customer-details-from-order-in-woocommerce/57562904#57562904 – 7uc1f3r May 16 '20 at 23:00
  • Thank you, but the remaining piece seems to be the delivery date. I can't seem to figure that one out or see it referenced anywhere, for how to get it to calculate properly, especially if there are different shipping options. Any ideas? – joycegrace May 18 '20 at 20:57
  • The [example](https://stackoverflow.com/questions/45215391/save-custom-delivery-dates-range-calculations-to-woocommerce-order-meta-data) cited above is a very good reference for this. Let me say, to fully answer your question, a little more commitment will be expected from your side. Don't get me wrong but stackoverflow namely is not a 'write code for me service'. In other words, if you get started with that example and you can't figure it out, you can still adjust your question and then someone will be able to help you further. With best regards – 7uc1f3r May 18 '20 at 21:23
  • Thank you, and I yes I completely understand this is a not a free 'write code for me' service. However, in all the examples and docs I've looked at, including the ones in my original post, I can't see or find anything related to the shipping date. I see other shipping details, but nothing for the times that packages arrive. I'm trying to see if the community knows where these are referenced in the WooCommerce database, if at all. I was wondering if there is a simpler way to do this with existing data, without having to calculate it with special code. I guess the answer is no, based on this. – joycegrace May 21 '20 at 02:54

1 Answers1

0

maybe use google tag manager. GTM runs in JA and iff you are running the GTM plugun it will have access to Woo variables

Olly P
  • 1