Created
July 29, 2026 19:42
-
-
Save helgatheviking/6cafc28b305f34b2567aaa0c0f4232bf to your computer and use it in GitHub Desktop.
NYP Hide Input until custom is selected
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
| function wc_nyp_relocate_suggested_amounts() { | |
| if ( class_exists( 'WC_NYP_Suggested_Amounts' ) ) { | |
| remove_action( 'wc_nyp_after_price_input', array( 'WC_NYP_Suggested_Amounts', 'display_amounts' ), 5, 2 ); | |
| add_action( 'wc_nyp_after_price_label', array( 'WC_NYP_Suggested_Amounts', 'display_amounts' ), 5, 2 ); | |
| } | |
| } | |
| add_action( 'wc_nyp_before_price_input', 'wc_nyp_relocate_suggested_amounts', 1 ); | |
| function wc_nyp_js_for_suggested_amounts() { | |
| wp_add_inline_script( | |
| 'wc-nyp-suggested-amounts', | |
| ' | |
| jQuery( ".nyp" ).on( | |
| "change", | |
| ".suggested-amounts input:radio", | |
| function (e) { | |
| if ( "custom" === e.target.value ) { | |
| jQuery(e.delegateTarget).find( ".nyp-input" ).slideDown().trigger("focus"); | |
| } else { | |
| jQuery(e.delegateTarget).find( ".nyp-input" ).slideUp(); | |
| } | |
| }); | |
| ' | |
| ); | |
| wp_add_inline_style( 'wc-nyp-suggested-amounts-frontend', ' | |
| .nyp .suggested-amounts .suggested-amounts__amount label { float: none !important; } | |
| .product .nyp .nyp-input { display: none; } | |
| ' ); | |
| } | |
| add_action( 'wp_enqueue_scripts', 'wc_nyp_js_for_suggested_amounts', 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment