WPIntell

Source evidence

Always Fail To Add Custom Function

CodeKit – Custom Codes Editor · support · 2021-04-16T09:32:00+00:00

mixedsentiment
highseverity
0.76relevance
2replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

5 / 34 rows with source links

14.7% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

29 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
wootechno resolved
Hello, 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.

Comments

2 shown
Bilal TAS 2021-04-16T18:47:00+00:00

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> '; }

wootechno 2021-04-17T16:09:00+00:00

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.