Skip to content

Commit

Permalink
Update order-script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmigf committed Dec 12, 2024
1 parent 802e947 commit 3ad555e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions assets/js/order-script.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
jQuery( function( $ ) {

$( '#doaction, #doaction2' ).on( 'click', function( e ) {
let actionselected = $( this ).attr( "id" ).substr( 2 );
let action = $( 'select[name="' + actionselected + '"]' ).val();
let actionSelected = $( this ).attr( "id" ).substr( 2 );
let action = $( 'select[name="' + actionSelected + '"]' ).val();

if ( $.inArray( action, wpo_wcpdf_ajax.bulk_actions ) !== -1 ) {
e.preventDefault();
Expand All @@ -28,20 +28,20 @@ jQuery( function( $ ) {
return;
}

let baseUrl = wpo_wcpdf_ajax.ajaxurl;
let separator = baseUrl.includes( '?' ) ? '&' : '?';
let partial_url = baseUrl + separator + 'action=generate_wpo_wcpdf&document_type=' + documentType + '&bulk&_wpnonce=' + wpo_wcpdf_ajax.nonce;
let baseUrl = wpo_wcpdf_ajax.ajaxurl;
let separator = baseUrl.includes( '?' ) ? '&' : '?';
let partialUrl = baseUrl + separator + 'action=generate_wpo_wcpdf&document_type=' + documentType + '&bulk&_wpnonce=' + wpo_wcpdf_ajax.nonce;

// Generate URLs based on format
if ( outputFormat !== 'pdf' ) {
$.each( checked, function( i, order_id ) {
full_url = partial_url + '&order_ids=' + order_id + '&output=' + outputFormat;
window.open( full_url, '_blank' );
$.each( checked, function( i, orderId ) {
fullUrl = partialUrl + '&order_ids=' + orderId + '&output=' + outputFormat;
window.open( fullUrl, '_blank' );
} );
} else {
let order_ids = checked.join( 'x' );
full_url = partial_url + '&order_ids=' + order_ids;
window.open( full_url, '_blank' );
let orderIds = checked.join( 'x' );
fullUrl = partialUrl + '&order_ids=' + orderIds;
window.open( fullUrl, '_blank' );
}
}
} );
Expand Down

0 comments on commit 3ad555e

Please sign in to comment.