![Check out Enfold](https://kriesi.at/wp-content/themes/kriesi/images/banner-enfold.jpg)
Tagged: checkout page
-
AuthorPosts
-
May 24, 2021 at 10:17 pm #1302096
I’m trying to move the checkout form from the top of the page to Your Order and make the coupon code entry (by the credit card info) only available when clicked on. With help from you guys I did it with the following code:
Initially hide the forms with this css code:
#order_review .form-row-first, #order_review .form-row-last, .woocommerce-form-coupon-toggle + p {
display: none;
}And use this script in the functions.php file to toggle their visibility when the showcoupon link is clicked.:
// a custom script
function ava_custom_script_mod() {
if ( wp_script_is( ‘avia-default’, ‘registered’ ) ) {
wp_add_inline_script( ‘avia-default’, ‘
(function($) {
$(“.showcoupon”).on(“click”, function() {
$(“#order_review .form-row-first, #order_review .form-row-last, .woocommerce-form-coupon-toggle + p”).toggle();
});
})(jQuery);
‘);
}
}
add_action( ‘wp_enqueue_scripts’, ‘ava_custom_script_mod’, 9999);This works well for doing all that, but it causes the Expiration Date and CVC code boxes to be hidden/removed from the credit card section (unless you click the “Click here to enter your coupon code” and unhide the Apply Coupon. How can I fix it so those fields remain no matter if the coupon code option is showing or not.
Thanks in advance for your help.
May 26, 2021 at 1:10 pm #1302414Hey advteksol,
Thank you for your patience and the link to your site, please try changing your css to this:#order_review > p.form-row.form-row-first, #order_review > p.form-row.form-row-last, .woocommerce-form-coupon-toggle + p { display: none; }
and your script to this:
function ava_custom_script_mod() { if ( wp_script_is( 'avia-default', 'registered' ) ) { wp_add_inline_script( 'avia-default', ' (function($) { $(".showcoupon").on("click", function() { $("#order_review > p.form-row.form-row-first, #order_review > p.form-row.form-row-last, .woocommerce-form-coupon-toggle + p").toggle(); }); })(jQuery); '); } } add_action( 'wp_enqueue_scripts', 'ava_custom_script_mod', 9999);
Best regards,
MikeMay 26, 2021 at 6:21 pm #1302451Thanks, that seems to work great!
May 27, 2021 at 6:00 am #1302511Hi,
I’m glad this was resolved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘Fix Credit Card Expiration and CCV Fields’ is closed to new replies.