I have a Nuxt frontend for a WooCommerce store. What would be the best way to clear the cart in this setup?
My current (only) go at this is to clear the cart using ajax call to WordPress on thank-you page, that does this:
WC()->cart->empty_cart(true);
WC()->session->set('cart', array());
WC()->session->set('order_awaiting_payment', null);
But this seems reliant on too many factors and if any of them blows, the end user will be left in doubt.
Related
I am using BigCommerce API with Nextjs and I am trying to understand how cart API works from BC ( https://developer.bigcommerce.com/api-reference/20c2c55c1763f-create-a-cart ).
When I implement it as it is there, whenever I click on Add to cart button (same/different item ) it generates a new cart with that item.
I don't know how to keep adding items to the same cart (with the same cart-id, etc). There is no API for updating the current cart (i.e. send PUT req with new items on api/cart/cart-id).
Is there any other solution?
Have you checked out the Add Cart Line Items Storefront API? I think this might be what you are looking for to add products to an existing cart.
A
we are building the REST API for WooCommerce and we want to add a product to user's cart. For that we have used Cart API for WooCommerce but it doesn't seems to working for us as it doesn't giving any option to set user_id along with the data so we are facing issues with mobile app and website syncing. We want to make it generalize like if user is using mobile and adds product to cart, it should be remain in the cart if login from web too and it's seems not working for us
Any help will be appreciated for it
Thanks in advance
Woo-commerce cart items is temporary store in session so you can not get items using REST API, for that you have to make a custom table of cart then store details in your custom cart table using REST API.
Hi I want to add checkbox on my Cart page of woocommerce when user check the box it will automatically subscribe them for my product. I have bought woocommerce subcriber plugin but I don't know how to add checkbox which will have this functionality in cart page.
I will try to answer to the best of my knowledge given that I am not proficient with woocommerce. But the general idea is that, you add your checkbox on the cart page of the theme and pass the the value via form data(like name="subscribe" value="True/false") to the data handler(most probably the next page in the checkout cycle which would be delivery or payment options page), which will then call the plugin and pass the subscriber info to it. I would say that it would make sense to put the checkbox where you collect customer info but hey your site, your choice.
Sorry if this is a very generic answer and not a detailed one. I am very new to this myself. Best of luck.
I am totally new on WooCommerce, and I have a client with an "issue", that I am not sure if that is really an issue.
What he described to me, was the following scenario:
The client comes in the web site,
The client add some product in the cart,
Then he goes in the cart, and he perform a login
then the client logou, and the cart is getting empty.
So the question is, this behavior is the normal procedure for WooCommerce ? If so, is there a way to avoid the empty cart after the user is getting log ou of his account ?
There is a setting "clear cart on logout". Probably is enabled.
I have woocommerce store in my wordperss site.
What I want is I want to add checkbox box to my product page in front side.
How can I do this??
Need Your help.
Thanks.
Not sure if this is the best way but I guess you could something along the lines of this..
Add the checkbox in single-product\add-to-cart\simple.php inside the form and then add_action('init', 'check_for_checkbox_value_here'); and inside the init hook you can store that checkbox value in the session and then check on checkout page for that session value.
Then on action woocommerce_checkout_update_order_meta you can save that value in the database for future reference or any backend functionalities you may be having.
Hope that helps!