From 9ba79f26bbf23dbd931a518525d21d299d9c3a6d Mon Sep 17 00:00:00 2001 From: ChetanGN Date: Wed, 15 Jun 2022 16:36:14 +0530 Subject: [PATCH 1/3] Fixed UTM param issue --- btn-1cc-checkout.js | 3 +++ includes/api/order.php | 12 +++++++++--- woo-razorpay.php | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/btn-1cc-checkout.js b/btn-1cc-checkout.js index 7c8ed32f..2a8b812a 100644 --- a/btn-1cc-checkout.js +++ b/btn-1cc-checkout.js @@ -8,6 +8,9 @@ window.addEventListener('DOMContentLoaded', function() { var pageURL = jQuery(location).attr('href'); var url = new URL(pageURL); var accessToken = new URLSearchParams(url.search).get('wcf_ac_token'); + var referrerDomain = document.referrer.toString(); + + rzp1ccCheckoutData.referrerDomain = referrerDomain; // event triggered by wc on any cart change // as input function is the same, duplicate event listeners are NOT called diff --git a/includes/api/order.php b/includes/api/order.php index c5156592..01845b49 100644 --- a/includes/api/order.php +++ b/includes/api/order.php @@ -274,11 +274,17 @@ function wooSaveCheckoutUTMFields($orderId, $params) { $pysData = []; $cookieData = $params['cookies']; + $getQuery = $params['requestData']; $browserTime = $params['dateTime']; $pysData['pys_landing'] = isset($cookieData['pys_landing_page']) ? ($cookieData['pys_landing_page']) : ""; - $pysData['pys_source'] = isset($cookieData['pysTrafficSource']) ? ($cookieData['pysTrafficSource']) : "direct"; - - $pysData['pys_utm'] = "utm_source:" . $cookieData['pys_utm_source'] . "|utm_medium:" . $cookieData['pys_utm_medium'] . "|utm_campaign:" . $cookieData['pys_utm_campaign'] . "|utm_term:" . $cookieData['pys_utm_term'] . "|utm_content:" . $cookieData['pys_utm_content']; + $pysData['pys_source'] = $params['referrerDomain'] != '' ? $params['referrerDomain'] : "direct"; + $pysUTMSource = $cookieData['pys_utm_source'] ?? $getQuery['utm_source']; + $pysUTMMedium = $cookieData['pys_utm_medium'] ?? $getQuery['utm_medium']; + $pysUTMCampaign = $cookieData['pys_utm_campaign'] ?? $getQuery['utm_medium']; + $pysUTMTerm = $cookieData['pys_utm_term'] ?? $getQuery['utm_term']; + $pysUTMContent = $cookieData['pys_utm_content'] ?? $getQuery['utm_content']; + + $pysData['pys_utm'] = "utm_source:" . $pysUTMSource . "|utm_medium:" . $pysUTMMedium . "|utm_campaign:" . $pysUTMCampaign . "|utm_term:" . $pysUTMTerm . "|utm_content:" . $pysUTMContent; $pysData['pys_browser_time'] = $browserTime[0] . "|" . $browserTime[1] . "|" . $browserTime[2]; update_post_meta($orderId, "pys_enrich_data", $pysData); diff --git a/woo-razorpay.php b/woo-razorpay.php index ec94709e..78c611c3 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -1929,6 +1929,7 @@ function enqueueScriptsFor1cc() 'siteurl' => $siteurl, 'blogname' => get_bloginfo('name'), 'cookies' => $_COOKIE, + 'requestData' => $_REQUEST, ) ); wp_enqueue_script('btn_1cc_checkout'); } From 8353d4a622c42e05a3832187f56654ef37d70e72 Mon Sep 17 00:00:00 2001 From: ChetanGN Date: Thu, 16 Jun 2022 15:12:49 +0530 Subject: [PATCH 2/3] Handled the home screen landing source data --- includes/api/order.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/api/order.php b/includes/api/order.php index 01845b49..d803950b 100644 --- a/includes/api/order.php +++ b/includes/api/order.php @@ -277,7 +277,11 @@ function wooSaveCheckoutUTMFields($orderId, $params) $getQuery = $params['requestData']; $browserTime = $params['dateTime']; $pysData['pys_landing'] = isset($cookieData['pys_landing_page']) ? ($cookieData['pys_landing_page']) : ""; - $pysData['pys_source'] = $params['referrerDomain'] != '' ? $params['referrerDomain'] : "direct"; + $pysData['pys_source'] = isset($cookieData['pysTrafficSource']) ? ($cookieData['pysTrafficSource']) : "direct"; + if($pysData['pys_source'] == 'direct') + { + $pysData['pys_source'] = $params['referrerDomain'] != '' ? $params['referrerDomain'] : "direct"; + } $pysUTMSource = $cookieData['pys_utm_source'] ?? $getQuery['utm_source']; $pysUTMMedium = $cookieData['pys_utm_medium'] ?? $getQuery['utm_medium']; $pysUTMCampaign = $cookieData['pys_utm_campaign'] ?? $getQuery['utm_medium']; From 25fea2f513680df14efa2da6cb32a7fd1dec7ebb Mon Sep 17 00:00:00 2001 From: ChetanGN Date: Thu, 16 Jun 2022 15:15:20 +0530 Subject: [PATCH 3/3] Version bump to 3.8.3 --- readme.txt | 5 ++++- woo-razorpay.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index 57e5789d..743e5127 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: razorpay Tags: razorpay, payments, india, woocommerce, ecommerce Requires at least: 3.9.2 Tested up to: 5.9 -Stable tag: 3.8.2 +Stable tag: 3.8.3 Requires PHP: 5.6 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -41,6 +41,9 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has == Changelog == += 3.8.3 = +* Bug fix for UTM data for pixel your site plugin for magic checkout. + = 3.8.2 = * Bug fix for blog name in magic checkout. diff --git a/woo-razorpay.php b/woo-razorpay.php index 78c611c3..80daacbf 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -3,8 +3,8 @@ * Plugin Name: Razorpay for WooCommerce * Plugin URI: https://razorpay.com * Description: Razorpay Payment Gateway Integration for WooCommerce - * Version: 3.8.2 - * Stable tag: 3.8.2 + * Version: 3.8.3 + * Stable tag: 3.8.3 * Author: Team Razorpay * WC tested up to: 6.4.1 * Author URI: https://razorpay.com