Skip to content

Commit

Permalink
Merge pull request #140 from wpswings/v4.4.4
Browse files Browse the repository at this point in the history
V4.4.4
  • Loading branch information
mohammaddanish-cedcoss authored Jan 6, 2025
2 parents d3c8fb0 + 2dd7250 commit 16d60b4
Show file tree
Hide file tree
Showing 19 changed files with 1,176 additions and 480 deletions.
23 changes: 22 additions & 1 deletion admin/class-woo-refund-and-exchange-lite-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,17 @@ public function wps_rma_refund_settings_page( $wps_rma_settings_refund ) {
'no' => esc_html__( 'NO', 'woo-refund-and-exchange-lite' ),
),
),
array(
'title' => esc_html__( 'Enable To Allow the Refund Request Cancellation by user', 'woo-refund-and-exchange-lite' ),
'type' => 'radio-switch',
'id' => 'wps_rma_refund_cancellation',
'value' => get_option( 'wps_rma_refund_cancellation' ),
'class' => 'wrael-radio-switch-class',
'options' => array(
'yes' => esc_html__( 'YES', 'woo-refund-and-exchange-lite' ),
'no' => esc_html__( 'NO', 'woo-refund-and-exchange-lite' ),
),
),
);
$wps_rma_settings_refund =
// To extend the refund setting.
Expand Down Expand Up @@ -1233,7 +1244,7 @@ public function wps_rma_wallet_settings_array( $wps_rma_settings_wallet ) {
}

/**
* SMS notifcaiton settings register
* SMS notifcaiton settings register.
*
* @param array $wps_rma_settings_wallet .
*/
Expand All @@ -1242,6 +1253,16 @@ public function wps_rma_sms_notification_settings_array( $wps_rma_settings_walle
return $setting_obj->wps_rma_sms_notification_settings_array_set( $wps_rma_settings_wallet );
}

/**
* Whatsapp notifcaiton settings register.
*
* @param array $wps_rma_settings_wallet .
*/
public function wps_rma_whatsapp_notification_settings_array( $wps_rma_settings_wallet ){
$setting_obj = new Wps_Rma_Settings_Extend();
return $setting_obj->wps_rma_whatsapp_notification_settings_array_set( $wps_rma_settings_wallet );
}

/**
* Order message seting extend.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* @subpackage woo-refund-and-exchange-lite/admin/partials
*/

$order_obj = wc_get_order( $order_id );
$lang = $order_obj->get_meta( 'wpml_language' );
do_action( 'wpml_switch_language', $lang );
$products = wps_rma_get_meta_data( $order_id, 'wps_rma_return_product', true );
if ( isset( $products ) && ! empty( $products ) ) {
foreach ( $products as $date => $product ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* @subpackage woo-refund-and-exchange-lite/admin/partials
*/

$order_obj = wc_get_order( $order_id );
$order_obj = wc_get_order( $order_id );
$lang = $order_obj->get_meta( 'wpml_language' );
do_action( 'wpml_switch_language', $lang );
$message =
'<div class="wps_rma_refund_cancel_email>
<div class="Order">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,17 @@ public function wps_rma_exchange_settings_array_set( $wps_rma_settings_exchange
'no' => esc_html__( 'NO', 'woo-refund-and-exchange-lite' ),
),
),
array(
'title' => esc_html__( 'Enable To Allow the Exchange Request Cancellation by user', 'woo-refund-and-exchange-lite' ),
'type' => 'radio-switch',
'id' => 'wps_rma_exchange_cancellation',
'value' => get_option( 'wps_rma_exchange_cancellation' ),
'class' => 'wrael-radio-switch-class ' . $this->rma_pro_activate,
'options' => array(
'yes' => esc_html__( 'YES', 'woo-refund-and-exchange-lite' ),
'no' => esc_html__( 'NO', 'woo-refund-and-exchange-lite' ),
),
),
);
$wps_rma_settings_exchange =
// To extend the refund setting.
Expand Down Expand Up @@ -867,5 +878,132 @@ public function wps_rma_sms_notification_settings_array_set( $wps_rma_settings_s
);
return $wps_rma_settings_sms_notification;
}

/**
* Register the whatsapp notification setting.
*
* @param array $wps_rma_settings_whatsapp_notification .
*/
public function wps_rma_whatsapp_notification_settings_array_set( $wps_rma_settings_whatsapp_notification ){
$wps_rma_settings_sms_notification = array(
array(
'type' => 'breaker',
'id' => 'Connection',
'name' => 'Connection',
),
array(
'title' => esc_html__( 'Enable To Use Whatsapp Notification For Refund And Exchange ', 'woo-refund-and-exchange-lite' ),
'type' => 'radio-switch',
'id' => 'wps_rma_enable_whatsapp_notification',
'value' => get_option( 'wps_rma_enable_whatsapp_notification' ),
'show_link' => true,
'class' => 'wrael-radio-switch-class ' . $this->rma_pro_activate ,
'options' => array(
'yes' => esc_html__( 'YES', 'woo-refund-and-exchange-lite' ),
'no' => esc_html__( 'NO', 'woo-refund-and-exchange-lite' ),
),

),
array(
'title' => esc_html__( 'Enter Phone number ID', 'woo-refund-and-exchange-lite' ),
'type' => 'text',
'id' => 'wps_rma_whatsapp_number_id',
'value' => get_option( 'wps_rma_whatsapp_number_id' ),
'class' => 'wrael-text-class ' . $this->rma_pro_activate,
'placeholder' => esc_html__( 'Enter Phone number ID here.', 'woo-refund-and-exchange-lite' ),

),

array(
'title' => esc_html__( 'Enter Access Token', 'woo-refund-and-exchange-lite' ),
'type' => 'text',
'id' => 'wps_rma_whatsapp_access_token',
'value' => get_option( 'wps_rma_whatsapp_access_token' ),
'class' => 'wrael-text-class ' . $this->rma_pro_activate,
'placeholder' => esc_html__( 'Enable Access Token here.', 'woo-refund-and-exchange-lite' ),
'description' => esc_html__( ' you can go through this','woo-refund-and-exchange-lite') .'<a href="https://developers.facebook.com/docs/whatsapp/cloud-api/get-started" target="_blank">'. esc_html( ' docs ', 'woo-refund-and-exchange-lite') .'</a> you need to register from <a href="https://developers.facebook.com/docs/development/register" target="_blank">'. esc_html(' here ','woo-refund-and-exchange-lite').'</a>',
),

array(
'type' => 'breaker',
'id' => 'Refund',
'name' => 'Refund SMS Content',
),

array(
'title' => __( 'Enter Content To Send In Sms With Refund Request Process', 'woo-refund-and-exchange-lite' ),
'type' => 'textarea',
'id' => 'wps_wet_twilio_sms_content_refund_request',
'value' => get_option( 'wps_wet_twilio_sms_content_refund_request' ),
'description' => esc_html__( 'Use Placeholders ', 'woo-refund-and-exchange-lite' ) . esc_html( '{customer-name}' ) . esc_html( ' for customer name and ', 'woo-refund-and-exchange-lite' ) . esc_html( ' {order-id} ' ) . esc_html( ' for order id and ,', 'woo-refund-and-exchange-lite' ) . esc_html( ' {siteurl} ' ) . esc_html( ' for site url.', 'woo-refund-and-exchange-lite' ),
'class' => 'wrael-text-class ' . $this->rma_pro_activate,
'placeholder' => __( 'Enter content to send in sms', 'woo-refund-and-exchange-lite' ),
),

array(
'title' => __( 'Enter Content To Send In Sms With Refund Approve Process', 'woo-refund-and-exchange-lite' ),
'type' => 'textarea',
'id' => 'wps_wet_twilio_sms_content_refund_approve',
'value' => get_option( 'wps_wet_twilio_sms_content_refund_approve' ),
'description' => esc_html__( 'Use Placeholders ', 'woo-refund-and-exchange-lite' ) . esc_html( '{customer-name}' ) . esc_html( ' for customer name and ', 'woo-refund-and-exchange-lite' ) . esc_html( ' {order-id} ' ) . esc_html( ' for order id and ,', 'woo-refund-and-exchange-lite' ) . esc_html( ' {siteurl} ' ) . esc_html( ' for site url.', 'woo-refund-and-exchange-lite' ),
'class' => 'wrael-text-class ' . $this->rma_pro_activate,
'placeholder' => __( 'Enter content to send in sms', 'woo-refund-and-exchange-lite' ),
),

array(
'title' => __( 'Enter Content to Send In Sms With Refund Cancel Process', 'woo-refund-and-exchange-lite' ),
'type' => 'textarea',
'id' => 'wps_wet_twilio_sms_content_refund_cancel',
'value' => get_option( 'wps_wet_twilio_sms_content_refund_cancel' ),
'description' => esc_html__( 'Use Placeholders ', 'woo-refund-and-exchange-lite' ) . esc_html( '{customer-name}' ) . esc_html( ' for customer name and ', 'woo-refund-and-exchange-lite' ) . esc_html( ' {order-id} ' ) . esc_html( ' for order id and ,', 'woo-refund-and-exchange-lite' ) . esc_html( ' {siteurl} ' ) . esc_html( ' for site url.', 'woo-refund-and-exchange-lite' ),
'class' => 'wrael-text-class ' . $this->rma_pro_activate,
'placeholder' => __( 'Enter content to send in sms', 'woo-refund-and-exchange-lite' ),
),

array(
'type' => 'breaker',
'id' => 'Exchange',
'name' => 'Exchange SMS Content',
),

array(
'title' => __( 'Enter Content To Send In Sms With Exchange Request Process', 'woo-refund-and-exchange-lite' ),
'type' => 'textarea',
'id' => 'wps_wet_twilio_sms_content_exchange_request',
'value' => get_option( 'wps_wet_twilio_sms_content_exchange_request' ),
'description' => esc_html__( 'Use Placeholders ', 'woo-refund-and-exchange-lite' ) . esc_html( '{customer-name}' ) . esc_html( ' for customer name and ', 'woo-refund-and-exchange-lite' ) . esc_html( ' {order-id} ' ) . esc_html( ' for order id and ,', 'woo-refund-and-exchange-lite' ) . esc_html( ' {siteurl} ' ) . esc_html( ' for site url.', 'woo-refund-and-exchange-lite' ),
'class' => 'wrael-text-class ' . $this->rma_pro_activate,
'placeholder' => __( 'Enter content to send in sms', 'woo-refund-and-exchange-lite' ),
),

array(
'title' => __( 'Enter Content To Send In Sms With Exchange Approve Process', 'woo-refund-and-exchange-lite' ),
'type' => 'textarea',
'id' => 'wps_wet_twilio_sms_content_exchange_approve',
'value' => get_option( 'wps_wet_twilio_sms_content_exchange_approve' ),
'description' => esc_html__( 'Use Placeholders ', 'woo-refund-and-exchange-lite' ) . esc_html( '{customer-name}' ) . esc_html( ' for customer name and ', 'woo-refund-and-exchange-lite' ) . esc_html( ' {order-id} ' ) . esc_html( ' for order id and ,', 'woo-refund-and-exchange-lite' ) . esc_html( ' {siteurl} ' ) . esc_html( ' for site url.', 'woo-refund-and-exchange-lite' ),
'class' => 'wrael-text-class ' . $this->rma_pro_activate,
'placeholder' => __( 'Enter content to send in sms', 'woo-refund-and-exchange-lite' ),
),

array(
'title' => __( 'Enter Content To Send In Sms With Exchange Cancel Process', 'woo-refund-and-exchange-lite' ),
'type' => 'textarea',
'id' => 'wps_wet_twilio_sms_content_exchange_cancel',
'value' => get_option( 'wps_wet_twilio_sms_content_exchange_cancel' ),
'description' => esc_html__( 'Use Placeholders ', 'woo-refund-and-exchange-lite' ) . esc_html( '{customer-name}' ) . esc_html( ' for customer name and ', 'woo-refund-and-exchange-lite' ) . esc_html( ' {order-id} ' ) . esc_html( ' for order id and ,', 'woo-refund-and-exchange-lite' ) . esc_html( ' {siteurl} ' ) . esc_html( ' for site url.', 'woo-refund-and-exchange-lite' ),
'class' => 'wrael-text-class ' . $this->rma_pro_activate,
'placeholder' => __( 'Enter content to send in sms', 'woo-refund-and-exchange-lite' ),
),

array(
'type' => 'button',
'id' => 'wps_rma_save_whatsapp_notification_setting',
'button_text' => esc_html__( 'Save Setting', 'woo-refund-and-exchange-lite' ),
'class' => 'wrael-button-class button_' . $this->rma_pro_activate,
),
);
return $wps_rma_settings_sms_notification;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Provide a admin area view for the plugin
*
* This file is used to markup the html field for general tab.
*
* @link https://wpswings.com/
* @since 1.0.0
*
* @package woocommerce-rma-for-return-refund-and-exchange
* @subpackage woocommerce-rma-for-return-refund-and-exchange/admin/partials
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $wrael_wps_rma_obj;
$mwr_whatsapp_notification_settings =
// Wallet Setting register filter.
apply_filters( 'wps_rma_whatsapp_notification_settings_array', array() );
?>
<!-- template file for admin settings. -->
<form action="" method="POST" class="wps-mwr-gen-section-form">
<div class="mwr-secion-wrap">
<?php
$mwr_whatsapp_notification_html = $wrael_wps_rma_obj->wps_rma_plug_generate_html( $mwr_whatsapp_notification_settings );
echo esc_html( $mwr_whatsapp_notification_html );
wp_nonce_field( 'admin_save_data', 'wps_tabs_nonce' );
?>
</div>
</form>
26 changes: 26 additions & 0 deletions assets/src/common/js/woo-refund-and-exchange-lite-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,5 +297,31 @@ jQuery(function($){
e.preventDefault();
$('.wps_order_msg_notice_wrapper').hide();
});
$( document ).on( 'submit', '#wps_rma_cancel_return_request', function(e){
e.preventDefault();

// Show confirmation alert
if (!confirm(wrael_common_param.return_cancellation_alert)) {
return; // Exit if the user clicks "Cancel"
}
const order_id = $('.wps_rma_cancel_return_request').val();

var data = {
action :'wps_rma_cancel_return_request',
order_id: order_id,
security_check : wrael_common_param.wps_rma_nonce,
}
//cancel return request
$.ajax({
url: wrael_common_param.ajaxurl,
type: 'POST',
data: data,
dataType :'json',
success: function(response)
{
window.location.href = window.location.href;
}
});
});
});

48 changes: 35 additions & 13 deletions common/class-woo-refund-and-exchange-lite-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,21 @@ public function wrael_common_enqueue_scripts() {
$this->plugin_name . 'common',
'wrael_common_param',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'wps_rma_nonce' => wp_create_nonce( 'wps_rma_ajax_security' ),
'return_subject_msg' => esc_html__( 'Please Enter Refund Subject.', 'woo-refund-and-exchange-lite' ),
'return_reason_msg' => esc_html__( 'Please Enter Refund Reason.', 'woo-refund-and-exchange-lite' ),
'return_select_product' => esc_html__( 'Please Select Product to refund.', 'woo-refund-and-exchange-lite' ),
'check_pro_active' => esc_html( $pro_active ),
'message_sent' => esc_html__( 'The message has been sent successfully', 'woo-refund-and-exchange-lite' ),
'message_empty' => esc_html__( 'Please Enter a Message.', 'woo-refund-and-exchange-lite' ),
'myaccount_url' => esc_attr( $myaccount_page_url ),
'refund_form_attachment' => get_option( 'wps_rma_refund_attachment' ),
'order_msg_attachment' => get_option( 'wps_rma_general_enable_om_attachment' ),
'file_not_supported' => esc_html__( 'Attached File type is not supported', 'woo-refund-and-exchange-lite' ),
'qty_error' => esc_html__( 'Selected product must have the quantity', 'woo-refund-and-exchange-lite' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'wps_rma_nonce' => wp_create_nonce( 'wps_rma_ajax_security' ),
'return_subject_msg' => esc_html__( 'Please Enter Refund Subject.', 'woo-refund-and-exchange-lite' ),
'return_reason_msg' => esc_html__( 'Please Enter Refund Reason.', 'woo-refund-and-exchange-lite' ),
'return_select_product' => esc_html__( 'Please Select Product to refund.', 'woo-refund-and-exchange-lite' ),
'check_pro_active' => esc_html( $pro_active ),
'message_sent' => esc_html__( 'The message has been sent successfully', 'woo-refund-and-exchange-lite' ),
'message_empty' => esc_html__( 'Please Enter a Message.', 'woo-refund-and-exchange-lite' ),
'myaccount_url' => esc_attr( $myaccount_page_url ),
'refund_form_attachment' => get_option( 'wps_rma_refund_attachment' ),
'order_msg_attachment' => get_option( 'wps_rma_general_enable_om_attachment' ),
'file_not_supported' => esc_html__( 'Attached File type is not supported', 'woo-refund-and-exchange-lite' ),
'qty_error' => esc_html__( 'Selected product must have the quantity', 'woo-refund-and-exchange-lite' ),
'return_cancellation_alert' => esc_html__( 'Are you sure you want to cancel this return request?', 'woo-refund-and-exchange-lite' ),

)
);
wp_enqueue_script( $this->plugin_name . 'common' );
Expand Down Expand Up @@ -527,4 +529,24 @@ public function wps_rma_woocommerce_get_order_item_totals( $results, $args ) {
}
return $results;
}
/**
* Request Cancellation by the user
*
*/
public function wps_rma_cancel_return_request_callback() {
check_ajax_referer( 'wps_rma_ajax_security', 'security_check' );

$order_id = isset( $_POST['order_id'] ) ? filter_input( INPUT_POST, 'order_id' ) : '';

$products = wps_rma_get_meta_data( $order_id, 'wps_rma_return_product', true );
$response = wps_rma_return_req_cancel_callback( $order_id, $products );

if ( isset( $response['response'] ) ) {
$order = wc_get_order( $order_id );
$custom_note = esc_html__( 'The request was cancelled by the customer', 'woo-refund-and-exchange-lite' );
$order->add_order_note( $custom_note, true );
}
echo wp_json_encode( $response );
wp_die();
}
}
26 changes: 26 additions & 0 deletions common/js/woo-refund-and-exchange-lite-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,5 +297,31 @@ jQuery(function($){
e.preventDefault();
$('.wps_order_msg_notice_wrapper').hide();
});
$( document ).on( 'submit', '#wps_rma_cancel_return_request', function(e){
e.preventDefault();

// Show confirmation alert
if (!confirm(wrael_common_param.return_cancellation_alert)) {
return; // Exit if the user clicks "Cancel"
}
const order_id = $('.wps_rma_cancel_return_request').val();

var data = {
action :'wps_rma_cancel_return_request',
order_id: order_id,
security_check : wrael_common_param.wps_rma_nonce,
}
//cancel return request
$.ajax({
url: wrael_common_param.ajaxurl,
type: 'POST',
data: data,
dataType :'json',
success: function(response)
{
window.location.href = window.location.href;
}
});
});
});

Loading

0 comments on commit 16d60b4

Please sign in to comment.