We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum
Stock Level for Variants
Okay, so here's the issue. I'm surprised no one has run into this. My client sells hats, but the product could be anything like t-shirts. Each hat style has a color variant.
Well, I want to display if the product is in stock or not ... problem is, the client tracks the products by variant. Is there a way to show if the product is in stock by getting a count of all the variant stock numbers COMBINED?
In theory, if I
count stock on individual variant, then the
stock_level will always read zero ... if I set it to
1, then even if the client sells out all of variants, the stock level will still read
1 and show that we have that item in stock.
I feel like there's a disconnect between
count stock on individual variant and the
stock_level for the item as a whole. If you track
count stock on individual variant then the
stock_level should be auto-calculated as such.
I thought of a hack, in the template looping though all the variants and gathering their individual stock numbers and adding them together, but as far as I can tell, theres no way to do math inside a template.
Even then, if that did work, this would still fail or at least not match:
perch_shop_products([ 'filter' => 'stock_level', 'match' => 'gte', 'value' => '1' ]);
correct me if I'm wrong on all this ...
Want to reply to this thread?Login with Perch