Conversation
supportHello, Thanks for your plugin, but I always fail to make my custom code live properly. When I add custom code, it always appears plain code in my website head. Do you have guide to add custom code ? I try to add : add_action( 'wp_footer', 'woocommerce_show_coupon', 99 ); function woocommerce_show_coupon() { echo ' <script type="text/javascript"> jQuery(document).ready(function($) { $(\'.checkout_coupon\').show(); }); </script> '; } it is showed not properly, just plain text. Thanks
Hi @wootechno , You just need to add opening PHP tag at the beginning of the editor. So it will be: <?php add_action( 'wp_footer', 'woocommerce_show_coupon', 99 ); function woocommerce_show_coupon() { echo ' <script type="text/javascript"> jQuery(document).ready(function($) { $(\'.checkout_coupon\').show(); }); </script> '; }
Thanks @bilaltas , The code works! but not working like if I add to child theme. I want to move coupon form below order overview in checkout page of Woocommerce with this code ( different code with above message ) : remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); add_action( 'woocommerce_review_order_after_cart_contents', 'woocommerce_checkout_coupon_form_custom' ); function woocommerce_checkout_coupon_form_custom() { echo '<tr class="coupon-form"><td colspan="2">'; wc_get_template( 'checkout/form-coupon.php', array( 'checkout' => WC()->checkout(), ) ); echo '</tr></td>'; } With child theme custom function the form will ONLY show below order overview, but with your plugin it shows twice after login form and after order overview.
Hi @wootechno , You just need to add opening PHP tag at the beginning of the editor. So it will be: <?php add_action( 'wp_footer', 'woocommerce_show_coupon', 99 ); function woocommerce_show_coupon() { echo ' <script type="text/javascript"> jQuery(document).ready(function($) { $(\'.checkout_coupon\').show(); }); </script> '; }
Thanks @bilaltas , The code works! but not working like if I add to child theme. I want to move coupon form below order overview in checkout page of Woocommerce with this code ( different code with above message ) : remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); add_action( 'woocommerce_review_order_after_cart_contents', 'woocommerce_checkout_coupon_form_custom' ); function woocommerce_checkout_coupon_form_custom() { echo '<tr class="coupon-form"><td colspan="2">'; wc_get_template( 'checkout/form-coupon.php', array( 'checkout' => WC()->checkout(), ) ); echo '</tr></td>'; } With child theme custom function the form will ONLY show below order overview, but with your plugin it shows twice after login form and after order overview.