i want to pull variables from the order confirmation/sucess page and pass these variables to Google trusted store script. Trusted store script is of this format


Has someone implemented Google Trusted Store for Magento? Any kind of help would be appreciated. Thanks

  • What have you already tried? You can easily extract this information from the active session/order in success.phtml
    – paj
    Commented Oct 6, 2015 at 8:26
  • Hi i have tried a script provided by human-element.com/google-trusted-stores-magento However, the script doesnot work for extracting email address when the person purchases as a guest
    – Gill
    Commented Oct 6, 2015 at 14:11

1 Answer 1


After several modifications, here's what worked for me.

$orderId = $this->getOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
$address = $order->getShippingAddress();
$backorder = false; // some backorder logic
$download = false; // some download logic
$shipDate = new Zend_Date(); // some logic to determine ship date

<div id="gts-order" style="display:none;">
    <span id="gts-o-id"><?php echo $orderId; ?></span>
    <span id="gts-o-domain">www.yourdomain.com</span>
    <span id="gts-o-email"><?php echo htmlentities($customer->getEmail()); ?></span>
    <span id="gts-o-country">US</span>
    <span id="gts-o-currency">USD</span>
    <span id="gts-o-total"><?php echo (round($order->getGrandTotal(),2)); ?></span>
    <span id="gts-o-discounts"><?php echo (round($order->getDiscountAmount(),2)); ?></span>
    <span id="gts-o-shipping-total"><?php echo (round($order->getShippingAmount(),2)); ?></span>
    <span id="gts-o-tax-total"><?php echo (round($order->getTaxAmount(),2)); ?></span>
    <span id="gts-o-est-ship-date"><?php echo $shipDate->toString('yyyy-MM-dd'); ?></span>
    <span id="gts-o-has-preorder"><?php echo $backorder ? 'Y' : 'N'; ?></span>
    <span id="gts-o-has-digital"><?php echo $download ? 'Y' : 'N'; ?></span>
    <?php foreach ($order->getAllItems() as $item): ?>
        <span class="gts-item">
          <span class="gts-i-name"><?php echo htmlentities($item->getName()); ?></span>
          <span class="gts-i-price"><?php echo (round($item->getBasePrice(),2)); ?></span>
          <span class="gts-i-quantity"><?php echo (int)$item->getQtyOrdered(); ?></span>
          <span class="gts-i-prodsearch-id">ITEM_GOOGLE_SHOPPING_ID</span>
          <span class="gts-i-prodsearch-store-id">ITEM_GOOGLE_SHOPPING_ACCOUNT_ID</span>
          <span class="gts-i-prodsearch-country">US</span>
          <span class="gts-i-prodsearch-language">en</span>
    <?php endforeach; ?>
<!-- END Trusted Stores -->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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