“Buy now or Add to cart” Redirect to contact page
-
“Buy now or Add to cart” Redirect to contact page
I want to redirect to the “Buy Now or Add to cart” Button to the Contact page, and after submitting the form its will auto redirect to the checkout page. (Contact form redirect to checkout work fine) Add to cart also redirect fine.My main issue, with the “Buy Now” Button how can redirect to the same place.
<a key="31714" style=" margin-right: 2px;" class="button product_type_simple add_to_cart_button ajax_add_to_cart chk_out ">Buy Now</a>
Add To cart :
<a href="?add-to-cart=31714" data-quantity="1" class="button product_type_simple add_to_cart_button ajax_add_to_cart" data-product_id="31714" data-product_sku="" aria-label="Add “Online Listing” to your cart" rel="nofollow">Add to Cart</a>
Please if you check this screenshot, you will better understand.
https://prnt.sc/v5en5iPlease, anyone, give me a solution? I want for Buy now or add to cart both are redirected to the specific page for specific products
-
For redirect add to cart: I have used the below code.
function my_custom_add_to_cart_redirect( $url ) { if ( ! isset( $_REQUEST['add-to-cart'] ) || ! is_numeric( $_REQUEST['add-to-cart'] ) ) { return $url; } $product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $_REQUEST['add-to-cart'] ) ); // Only redirect the product IDs in the array to the checkout if ( in_array( $product_id, array( 31714 ) ) ) { //$url = WC()->cart->get_checkout_url(); $url = get_permalink( 533285 ); // URL to redirect to (1 is the page ID here) } return $url; } add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' );
The page I need help with: https://burstbiz.com
The page I need help with: [log in to see the link]
- The topic ‘“Buy now or Add to cart” Redirect to contact page’ is closed to new replies.