Items grid stock info

Phoca Cart - complex e-commerce extension
klimajan
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 12 Dec 2023, 16:09

Items grid stock info

Post 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!

Tags:
mino182
Phoca Professional
Phoca Professional
Posts: 188
Joined: 12 Feb 2015, 13:30

Re: Items grid stock info

Post by mino182 »

You can get stock info only for main product. So when you stocking products, you need to update also overall stock value...
klimajan
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 12 Dec 2023, 16:09

Re: Items grid stock info

Post by klimajan »

OK and is it then gonna be as some info in $d var?
mino182
Phoca Professional
Phoca Professional
Posts: 188
Joined: 12 Feb 2015, 13:30

Re: Items grid stock info

Post 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...
klimajan
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 12 Dec 2023, 16:09

Re: Items grid stock info

Post 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?
mino182
Phoca Professional
Phoca Professional
Posts: 188
Joined: 12 Feb 2015, 13:30

Re: Items grid stock info

Post by mino182 »

klimajan
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 12 Dec 2023, 16:09

Re: Items grid stock info

Post by klimajan »

Awesome thank you!
Post Reply