Skip to content

Commit

Permalink
Add modifier type via localization
Browse files Browse the repository at this point in the history
Facilitates the correct message for deletion
  • Loading branch information
JPry committed Feb 12, 2025
1 parent 62e479d commit 9341e7f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ protected function register_assets() {
->set_dependencies( 'jquery', 'wp-util' )
->enqueue_on( 'admin_enqueue_scripts' )
->add_to_group( 'tec-tickets-order-modifiers' )
->add_localize_script(
'etOrderModifiersTable',
function() {
return [
'modifier' => $this->get_modifier_type_from_request(),
];
}
)
->register();
}

Expand Down
17 changes: 14 additions & 3 deletions src/resources/js/admin/order-modifiers/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@
* @since 5.18.0
*/

( function( $ ) {
( function( $, tableSettings ) {
$( document ).on( 'click', '.row-actions .delete a', ( e ) => {
let message;
switch ( tableSettings.modifier ) {
case 'fee':
message = wp.i18n.__( 'Are you sure you want to delete this Fee?', 'event-tickets' );

Check failure on line 12 in src/resources/js/admin/order-modifiers/table.js

View workflow job for this annotation

GitHub Actions / lint

'wp' is not defined
break;

case 'coupon':
default:
message = wp.i18n.__( 'Are you sure you want to delete this Coupon?', 'event-tickets' );

Check failure on line 17 in src/resources/js/admin/order-modifiers/table.js

View workflow job for this annotation

GitHub Actions / lint

'wp' is not defined
break;
}
/* eslint-disable no-undef */
if ( ! confirm( wp.i18n.__( 'Are you sure you want to delete this Fee?', 'event-tickets' ) ) ) {
if ( ! confirm( message ) ) {
e.preventDefault();
}
/* eslint-enable no-undef */
} );
} )( jQuery );
} )( jQuery, window.etOrderModifiersTable || {} );

0 comments on commit 9341e7f

Please sign in to comment.