Post by justint24 » Mon Oct 27, 2014 12:57 am

Hi There,

I am struggling with getting this to work.

I have got the badge for all pages working but struggling with the confirmation module code to work, any help would be very much appreciated.

I believe the code goes in /catalog/view/theme/default/template/common/success.tpl

Here's what i have but its not working, do i have the variables correct???

Code: Select all

<!-- START Google Certified Shops Order -->
<div id="gts-order" style="display:none;" translate="no">

  <!-- start order and merchant information -->
  <span id="gts-o-id">[order_id]</span>
  <span id="gts-o-domain">www.#.com</span>
  <span id="gts-o-email">[email]</span>
  <span id="gts-o-country">[iso_code_2]</span>
  <span id="gts-o-currency">GBP</span>
  <span id="gts-o-total">[order_total]</span>
  <span id="gts-o-discounts">[discounts]</span>
  <span id="gts-o-shipping-total">[shipping]</span>
  <span id="gts-o-tax-total">[tax]</span>
  <span id="gts-o-est-ship-date">5 days</span>
  <span id="gts-o-est-delivery-date">5 days</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 -->
  <span class="gts-item">
    <span class="gts-i-name">[name]</span>
    <span class="gts-i-price">[price]</span>
    <span class="gts-i-quantity">[quantity]</span>
    <span class="gts-i-prodsearch-id">#</span>
    <span class="gts-i-prodsearch-store-id">#</span>
    <span class="gts-i-prodsearch-country">GB</span>
    <span class="gts-i-prodsearch-language">en</span>
  </span>
  <!-- end item 1 example -->
  <!-- end repeated item specific information -->

New member

Posts

Joined
Mon Oct 27, 2014 12:49 am

Post by soundzgood-nz » Mon Oct 27, 2014 2:53 am

Hi

I'm not sure if the placeholder tags like [order_id] and [email] are just standing in for data that's being pulled from the order's session data or database tables ... or if the data isn't being grabbed at all.

So to explain - most of the placeholder tags like [order_id] need to be pulled from the order's session data or database and calculated ... so the example code you've given has placeholder tags but no actual way of getting the data needed to populate them. For example the dates require an actual date relative to the order date in a yyyy/mm/dd format.

Here's a basic outline with variables that need to be created for the correct data to go (from an oscommerce cart, not opencart, but it gives you the idea):

Code: Select all

<!-- START Google Certified Shops Order -->
	<div id="gts-order" style="display:none;" translate="no">
	<!-- start order and merchant information -->
		<span id="gts-o-id"><?php echo $trans['id']; ?></span> <!--// MERCHANT_ORDER_ID //-->
		<span id="gts-o-domain"><?php echo $domain; ?></span> <!--// MERCHANT_ORDER_DOMAIN  //-->
		<span id="gts-o-email"><?php echo $cemail; ?></span> <!--// CUSTOMER_EMAIL //-->
		<span id="gts-o-country"><?php echo $ccountry; ?></span> <!--// CUSTOMER_COUNTRY //-->
		<span id="gts-o-currency"><?php echo $currency; ?></span> <!--// CURRENCY //-->
		<span id="gts-o-total"><?php echo $trans['revenue']; ?></span> <!--//ORDER_TOTAL //-->
		<span id="gts-o-discounts"><?php echo $trans['discount']; ?></span> <!--// ORDER_DISCOUNTS //-->
		<span id="gts-o-shipping-total"><?php echo $trans['shipping']; ?></span> <!--// ORDER_SHIPPING //-->
		<span id="gts-o-tax-total"><?php echo $trans['tax']; ?></span> <!--// ORDER_TAX -->
		<span id="gts-o-est-ship-date"><?php echo $trans['sdate']; ?></span> <!--// ORDER_EST_SHIP_DATE //-->
		<span id="gts-o-est-delivery-date"><?php echo $trans['ddate']; ?></span> <!--// ORDER_EST_DELIVERY_DATE //-->
		<span id="gts-o-has-preorder">N</span> <!--// HAS_BACKORDER_PREORDER - hardcoded //-->
		<span id="gts-o-has-digital">N</span> <!--// HAS_DIGITAL_GOODS - hardcoded //-->
	<!-- end order and merchant information -->
	<!-- start repeated item specific information -->
<?php foreach ($itemz as &$item) { ?>  
		<span class="gts-item">
			<span class="gts-i-name"><?php echo $item['name']; ?></span> <!--// ITEM_NAME //-->  
			<span class="gts-i-price"><?php echo number_format($item['price'], 2, '.', ''); ?></span> <!--// ITEM_PRICE //-->
			<span class="gts-i-quantity"><?php echo $item['quantity']; ?></span> <!--// ITEM_QUANTITY //-->
			<span class="gts-i-prodsearch-id"><?php echo $item['pid']; ?></span> <!--// ITEM_GOOGLE_SHOPPING_ID //-->
			<span class="gts-i-prodsearch-store-id">99999999</span> <!--// ITEM_GOOGLE_SHOPPING_ACCOUNT_ID - hardcoded //-->
			<span class="gts-i-prodsearch-country">GB</span> <!--// ITEM_GOOGLE_SHOPPING_COUNTRY - hardcoded //-->
			<span class="gts-i-prodsearch-language">en</span> <!--// ITEM_GOOGLE_SHOPPING_LANGUAGE - hardcoded //-->
		</span>
<?php } ?>  
	<!-- end repeated item specific information -->
	</div>
<!-- END Google Certified Shops Order -->
The template file you mention should work ok as long as you're aware that it'd require the customer to return here after purchasing ... not all do as they may bail out before returning to your store eg Paypal.

Simon

User avatar
Active Member

Posts

Joined
Sat Oct 25, 2014 5:15 pm
Location - New Zealand

Post by justint24 » Tue Oct 28, 2014 3:16 pm

Thanks.

Paypal does redirect to the success page, when i make a test purchase i'm sent to the success page and when i view the source code of that page the code is there which made me think it was the incorrect variables that was causing it to not work.

Thanks for the variables from oscommerce, although this initial thread was to ask for the correct variables from opencart, i've done everything else i just the variables, i have also tried this for for example order id

Code: Select all

<?php echo $order_id; ?>
but it still doesn't work

New member

Posts

Joined
Mon Oct 27, 2014 12:49 am

Post by uksitebuilder » Tue Oct 28, 2014 4:35 pm

Cart session variables are cleared in the checkout/success controller, so you will need to grab them before they get unset. This link may get your started

http://forum.opencart.com/viewtopic.php ... pl#p503522

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by justint24 » Tue Oct 28, 2014 6:01 pm

That's awesome thanks.

So just to clarify, I need to add these session variables to success.php

Then add the following variables to success.tpl

Code: Select all

<?php echo $order_id; ?>

New member

Posts

Joined
Mon Oct 27, 2014 12:49 am

Post by uksitebuilder » Tue Oct 28, 2014 6:14 pm

In catalog/controller/check/success.php

you have this section at the top which clears the cart session data

Code: Select all

<?php
class ControllerCheckoutSuccess extends Controller { 
	public function index() { 	
		if (isset($this->session->data['order_id'])) {
			$this->cart->clear();

			unset($this->session->data['shipping_method']);
			unset($this->session->data['shipping_methods']);
			unset($this->session->data['payment_method']);
			unset($this->session->data['payment_methods']);
			unset($this->session->data['guest']);
			unset($this->session->data['comment']);
			unset($this->session->data['order_id']);	
			unset($this->session->data['coupon']);
			unset($this->session->data['reward']);
			unset($this->session->data['voucher']);
			unset($this->session->data['vouchers']);
			unset($this->session->data['totals']);
		}	
What you need to do is define the variables you need for your tracking code before the sesion data gets unset

You can then access those variables in your .tpl file

e.g

Code: Select all

<?php
class ControllerCheckoutSuccess extends Controller { 
	public function index() { 	
		if (isset($this->session->data['order_id'])) {
			$this->data['order_id'] = $this->session->data['order_id'];
			// etc etc

			$this->cart->clear();

			unset($this->session->data['shipping_method']);
			unset($this->session->data['shipping_methods']);
			unset($this->session->data['payment_method']);
			unset($this->session->data['payment_methods']);
			unset($this->session->data['guest']);
			unset($this->session->data['comment']);
			unset($this->session->data['order_id']);	
			unset($this->session->data['coupon']);
			unset($this->session->data['reward']);
			unset($this->session->data['voucher']);
			unset($this->session->data['vouchers']);
			unset($this->session->data['totals']);
		}	
Then $order_id is available to you because it was created before the session was unset

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by justint24 » Tue Oct 28, 2014 7:28 pm

Thanks for your help, I'll give that a go today and report back, much appreciated.

New member

Posts

Joined
Mon Oct 27, 2014 12:49 am

Post by justint24 » Wed Oct 29, 2014 5:01 am

Hi again,

I've tried my best to follow your instructions but the google bar is still saying failed, i'm getting this error

Code: Select all

<b>Notice</b>:  Undefined variable
Here's what i have in catalog/controller/checkout/success.php

Code: Select all

<?php
class ControllerCheckoutSuccess extends Controller { 
	public function index() { 	
		
		if ( isset($this->session->data['order_id']) && ( ! empty($this->session->data['order_id']))  ) {
			$this->session->data['last_order_id'] = $this->session->data['order_id'];
		}
		
		if (isset($this->session->data['order_id'])) {
                        $this->data['order_id'] = $this->session->data['order_id'];
                        $this->data['email'] = $this->session->data['email'];
                        $this->data['iso_code_2'] = $this->session->data['iso_code_2'];
                        $this->data['order_total'] = $this->session->data['order_total'];
                        $this->data['discounts'] = $this->session->data['discounts'];
                        $this->data['shipping'] = $this->session->data['shipping'];
                        $this->data['tax'] = $this->session->data['tax'];
                        $this->data['product_name'] = $this->session->data['product_name'];
                        $this->data['price'] = $this->session->data['price'];
                        $this->data['quantity'] = $this->session->data['quantity'];
			$this->cart->clear();
			
			unset($this->session->data['shipping_method']);
			unset($this->session->data['shipping_methods']);
			unset($this->session->data['payment_method']);
			unset($this->session->data['payment_methods']);
			unset($this->session->data['guest']);
			unset($this->session->data['comment']);
			unset($this->session->data['order_id']);	
			unset($this->session->data['coupon']);
			unset($this->session->data['reward']);
			unset($this->session->data['voucher']);
			unset($this->session->data['vouchers']);
		}	
									   
		$this->language->load('checkout/success');
And here's the google confirmation code in success.tpl

Code: Select all

<!-- START Google Certified Shops Order -->
<div id="gts-order" style="display:none;" translate="no">

  <!-- start order and merchant information -->
  <span id="gts-o-id"><?php echo $order_id; ?></span>
  <span id="gts-o-domain">www.mysite.com</span>
  <span id="gts-o-email"><?php echo $email; ?></span>
  <span id="gts-o-country"><?php echo $iso_code_2; ?></span>
  <span id="gts-o-currency">GBP</span>
  <span id="gts-o-total"><?php echo $order_total; ?></span>
  <span id="gts-o-discounts"><?php echo $discounts; ?></span>
  <span id="gts-o-shipping-total"><?php echo $shipping; ?></span>
  <span id="gts-o-tax-total"><?php echo $tax; ?></span>
  <span id="gts-o-est-ship-date">YYYY-MM-DD</span>
  <span id="gts-o-est-delivery-date">YYYY-MM-DD</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 -->
  <span class="gts-item">
    <span class="gts-i-name"><?php echo $product_name; ?></span>
    <span class="gts-i-price"><?php echo $price; ?>]</span>
    <span class="gts-i-quantity"><?php echo $quantity; ?></span>
    <span class="gts-i-prodsearch-id">123456</span>
    <span class="gts-i-prodsearch-store-id">123456</span>
    <span class="gts-i-prodsearch-country">GB</span>
    <span class="gts-i-prodsearch-language">en</span>
  </span>
  <!-- end item 1 example -->
  <!-- end repeated item specific information -->
Can you have a quick look please to see if i have got it right, thanks.

New member

Posts

Joined
Mon Oct 27, 2014 12:49 am

Post by uksitebuilder » Wed Oct 29, 2014 5:20 am

I'm guessing you are not using OC 1.5.6.4, so you don't get access to the 'order_totals' session.

Alas this is looking like more than a 5 minute on the forums fix.

What you do have is the order id.

This topic deals with a similar problem albeit for Google Analytics E-Commerce Tracking

http://forum.opencart.com/viewtopic.php?t=21675

But explains later on how to get the variables etc

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by justint24 » Wed Oct 29, 2014 6:11 am

Sorry I'm using OC 1.5.4

I can't really grasp what the other thread means, I am a bit of a noob with this but trying my best to understand it, what do I do if I can't fix this myself? Is there someone I can pay to help with this?

Really appreciate your help so far.

New member

Posts

Joined
Mon Oct 27, 2014 12:49 am

Post by uksitebuilder » Wed Oct 29, 2014 6:20 am

No problem, there is a commercial support forum you can post a request to which you will be inundated with replies to get this working for you.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by justint24 » Wed Oct 29, 2014 2:21 pm

Thank you, i've now posted this on the commercial support forum.

New member

Posts

Joined
Mon Oct 27, 2014 12:49 am

Post by NigGuis » Wed Sep 23, 2015 9:01 pm

Hi Justint24
Did you resolve this as I am having the same issue.
Thanks

Cheers Mark


Newbie

Posts

Joined
Sat May 19, 2012 10:13 pm
Location - UK
Who is online

Users browsing this forum: No registered users and 26 guests