[Resolved] Moving WooCommerce Coupon Code Box

Home Forums Support [Resolved] Moving WooCommerce Coupon Code Box

Home Forums Support Moving WooCommerce Coupon Code Box

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1172148
    Anthony

    I’m trying to move the coupon code input to display down by the payment methods.

    This is what I’m trying to do here:

    https://drive.google.com/file/d/1Tnl-XrLi57gNGscPLKBiKm7OnFt5UC8i/view?usp=sharing

    I want to disable the dropdown and move A in the screenshot, to where B is in the screenshot.

    At the very least I would love to disable the dropdown and just have the input present.

    Thanks

    #1172408
    David
    Staff
    Customer Support

    Hi there,

    try adding this to your sites functions:

    remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
    add_action( 'woocommerce_review_order_before_payment', 'woocommerce_checkout_coupon_form', 5 );

    https://docs.generatepress.com/article/adding-php/

    And this CSS to remove the now redundant toggle:

    .woocommerce-form-coupon-toggle {
        display: none;
    }
    #1172499
    Anthony

    Perfect! Thanks David!

    #1172504
    David
    Staff
    Customer Support
    #1172514
    Anthony

    I’m trying to remove the billing details and just have the checkout portion on the right-hand side.

    But now when I enter the coupon code in the area you helped me move it to, it just kick starts the Paypal Processor.

    Here’s the code I’m using:

    CSS that hides the headers customer details:

    .woocommerce-products-header,
    #customer_details,
    #order_review_heading
    {
    display: none;
    }

    #customer_details+#wc_checkout_add_ons,
    #order_review, #order_review_heading
    {
    margin: 0 auto!important;
    float:none;
    width: 80%
    }

    PHP that hides the checkout fields and moves/removes dropdown of the coupon box:

    // Moving Enter Coupon Box —————————————————

    remove_action( ‘woocommerce_before_checkout_form’, ‘woocommerce_checkout_coupon_form’, 10 );
    add_action( ‘woocommerce_review_order_before_payment’, ‘woocommerce_checkout_coupon_form’, 5 );

    // Remove Billing Info Checkout Page —————————————————

    add_filter( ‘woocommerce_checkout_fields’ , ‘custom_override_checkout_fields’ );

    function custom_override_checkout_fields( $fields ) {
    unset($fields[‘billing’][‘billing_first_name’]);
    unset($fields[‘billing’][‘billing_last_name’]);
    unset($fields[‘billing’][‘billing_company’]);
    unset($fields[‘billing’][‘billing_address_1’]);
    unset($fields[‘billing’][‘billing_address_2’]);
    unset($fields[‘billing’][‘billing_city’]);
    unset($fields[‘billing’][‘billing_postcode’]);
    unset($fields[‘billing’][‘billing_country’]);
    unset($fields[‘billing’][‘billing_state’]);
    unset($fields[‘billing’][‘billing_phone’]);
    unset($fields[‘order’][‘order_comments’]);
    unset($fields[‘billing’][‘billing_address_2’]);
    unset($fields[‘billing’][‘billing_postcode’]);
    unset($fields[‘billing’][‘billing_company’]);
    unset($fields[‘billing’][‘billing_email’]);
    unset($fields[‘billing’][‘billing_city’]);
    return $fields;
    }

    Do I need the checkout fields in order for the coupon box to work?

    I had the idea to remove the billing details after I first got in touch with you so now if it helps the coupon area can be above everything on the right column.

    Thanks

    #1172521
    David
    Staff
    Customer Support

    Actually – it looks like moving the field within the ‘payment form’ is the issue – as you now have a form within a form and the coupon field submit triggers the payment ….

    So re-hooking the coupon field is not a valid option unfortunately.

    #1172739
    Anthony

    Ok thank you! I found a work around for what I’m doing.

    #1172749
    David
    Staff
    Customer Support
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.