Page 1 of 1

Items grid stock info

Posted: 01 Nov 2024, 12:57
by klimajan
Hey guys,

I have a rather specific problem here. So I am overriding a file layouts/com_phocacart/items_grid.php and the reason is I needed to create a design specific card from each product. Now the only thing I need to also implement is some sort of Sold out label for each item (if its sold out). So my question is - can I somehow get the info about stock being 0 for all variants of a product here? Because I didnt find this in any of the variables that are in this file:

Code: Select all

$d 		= $displayData;
$t		= $d['t'];
$s      = $d['s'];
$col    = $d['col'];
I basically just need to know if there are no variants with remaining stock or if the product has no variants and there is 0 stock. Then I could use it as a condition to implement the sold out tag...

Btw - it might be some straightforward thing I just didnt notice... Please let me know. Thank you!

Re: Items grid stock info

Posted: 01 Nov 2024, 14:02
by mino182
You can get stock info only for main product. So when you stocking products, you need to update also overall stock value...

Re: Items grid stock info

Posted: 01 Nov 2024, 15:34
by klimajan
OK and is it then gonna be as some info in $d var?

Re: Items grid stock info

Posted: 01 Nov 2024, 16:16
by mino182
I don't know if you are in right file and don't remember variable name... You need to dump those variables and you will see...

Re: Items grid stock info

Posted: 01 Nov 2024, 16:27
by klimajan
Ahhh yes I found it:

Code: Select all

$d['item']->stock
Anyway - if I used attributes stock lets say Variant 1 has 10 stock then I also need to add 10 stock to main product right? Question is - if someone buys Variant 1 - it will then have 9 stock but the main product still has 10? Or does it also go to 9?

Re: Items grid stock info

Posted: 01 Nov 2024, 16:37
by mino182

Re: Items grid stock info

Posted: 01 Nov 2024, 16:39
by klimajan
Awesome thank you!