Post by rhorne » Mon Oct 09, 2017 11:02 pm

Hello,

I'm trying to add Google Customer Reviews to our web shop.

It's quite simple in that you just add the following script to the end of your success.php page.

Code: Select all

<script src="https://apis.google.com/js/platform.js?onload=renderOptIn" async defer></script>			
			<script>
			  window.renderOptIn = function() {
				window.gapi.load('surveyoptin', function() {
				  window.gapi.surveyoptin.render(
					{
					  "merchant_id": MERCHANT ID,
					  "order_id": "ORDER ID",
					  "email": "CUSTOMER EMAILS",
					  "delivery_country": "COUNTRY ID",
					  "estimated_delivery_date": "ESTIMATED DELIVERY DATE"
					});
				});
			  }
			</script>
However, I'm having problems accessing the Order ID, Customer Email and Country ID variables as they're all unset at this point.

I've looked at a few other similar posts and they've suggested making changes to the base success.php code but I'm trying to make this a VQMOD that is added to the end of the success.php page. I know there are paid extensions out there, but I don't want to pay $49.99 just to capture 4 variables.

Any help would be gratefully received. I did consider setting these to session variables from the checkout.php page and then unsetting them on success.php but this seems a messy solution.

Active Member

Posts

Joined
Wed Jan 18, 2012 3:07 am

Post by straightlight » Mon Oct 09, 2017 11:30 pm

Hi,

this free tutorial may greatly help you: viewtopic.php?f=24&t=191768 . You can create a VQMod version of the JS code above.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by rhorne » Wed Oct 18, 2017 9:07 pm

That all seems a lot of unnecessary work just to capture a couple of variables.

I was hoping to just create a few session variables that I could call on the success page then unset.

Active Member

Posts

Joined
Wed Jan 18, 2012 3:07 am

Post by straightlight » Wed Oct 18, 2017 9:20 pm

In this case, better to use VQMod, OCMod or the override engine to make those captures. It will be way easier for you to handle parts of lines than having to play with core files. ;)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Qphoria » Wed Oct 18, 2017 11:11 pm

The way I do it is to add code the checkout/success.php controller within the

Code: Select all

if (isset($this->session->data['order_id'])) {
conditional, and append it to the $data['text_message'] variable later in the code if it was set.
Prevents the need to edit the tpl file

Alternatively, you can pass that session order id as a variable within the success.php controller, and then add a check for that variable in the common/success.tpl file. But keep in mind that the common/success.tpl file is common so you'll want to add some additional variable to ensure you are handling the checkout success and not the registration success or some other success call that shares this file.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by straightlight » Wed Oct 18, 2017 11:19 pm

I do have an already example developed for those requests: viewtopic.php?f=24&t=191768

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 104 guests