Razorpay for WooCommerce - Version 4.3.3

Version Description

  • Added, checkbox to enable affordability widget.
  • Fixed, Api call being made from all pages for features.
Download this release

Release Info

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

Code changes from version 4.3.2 to 4.3.3

includes/razorpay-affordability-widget.php CHANGED
@@ -358,6 +358,13 @@ function getAffordabilityWidgetSettings()
358
  'desc' => '',
359
  'id' => 'rzp_afd_section_title'
360
  ),
 
 
 
 
 
 
 
361
  'enable_test_mode' => array(
362
  'title' => __('Test Mode Enable/Disable'),
363
  'type' => 'checkbox',
358
  'desc' => '',
359
  'id' => 'rzp_afd_section_title'
360
  ),
361
+ 'enable' => array(
362
+ 'title' => __('Affordability Widget Enable/Disable'),
363
+ 'type' => 'checkbox',
364
+ 'desc' => __('Enable Affordability Widget?'),
365
+ 'default' => 'no',
366
+ 'id' => 'rzp_afd_enable'
367
+ ),
368
  'enable_test_mode' => array(
369
  'title' => __('Test Mode Enable/Disable'),
370
  'type' => 'checkbox',
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: 6.0.1
6
- Stable tag: 4.3.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,10 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has
41
 
42
  == Changelog ==
43
 
 
 
 
 
44
  = 4.3.2 =
45
  * Added, support for variable products.
46
  * Removed, checkbox to enable affordability widget.
3
  Tags: razorpay, payments, india, woocommerce, ecommerce
4
  Requires at least: 3.9.2
5
  Tested up to: 6.0.1
6
+ Stable tag: 4.3.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
+ = 4.3.3 =
45
+ * Added, checkbox to enable affordability widget.
46
+ * Fixed, Api call being made from all pages for features.
47
+
48
  = 4.3.2 =
49
  * Added, support for variable products.
50
  * Removed, checkbox to enable affordability widget.
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: 4.3.2
7
- * Stable tag: 4.3.2
8
  * Author: Team Razorpay
9
  * WC tested up to: 6.7.0
10
  * Author URI: https://razorpay.com
@@ -328,42 +328,47 @@ function woocommerce_razorpay_init()
328
  }
329
 
330
  //Affordability Widget Code
331
- try
 
 
332
  {
333
- if (isset($_POST['woocommerce_razorpay_key_id']) and
334
- empty($_POST['woocommerce_razorpay_key_id']) === false and
335
- isset($_POST['woocommerce_razorpay_key_secret']) and
336
- empty($_POST['woocommerce_razorpay_key_secret']) === false)
337
- {
338
- $api = new Api($_POST['woocommerce_razorpay_key_id'], $_POST['woocommerce_razorpay_key_secret']);
339
- }
340
- else
341
- {
342
- $api = $this->getRazorpayApiInstance();
343
- }
344
-
345
- $merchantPreferences = $api->request->request('GET', 'accounts/me/features');
346
-
347
- if (isset($merchantPreferences) === false or
348
- isset($merchantPreferences['assigned_features']) === false)
349
- {
350
- throw new Exception("Error in Api call.");
351
- }
352
-
353
- foreach ($merchantPreferences['assigned_features'] as $preference)
354
  {
355
- if ($preference['name'] === 'affordability_widget')
 
 
 
356
  {
357
- add_action('woocommerce_sections_checkout', 'addSubSection');
358
- add_action('woocommerce_settings_tabs_checkout', 'displayAffordabilityWidgetSettings');
359
- add_action('woocommerce_update_options_checkout', 'updateAffordabilityWidgetSettings');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  }
361
  }
362
- }
363
- catch (\Exception $e)
364
- {
365
- rzpLogError($e->getMessage());
366
- return;
367
  }
368
  }
369
 
@@ -2230,30 +2235,39 @@ EOT;
2230
 
2231
  add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'razorpay_woo_plugin_links');
2232
 
2233
- try
2234
- {
2235
- $api = new Api(get_option('woocommerce_razorpay_settings')['key_id'], get_option('woocommerce_razorpay_settings')['key_secret']);
2236
- $merchantPreferences = $api->request->request('GET', 'accounts/me/features');
2237
 
2238
- if (isset($merchantPreferences) === false or
2239
- isset($merchantPreferences['assigned_features']) === false)
 
 
2240
  {
2241
- throw new Exception("Error in Api call.");
2242
- }
 
 
2243
 
2244
- foreach ($merchantPreferences['assigned_features'] as $preference)
2245
- {
2246
- if ($preference['name'] === 'affordability_widget')
 
 
 
 
 
 
 
 
 
 
 
 
2247
  {
2248
- add_action ('woocommerce_before_add_to_cart_form', 'addAffordabilityWidgetHTML');
 
2249
  }
2250
  }
2251
  }
2252
- catch(\Exception $e)
2253
- {
2254
- rzpLogError($e->getMessage());
2255
- return;
2256
- }
2257
  }
2258
 
2259
  // This is set to a priority of 10
3
  * Plugin Name: Razorpay for WooCommerce
4
  * Plugin URI: https://razorpay.com
5
  * Description: Razorpay Payment Gateway Integration for WooCommerce
6
+ * Version: 4.3.3
7
+ * Stable tag: 4.3.3
8
  * Author: Team Razorpay
9
  * WC tested up to: 6.7.0
10
  * Author URI: https://razorpay.com
328
  }
329
 
330
  //Affordability Widget Code
331
+ global $current_section;
332
+ if ($current_section === 'razorpay' or
333
+ $current_section === 'affordability-widget')
334
  {
335
+ try
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
  {
337
+ if (isset($_POST['woocommerce_razorpay_key_id']) and
338
+ empty($_POST['woocommerce_razorpay_key_id']) === false and
339
+ isset($_POST['woocommerce_razorpay_key_secret']) and
340
+ empty($_POST['woocommerce_razorpay_key_secret']) === false)
341
  {
342
+ $api = new Api($_POST['woocommerce_razorpay_key_id'], $_POST['woocommerce_razorpay_key_secret']);
343
+ }
344
+ else
345
+ {
346
+ $api = $this->getRazorpayApiInstance();
347
+ }
348
+
349
+ $merchantPreferences = $api->request->request('GET', 'accounts/me/features');
350
+
351
+ if (isset($merchantPreferences) === false or
352
+ isset($merchantPreferences['assigned_features']) === false)
353
+ {
354
+ throw new Exception("Error in Api call.");
355
+ }
356
+
357
+ foreach ($merchantPreferences['assigned_features'] as $preference)
358
+ {
359
+ if ($preference['name'] === 'affordability_widget')
360
+ {
361
+ add_action('woocommerce_sections_checkout', 'addSubSection');
362
+ add_action('woocommerce_settings_tabs_checkout', 'displayAffordabilityWidgetSettings');
363
+ add_action('woocommerce_update_options_checkout', 'updateAffordabilityWidgetSettings');
364
+ }
365
  }
366
  }
367
+ catch (\Exception $e)
368
+ {
369
+ rzpLogError($e->getMessage());
370
+ return;
371
+ }
372
  }
373
  }
374
 
2235
 
2236
  add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'razorpay_woo_plugin_links');
2237
 
2238
+ add_action( 'woocommerce_before_single_product', 'trigger_affordability_widget', 10 );
 
 
 
2239
 
2240
+ function trigger_affordability_widget()
2241
+ {
2242
+ if (empty(get_option('rzp_afd_enable')) === false and
2243
+ get_option('rzp_afd_enable') === 'yes')
2244
  {
2245
+ try
2246
+ {
2247
+ $api = new Api(get_option('woocommerce_razorpay_settings')['key_id'], get_option('woocommerce_razorpay_settings')['key_secret']);
2248
+ $merchantPreferences = $api->request->request('GET', 'accounts/me/features');
2249
 
2250
+ if (isset($merchantPreferences) === false or
2251
+ isset($merchantPreferences['assigned_features']) === false)
2252
+ {
2253
+ throw new Exception("Error in Api call.");
2254
+ }
2255
+
2256
+ foreach ($merchantPreferences['assigned_features'] as $preference)
2257
+ {
2258
+ if ($preference['name'] === 'affordability_widget')
2259
+ {
2260
+ add_action ('woocommerce_before_add_to_cart_form', 'addAffordabilityWidgetHTML');
2261
+ }
2262
+ }
2263
+ }
2264
+ catch(\Exception $e)
2265
  {
2266
+ rzpLogError($e->getMessage());
2267
+ return;
2268
  }
2269
  }
2270
  }
 
 
 
 
 
2271
  }
2272
 
2273
  // This is set to a priority of 10