0

我正在尝试在我的 Magento 1.9 CE 网站中完成 Google Trusted Store 集成。我目前已经正确实施了徽章并通过了所有测试。我遇到的问题是确认脚本的美元金额。我收到格式错误的错误,并且从错误到错误,格式不一致。我尝试了几个不同的 php 片段从不同的地方提取美元金额(过于复杂的主题),但似乎没有任何效果。有没有人遇到过这个?

严重错误 1:不正确的数字格式:“gts-o-tax-total” 如何修复:在 Google Trusted 的“gts-o-shipping-total”字段中提供与订单相关的总税款时,请遵循所需的格式存储订单确认 JavaScript 代码。所需格式:“123.45” 您的值:“1.6500”。

严重错误 2:不正确的值格式:“gts-i-price” 如何修复:在 Google Trusted Stores Order Confirmation JavaScript 的“gts-i-price”字段中提供与订单关联的商品价格时,请遵循所需的格式代码。所需格式:“123.45” 您的值:“19.9900,0.0000”。

大多数错误显示为第一个错误,小数点后仅多出 2 位。“gts-i-price”是我无法理解的。

这是我在success.phtml 页面中的代码。在尝试了其他一些脚本后,我在 SE 上发现了这个:

<?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
?>
<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">www.mywebsite.com</span>
  <span id="gts-o-email"><?php echo $email = $customer->getData('email'); $email_address2 = $address->getEmail(); if($email=="") $email = $email_address2; ?></span>
  <span id="gts-o-country">US</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-est-delivery-date">ORDER_EST_DELIVERY_DATE</span>
  <span id="gts-o-has-preorder">N</span>
  <span id="gts-o-has-digital">N</span>
  <!-- end order and merchant information -->

  <!-- start repeated item specific information -->
  <!-- item example: this area repeated for each item in the order -->
  <?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-id">SKU</span>
    <span class="gts-i-prodsearch-store-id">000000</span>
    <span class="gts-i-prodsearch-country">US</span>
    <span class="gts-i-prodsearch-language">en</span>
  </span>
  <?php endforeach; ?>


</div>
4

1 回答 1

0

不确定我是否可以提供帮助,但我也在努力完成这项工作。我已经联系了谷歌,他们专门给我发了这个 Magento 的片段:

<?php
// Obtain order variables with Magento functions
$orderId = $this->getOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
$address = $order->getShippingAddress();
?>
<!-- START Google Trusted Stores Order -->
<div id="Google Trusted Stores-order" style="display:none;" translate=”no”&gt;
<!-- start order and merchant information -->
<span id="Google Trusted Stores-o-id"> <?php echo $orderId; ?> </span>
<span id="Google Trusted Stores-o-domain"> MERCHANT_ORDER_DOMAIN </span>
<span id="Google Trusted Stores-o-email"> <?php echo
htmlentities($customer->getEmail()); ?> </span>
<span id="Google Trusted Stores-o-country"> <?php echo
htmlentities($address->getCountryId()); ?> </span>
<span id="Google Trusted Stores-o-currency"> CURRENCY </span>
<span id="Google Trusted Stores-o-total"> <?php echo $order->getGrandTotal(); ?> </span>
<span id="Google Trusted Stores-o-discounts"> -<?php echo $order->getDiscountAmount();
?> </span>
<span id="Google Trusted Stores-o-shipping-total"> <?php echo
$order->getShippingAmount(); ?> </span>
  <span id="Google Trusted Stores-o-tax-total"> <?php echo $order->getTaxAmount();
?> </span>
<span id="Google Trusted Stores-o-est-ship-date"> ORDER_EST_SHIP_DATE </span>
<span id="Google Trusted Stores-o-est-delivery-date"> ORDER_EST_DELIVERY_DATE </span>
<span id="Google Trusted Stores-o-has-preorder"> HAS_BACKORDER_PREORDER </span>
<span id="Google Trusted Stores-o-has-digital"> HAS_DIGITAL_GOODS </span>
<!-- end order and merchant information -->
<!-- start repeated item specific information -->
<?php foreach ($order->getAllItems() as $item): ?>
<span class="Google Trusted Stores-item">
<span class="Google Trusted Stores-i-name"> <?php echo htmlentities($item->getName());
?> </span>
<span class="Google Trusted Stores-i-price"> <?php echo $item->getBasePrice(); ?> </span>
<span class="Google Trusted Stores-i-quantity"> <?php echo (int)$item->getQtyOrdered();
?> </span>
</span>
<?php endforeach; ?>
<!-- end repeated item specific information -->
</div>
<!-- END Trusted Stores -->

他还说:

为了触发 OCM 代码,需要以下所有变量。请参阅此处的订单级别变量

<span id="Google Trusted Stores-o-est-ship-date">ORDER_EST_SHIP_DATE</span>
<span id="Google Trusted Stores-o-est-delivery-date">ORDER_EST_DELIVERY_DATE</span>
<span id="Google Trusted Stores-o-has-preorder"> HAS_BACKORDER_PREORDER </span>
<span id="Google Trusted Stores-o-has-digital"> HAS_DIGITAL_GOODS </span>

我根据需要更改了变量,但对我来说,我什至没有像 OCM 那样收到错误消息,所以我不知道这些代码是否正确,但可能适用于其他人。

我确定您已经遇到了所有这些信息,但我也需要一个答案。

于 2015-03-17T03:07:36.183 回答