Skip to content

Commit

Permalink
Merge pull request #72 from wpswings/v4.0.5
Browse files Browse the repository at this point in the history
V4.0.5
  • Loading branch information
mohammaddanish-cedcoss authored Jul 21, 2022
2 parents ca3af2e + 38092bb commit ccbfcc6
Show file tree
Hide file tree
Showing 22 changed files with 476 additions and 633 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
}
$message .= '<tr><td style="border: 1px solid #C7C7C7;">' . $item['name'] . '<br>';
$message .= '<small>' . $item_meta_html . '</small></td>
<td style="border: 1px solid #C7C7C7;">' . $item['qty'] . '</td>
<td style="border: 1px solid #C7C7C7;">' . $requested_product['qty'] . '</td>
<td style="border: 1px solid #C7C7C7;">' . wps_wrma_format_price( $requested_product['price'] * $requested_product['qty'], $get_order_currency ) . '</td>
</tr>';
}
Expand Down
58 changes: 47 additions & 11 deletions assets/src/common/js/woo-refund-and-exchange-lite-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,26 @@ jQuery( document ).on( 'ready', function(){
}
}
}

var attachment_enable = wrael_common_param.refund_form_attachment;
if ( attachment_enable && 'on' == attachment_enable ) {
$('.wps_rma_return_request_files').each(function(){
var up_files = $(this);
var totalfiles = up_files[0].files.length;
if ( totalfiles ) {
var file_type = up_files[0].files[0].type;
if ( 'image/png' == file_type || 'image/jpeg' == file_type || 'image/jpg' == file_type ) {
} else {
alerthtml += '<li>'+ wrael_common_param.file_not_supported + '</li>';
}
} else {
alerthtml += '<li>'+ wrael_common_param.no_file_attached +'</li>';
}
});
}

if (alerthtml != '') {
$( '#wps_rma_return_alert' ).show();
$( '#wps_rma_return_alert' ).html( alerthtml );
$( '#wps_rma_return_alert' ).addClass('woocommerce-error');
$( '#wps_rma_return_alert' ).removeClass('woocommerce-message');
Expand All @@ -49,6 +68,7 @@ jQuery( document ).on( 'ready', function(){
$( '#wps_rma_return_alert' ).hide();
$( '#wps_rma_return_alert' ).html( alerthtml );
}

if( pro_act ){
if (typeof wps_rma_refund_total == 'function') {
var return_data = wps_rma_refund_total();
Expand Down Expand Up @@ -166,25 +186,41 @@ jQuery( document ).on( 'ready', function(){
var msg = $('#wps_order_new_msg').val();
var order_msg_type = $('#order_msg_type').val();
var alerthtml = '';
if ( msg == '' ) {
alerthtml = '<p class="wps_order_msg_sent_notice">'+ wrael_common_param.message_empty +'</p><a href="" class="wps_remove_notice_msg">X</a>';
$('.wps_order_msg_notice_wrapper').css('display', 'flex');
$('.wps_order_msg_notice_wrapper').css('background-color', 'red');
$('.wps_order_msg_notice_wrapper').html(alerthtml);
$('#wps_order_msg_submit').css({'outline-color':'white', 'border-color':'white'});
return false;
}
var order_id = $(this).data('id');

var form_data = new FormData();

// Read selected files
if ( up_files[0] ) {
var attachment_enable = wrael_common_param.order_msg_attachment;
if ( attachment_enable && 'on' == attachment_enable && up_files[0] ) {
var totalfiles = up_files[0].files.length;
for (var index = 0; index < totalfiles; index++) {
form_data.append('wps_order_msg_attachment[]', up_files[0].files[index]);
if ( totalfiles ) {
for (var index = 0; index < totalfiles; index++) {
var file_type = up_files[0].files[index].type;
if ( 'image/png' == file_type || 'image/jpeg' == file_type || 'image/jpg' == file_type ) {
form_data.append('wps_order_msg_attachment[]', up_files[0].files[index]);
} else {
alerthtml = '<p class="wps_order_msg_sent_notice">'+ wrael_common_param.file_not_supported +'</p><a href="" class="wps_remove_notice_msg">X</a>';
}
}

} else {
alerthtml = '<p class="wps_order_msg_sent_notice">'+ wrael_common_param.no_file_attached +'</p><a href="" class="wps_remove_notice_msg">X</a>';
}
}
if ( order_msg_type == 'admin') {
alerthtml = '';
}
if ( msg == '' ) {
alerthtml = '<p class="wps_order_msg_sent_notice">'+ wrael_common_param.message_empty +'</p><a href="" class="wps_remove_notice_msg">X</a>';
}
if ( alerthtml ) {
$('.wps_order_msg_notice_wrapper').css('display', 'flex');
$('.wps_order_msg_notice_wrapper').css('background-color', 'red');
$('.wps_order_msg_notice_wrapper').html(alerthtml);
$('#wps_order_msg_submit').css({'outline-color':'white', 'border-color':'white'});
return false;
}
form_data.append( 'action', 'wps_rma_order_messages_save' );
form_data.append( 'msg', msg );
form_data.append( 'order_msg_type', order_msg_type );
Expand Down
6 changes: 5 additions & 1 deletion assets/src/front-end/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
}
.wps-rma-form__wrapper label{
margin-bottom: 8px;
display: inline-block;
display: inline-block !important;
line-height: 1.2;
}
.wps-rma-form__wrapper h4{
Expand Down Expand Up @@ -458,4 +458,8 @@ div.wps_order_msg_single_attachment a .wps_order_msg_attachment_thumbnail{
.wps_rma_customer_detail {
padding: 30px 15px;
overflow: hidden;
}

.wps_field_mendatory{
color:red;
}
30 changes: 17 additions & 13 deletions common/class-woo-refund-and-exchange-lite-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class Woo_Refund_And_Exchange_Lite_Common {
/**
* The version of this plugin.
*
* @since 1.0.0
* @var string $version The current version of this plugin.
* @since 1.0.0
* @var string $version The current version of this plugin.
*/
private $version;

Expand Down Expand Up @@ -69,23 +69,27 @@ public function wrael_common_enqueue_scripts() {
$myaccount_page = get_option( 'woocommerce_myaccount_page_id' );
$myaccount_page_url = get_permalink( $myaccount_page );
} else {
$myaccount_page_url = '';
$myaccount_page_url = apply_filters( 'myaccount_page_url', $myaccount_page_url );
$myaccount_page = get_option( 'woocommerce_myaccount_page_id' );
$myaccount_page_url = get_permalink( $myaccount_page );
}
wp_register_script( $this->plugin_name . 'common', WOO_REFUND_AND_EXCHANGE_LITE_DIR_URL . 'common/js/woo-refund-and-exchange-lite-common.min.js', array( 'jquery' ), $this->version, false );
wp_localize_script(
$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 ),
'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' ),
'no_file_attached' => esc_html__( 'No File Attached', 'woo-refund-and-exchange-lite' ),
'file_not_supported' => esc_html__( 'Attached File type is not supported', 'woo-refund-and-exchange-lite' ),
)
);
wp_enqueue_script( $this->plugin_name . 'common' );
Expand Down
58 changes: 47 additions & 11 deletions common/js/woo-refund-and-exchange-lite-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,26 @@ jQuery( document ).on( 'ready', function(){
}
}
}

var attachment_enable = wrael_common_param.refund_form_attachment;
if ( attachment_enable && 'on' == attachment_enable ) {
$('.wps_rma_return_request_files').each(function(){
var up_files = $(this);
var totalfiles = up_files[0].files.length;
if ( totalfiles ) {
var file_type = up_files[0].files[0].type;
if ( 'image/png' == file_type || 'image/jpeg' == file_type || 'image/jpg' == file_type ) {
} else {
alerthtml += '<li>'+ wrael_common_param.file_not_supported + '</li>';
}
} else {
alerthtml += '<li>'+ wrael_common_param.no_file_attached +'</li>';
}
});
}

if (alerthtml != '') {
$( '#wps_rma_return_alert' ).show();
$( '#wps_rma_return_alert' ).html( alerthtml );
$( '#wps_rma_return_alert' ).addClass('woocommerce-error');
$( '#wps_rma_return_alert' ).removeClass('woocommerce-message');
Expand All @@ -49,6 +68,7 @@ jQuery( document ).on( 'ready', function(){
$( '#wps_rma_return_alert' ).hide();
$( '#wps_rma_return_alert' ).html( alerthtml );
}

if( pro_act ){
if (typeof wps_rma_refund_total == 'function') {
var return_data = wps_rma_refund_total();
Expand Down Expand Up @@ -166,25 +186,41 @@ jQuery( document ).on( 'ready', function(){
var msg = $('#wps_order_new_msg').val();
var order_msg_type = $('#order_msg_type').val();
var alerthtml = '';
if ( msg == '' ) {
alerthtml = '<p class="wps_order_msg_sent_notice">'+ wrael_common_param.message_empty +'</p><a href="" class="wps_remove_notice_msg">X</a>';
$('.wps_order_msg_notice_wrapper').css('display', 'flex');
$('.wps_order_msg_notice_wrapper').css('background-color', 'red');
$('.wps_order_msg_notice_wrapper').html(alerthtml);
$('#wps_order_msg_submit').css({'outline-color':'white', 'border-color':'white'});
return false;
}
var order_id = $(this).data('id');

var form_data = new FormData();

// Read selected files
if ( up_files[0] ) {
var attachment_enable = wrael_common_param.order_msg_attachment;
if ( attachment_enable && 'on' == attachment_enable && up_files[0] ) {
var totalfiles = up_files[0].files.length;
for (var index = 0; index < totalfiles; index++) {
form_data.append('wps_order_msg_attachment[]', up_files[0].files[index]);
if ( totalfiles ) {
for (var index = 0; index < totalfiles; index++) {
var file_type = up_files[0].files[index].type;
if ( 'image/png' == file_type || 'image/jpeg' == file_type || 'image/jpg' == file_type ) {
form_data.append('wps_order_msg_attachment[]', up_files[0].files[index]);
} else {
alerthtml = '<p class="wps_order_msg_sent_notice">'+ wrael_common_param.file_not_supported +'</p><a href="" class="wps_remove_notice_msg">X</a>';
}
}

} else {
alerthtml = '<p class="wps_order_msg_sent_notice">'+ wrael_common_param.no_file_attached +'</p><a href="" class="wps_remove_notice_msg">X</a>';
}
}
if ( order_msg_type == 'admin') {
alerthtml = '';
}
if ( msg == '' ) {
alerthtml = '<p class="wps_order_msg_sent_notice">'+ wrael_common_param.message_empty +'</p><a href="" class="wps_remove_notice_msg">X</a>';
}
if ( alerthtml ) {
$('.wps_order_msg_notice_wrapper').css('display', 'flex');
$('.wps_order_msg_notice_wrapper').css('background-color', 'red');
$('.wps_order_msg_notice_wrapper').html(alerthtml);
$('#wps_order_msg_submit').css({'outline-color':'white', 'border-color':'white'});
return false;
}
form_data.append( 'action', 'wps_rma_order_messages_save' );
form_data.append( 'msg', msg );
form_data.append( 'order_msg_type', order_msg_type );
Expand Down
Loading

0 comments on commit ccbfcc6

Please sign in to comment.