I'm trying to complete the Google Trusted Store integration in my Magento 1.9 CE website. I've currently got the badge properly implemented and passing all tests. What I'm having trouble with is the confirmation script dollar amounts. I'm getting errors that the format is wrong and from error to error the format is inconsistent. I've tried a couple of different php snippets to pull dollar amounts from different places (overly complicated theme) but nothing seems to work. Has anyone encountered this before?
Critical Error 1: Incorrect number format: “gts-o-tax-total” How to Fix: Follow the required format when providing the total taxes associated with the order in the “gts-o-shipping-total” field of the Google Trusted Stores Order Confirmation JavaScript code. Required format: “123.45” Your value: “1.6500”.
Critical Error 2: Incorrect value format: “gts-i-price” How to Fix: Follow the required format when providing the item price associated with the order in the “gts-i-price” field of the Google Trusted Stores Order Confirmation JavaScript code. Required format: “123.45” Your value: “19.9900,0.0000”.
Most errors show as the first with only 2 extra places behind the decimal. "gts-i-price" is something I can't understand.
Here's the code I have in my success.phtml page. I found this on SE after trying a few other scripts:
<?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>