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

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?

Related

Add continue shopping button at woocommerce store category

Help me I'm looking around, but I still don't find what I need, add another button on my woocomerce store page with the option to add to cart and continue shopping without leaving the page
Here's an example of what I need:

How can I ensure that only one instance of any product in woocommerce is sold?

I've been looking for an answer to this. Client has a woocommerce shop that will only ever have one of each product. What I need to accomplish is that when a product is added to their cart, the item is unavailable for anyone else to add the same product to a cart. I've tried the old plugin but it breaks portions of the front end, I've tried using several similar solutions I've found here, but nothing seems to do the trick. The plugin also made inventory management on the backend a total nightmare.
So, to walk you through, user A adds product A to cart. User B tries to add this product to cart but woocommerce says its sold out currently to user B. User A can checkout with product A or if user A closes the browser, woocommerce waits one minute and then puts product A back in stock so person B can then add product A to their cart.
I've been searching for this and have come up with nothing from here and some company claiming they can but it's done case by case and they want to handcode it aka very expensive to do.
Please, help!
Just an opinion here so maybe I am wrong, but woo commerce uses stock counts in the backend, so if this is set to 1, then there can only ever be one that can go through the checkout process unless cancelled.
The functionality to reduce that stock count to 0 whilst a user has that item in their basket (or just viewing the checkout page) is not feasible as they have not purchased, at that stage it is just showing intent to purchase.
As you mentioned, that functionality is possible, it wouldn't be pretty, but possible and not something that is available by default in the plugin. Development of such functionality would be needed, and you're right probably quite expensive for development time.

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.

Customers can add variation to cart even when drop down menu not selected

I run a website that sells variants of the same product, allowing customers to select from a drop down menu to choose which one they want. In this case, choosing between 125ml and 250ml.
The problem is, customers can add a product to their cart, even if no size has been selected and it still says Please Select in the drop down field. In this case, the Starting From price will be added to the cart, and if a transaction goes through I have no way of knowing what size they actually wanted.
Is there any way I can block their ability to Add to Cart until they make a selection?
Thanks in advance.
yes - that is the way amazon does it for some products especially when you have to choose both a size and color option. the buy button is disabled, there is a message above it to choose a size, and sometimes they won't show the price until you choose.
However - thats only for products with lots of different sizes - and you only have two sizes. So my suggestion would be - just put the two products on there: the size, the price, and a buy button for each one. Eliminate the drop down completely. You have plenty of room to do this and it will make it much easier for the customer to compare price/size, click and buy - which translates to more sales.
my other suggestion would be if possible to bring them to the cart page when they click to buy. on the cart page tighten up the shipping options and put some other recommended products below that to encourage them to browse the store more. p.s. you have awesome products keep up the good work.

Drupal Commerce Ajax cart with added fields

Sorry for the really bad title but wasn't sure how to describe my problem in 10 words.
I have drupal commerce and have made a view that displays the cart contents on top of the checkout page.
Quantity is a text field so it is editable and I have an update button. Unfortunately when I press the update button, naturally the whole checkout page tries to submit. Is there a way to intercept the update button and just refresh the cart with ajax?
Moreover, if I can do that, I want a number of text fields (as many as the quantity number entered) to appear underneath the cart so the user can enter different values on each of them (each referring to the products about to be bought).
Drupal Commerce Cart does this - sort of.. http://drupal.org/project/dc_cart_ajax
It works fine on the cart page, though I too am trying to combine these pages to cut down on the 'checkout steps'. Though it is the same view as the /cart page and I get an ajax refresh indicator it doesn't actually update the cart on the checkout page.
There is a issue related to that, you can subscribe: http://drupal.org/node/1443470
You can disable the Shopping cart contents using the checkout settings. Modify the Shopping Cart View to add a block display and add modify the contextual filter by providing default value using PHP:
if (arg(0) == 'checkout') return arg(1);
else return null;
Add the new Shopping cart block dispplay only on the checkout page and here you go.

Resources