Php – Disable ajax for add to cart button in single product page / WordPress / Woocommerce

ajaxe-commercePHPwoocommerceWordpress

I am developing an eCommerce website using wordpress, cartify theme, woocommerce 3.0.3.

I would like to redirect after to cart or checkout after clicking the buy now product.

Here you can see the page

**Add to cart behaviour**

✔︎ Redirect to the cart page after successful addition
(Unchecked) Enable AJAX add to cart buttons on archives

I activated redirect to cart after add to cart click and left in the woo commerce options but it seems to still using ajax.

**WooCommerce System status**

MySQL version: 5.5.51 - We recommend a minimum MySQL version of 5.6.
(THE HOST PROVIDER DOESN'T ALLOW ME TO UPGRADE)

WC pages
My account:      Page does not contain the shortcode.

cartify/woocommerce/single-product/product-image.php version 2.6.3 is out of date. The core version is 3.0.2, 
cartify/woocommerce/single-product/product-thumbnails.php version 2.6.3 is out of date. The core version is 3.0.2,
This two really mess my site when I update them.

Any suggestions, please?

Thank you in advance for your help

Best Answer

SO here I am going to explain three steps

Step 1 if you want customer to redirect after adding to cart to checkout then add below code to the functions.php

function my_custom_add_to_cart_redirect( $url ) {

  $url = WC()->cart->get_checkout_url();
  // $url = wc_get_checkout_url(); // since WC 2.5.0

  return $url;

  }
  add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' );

Step 2 if you want customer to redirect to the cart page after add to cart the following image link showing you can do this from admin end

http://prntscr.com/ewo99j

Step 3 if from admin end it's not redirecting the customer to the cart page then add following code to your functions.PHP

 function custom_add_to_cart_redirect() { 
  return 'http://localhost:8080/wordpress2/cart/'; 
  }
  add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );

replace this URL http://localhost:8080/wordpress2/cart/ with your cart page URL hope it will work for you

Thanks

Related Topic