Site logo

Archived topic

WooCommerce - Skip product & cart pages

1 reply · Started by Sandeep on December 11, 2017

Viewing posts 1–2 of 2

Hi Tom & team,

Requesting your help. I plan to use GeneratePress (with child theme) + ElementorPrp + LearnDash combination to sell a few online courses. My password protected development homepage - http://www.dev.fineprep.com/dev/ I have sent you the password information in an email.

As you will see,

1) I have a home page with a list of courses.
2) User can click on "View Details" to see more information for an individual course.
3) User clicks on "Buy Now" to buy the course.

Now I want the user -

A) To skip the WooCommerce product and cart pages and go to the check-out page directly.
B) Be able to add add individual course only once in the cart. If user has added a course to the cart and has come back later and try to buy the same course by clicking "Buy Now"
, it should still take him to the check-out page showing just one item in the cart.

Now coming to the issue -

I have following functions written in my child theme's functions.php to acheive #A and #B respectively.
However; the issue is that the "redirect" to check-out page works fine only when the item is getting added first time. If the user does not complete the purchase the first time and comes back later on the site and tries to add the same item again, it just redirects him to the home page (instead of the check-out page). Would you be able advise on what could be wrong and how to resolve? (Very similar flow works fine on my production site using Avada - fineprep.com).

//Add to cart redirects to checkout page
add_filter ('woocommerce_add_to_cart_redirect', 'woo_redirect_to_checkout');
function woo_redirect_to_checkout() {
$checkout_url = WC()->cart->get_checkout_url();
return $checkout_url;
}

//BAgrawala: Restricts product addition to one & disables quantity field in the check-out page.

add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );
function wc_remove_all_quantity_fields( $return, $product ) {
switch ( $product->product_type ) :
case "variable":
return true;
break;
case "grouped":
return true;
break;
case "external":
return true;
break;
default: // simple product type
return true;
break;
endswitch;
}

Thanks,
Sandeep

Hi there,

This is something you will need to check with WooCommerce.

GP's WooCommerce add-on simply style the WooCommerce appearance and does not alter it's functions.

Hope this helps!

This archived topic is closed to new replies.