• 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)
  • josephkearns

    (@josephkearns)

    Hi sashatchepourko,

    Thankyou for your work here.
    I am having some issues getting this to work correctly.
    I am running woocommerce, canvas with fashionable theme.
    When i paste the code into the functions.php i get errors and the entire site crashes.

    Could you please give me some further instructions to complete this setup?

    I added the code into the thankyou.php page and entered my ID and Account ID
    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”);

    in this part of your script.
    I then uploaded the file back to the server, ran a test sale and arrived at the thankyou page.
    With no trusted store badge or information anywhere?

    Please help.

    @sashatchepourko works perfect! Thanks for taking the time to post this, I couldn’t find instructions on how to do this anywhere, much appreciated!

    Here’s the code for child directory creation from /wp-content/themes:

    $ mkdir storefront-child
    $ vi storefront/style.css
    $ vi storefront-child/style.css
    $ vi storefront-child/functions.php
    $ mkdir storefront-child/woocommerce
    $ mkdir storefront-child/woocommerce/checkout
    $ cp ../plugins/woocommerce/templates/checkout/thankyou.php storefront-child/woocommerce/checkout/
    $ vi storefront-child/woocommerce/checkout/thankyou.php

    Hey All,

    I’m fairly new to woocommerce and google trusted stores… I followed the steps listed above, created the child theme, have the correct code in the functions.php and the child-theme/checkout/thankyou.php As I go through the google tests I get “passed” up until the checkout process… I, for whatever reason can’t get the “google protected purchase” option to show up, this not allowing me to complete the google verification.

    I would be extremely grateful for any insight.

    Best,
    Steve

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Google Trusted Stores with WooCommerce’ is closed to new replies.