Add confirmation dialog to License Key Delete button

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this page

The WP Software License incorporates a range of additional filters and actions, allowing you to fulfill diverse requirements.

The ‘View License’ interface is highly customizable. To initiate customization, start by duplicating the /templates/my-account/my-license-manage.php template file from the plugin directory to your theme or child theme, specifically to /woocommerce/my-account/my-license-manage.php. This approach ensures that any modifications made to the template file remain unaffected by future plugin updates, offering a seamless and worry-free customization process.

To change the Delete button and create a confirmation dialogue, two filters will be used:

Within the /wp-content/mu-plugins/ create a file woosl-custom.php. Append the following code:

    add_filter('woo_sl/license_manage/disabled_buttons', '_licence_manage_get_disabled_buttons', 10, 3);
    function _licence_manage_get_disabled_buttons( $disabled_buttons, $licence_id, $domain )
            $disabled_buttons['delete']   =   TRUE;
            return  $disabled_buttons;   
    add_action ('woo_sl/after_interface_licence_actions', '_woo_sl_after_interface_licence_actions');
    function _woo_sl_after_interface_licence_actions( $licence_id )
                <a href="javascript: void(0)" onClick=" var result = confirm('<?php _e('Are you sure you want to delete?') ?>'); if (result) { woo_sl.keyDelete(<?php echo esc_attr ( $licence_id ) ?>, '<?php echo wp_create_nonce( 'woo_sl/actions/delete/'.$licence_id ) ?>') }" class="button"><?php _e("Delete", 'software-license') ?></a>   

Through the first filter woo_sl/license_manage/disabled_buttons, the default Delete button is unassigned to be generated by the core. The second filter woo_sl/after_interface_licence_actions creates a custom action, as a delete button, which includes the confirmation dialogue.


By woocommerce-sl, posted on November 25, 2022

Notify of
Inline Feedbacks
View all comments