4

我正在尝试将 Google Trust Badge 添加到我的 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 -->
4

4 回答 4

6

实施 Google 可信商店#3 将 JavaScript 添加到您的站点

Google 实际上希望您将第一部分放在网站的每个页面上。无需在模板文件中执行此操作,您可以将其添加到 System > Configuration > General > Design 中的 Footer > Miscellaneous HTML。我删除了ITEM_PRODUCT_SEARCH_IDITEM_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 -->

Magento 系统/配置/设计/页脚 HTML 的屏幕截图

其余代码只需在Checkout Success页面 (app/design/frontend/{your}/{theme}/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 -->
于 2012-06-08T00:12:34.280 回答
2

您可以在底部插入该代码以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 钩子在任何你想要的地方展示谷歌片段,而不需要在模板中实现它。

于 2012-06-07T21:11:30.673 回答
2

代码肯定需要在 app 文件夹 (app/design/frontend/ yourtheme /template/checkout/ success.phtml) 中的结帐成功页面上。我在这里找到了关于magento 徽章实现的答案,但就像几个答案表明它很重要一样,它是逻辑的,并且每个商店通常都不同,具体取决于您正在运行的扩展和自定义开发。

    <!– START Google Trusted Stores Order –&gt;
<div id=”gts-order” style=”display:none;” translate=”no”&gt;

<!– start order and merchant information –&gt;
<span id=”gts-o-id”&gt;<?php echo $orderId; ?></span>
<span id=”gts-o-domain”&gt;[INSERT URL (www.example.com)]</span>
<span id=”gts-o-email”&gt;<?php echo htmlentities($customer->getEmail()); ?></span>
<span id=”gts-o-country”&gt;<?php echo htmlentities($address->getCountryId()); ?></span>
<span id=”gts-o-currency”&gt;[USD]</span>
<span id=”gts-o-total”&gt;<?php echo round_and_kep($order->getGrandTotal()); ?></span>
<span id=”gts-o-discounts”&gt;[CALL IT OUT WITH CODE – use 0 if no discounts]</span>
<span id=”gts-o-shipping-total”&gt;<?php echo round_and_kep($order->getShippingAmount()); ?></span>
<span id=”gts-o-tax-total”&gt;<?php echo round_and_kep($order->getTaxAmount()); ?></span>
<span id=”gts-o-est-ship-date”&gt;<?php echo $shipDate->toString(‘yyyy-MM-dd’); ?></span>
<span id=”gts-o-est-delivery-date”&gt;<?php echo $shipDate->toString(‘yyyy-MM-dd’); ?></span>
<span id=”gts-o-has-preorder”&gt;<?php echo $backorder ? ‘Y’ : ‘N'; ?></span>
<span id=”gts-o-has-digital”&gt;<?php echo $download ? ‘Y’ : ‘N'; ?></span>
<!– end order and merchant information –&gt;

<!– start repeated item specific information –&gt;
<!– item example: this area repeated for each item in the order –&gt;
<span class=”gts-item”&gt;
<span class=”gts-i-name”&gt;<?php echo htmlentities($item->getName()); ?></span>
<span class=”gts-i-price”&gt;<?php echo round_and_kep($item->getBasePrice()); ?></span>
<span class=”gts-i-quantity”&gt;<?php echo (int)$item->getQtyOrdered(); ?></span>
<span class=”gts-i-prodsearch-id”&gt;[ITEM_GOOGLE_SHOPPING_ID]</span>
<span class=”gts-i-prodsearch-store-id”&gt;[YOUR STORE ID GIVEN TO YOU BY GOOGLE]</span>
<span class=”gts-i-prodsearch-country”&gt;US</span>
<span class=”gts-i-prodsearch-language”&gt;en</span>
</span>
<!– end item 1 example –&gt;
<!– end repeated item specific information –&gt;

</div>
<!– END Google Trusted Stores Order –&gt;
于 2015-10-20T04:17:19.100 回答
1

此后谷歌自己发布了一个 Magento 扩展:http: //www.magentocommerce.com/magento-connect/google-trusted-stores-3308.html

于 2012-09-01T03:04:01.967 回答