我想谷歌信托徽章添加到我的Magento商店。 我试图寻找关于Magento的网站扩展,但我找不到一个。 我需要的只是下面的代码粘贴到产品和结帐页面或我必须做出改变呢? 我会很感激,如果有人能指导我正确的方向。
<!-- 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 -->
目前此后一直Magento的扩展名由谷歌自己发布: http://www.magentocommerce.com/magento-connect/google-trusted-stores-3308.html
谷歌执行信誉商店 : #3添加的JavaScript到您的网站 :
谷歌实际上要你把第一部分网站的每个页面上。 而不是一个模板文件做到这一点,你可以把它添加到页脚>其他HTML在系统>配置>常规>设计。 我删除ITEM_PRODUCT_SEARCH_ID
和ITEM_PRODUCT_SEARCH_ACCOUNT_ID
,但随时修改产品页面添加此数据。 下面的代码:
<!-- 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 -->
代码的其余部分只需要在结帐成功页面(应用程序/设计/前端/ {您} / {}主题/template/checkout/success.phtml)上。 我们需要加载为了抢客户的电子邮件,国家和订单数据。 你需要实现逻辑,以确定任何物品是否是在缺货,任何项目是否下载,当项目将被运。 添加在该文件中的任何地方这样:
<?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 -->
您可以在底部插入代码app/design/frontend/default/USED_TEMPLATE/template/checkout/onepage.phtml
有它出现在最终结账页面上。
您需要填写的变量,使用Magento的,功能和输出它们。 例如:
// Magento .phtml-style
<?php $cart = Mage::getSingleton( 'checkout/cart' ); ?>
<span class="gts-i-quantity"><?php echo $cart->getItemsCount(); ?></span>`
或者你走很长的路,使用Magento的钩在自己的扩展到目前的谷歌 - 摘录不管你想要的,而不需要实现它的模板。
代码肯定需要在应用程序文件夹(应用程序/设计/前端/ yourtheme /template/checkout/success.phtml)结账成功页面上。 我发现我的答案这里Magento的徽章实施 ,但就像几个答案表明,它是逻辑,它是重要的,它是根据你所运行的扩展和定制开发每家商店通常是不同的。
<!– START Google Trusted Stores Order –>
<div id=”gts-order” style=”display:none;” translate=”no”>
<!– start order and merchant information –>
<span id=”gts-o-id”><?php echo $orderId; ?></span>
<span id=”gts-o-domain”>[INSERT URL (www.example.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 round_and_kep($order->getGrandTotal()); ?></span>
<span id=”gts-o-discounts”>[CALL IT OUT WITH CODE – use 0 if no discounts]</span>
<span id=”gts-o-shipping-total”><?php echo round_and_kep($order->getShippingAmount()); ?></span>
<span id=”gts-o-tax-total”><?php echo round_and_kep($order->getTaxAmount()); ?></span>
<span id=”gts-o-est-ship-date”><?php echo $shipDate->toString(‘yyyy-MM-dd’); ?></span>
<span id=”gts-o-est-delivery-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 –>
<!– item example: this area repeated for each item in the order –>
<span class=”gts-item”>
<span class=”gts-i-name”><?php echo htmlentities($item->getName()); ?></span>
<span class=”gts-i-price”><?php echo round_and_kep($item->getBasePrice()); ?></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”>[YOUR STORE ID GIVEN TO YOU BY GOOGLE]</span>
<span class=”gts-i-prodsearch-country”>US</span>
<span class=”gts-i-prodsearch-language”>en</span>
</span>
<!– end item 1 example –>
<!– end repeated item specific information –>
</div>
<!– END Google Trusted Stores Order –>