Mewz
Forum Replies Created
-
Ok, as I understand it you want your products linked together via attributes, so they can be bought directly or from each other.
It’s a bit tricky, but it is possible to do. You just need to create a new attribute to act as the product stock, instead of managing the product stock directly.
For example, add attribute Bag Stock with terms Yellow X, White X, Black X. Then go into your Attribute Stock items and add a new match under the Attributes tab for each term.
Then all you need to do is assign each attribute/term to its respective product (with “Used for variations” disabled). With manage stock disabled on the product, it will now use attribute stock only.
https://pasteboard.co/J4Gnlng.png – Example of how the attribute stock matches should be added.
https://pasteboard.co/J4GpBxh.png – Example of how the product attributes should be added.
Hi @sylwiaofwarsaw!
We spoke with @monsterdev via our direct support channel and figured out a better solution for his use case that doesn’t involve explicitly updating his product stock.
Perhaps you could give me some more details about what you’re trying to achieve with this feature?
Our plugin will already display the correct available product stock (according to available attribute stock) on the frontend and prevent over-purchasing.
Hi again @sylwiaofwarsaw,
Upon further investigation of this issue, it seems the default behaviour of WooCommerce is to not restore stock when simply deleting an order. Stock will only be restored when refunding the order, or when updating the order status to Cancelled.
Since our plugin already follows this behaviour, no further changes will be made to the core functionality. If you specifically need this feature, it can be added using WordPress hooks (in PHP).
Thanks again for your feedback. If there’s anything else we can assist you with, please let us know!
Hi @sylwiaofwarsaw!
Ordinarily if a product is returned the item would be refunded in the order (if applicable) rather than deleting the order. In this case the attribute stock will be restored.
In any case, it definitely should also restore the stock if the order is deleted. Thank you for pointing this out ??
We’ll be sure to release a fix for this soon!
We haven’t heard back from you, so we are marking this as resolved.
Please feel free to reply if you need any further assistance.
Hi @kabarovsky!
This sounds like a pretty straight forward use-case of attribute-level stock.
You’ll want to set up the stock for your Front Row attribute like this: https://pasteboard.co/IZy4emA.png
Note that you are only managing stock for the Front Row attribute. You should not manage stock for each term as then their stock will be managed individually rather than being shared between all the Front Row tickets.
I hope that makes sense. If you need any further assistance, just let us know ??
Thank you very much for taking the time to leave your feedback @yward. This is our first release and we are still figuring out the best way to offer this and future plugins.
We’ve taken your comment into consideration and WooCommerce Attribute Stock is now available to purchase exclusively on CodeCanyon!
This version will remain on wp.org for now, but will be clearly and accurately titled as a “Lite” version.
Thanks again, and we hope to get your feedback on the full version at some point ??
Thank you very much for the positive feedback @monsterdev! We’re glad you’re enjoying our plugin ??
No problem. I can’t give an exact date, but we’re hoping to release it by the end of the month.
Hi @monsterdev! ??
I’m sorry to say that this is not a feature that our plugin currently offers. However, product stock synchronization is something we’re actively working on and will release very soon in our PRO version.
If you prefer to stick with the free version, this can be done fairly easily by adding a custom hook (e.g. in your theme’s functions.php file). Below is an example snippet on how to get started with this:
use Mewz\WCAS\Models\AttributeStock; add_action('mewz_attribute_stock_saved', function(AttributeStock $stock) { if ($stock->id() === 123) { // Find your products, e.g. $products = wc_get_products([ 'category' => 'shirts', 'status' => 'publish', 'limit' => -1, ]); /** @var WC_Product $product */ foreach ($products as $product) { $quantity = $stock->quantity(); if ($product->get_stock_quantity('edit') != $quantity) { $product->set_stock_quantity($quantity); $product->save(); } } } });
This is a very simple function that will update the stock quantity of all published products in the Shirts category whenever the stock quantity of the attribute stock item with ID 123 is updated. Of course this can be expanded to update your product stock however you like.
If there’s anything further we can assist you with, please let us know!