Last active
April 5, 2022 15:53
-
-
Save Ercogx/8cb6fb8d35b3390150b10e6893b9970b to your computer and use it in GitHub Desktop.
Revisions
-
Ercogx revised this gist
Apr 5, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ function woocommerce_checkout_coupon_form_custom() { <div class="add_gift_card_form coupon-fictitious-form"> <h4>Have a coupon?</h4> <div id="wc_gc_cart_redeem_form"> <input placeholder="Coupon code" type="text" name="coupon_code" id="wc_gc_cart_code" autocomplete="off"> <button type="button" name="apply_coupon" id="wc_gc_cart_redeem_send">Apply</button> </div> </div> -
Ercogx revised this gist
Apr 5, 2022 . No changes.There are no files selected for viewing
-
Ercogx created this gist
Apr 5, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ <?php // Add a custom coupon field before checkout payment section add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_coupon_form_custom' ); function woocommerce_checkout_coupon_form_custom() { ?> <div class="add_gift_card_form coupon-fictitious-form"> <h4>Have a coupon?</h4> <div id="wc_gc_cart_redeem_form"> <input placeholder="Enter your code…" type="text" name="coupon_code" id="wc_gc_cart_code" autocomplete="off"> <button type="button" name="apply_coupon" id="wc_gc_cart_redeem_send">Apply</button> </div> </div> <?php } // jQuery code add_action( 'wp_footer', 'custom_checkout_jquery_script' ); function custom_checkout_jquery_script() { if ( is_checkout() && ! is_wc_endpoint_url() ) : ?> <script type="text/javascript"> jQuery( function($){ // Copy the inputed coupon code to WooCommerce hidden default coupon field $('.coupon-fictitious-form input[name="coupon_code"]').on( 'input change', function(){ $('form.checkout_coupon input[name="coupon_code"]').val($(this).val()); }); // On button click, submit WooCommerce hidden default coupon form $('.coupon-fictitious-form button[name="apply_coupon"]').on( 'click', function(){ $('form.checkout_coupon').submit(); }); }); </script> <?php endif; } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ .thb-checkout-coupon{ display: none; }