• Resolved dmmezchris

    (@dmmezchris)


    Hello, I was wondering if there was a way for me to trigger the add to cart functionality from woocommerce to the submit form button on forminator? Basically I want users to be able to fill out a form I created on forminator that will submit their info but also add a product to their cart at the same time. I’d like to redirect to the checkout page after form submission instead of having a shop page.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    Hi there @dmmezchris

    Yes, that can be done by selecting the Redirect user to a URL option in your form’s Behavior > Submission Behavior settings.

    In that field, enter the redirect URL to your cart page with the add-to-cart added as a query parameter, like so:

    https://yoursite.tld/?add-to-cart=7283

    Change yoursite.tld to your actual site, and change 7283 to the ID of the product you want added to the user’s cart.

    When the user submits the form, it will redirect to your cart page with that specific product already in their cart.

    If you want to take it one step further – bypass the cart and go directly to the checkout page with that product in their cart – you’ll want to add this bit of custom code to either your active theme’s functions.php or a mu-plugin:

    add_filter( 'woocommerce_add_to_cart_redirect', 'custom_skip_cart_redirect_checkout' );
     
    function custom_skip_cart_redirect_checkout( $url ) {
        return wc_get_checkout_url();
    }

    Cheers!
    Patrick

    Thread Starter dmmezchris

    (@dmmezchris)

    Thank you! This is exactly what I was looking for!! I appreciate it!

    a1nur1g

    (@a1nur1g)

    In addition to wonderful answer by Patrick, jut want to add that user can be directly sent to checkout page without using custom hooks, by method described here
    https://quadlayers.com/woocommerce-direct-checkout-link/

    • This reply was modified 4 years ago by a1nur1g.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Woocommerce add to cart trigger on forminator button’ is closed to new replies.