I am trying to add Google Trust Badge to my magento store. I tried to search extension on Magento website, but I couldn't find one. Do I need to just paste the below code to the products and checkout page or I have to make changes to it? I will be very thankful if someone can guide me to right direction.
<!-- BEGIN: Google Trusted Store -->
<script type="text/javascript">
var gts = gts || [];
gts.push(["id", "54785"]);
gts.push(["google_base_offer_id", "ITEM_PRODUCT_SEARCH_ID"]);
gts.push(["google_base_subaccount_id", "ITEM_PRODUCT_SEARCH_ACCOUNT_ID"]);
gts.push(["google_base_country", "ITEM_PRODUCT_SEARCH_COUNTRY"]);
gts.push(["google_base_language", "ITEM_PRODUCT_SEARCH_LANGUAGE"]);
(function() {
var scheme = (("https:" == document.location.protocol) ? "https://" : "http://");
var gts = document.createElement("script");
gts.type = "text/javascript";
gts.async = true;
gts.src = scheme + "www.googlecommerce.com/trustedstores/gtmp_compiled.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(gts, s);
})();
</script>
<!-- END: Google Trusted Store -->
<!-- START Trusted Stores Order -->
<div id="gts-order" style="display:none;">
<!-- start order and merchant information -->
<span id="gts-o-id">MERCHANT_ORDER_ID</span>
<span id="gts-o-domain">MERCHANT_ORDER_DOMAIN</span>
<span id="gts-o-email">CUSTOMER_EMAIL</span>
<span id="gts-o-country">CUSTOMER_COUNTRY</span>
<span id="gts-o-currency">CURRENCY</span>
<span id="gts-o-total">ORDER_TOTAL</span>
<span id="gts-o-discounts">ORDER_DISCOUNTS</span>
<span id="gts-o-shipping-total">ORDER_SHIPPING</span>
<span id="gts-o-tax-total">ORDER_TAX</span>
<span id="gts-o-est-ship-date">ORDER_EST_SHIP_DATE</span>
<span id="gts-o-has-preorder">HAS_BACKORDER_PREORDER</span>
<span id="gts-o-has-digital">HAS_DIGITAL_GOODS</span>
<!-- end order and merchant information -->
<!-- start repeated item specific information -->
<!-- item example: this area repeated for each item in the order -->
<span class="gts-item">
<span class="gts-i-name">ITEM_NAME</span>
<span class="gts-i-price">ITEM_PRICE</span>
<span class="gts-i-quantity">ITEM_QUANTITY</span>
<span class="gts-i-prodsearch-id">ITEM_PRODUCT_SEARCH_ID</span>
<span class="gts-i-prodsearch-store-id">ITEM_PRODUCT_SEARCH_ACCOUNT_ID</span>
<span class="gts-i-prodsearch-country">ITEM_PRODUCT_SEARCH_COUNTRY</span>
<span class="gts-i-prodsearch-language">ITEM_PRODUCT_SEARCH_LANGUAGE</span>
</span>
<!-- end item 1 example -->
<!-- end repeated item specific information -->
</div>
<!-- END Trusted Stores -->
Implementing Google Trusted Stores: #3 Add the JavaScript to Your Site:
Google actually wants you to put the first part on every page of your site. Rather than do this in a template file you can add it to the Footer > Miscellaneous HTML in System > Configuration > General > Design. I removed ITEM_PRODUCT_SEARCH_ID
and ITEM_PRODUCT_SEARCH_ACCOUNT_ID
, but feel free to edit your product page to add this data. Here's the code:
<!-- BEGIN: Google Trusted Store -->
<script type="text/javascript">
var gts = gts || [];
gts.push(["id", "54785"]);
gts.push(["google_base_country", "US"]);
gts.push(["google_base_language", "en"]);
(function() {
var scheme = (("https:" == document.location.protocol) ? "https://" : "http://");
var gts = document.createElement("script");
gts.type = "text/javascript";
gts.async = true;
gts.src = scheme + "www.googlecommerce.com/trustedstores/gtmp_compiled.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(gts, s);
})();
</script>
<!-- END: Google Trusted Store -->
The rest of the code only needs to be on the Checkout Success page (app/design/frontend/{your}/{theme}/template/checkout/success.phtml). We need to load the order to grab the customer's email, country, and order data. You'll need to implement logic to determine whether or not any items are on backorder, whether any of the items are downloads, and when the items will be shipped. Add this anywhere in that file:
<?php
$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
?>
<!-- START Trusted Stores Order -->
<div id="gts-order" style="display:none;">
<!-- start order and merchant information -->
<span id="gts-o-id"><?php echo $orderId; ?></span>
<span id="gts-o-domain">{www.yourstore.com}</span>
<span id="gts-o-email"><?php echo htmlentities($customer->getEmail()); ?></span>
<span id="gts-o-country"><?php echo htmlentities($address->getCountryId()); ?></span>
<span id="gts-o-currency">USD</span>
<span id="gts-o-total"><?php echo $order->getGrandTotal(); ?></span>
<span id="gts-o-discounts">-<?php echo $order->getDiscountAmount(); ?></span>
<span id="gts-o-shipping-total"><?php echo $order->getShippingAmount(); ?></span>
<span id="gts-o-tax-total"><?php echo $order->getTaxAmount(); ?></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>
<!-- end order and merchant information -->
<!-- start repeated item specific information -->
<?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 $item->getBasePrice(); ?></span>
<span class="gts-i-quantity"><?php echo (int)$item->getQtyOrdered(); ?></span>
<span class="gts-i-prodsearch-country">US</span>
<span class="gts-i-prodsearch-language">en</span>
</span>
<?php endforeach; ?>
<!-- end repeated item specific information -->
</div>
<!-- END Trusted Stores -->
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With