1

I'm trying to add the google customer reviews opt-in survey to my order confirmation page using the code below. The script appears to be working, pulling the correct order information. However, there is no box in the middle of the screen for the customer to opt-in to the survey as google suggested there would be. If anyone has had any success implementing this on Magento 1.9 please help in any way you can.

Thank you.

<?php
    $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
    $order = Mage::getModel('sales/order')->load($orderId);
    ?>
    <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": 112592416,
                    "order_id": "<?php echo $order->getIncrementId() ?>",
                    "email": <?php echo $order->getCustomerEmail() ?>,
                    "delivery_country":  "<?php echo $order->getShippingAddress()->getCountryId() ?>",
                    "estimated_delivery_date": "<?php $date = date("Y-m-d"); $mod_date = strtotime($date."+ 6 days"); echo date("Y-m-d",$mod_date); ?>"

                });
        });
    }
    </script>
<!-- END GCR Opt-in Module Code -->
0

Try to change this line:

"email": getCustomerEmail() ?>,

into

"email": "getCustomerEmail() ?>",

or, copy and past (check your Merchant ID):

<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": 112592416,
              "order_id": "<?php echo $order->getIncrementId(); ?>",
              "email": "<?php echo $order->getCustomerEmail(); ?>",
              "delivery_country": "<?php echo $order->getShippingAddress()->getCountryId(); ?>",
              "estimated_delivery_date": "<?php $date = date('Y-m-d'); $mod_date = strtotime($date.'+ 3 days'); echo date('Y-m-d',$mod_date); ?>"
            });
        });
    }
    </script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.