Skip to content

Commit 6a881d8

Browse files
author
Shivamddeveloper
committed
refund count feature
1 parent 4e9deed commit 6a881d8

6 files changed

Lines changed: 133 additions & 3 deletions

admin/class-woo-refund-and-exchange-lite-admin.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,29 @@ public function wps_rma_refund_settings_page( $wps_rma_settings_refund ) {
640640
'placeholder' => '',
641641
'options' => $woocommerce_roles,
642642
),
643+
array(
644+
'title' => esc_html__( 'Enable/Disable Refund Functionality based on User Count', 'woo-refund-and-exchange-lite' ),
645+
'type' => 'radio-switch',
646+
'id' => 'wps_rma_disable_refund_user_count',
647+
'value' => get_option( 'wps_rma_disable_refund_user_count' ),
648+
'class' => 'wrael-radio-switch-class',
649+
'options' => array(
650+
'yes' => esc_html__( 'YES', 'woo-refund-and-exchange-lite' ),
651+
'no' => esc_html__( 'NO', 'woo-refund-and-exchange-lite' ),
652+
),
653+
),
654+
655+
array(
656+
'title' => esc_html__( 'Refund Limit for User Count', 'woo-refund-and-exchange-lite' ),
657+
'type' => 'number',
658+
'description' => esc_html__( 'Need to enter a value for Refund Limit for User Count.', 'woo-refund-and-exchange-lite' ),
659+
'id' => 'wps_rma_refund_limit',
660+
'value' => get_option( 'wps_rma_refund_limit' ),
661+
'class' => 'wrael-number-class',
662+
'min' => '0',
663+
'max' => '15',
664+
'placeholder' => 'Enter the refund limit',
665+
),
643666
);
644667
$wps_rma_settings_refund =
645668
// To extend the refund setting.

admin/partials/pro_setting_templates/admin_setting/class-wps-rma-settings-extend.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,29 @@ public function wps_rma_exchange_settings_array_set( $wps_rma_settings_exchange
475475
'placeholder' => '',
476476
'options' => $woocommerce_roles,
477477
),
478+
479+
array(
480+
'title' => esc_html__( 'Enable/Disable Exchange Functionality based on User Count', 'woo-refund-and-exchange-lite' ),
481+
'type' => 'radio-switch',
482+
'id' => 'wps_rma_disable_exchange_user_count',
483+
'value' => get_option( 'wps_rma_disable_exchange_user_count' ),
484+
'class' => 'wrael-radio-switch-class ' . $this->rma_pro_activate,
485+
'options' => array(
486+
'yes' => esc_html__( 'YES', 'woo-refund-and-exchange-lite' ),
487+
'no' => esc_html__( 'NO', 'woo-refund-and-exchange-lite' ),
488+
),
489+
),
490+
array(
491+
'title' => esc_html__( 'Exchange Limit for User Count', 'woo-refund-and-exchange-lite' ),
492+
'type' => 'number',
493+
'description' => esc_html__( 'Need to enter a value for Exchange Limit for User Count.', 'woo-refund-and-exchange-lite' ),
494+
'id' => 'wps_rma_exchange_user_count_limit',
495+
'value' => get_option( 'wps_rma_exchange_user_count_limit' ),
496+
'class' => 'wrael-number-class ' . $this->rma_pro_activate,
497+
'min' => '0',
498+
'max' => '15',
499+
'placeholder' => 'Enter the user count limit',
500+
),
478501
);
479502
$wps_rma_settings_exchange =
480503
// To extend the refund setting.
@@ -699,6 +722,29 @@ public function wps_rma_cancel_settings_array_set( $wps_rma_settings_cancel ) {
699722
'placeholder' => '',
700723
'options' => $woocommerce_roles,
701724
),
725+
726+
array(
727+
'title' => esc_html__( 'Enable/Disable Cancel Functionality based on User Count', 'woo-refund-and-exchange-lite' ),
728+
'type' => 'radio-switch',
729+
'id' => 'wps_rma_disable_cancel_user_count',
730+
'value' => get_option( 'wps_rma_disable_cancel_user_count' ),
731+
'class' => 'wrael-radio-switch-class ' . $this->rma_pro_activate,
732+
'options' => array(
733+
'yes' => esc_html__( 'YES', 'woo-refund-and-exchange-lite' ),
734+
'no' => esc_html__( 'NO', 'woo-refund-and-exchange-lite' ),
735+
),
736+
),
737+
array(
738+
'title' => esc_html__( 'Cancel Limit for User Count', 'woo-refund-and-exchange-lite' ),
739+
'type' => 'number',
740+
'description' => esc_html__( 'Need to enter a value for Cancel Limit for User Count.', 'woo-refund-and-exchange-lite' ),
741+
'id' => 'wps_rma_cancel_limit',
742+
'value' => get_option( 'wps_rma_cancel_limit' ),
743+
'class' => 'wrael-number-class ' . $this->rma_pro_activate,
744+
'min' => '0',
745+
'max' => '15',
746+
'placeholder' => 'Enter the cancel limit',
747+
),
702748
array(
703749
'type' => 'breaker',
704750
'id' => 'Appearance',

common/class-woo-refund-and-exchange-lite-common.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,22 @@ public function wps_rma_save_return_request() {
341341
$shipping_price += $order->get_shipping_tax();
342342
}
343343
}
344+
344345
$return_data['shipping_price'] = $shipping_price;
345346
$return_data['refund_method'] = $refund_method;
346347
do_action( 'wps_rma_return_request_data', $return_data, $order_id );
347348
$response = wps_rma_save_return_request_callback( $order_id, $refund_method, $return_data );
348349
if ( true == $response['flag'] ) {
349350
do_action( 'wps_rma_do_shiprocket_integration', $order_id, $return_data );
351+
352+
// save refund request count for user.
353+
$wps_rma_disable_refund_user_count = get_option( 'wps_rma_disable_refund_user_count' );
354+
$wps_rma_user_refund_request_count = get_user_meta( $user_id, 'wps_rma_user_refund_request_count', true );
355+
if( 'on' == $wps_rma_disable_refund_user_count ){
356+
$wps_rma_user_refund_request_count = (int)$wps_rma_user_refund_request_count + 1;
357+
update_user_meta( $user_id, 'wps_rma_user_refund_request_count', $wps_rma_user_refund_request_count );
358+
}
359+
// save refund request count for user.
350360
}
351361
}
352362
}

includes/class-woo-refund-and-exchange-lite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function __construct() {
7777
$this->version = WOO_REFUND_AND_EXCHANGE_LITE_VERSION;
7878
} else {
7979

80-
$this->version = '4.5.6';
80+
$this->version = '4.5.7';
8181
}
8282

8383
$this->plugin_name = 'return-refund-and-exchange-for-woocommerce';

includes/woo-refund-and-exchange-lite-common-functions.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,57 @@ function ( $item ) {
243243
$show_button = ucfirst( $func ) . esc_html__( 'is not available right now, Please try again later', 'woo-refund-and-exchange-lite' );
244244
}
245245
}
246+
$wps_rma_disable_refund_user_count = get_option( 'wps_rma_disable_refund_user_count' );
247+
if( 'on' == $wps_rma_disable_refund_user_count && 'refund' == $func ){
248+
249+
$current_user = wp_get_current_user();
250+
$user_id = $current_user->ID;
251+
252+
$refund_request_count = get_user_meta( $user_id, 'wps_rma_user_refund_request_count', true );
253+
254+
$max_refund_request_count = get_option( 'wps_rma_refund_limit', 0 );
255+
256+
if( $refund_request_count >= $max_refund_request_count && $max_refund_request_count > 0 ){
257+
258+
$show_button = esc_html__( 'You have reached the maximum number of refund requests allowed.', 'woo-refund-and-exchange-lite' );
259+
} else {
260+
$show_button = 'yes';
261+
}
262+
}
263+
$wps_rma_disable_exchange_user_count = get_option( 'wps_rma_disable_exchange_user_count' );
264+
if( 'on' == $wps_rma_disable_exchange_user_count && 'exchange' == $func ){
265+
266+
$current_user = wp_get_current_user();
267+
$user_id = $current_user->ID;
268+
269+
$exchange_request_count = get_user_meta( $user_id, 'wps_rma_user_exchange_request_count', true );
270+
271+
$max_exchange_request_count = get_option( 'wps_rma_exchange_user_count_limit', 0 );
272+
273+
if( $exchange_request_count >= $max_exchange_request_count && $max_exchange_request_count > 0 ){
274+
275+
$show_button = esc_html__( 'You have reached the maximum number of exchange requests allowed.', 'woo-refund-and-exchange-lite' );
276+
} else {
277+
$show_button = 'yes';
278+
}
279+
}
280+
$wps_rma_disable_cancel_user_count = get_option( 'wps_rma_disable_cancel_user_count' );
281+
if( 'on' == $wps_rma_disable_cancel_user_count && 'cancel' == $func ){
282+
283+
$current_user = wp_get_current_user();
284+
$user_id = $current_user->ID;
285+
286+
$cancel_request_count = get_user_meta( $user_id, 'wps_rma_user_cancel_request_count', true );
287+
288+
$max_cancel_request_count = get_option( 'wps_rma_cancel_limit', 0 );
289+
290+
if( $cancel_request_count >= $max_cancel_request_count && $max_cancel_request_count > 0 ){
291+
292+
$show_button = esc_html__( 'You have reached the maximum number of cancel requests allowed.', 'woo-refund-and-exchange-lite' );
293+
} else {
294+
$show_button = 'yes';
295+
}
296+
}
246297
return apply_filters( 'wps_rma_policies_functionality_extend', $show_button, $func, $order, $get_specific_setting );
247298
}
248299
}

woocommerce-refund-and-exchange-lite.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Plugin Name: Return Refund and Exchange for WooCommerce
1616
* Plugin URI: https://wordpress.org/plugins/woo-refund-and-exchange-lite/
1717
* Description: <code><strong>Return Refund and Exchange for WooCommerce</strong></code> allows users to submit product refund. The plugin provides a dedicated mailing system that would help to communicate better between store owner and customers.This is lite version of WooCommerce Refund And Exchange. <a target="_blank" href="https://wpswings.com/woocommerce-plugins/?utm_source=wpswings-rma-shop&utm_medium=rma-org-backend&utm_campaign=shop-page">Elevate your e-commerce store by exploring more on WP Swings</a>
18-
* Version: 4.5.6
18+
* Version: 4.5.7
1919
* Author: WP Swings
2020
* Author URI: https://wpswings.com/?utm_source=wpswings-rma-official&utm_medium=rma-org-page&utm_campaign=official
2121
* Text Domain: woo-refund-and-exchange-lite
@@ -25,7 +25,7 @@
2525
* Requires at least: 6.7.0
2626
* Tested up to: 6.8.3
2727
* WC requires at least: 6.5.0
28-
* WC tested up to: 10.3.4
28+
* WC tested up to: 10.3.5
2929
*
3030
* License: GNU General Public License v3.0
3131
* License URI: http://www.gnu.org/licenses/gpl-3.0.html

0 commit comments

Comments
 (0)