Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #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.

    #1302414

    Hey 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,
    Mike

    #1302451

    Thanks, that seems to work great!

    #1302511

    Hi,

    I’m glad this was resolved. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Fix Credit Card Expiration and CCV Fields’ is closed to new replies.