Google Trusted Stores with WooCommerce
-
This is how I’ve done it. Works for me.
Trusted Stores Badge Code
a) create child theme
b) create functions.php under your child theme with this code<?php add_action('wp_footer', 'add_gts_badge_code'); function add_gts_badge_code() { ?> // Paste your Trusted Stores Badge Code here <?php } ?>Order Confirmation Module Code
a) create override woocommerce/checkout/thankyou.php file under your child theme
b) add this code after<div class="clear"></div><!-- 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 $order->get_order_number(); ?></span> <span id="gts-o-email"><?php echo $order->billing_email; ?></span> <span id="gts-o-country"><?php echo $order->billing_country; ?></span> <span id="gts-o-currency"><?php echo $order->order_currency; ?></span> <span id="gts-o-total"><?php echo $order->order_total; ?></span> <span id="gts-o-discounts"><?php echo $order->cart_discount; ?></span> <span id="gts-o-shipping-total"><?php echo $order->order_shipping; ?></span> <span id="gts-o-tax-total"><?php echo $order->order_tax; ?></span> <span id="gts-o-est-ship-date"><?php echo date('Y-m-d', strtotime('+1 weekday')); ?></span> <span id="gts-o-est-delivery-date"><?php echo date('Y-m-d', strtotime('+6 weekday')); ?></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 --> <span class="gts-item"> <?php $gts_cart_items = $order->get_items(); foreach ( $gts_cart_items as $gts_line_item ) { print ("\t<span class='gts-i-name'>$gts_line_item[name]</span>\n"); print ("\t<span class='gts-i-price'>$gts_line_item[line_total]</span>\n"); print ("\t<span class='gts-i-quantity'>$gts_line_item[qty]</span>\n"); print ("\t<span class='gts-i-prodsearch-id'>YOUR_ITEM_GOOGLE_SHOPPING_ID</span>\n"); print ("\t<span class='gts-i-prodsearch-store-id'>YOUR_ITEM_GOOGLE_SHOPPING_ACCOUNT_ID</span>\n"); } ?> </span> <!-- end repeated item specific information --> </div> <!-- END Google Trusted Stores Order -->ps. I’ve seen a neater example on the web on how to handle digital downloads and backorder items, however in my case they don’t apply so I’ve used static values.
Good luck.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Google Trusted Stores with WooCommerce’ is closed to new replies.