Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Magento和Google Trusted Store实现-Google返回数据集中的额外小数_Javascript_Php_Magento_Google Trusted Stores - Fatal编程技术网

Javascript Magento和Google Trusted Store实现-Google返回数据集中的额外小数

Javascript Magento和Google Trusted Store实现-Google返回数据集中的额外小数,javascript,php,magento,google-trusted-stores,Javascript,Php,Magento,Google Trusted Stores,我正在尝试在我的Magento 1.9 CE网站中完成Google Trusted Store集成。我目前已正确实施了该徽章,并通过了所有测试。我遇到的问题是确认脚本美元金额。我得到错误的格式是错误的,从错误到错误的格式是不一致的。我尝试了几个不同的php代码片段,从不同的地方(过于复杂的主题)提取美元金额,但似乎没有任何效果。以前有人遇到过这种情况吗 严重错误1: 编号格式不正确:“gts-o-tax-total” 如何修复:在Google Trusted Stores订单确认JavaScri

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

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

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

大多数错误显示为第一个,小数点后仅多出两位。“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>

www.mywebsite.com
美国
美元
-
订单预计交货日期
N
N
SKU
000000
美国
EN

我不确定是否能帮上忙,但我也在努力完成这项工作。 我已经联系了谷歌,他们专门为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”>
<!-- 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代码需要以下所有变量。请参阅

ORDER\u EST\u SHIP\u DATE
订单预计交货日期
有"缺货"和"预购"吗?
有数码产品吗
我根据需要更改了变量,但对我来说,我甚至没有像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>