News:

Looking for documentation? Take a look on our wiki

Main Menu

Multi Variant child with line-through when not in stock

Started by kogos, July 20, 2017, 15:15:11 PM

Previous topic - Next topic

kogos

I rarely ask something in forums, i usually try to figure out things myself and not ask people to do the work for me... but in this case, i 'm afraid i must ask cause i' m banging my head through a wall here.

I'm developing a clothes store and i will have 2 variants per product. One is color and second one it size. I am using multivariants custom fields with 2 ramifications, one for color and one for size. I got the layout out the way i want it to be, but i can't do one simple thing.

What i want to achieve:
I want to show products' sizes in category view layout (browse view) and if a size is out of stock, i want it to be shown with line-through. For that to appear, i am overriding sublayouts/customfield.php (its type C custom field). Although, i read the whole file and i understand it completely, i cannot get the stock level of multivariants' child products, so that i can change style or text. Adding a simple word at the end of the $o->text = $text; would do, and i could change it with a php regex afterwards. Of course, ideally, adding class to <option> or <div> tag would be the best bet.

Things i have tried to far:
I can get the array() or $product_id of products that are out of stock, with db query (the same way it's done in the original customfield.php file) but i cannot alter $o->text = $text; or, even better, add a class to that particular loop. I can only get the array and simply show it to any position i want.
I also tried to change the whole structure of customfield.php file, with no luck. Too many foreach loops makes the whole file hard to change. I also tried to add custom foreach loops to change $o->text = $text;, again with no luck.
Of course, out of stock items are showing, and my problem has nothing to do with virtuemart shopfront configuration setting ( Action when a Product is Out of Stock ).

I prefer NOT to use any extra plugin for this, and i don't even know if there is one available. I am already trying to achieve this layout for 3 days now, and it bugs me that i can't make it without a plugin/extension. I know there must be a way, i just can't figure this out.

Any help would be greatly appreciated.

Thanks for your time to anyone who answers and put some thinking on it:)

btw, i am using latest virtuemart and joomla versions

Unfortunately, i cannot provide any link, it's still on developing stage, and not on live server... and of course not styled, with only basic css so far.