Razorpay for WooCommerce - Version 3.8.3

Version Description

  • Bug fix for UTM data for pixel your site plugin for magic checkout.
Download this release

Release Info

Developer razorpay
Plugin Icon 128x128 Razorpay for WooCommerce
Version 3.8.3
Comparing to
See all releases

Code changes from version 3.8.2 to 3.8.3

btn-1cc-checkout.js CHANGED
@@ -8,6 +8,9 @@ window.addEventListener('DOMContentLoaded', function() {
8
  var pageURL = jQuery(location).attr('href');
9
  var url = new URL(pageURL);
10
  var accessToken = new URLSearchParams(url.search).get('wcf_ac_token');
 
 
 
11
 
12
  // event triggered by wc on any cart change
13
  // as input function is the same, duplicate event listeners are NOT called
8
  var pageURL = jQuery(location).attr('href');
9
  var url = new URL(pageURL);
10
  var accessToken = new URLSearchParams(url.search).get('wcf_ac_token');
11
+ var referrerDomain = document.referrer.toString();
12
+
13
+ rzp1ccCheckoutData.referrerDomain = referrerDomain;
14
 
15
  // event triggered by wc on any cart change
16
  // as input function is the same, duplicate event listeners are NOT called
includes/api/order.php CHANGED
@@ -274,11 +274,21 @@ function wooSaveCheckoutUTMFields($orderId, $params)
274
  {
275
  $pysData = [];
276
  $cookieData = $params['cookies'];
 
277
  $browserTime = $params['dateTime'];
278
  $pysData['pys_landing'] = isset($cookieData['pys_landing_page']) ? ($cookieData['pys_landing_page']) : "";
279
  $pysData['pys_source'] = isset($cookieData['pysTrafficSource']) ? ($cookieData['pysTrafficSource']) : "direct";
 
 
 
 
 
 
 
 
 
280
 
281
- $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'];
282
  $pysData['pys_browser_time'] = $browserTime[0] . "|" . $browserTime[1] . "|" . $browserTime[2];
283
 
284
  update_post_meta($orderId, "pys_enrich_data", $pysData);
274
  {
275
  $pysData = [];
276
  $cookieData = $params['cookies'];
277
+ $getQuery = $params['requestData'];
278
  $browserTime = $params['dateTime'];
279
  $pysData['pys_landing'] = isset($cookieData['pys_landing_page']) ? ($cookieData['pys_landing_page']) : "";
280
  $pysData['pys_source'] = isset($cookieData['pysTrafficSource']) ? ($cookieData['pysTrafficSource']) : "direct";
281
+ if($pysData['pys_source'] == 'direct')
282
+ {
283
+ $pysData['pys_source'] = $params['referrerDomain'] != '' ? $params['referrerDomain'] : "direct";
284
+ }
285
+ $pysUTMSource = $cookieData['pys_utm_source'] ?? $getQuery['utm_source'];
286
+ $pysUTMMedium = $cookieData['pys_utm_medium'] ?? $getQuery['utm_medium'];
287
+ $pysUTMCampaign = $cookieData['pys_utm_campaign'] ?? $getQuery['utm_medium'];
288
+ $pysUTMTerm = $cookieData['pys_utm_term'] ?? $getQuery['utm_term'];
289
+ $pysUTMContent = $cookieData['pys_utm_content'] ?? $getQuery['utm_content'];
290
 
291
+ $pysData['pys_utm'] = "utm_source:" . $pysUTMSource . "|utm_medium:" . $pysUTMMedium . "|utm_campaign:" . $pysUTMCampaign . "|utm_term:" . $pysUTMTerm . "|utm_content:" . $pysUTMContent;
292
  $pysData['pys_browser_time'] = $browserTime[0] . "|" . $browserTime[1] . "|" . $browserTime[2];
293
 
294
  update_post_meta($orderId, "pys_enrich_data", $pysData);
includes/api/shipping-info.php CHANGED
@@ -278,13 +278,13 @@ function getCodShippingInfo1cc($instanceId, $methodId, $orderId, $address)
278
 
279
  $availablePaymentMethods = WC()->payment_gateways->payment_gateways();
280
 
 
 
 
281
  if (!isset($availablePaymentMethods['cod']) || 'no' == $availablePaymentMethods['cod']->enabled || !(($minCODAmount1cc <= $amount) && ($maxCODAmount1cc <= $amount))) {
282
  return false;
283
  }
284
 
285
- $minCODAmount1cc = !empty(get_option('woocommerce_razorpay_settings')['1cc_min_COD_slab_amount']) ? get_option('woocommerce_razorpay_settings')['1cc_min_COD_slab_amount'] : 0;
286
- $maxCODAmount1cc = !empty(get_option('woocommerce_razorpay_settings')['1cc_max_COD_slab_amount']) ? get_option('woocommerce_razorpay_settings')['1cc_max_COD_slab_amount'] : 0;
287
-
288
  $order = wc_get_order($orderId);
289
  $amount = floatval($order->get_total());
290
 
@@ -431,6 +431,7 @@ function smartCodRestriction($addresses, $order)
431
  $postals = explode(',', trim($restriction['restrict_postals']));
432
  $postals = array_map('trim', $postals);
433
  $customerZipcode = $addresses['zipcode'];
 
434
 
435
  foreach ($postals as $p) {
436
  if (!$p) {
278
 
279
  $availablePaymentMethods = WC()->payment_gateways->payment_gateways();
280
 
281
+ $minCODAmount1cc = !empty(get_option('woocommerce_razorpay_settings')['1cc_min_COD_slab_amount']) ? get_option('woocommerce_razorpay_settings')['1cc_min_COD_slab_amount'] : 0;
282
+ $maxCODAmount1cc = !empty(get_option('woocommerce_razorpay_settings')['1cc_max_COD_slab_amount']) ? get_option('woocommerce_razorpay_settings')['1cc_max_COD_slab_amount'] : 0;
283
+
284
  if (!isset($availablePaymentMethods['cod']) || 'no' == $availablePaymentMethods['cod']->enabled || !(($minCODAmount1cc <= $amount) && ($maxCODAmount1cc <= $amount))) {
285
  return false;
286
  }
287
 
 
 
 
288
  $order = wc_get_order($orderId);
289
  $amount = floatval($order->get_total());
290
 
431
  $postals = explode(',', trim($restriction['restrict_postals']));
432
  $postals = array_map('trim', $postals);
433
  $customerZipcode = $addresses['zipcode'];
434
+ $flag = 0;
435
 
436
  foreach ($postals as $p) {
437
  if (!$p) {
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: razorpay
3
  Tags: razorpay, payments, india, woocommerce, ecommerce
4
  Requires at least: 3.9.2
5
  Tested up to: 5.9
6
- Stable tag: 3.8.2
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  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
41
 
42
  == Changelog ==
43
 
 
 
 
44
  = 3.8.2 =
45
  * Bug fix for blog name in magic checkout.
46
 
3
  Tags: razorpay, payments, india, woocommerce, ecommerce
4
  Requires at least: 3.9.2
5
  Tested up to: 5.9
6
+ Stable tag: 3.8.3
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
41
 
42
  == Changelog ==
43
 
44
+ = 3.8.3 =
45
+ * Bug fix for UTM data for pixel your site plugin for magic checkout.
46
+
47
  = 3.8.2 =
48
  * Bug fix for blog name in magic checkout.
49
 
woo-razorpay.php CHANGED
@@ -3,8 +3,8 @@
3
  * Plugin Name: Razorpay for WooCommerce
4
  * Plugin URI: https://razorpay.com
5
  * Description: Razorpay Payment Gateway Integration for WooCommerce
6
- * Version: 3.8.2
7
- * Stable tag: 3.8.2
8
  * Author: Team Razorpay
9
  * WC tested up to: 6.4.1
10
  * Author URI: https://razorpay.com
@@ -1440,6 +1440,9 @@ EOT;
1440
  //Apply coupon to woo-order
1441
  if (empty($couponKey) === false)
1442
  {
 
 
 
1443
  //TODO: Convert all razorpay amount in paise to rupees
1444
  $discount_total = $razorpayData['promotions'][0]['value']/100;
1445
 
@@ -1463,6 +1466,18 @@ EOT;
1463
  //Apply shipping charges to woo-order
1464
  if(isset($razorpayData['shipping_fee']) === true)
1465
  {
 
 
 
 
 
 
 
 
 
 
 
 
1466
  // Get a new instance of the WC_Order_Item_Shipping Object
1467
  $item = new WC_Order_Item_Shipping();
1468
 
@@ -1914,6 +1929,7 @@ function enqueueScriptsFor1cc()
1914
  'siteurl' => $siteurl,
1915
  'blogname' => get_bloginfo('name'),
1916
  'cookies' => $_COOKIE,
 
1917
  ) );
1918
  wp_enqueue_script('btn_1cc_checkout');
1919
  }
3
  * Plugin Name: Razorpay for WooCommerce
4
  * Plugin URI: https://razorpay.com
5
  * Description: Razorpay Payment Gateway Integration for WooCommerce
6
+ * Version: 3.8.3
7
+ * Stable tag: 3.8.3
8
  * Author: Team Razorpay
9
  * WC tested up to: 6.4.1
10
  * Author URI: https://razorpay.com
1440
  //Apply coupon to woo-order
1441
  if (empty($couponKey) === false)
1442
  {
1443
+ // Remove the same coupon, if already being added to order.
1444
+ $order->remove_coupon($couponKey);
1445
+
1446
  //TODO: Convert all razorpay amount in paise to rupees
1447
  $discount_total = $razorpayData['promotions'][0]['value']/100;
1448
 
1466
  //Apply shipping charges to woo-order
1467
  if(isset($razorpayData['shipping_fee']) === true)
1468
  {
1469
+
1470
+ //To remove by default shipping method added on order.
1471
+ $existingItems = (array) $order->get_items('shipping');
1472
+ rzpLogInfo("Shipping details updated for orderId: $wcOrderId is".json_encode($existingItems));
1473
+
1474
+ if (sizeof($existingItems) != 0) {
1475
+ // Loop through shipping items
1476
+ foreach ($existingItems as $existingItemId) {
1477
+ $order->remove_item($existingItemId);
1478
+ }
1479
+ }
1480
+
1481
  // Get a new instance of the WC_Order_Item_Shipping Object
1482
  $item = new WC_Order_Item_Shipping();
1483
 
1929
  'siteurl' => $siteurl,
1930
  'blogname' => get_bloginfo('name'),
1931
  'cookies' => $_COOKIE,
1932
+ 'requestData' => $_REQUEST,
1933
  ) );
1934
  wp_enqueue_script('btn_1cc_checkout');
1935
  }