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 include additional filters and actions for making any requirement possible. The View License interface is also highly customisable.
The first step will be to copy the /templates/my-account/my-licence-manage.php template file from the plugin directory to theme/child-theme, into /woocommerce/my-account/my-licence-manage.php. Further, any template file can be made without worry to lose anything, on plugin updates.

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/get_licence_actions', '_licence_ignore_delete_action', 10, 3);
    function _licence_ignore_delete_action($ignore_actions, $licence_id, $domain)
        {
            $ignore_actions['delete']   =   TRUE;
             
            return  $ignore_actions;   
        }
        
    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>   
            <?php
        }

Through the first filter woo_sl/get_licence_actions, the 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, that includes the confirmation dialogue.


Category:

By woocommerce-sl, posted on November 25, 2022

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments