Coupon Code on Checkout Woocommerce - php

I am currently trying to have coupon codes work on my checkout page, using the Oxygen theme. Currently I am loading both the cart and the checkout on the same page, but when using the coupon code provided by the cart, I get redirected to the cart page, which I absolutely do not want (want to stay on xxxx.com/checkout.
How can I go about removing this href, or including the coupon code solely on the checkout page without using the coupon window provided by the [woocommerce_cart]

What you are asking is not traditional behavior of checkout, but it can be done. All you have to do is change the Cart Page's target Page.
Goto to Woocommerce settings
Flip to the Checkout tab
Under Checkout Pages, locate Cart Page
Change its target page to Checkout or whatever page you are using for that purpose
Save and Test

Related

Force redirection to cart on error in WooCommerce

I'm adding to the WooCommerce cart via redirecting to an add-to-cart url. For example, my code generates this URL and redirects to it:
/?add-to-cart=2316723&variation_id=2316727&attribute_program=General&nyp=10
I have to add to cart this way since I'm using the Name Your Price add-on, and so I can't add to cart via WC()->cart->add_to_cart()
Unfortunately, when there is an error in adding to cart, WooCommerce redirects to my home page, instead of staying on the cart so that the user can see the error.
This does not happen when there's a cart error after a customer clicks a product button to add to cart, but only when there's a cart error after my code redirects to the add-to-cart url.
I have tried this filter:
add_filter( 'woocommerce_cart_redirect_after_error', 'stop_woo_cart_redirect');
function stop_woo_cart_redirect( $url ) {
$url = WC()->cart->get_cart_url();
return $url;
}
and it doesn't make a difference.
The cart error is usually from some of my other, using woocommerce_add_to_cart_validation filter.
So, in other words, my code generates an add-to-cart URL and redirects to it, my other code determines that specific product mix is invalid and generates a cart error, but WooCommerce does not stay on the cart, but redirects away from it.
Is there any way I can fix this?
As you can't use WC()->cart->add_to_cart() I doubt WC()->cart->get_cart_url(); will work. You will need to hook into using your custom code.
Try this. I have no idea if it will work but worth a shot.
add_filter( 'woocommerce_cart_redirect_after_error', '__return_false' );

How to stop Woocommerce Add to Cart redirecting to Product Pages

Because of a way a customer wanted their products displayed I've used woocommerce shortcode to display products. When Add to Cart is clicked, I didn't want the customer to leave the page but stay on that page until they'd finished ordering.
I have used this code in my Child Theme functions.php file and it successfully stopped the redirection and kept the customer on the page they were on.
//Prevent shortcode [product_page] redirecting to the actual product's page after add to cart
add_filter( 'woocommerce_add_to_cart_redirect', 'wp_get_referer' );
BUT after I added a plugin that gave minimum or maximum quantities and the quantity is below the minimum the Add to Cart redirects to the product page again whenever a product is below the minimum.
I'm not great on php and am not sure what I need to put in the functions.php file to stop this happening.
Any suggestions much appreciated.
Maybe other plugins are adding filter to the cart redirect as well. You could try to set your own filter's priority to a big number so that it's executed after the other filters.
add_filter('','',50); //or even a bigger number

Woocommerce one page checkout custom

I want to use one page checkout process in woocommerce. i have created a new page(addition) with some name and have added the shortcode
[woocommerce_cart][woocommerce_checkout]
here is the shortcodes i am using
It is working fine but login for returning customer login button is not working.
but on checkout page returning customer login button is working.
Can you please help?
i want to make one page checkout process. Image is attached Please help
Try to go to the woocommerce settings (checkout tab) and set both cart page and checkout page to your single-checkout page

How to get further of Checkout page in woocommerce

I am working on woocommerce wordpress plugin. My project is located at the link :
http://tiffinkaku.com/planner/
When I add any product in cart go to the checkout page
When I select Cash on delivery and click on Place order then it doesnt go further only the link goes blur
How can I come out to the situation ?

woocommerce - coupon on checkout page

I'm using Woocommerce for Wordpress to build a webshop.
I have removed the coupon from cart and added it to the checkout. When I enter the coupon code and hit 'apply coupon', it completes the whole form and goes directly to the payment gateways. I want to make sure the coupon first gets added to the order total. Any idea?
Thanks!
Woocommerce already provides provision to add coupon from the checkout page you don't need add. Probably you have edited the checkout page template and added the coupon form inside the checkout form that's why checkout form is submited on clicking apply coupon. In order to customize the coupon in checkout page you have to look into wooocmmerce checkout.js.

Categories