Hide product or variation if has a custom field - wordpress

I need to be able to hide some products and / or variations in a Woocommerce with WPML only for some languages at certain times.
I tried everything, tried to disable the synchronization of the _stock_status that manages WPML but I have not been able and it has occurred to me to add a custom field to each one (in the case of the variations I suppose I would have to do it via database because in the dashboard there is no option) and have a check:
if "custom_field" exists => _stock_status = outofstock (or simply deactivate the add to cart button and display a message.)
This is "easy" for the products, but I don't know how to solve it with the variations. Any ideas? I also hear other solutions to the problem.

Related

WooCommerce Hide Products

Out of the box, WooCommerce will create a shop page featuring a catalog of products and the products are accessible through the REST API at /wc/store/products. For my use case this is precisely what I want to avoid: users should not be able to browse the products by any means. Instead I'll use application logic to programmatically add products to the user's cart when appropriate.
My solution would be to
Disable the /wc/store/products REST API
Make sure there's no shop page set under settings
My questions are (1) is this solution is adequate (2) will disabling /wc/store/products have unforeseen consequences?
I found that it's possible to set the catalog visibility of a product as 'hidden' which is an adequate solution for my use case.

Specifically ordering products in a woocommerce shortcode

I'm using the shortcode [products ids="1094,2811,1097,1095,1098"] for a widget. The products need to appear in the exact order I've listed them, which is different to the order they have to appear in the store, so I wouldn't be able to drag and drop the product order.
None of the 'orderby' options I've found here seem to allow that.
Are there any ways to work around this?
Well, it turns out, you can do it very easily without additional coding.
[products] shortcode uses WP_Query call which accepts also post__in as a value for orderby option which does exactly what you need. So even though this option is not mentioned in woocommerce docs, it works.
[products ids="257,233,269" orderby="post__in"]
You can't do that without extra functions / plugins but you can change the default order to use the 'Menu order' -> Go to WooCommerce > Settings. On the Products tab, under the Display settings, ensure that Default Product Sorting is set to “Default sorting (custom ordering + name)”. You can then edit the order value in the Product Data > Advanced tab on the product edit page.

Sell a posts extra input fields - WordPress

I've been searching, trying to find a plugin that can help me set a price for each of my posts extra input fields.
So, I have a property post type that has the default title, content and featured image fields. Then I have extra fields such as attachment, video. What I need is to initially deny access to each of those extra fields (individually) and only when the user buys the necessary access, will one or all of those fields become available. This must be done when the user is adding a new post and use WooCommerce for the payment.
A visual example:
Plugins I've tried:
- myCRED (only allows the sale of a whole post and not individual fields)
- Fields Monetization (uses packages, not allowing individual field pricing)
- Restrict Content (only allows the sale of complete posts)
If you guys know about any plugins that can achieve this, even if it requires some tweaking, it would be greatly appreciated.

Woo commerce - variable product prices missing from WP

hoping for some help.
We use the following - Wordpress/ woo commerce /wcvendors pro. Prices for variable products are disappearing from wp engine view despite being in the product variation information. It doesn't impact every product on our site but a fair few. How it occurs is, the price is disappearing when you go in and edit the product. If we quick edit the product the price reappears. But it will dissapears again if we use the edit button. Initially the problem started because under the "Products" and "Inventory" We had checked the following setting: "Hide out of stock items from the catalog". Now this button is not ticked but it is still causing us issues.
It seems you have an error on the product page which cause the price not to be saved.
There can be some reasons, here are two I see occasioanlly:
PHP error is caused during the save, and therefore the data is lost. WordPress and WooCommerce works flawlessly together, so the first suspects are other plugins and your theme. Try first to turn off all your plugins and switch to another theme to see if this happens again. If not try to activate your theme, and recheck, and then the plugins one after the other, and check after each activation, until you find the one makes the problem.
Too many data is being saved at one time. It can be too many variations or too many custom fields. This can be fixed by changing some PHP settings. Please have a look here especially under the WPEngine note, and also check this plugin.

Hide Products from View in Drupal Commerce

I know this may be very basic but I can't seem to figure out a way to hide a product that I've got set up in Drupal Commerce. I'm new to Drupal so thanks for your patience.
In the product's edit screen, I go to 'Status' and choose 'Disabled' which prevents them from being added to carts (instead of Add To Cart, it displays 'Product Not Available' in the store) but it doesn't actually remove it from Product Display in the store. I've set the stock status to 0 on these products and made sure that they are not being displayed as 'Featured' yet they still show up.
Is there a simple setting where I can keep the product in the backend, in case I want to activate it later, but hide it from the store?
Thanks so much for your help.
For clarification, I am using the 'Expressa' theme.
It has been a while since I've worked with Drupal Commerce, but I assume that your product listing is a View.
You should be able to modify your View to filter out the disabled products.

Resources