Changing variantions inside cart on woocommerce - wordpress

Hello I have a shop that needs to have variation selection inside a cart. When a user tries to change item variation page should refresh and update current item.
The problem is I cannot find a function that does that. I was thinking to use
WC()->cart->add_to_cart($product_id,$quantity) but this one does not fit my needs. Also I tried to change variation key inside.
WC()->cart but that did not work either. How can I solve this problem?

I've found it myself
If you want to add variation just enter it inside third field like
WC()->cart->add_to_cart($product_id,$quantity,$variation_id)

Related

Hide variable product choice on shopping page when there is only one variation of the product

I've been browsing for 5-6 hours to get a solution to this problem and didn't manage to make it work for the solutions I found.
A thread answered by LoicTheAztec seemed to work for the guy who posted it but doesn't work for me.
Hide variable product dropdown that has a unique variation selected by default in Woocommerce
Also, it seems the problem occurred for another guy, but his situation was quite different so I can't say I have the same problem as him. If that helps: Hide dropdown with only 1 variable in Woocommerce
I've tried Loic's solution and made sure :
the code is set up in functions.php in my theme (right before "?>")
the only variant of the product is set as default on the product's page
I also tried to make the product with only one attribute but it didn't help (it already had one variant, but I deleted the other attributes to try to make it only one attribute too but didn't help)
I also tried to delete all the possible values for this attribute (even though, still I have only one variant that is set as default). That didn't help either
Here you can see how it's displayed on my product page, even with the code in my functions.php:

WooCommerce Variation Try or Buy with ACF

I have a strange request that I don't know how to approach or get working with WooCommerce.
On the product page we have two options. Buy or Try this product.
So generally "Buy" for say, $49.95 would include shipping and you can checkout as normal.
But "Try" for say $6.95 - that $6.95 is your shipping charge to try it, and the full product price at the end of the 15-30 days is the $49.95.
When you select Try you need to agree to some terms and conditions before you can add it to the cart.
So I think Advanced Custom Fields to add a conditional WYSIWYG to add in some specific information and make the Checkbox required to add to cart. I'm not required to think about the billing side of things just to get this Try or Buy working on a product page.
How the heck do I do this?
This is pretty straight forward with ACF.
Create a field like you mentioned as a wysiwig editor for the content.
Create a checkbox field and set Required: to yes. Add conditioning to hide it unless the checkbox from clicking the trial button is populated.
Create a checkbox field, that you will use to create the Trial button. Restyle it to be a button.
Now on the try button, add some JS in order to make a popup appear.
They read the popup and check the box.
Do an if statement to check if the checkbox has accept or whatever you set the checked yes value to. If it is equal to that value, add a styling or class to the try button to make it disappear. Remove styling or a class off an extra button that allows you to then get the product buy pressing it.
This seems like it would work, you'd then just need to figure out how to get the product charge to differ. Perhaps when they click that button it populates a hidden coupon field which applies a discount to the basket making it the amount you want the cost to be? Or it changes the value they have to pay. I will let you figure that one out.

woocommerce variation/add to cart not showing

so, I have coded a wordpress theme and integrated woocommerce with it. It has used only simple products for some time, and I was using a simple product to test codes, as it works fine. But I recently added a variation product and then, the add to cart button also gone ( variation select dropdown is there, but values are not bonded to drop down.
If anyone can give me a hint, showing what I have done wrong, that would be a big favor.
I just got the same issue and it solved when I manually entered a price for the variable products. Unfortunately I didn't find out yet why I have to enter it, even for the same value. But it fixed it.
Hope it helps !

WooCommerce - Variations

I am using WooCommerce in my project and would like to display variations in a similar style like http://www.e-rudy.com/en/products/detail/SN220724R1. They have a tab called "other colors". Is it possible to do that in WooCommerce?
Yes, it is possible, but you will have to add a custom template for that to be incorporated in the product tabs. In that template you should pull all the variations information corresponding to the main product.
If you don't do it as parent->variations products, you can still link them in the backend and show those in the template. In short, it's doable but you or someone else will have to code that part. It might also be possible to do it with wp-types views, but I have never used it so I can't comment.
Hope that helps to get you started.
Like this https://woocamp.com/product/classic-wordpress-shirt/ ?
When you click on the additional sizes, nothing visually happens. But the size is registered as a variation. Now, when you select a different color, the image actually changes and the image switches as well!
I did that using WooCommerce Variations and Swatches

WooCommerce display add to cart without default selection

I need to display the "add to cart button" without choosing default selection values with variations.
A customer can select the variable from the dropdown variations and reset the values back and the "single_variation_wrap" should always be visible.
I tried to remove "display:none" under variables.php but it didn't do the trick.
Could anyone help?
See the answer here
"WooCommerce: always showing add-to-cart button even before variation is selected"
This should work:
You can deregister the current add to cart variation Javascript, copy and paste this script into your theme directory and enqeue this new one. Here you can remove the slidedown feature and it will always show.
Caveat
When woocoomerce push a new release, you will have to check the changlog to see if anything has changed inside add-to-cart-variation.min.js

Resources