z00zer
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Admin Products page – Stock quantityWorks nicely. Hope it gets added to WooCommerce π
(or some variation of this)add_filter('woocommerce_admin_stock_html', 'admin_product',10,2); function admin_product($stock_html,$product) { if( $product->is_type( 'variable' ) ) { $stock_html = $product->get_stock_quantity() . '<br>' . '<mark class="instock">'. __('In stock', 'woocommerce' ) . '</mark>'; } return $stock_html; }Forum: Plugins
In reply to: [WooCommerce] Admin Products page – Stock quantityOk, thank you very much!
I’ll download 2.6 for my test server and test it out.
Forum: Plugins
In reply to: [WooCommerce] Admin Products page – Stock quantityYeah, I think admin products page gets the stock from simple product’s stock request or something.
woocommerce_get_stock_quantity -filter is used in the admin page stock display. I can filter through my function to echo out the product’s quantity (the data is only int) and it will echo main product’s stock but it will still show the total stock quantity of main product and variation’s, because the way it’s coded.
Weird, I thought it would echo the total amount, not just main product…‘
add_filter(‘woocommerce_get_stock_quantity’, ‘testings’,10,1);
function testings($product){
if(is_admin()){
echo “<b><font color=’#7ad03a’>Main product in stock : </font></b>”; echo $product; echo “
<hr>”;
}
return $product;
}
‘Forum: Plugins
In reply to: [WooCommerce] Admin Products page – Stock quantityIs it possible that admin products page gets that information from some different way than using woocommerce_get_availability filter?
I tested it and it works in shop’s product page but not in admin page? The returning array has key availability => “QTY in stock” and in product page it is in form of “In stock x QTY”
Forum: Plugins
In reply to: [WooCommerce] Admin Products page – Stock quantityWell, customer only sees variations and their stock quantity – they’ll never see main product’s quantity. Only place where user sees “wrong” stock quantity now is admin products page so basically admin is just the problem.
Wrapping it around is_admin() is very simply way, no idea why I didn’t thing of that. Let see what I do (prolly crash the server few times…) π
Forum: Plugins
In reply to: [WooCommerce] Admin Products page – Stock quantityYeah that I was thinking about that. But adding filter to that would affect globally variation/product availability stock quantity, not just admin products page…?
There is no way to narrow my custom filter/function just to work in one page’s call?
Hope you understand what I mean π
Forum: Plugins
In reply to: [WooCommerce] Admin Products page – Stock quantityYes I could add new field for the variation as “variation stock”, and take variation stock management off, so it doesn’t affect admin products page’s stock quantity, but I am assuming it will cause more problems when adding products to cart and in checkout page etc…?
Adding products to cart, alerts about trying to add more than there is stock, stock qty management after checkout etc. are working nicely with having variation’s stock management turned on.
offtopic :
(Expect that I need to find the best way to dynamically check/adjust stock so user can’t add more variations to cart than there are main product’s stock. User could buy 30x variation A (10) and 1x variation B (20), total of 320, when main product’s stock is 300)I’ll check can I achieve this with that woocommerce_get_availability filter, it is used by class-wc-product-variation.php and abstract-wc-product.php
Forum: Plugins
In reply to: [WooCommerce] Admin Products page – Stock quantityThanks for fast reply! π
Yes, 330 is correct total (main product + variations stock) but I made a plugin (which we talked two weeks ago) adds option for product’s variation to reduce main product’s stock amount by certain value.
Also I manage variation’s stock amount by given them values based on this value. (Example. main product 300, variation A value 10, so variation A stock is 30) so everything works beautifully in product’s page in the shop. Taking variation’s stock management off would cause other problems…
Because of this, I would need to have just main product’s stock showing on the products page.
Forum: Plugins
In reply to: [WooCommerce] Reduce main product stock with variation's amountYeah, but really would have loved some other option than coding plugin π Hope in some day this “feature” will find in to WooCommerce as default, because it’s like very common stuff in other ecommerces to have this kind of setup…
Thanks for the answer.
Forum: Plugins
In reply to: [WooCommerce] Reduce main product stock with variation's amountWould it be hard to add feature in to product variation’s options “[ ] amount of stock removed when bought. Default 1.” ?
I’m thinking about stabbing abstract-wc-order.php reduce_order_stock to reduce stock according to the variation’s name/details, but user could buy 50, while real stock is 1, so should get that going on product page… fun times π
Forum: Plugins
In reply to: [WooCommerce] Reduce main product stock with variation's amountI tested “VarkTech Pricing Deals for WooCommerce”-plugin and it looked promising but didn’t do what I wanted. Yes it could make that kind of deals (one for 1β¬, 5 for 4β¬ etc.) but it doesn’t show it in the product page, only in cart.
It might work with having product quantity field as dropdown menu (with pre determined quantity) but the price should update and show according to the selected value, or something π