WooCommerce - Remove cart? - wordpress

I want to take a straight payment for the one item, not have multiple items and cart functionality.
This is what I have so far:
User views product, presses buy and goes to checkout (via a straight checkout link), problem is here is that at the top of the checkout page it says “XXXX product has been added to cart – View Cart”. I don’t want this cart part there it should just go straight to the checkout and take the payment.
Another problem is if they go back through my funnel it adds a second item into the cart. I only want them to be able to purchase a quantity of 1 so I don't need any cart functionality just a straight checkout.
How can this be done?
Thanks

Try the following code redirect users to Checkout Page after add to cart.
/**
* Redirect users to Checkout Page after add to cart.
*/
function my_custom_add_to_cart_redirect( $url ) {
$url = WC()->cart->get_checkout_url();
return $url;
}
add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' );
You can also try this plugin https://wordpress.org/plugins/woocommerce-direct-checkout/

Related

how to prevent same product adding multiple times to cart when I want my visitor to directly go to checkout

Let say someone decides to buy my product and click on the buy now option and reached my checkout page. But for some reason he/she didn't buy it.
But after sometime he/she made his mind to purchase the product but when they click on buy know button the product price get doubles because the product is added a second time in the cart.
As i am not giving access to the cart page to my visitor so they can't modify there cart.
Is there anyway with which I can prevent the same product adding a second time in cart.
I don't want the min maximum plugin because it doesn't prevent from adding same product multiple time. It just shows a notification that the max amount is 1.
I just don't want the same product to be addded twice in the cart no matter what.
I tried this code:
add_filter( 'woocommerce_add_cart_item_data', 'woo_custom_add_to_cart' );
function woo_custom_add_to_cart( $cart_item_data ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
// Do nothing with the data and return
return $cart_item_data;
}
But after adding it I am not able to add a second product into my cart.
As I have added a order bump in my checkout page but when i tried to add it it replaced the main product.
You can force a single purchase of a given product from Edit Product > Product Data > Inventory > Sold Individually
No code needed

Woocommerce hides cart_totals when using cart and checkout on same page

On my cart page I updated it to include the two short codes:
[woocommerce_cart] – shows the cart page
[woocommerce_checkout] – shows the checkout page
By default the cart page is only populated with [woocommerce_cart] and it will show the cart, coupon code area, and cart totals. When I add the [woocommerce_checkout] it removes the cart totals box.
Does anyone know a work around for this? Or know of this problem?
WooCommerce hides the cart totals by default when the checkout is also present on the same page. This is because it gives duplicate information that might be confusing for your customer, since the checkout also displays subtotal, total and shipping information.
You could bring the cart totals back with a snippet like this:
add_action( 'woocommerce_after_cart_table', 'woocommerce_show_cart_totals', 10 );
function woocommerce_show_cart_totals() {
wc_get_template( 'cart/cart-totals.php' );
}
But changing the shipping method for instance wouldn't work as the shipping method option of the checkout would overwrite again what you have selected in the cart totals.

How to skip checkout page Woocommerce?

Tell me pls how to skip checkout page Woocommerce?
A page where a person simply has to click the "place order" button, since the rest of the data is substituted itself.
After clicking it is redirected to the payment gateway...
How do I skip this formality by clicking one button and redirect them straight to the payment gateway?
Payment gateways is part of the WooCommerce checkout page. Do you have any payment gateways set up? May be you are referring to skipping the cart page and going to the checkout. Here's a great tutorial to do that: https://www.webroomtech.com/woocommerce-skip-cart-and-go-to-checkout/
add_filter('add_to_cart_redirect', 'webroom_redirect_add_to_cart');
function webroom_redirect_add_to_cart() {
global $woocommerce;
$cw_redirect_url_checkout = $woocommerce->cart->get_checkout_url();
return $cw_redirect_url_checkout;
}
add the above code to functions.php file and save it. From now on every time a user clicks the add-to-cart button it will be redirected to the checkout page.

WooCommerce Add to Cart - Redirect to URL

I want to just show a simple add to cart button at the bottom of a page. I can do so by using shortcodes:
[add_to_cart id="99"] or [add_to_cart_url id="99"]
The problem is that I want to then go to another URL that is not related to WooCommerce. It has to be customized depending on the page we are on.
An example would be:
Intro Landing page (add to cart at bottom)
a. Action: adds product 99 to cart then redirects to #2.
Upsell page with 3 products on it
a. Action: adds one of the three products to the cart and redirects to #3.
Second Upsell page with 1 product on it
a. Action: adds the product to the cart and redirects to #4.
Checkout Page.
I was hoping there was a shortcode that I could use for Add to Cart and Redirect but can't find anything online. I have found a custom redirect option that woocommerce offers but it would set the redirect for all Add to Cart buttons.
I was thinking that there may be a way to create a function that expands the add to cart button shortcode so I can add a custom redirect URL to it.
For example: [add_to_cart id="99" redirect="../step2/"]
This can even be a URL that I can use in a link. I found that on this page under the section titled "URL: Add One Simple Product to Cart & Redirect to Any Page Afterwards" that says I should be able to just use:
href="http://yourdomain.com/your_custom_page/?add-to-cart=25"
It adds the product to the cart but then just redirects to the cart (I have AJAX add to cart buttons enabled).
Any ideas may help!
Thanks,
Matt
Using this works: http://yourdomain.com/your_custom_page/?add-to-cart=25
I just had to uncheck the box in WooCommerce Settings that says to go to cart when someone clicks add to cart and make sure AJAX links was checked

Add fields to woocommerce cart page

I want to add one or two fields on cart page. I want to take my users preferred delivery time.
for example I am selling cakes and want users preferred date and time when they want it.
I want it on carts page not on checkout page.
Thank you
I figured out the way.
add_action( 'woocommerce_after_cart_table', 'custom_timing_fields' );
function custom_timing_fields() {
echo "something like input or select box here";
}

Resources