WooCommerce Variation Try or Buy with ACF - woocommerce

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.

Related

Unique issue with WooCommerce and hiding the add to cart button..?

We have a plugin that allows people to submit offers on products, and then the site owner can accept, counter, or decline offers, and you can negotiate back and forth until a price agreement is reached.
We are using the woocommerce_after_add_to_cart_button hook to add the offer button after the cart button.
We are getting lots of feedback that people want to leave the price of the product empty so that it simply display a price on the site, it won't display the Add to Cart button, but they do want it to display the offer button and allow that functionality.
If you set the price to 0.00, then it says FREE on the site, and still includes the add to cart button, so that's no good.
When left blank, though, the problem we run into is that when a customer clicks to buy a product from an accepted offer, WooCommerce keeps removing the item out of the cart because it says it's not purchase. This is happening because of the is_purchasable() function. With a blank price WC says the product is not purchasable, so it will automatically remove itself out of the cart, which it is indeed doing.
There is a hook available that allows us to force $purchasable = true for the product, but then of course that makes the Add to Cart button show up again, which doesn't make sense for this use-case.
So as it stands now we're at that point. We've got the system overriding $purchasable so that we can complete the checkout on a product with an empty price, but it's leaving the Add to Cart button, which allows the person to add the product at 0.00.
I'm stumped on the best way to hide to the Add to Cart button in this scenario..?? I would usually hide it by using that hook to make $purchasable = false, which takes care of it nicely, but in this case I can't do that because that's what keeps us from being able to purchase the product, of course.
Any information on a way around this would be greatly appreciated!
UPDATE
I found this tutorial for overriding core template files from a plugin: https://www.skyverge.com/blog/override-woocommerce-template-file-within-a-plugin/
So I think what we're going to try is to basically say "if $purchasable = false and $offers_enabled = true, then use these templates for the add to cart button."
Within our template we're doing nothing but commenting out the actual <button> element. This leaves all hooks in place, but hides our button.
Decent solution? Horrible idea?

Changing variantions inside cart on woocommerce

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)

Woocommerce qty box just adds 1 product

I'm trying to make this work but i cannot solve it. In the single product page i have placed the product details in a tab, but the quantity box is no longer working. I also tried it with a text field, but it constantly adds just one product. Can anybody help me with this?
It seems that the submit button is not taking the amount into account...
Add to cart
Where data-quantity is not updating...

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

Ubercart add to cart trigger?

I want to keep track of all items added to uber cart. I.e. Whenever someone clicks ADD TO CART, I want to: create a database entry of the time and item added.
This way I can see which items are most clicked on.
The logic to add it to a db etc is easy to do. What I need to know is, how do I plug into the "add to cart" part. I.e. How do I know when this has been clicked?
You should be able to implement hook_add_to_cart in a custom module, which will get called exactly as you describe above.
In Drupal 7 it changed to hook_uc_add_to_cart

Resources