In Woocommerce some customers forget to select the variations or they don't know that they must select a variation first, so they keep clicking on the add to cart button but it doesn't work for them and they email me wondering why.
So, I thought of setting the first variation as default for all of the products.
I know I can do this through the admin but I cannot do this for all the products one by one, it's time consuming.
Please is there a code to add/edit to make the first variation the one selected by default?
I once were about to do the same and what i've found after searching a bit is this: https://quadlayers.com/default-product-attributes-woocommerce/
Basically he just hooks into woocommerce_before_single_product_summary and applies some logic that programmatically set the same thing you would set by going into the backend.
Beside this being maybe a good idea i finally gave up because i had to maintain an order into my variation choices and doing this would have break it for sure in the long term (imagine something like a dimension and you have it sorted, like 10,100,1000. You run the code today and it sets 10 as the default, then one day you add 5 and it is no longer correct)
Maybe you should think about giving some visual feedback to your users when they don't select the variation, that might solve the issue and actually create more internet-aware ppls around =)
Related
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:
Good day kind crew. I haBe a issue. what I am trying to do is this: a tennis league with 5 divisions. These 5 divisions are located in everytown and those towns in states. I am using ACF and pods. On the state archive page. We would like to choose the state and then on the specific state page we would see the divisions terms. And when you click the division you see all post from that tterm. We have a custom template for the taxonomy but want to limit how many template pages we need to create. If we go with categories than we have to make a custom template for every town/division. Any suggestions on best logic for this making it easy to use on front end without losing admin organization. We set up category hiearcy but we're looking for a better way because we need to allow for user to fill out form and populate post. At this point we have decided to use categories unless someone has another option. Categories just feel sloppy on admin side with children. Thanks for your time.
I'm not sure I understand the question, and thus am not sure I'm on the right track with this answer.
I think you're looking for towns/divisions to have content that can be customized by users. There may be a more WP specific way to do this, but a simple way would be to have a db table with these elements associated with the post id, for example post_id, town_desc, town_mascot, etc. Then, in the WP template, run a query to see if custom elements exist. If not, echo some default text, otherwise echo the custom element text from the db. I think I'd also have the default text be different based upon the level, i.e. with states, divisions, and towns all different based on their level.
Your answer might lie in simply working with custom fields, perhaps with
https://wordpress.org/support/article/custom-fields/
Specially wants to change functionality of those pages with custom coding.
Example: If any one ask for Buy two and get one free for similar category product, then what would be the best procedure to carry on. With out plugin need solution.
Well if you dont have much experience with woocommerce then i would suggest to stick with its default functionality.
Although "buy 2 get one free" kind of plugins would be perfect for this job but as you dont want to use plugins there is one more way. You can create a variable product. In your product page, mark it as variable product and then add variations to it. You can set one variation as "buy one" with a price of lets say $50, and make it the default variation and then add another variations "buy 2 get 1 free" with a price of $100. You can also add different images with each variation.
Now on your product page, you will be able to see a drop down (or if you like radio buttons you can use it too) with the default saying "buy one" with price of $50, and when some one clicks on the "buy 2 get 1 free", the price will automatically change to $100.
Yes, it is. The first step would be to get access to the relevant files. You can do that in several ways but the best way to go about it for your case will be to use an FTP client such as Filezilla. You can also access WooCommerce's files through the WordPress admin panel under Plugins->Editor. Bear in mind, however, that WooCommerce is a fairly massive and complex plugin and it will likely take considerable time and skill to locate the relevant files and code. Happy coding!
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 !
I'll try and give an example what i want:
(this isn't what I'm doing, but it seems like a decent example of how I'd like it to work)
Imagine we have a custom post type (CPT) of 'houses' and one of the custom meta options for this CPT is 'bedrooms' - obviously, different houses have different amount of bedrooms, all of which have different properties. So, I'd like to be able to allow the user to add several different properties about a bedroom i.e.
Dimensions, aspect, number of windows and floor type
When the user has added these details for the first bedroom, if the house has a second bedroom then I would like them to have an 'add bedroom' button and another set of these meta boxes is added so they can fill out the details about bedroom 2.
I understand that I'll need some javascript to add this facility (and something I don't mind writing) but what I'm struggling with in my poor, useless brain is how to save these to the database. I want to achieve this using WordPress meta so that I don't add any unnecessary database tables and I'm sure it's possible I just can't quite fathom the principles of how to save the data.
Pointers to any tutorials would be brilliant, or some examples of plugins which already do this kind of thing would be very gratefully received.
here is a screenshot to get an idea what i want to do.
Solution:
I have found solution here, it might be helpful for someone.
https://wordpress.stackexchange.com/questions/25478/custom-post-type-metabox-array
You are basically after repeater metaboxes. A few metabox classes support repeating fields. One worth checking out is http://www.farinspace.com/wpalchemy-metabox/
I wrote a plugin that uses repeating metabox fields that doesn't use wp-alchemy if you want to dig through it. http://code.google.com/p/css-thumbnail-sprites/