Last active
May 11, 2022 06:28
-
-
Save pramodjodhani/dbfda3f9863246f61ce1a3bac0e65ed4 to your computer and use it in GitHub Desktop.
Snippet to add a clear selection button to Iconic Delivery Slots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Add the clear selection button. | |
| */ | |
| add_action( | |
| 'iconic_wds_after_delivery_details_fields', | |
| function() { | |
| echo '<a href="#" class="iconic-wds-clear-selection-btn">Clear selection</a>'; | |
| } | |
| ); | |
| /** | |
| * Add JS code to the checkout page footer. | |
| */ | |
| function iconic_wds_add_custom_js() { | |
| if ( ! is_checkout() ) { | |
| return; | |
| } | |
| ?> | |
| <script> | |
| jQuery( document ).on( 'click', '.iconic-wds-clear-selection-btn', function(e) { | |
| e.preventDefault(); | |
| jQuery('#jckwds-delivery-date').datepicker('setDate', null); | |
| jQuery("#jckwds-delivery-time").val('0') | |
| jQuery(document.body).trigger( 'update_checkout' ); | |
| } ); | |
| </script> | |
| <?php | |
| } | |
| add_action( 'wp_footer', 'iconic_wds_add_custom_js' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment