[Skip to main content](#vessel-content)

#   hide product quantity label when no stock

##

- **[SG](/forum/user/12204-sg "View SG's Profile")**
- [![SG's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12204-sg "View SG's Profile") Topic Author
- [ Offline](/forum/user/12204-sg)

Less More

- Posts: 101
- Thank you received: 12
-
-

11 years 10 months ago -  11 years 10 months ago [\#184736](#184736) by [SG](/forum/user/12204-sg "View SG's Profile")  *[hide product quantity label when no stock](/forum/26-product-category-display/873912-hide-product-quantity-label-when-no-stock#184736 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 2.5.27  Hi,  How can I get the product quantity for the main product that has variants. I'm in PRODUCT / SHOW&#95;DEFAULT and I want to hide  Otherwise you get the following on the site:  I just want to show NO STOCK which resides in QUANTITY view if I'm not mistaken.  So I tried to use $this-&gt;row-&gt;product&#95;quantity but this doesn't give the right quantity. I think this has to do with the fact that the product has variants.  When I do var&#95;dump($this-&gt;element-&gt;main) I can see the  I just don't know how to access product&#95;quantity. When I try with $this-&gt;element-&gt;main-&gt;product&#95;quantity my page isn't loaded well and the layout disapears so there seams to be an error.  So my question is: How to get the product quantity of the main product so I can hide  under  in the product view.  Thanks in advance")* was created by *[SG](/forum/user/12204-sg "View SG's Profile")*

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 2.5.27

Hi,

How can I get the product quantity for the main product that has variants.
I'm in PRODUCT / SHOW_DEFAULT and I want to hide Code:

&lt;?php echo JText::_('PRODUCT_QUANTITY'); ?&gt;

Otherwise you get the following on the site:

> Quantity
> No stock

I just want to show NO STOCK which resides in QUANTITY view if I'm not mistaken.

So I tried to use $this-&gt;row-&gt;product_quantity but this doesn't give the right quantity.
I think this has to do with the fact that the product has variants.

When I do var_dump($this-&gt;element-&gt;main) I can see the Code:

object(stdClass)#831 (58) { ["product_id"]=&gt; string(4) "4469" ["product_parent_id"]=&gt; string(1) "0" ["product_name"]=&gt; string(23) "Geschenkpapier RF12000F" ["product_description"]=&gt; string(26) "Geschenkpapier test" ["product_quantity"]=&gt; string(1) "0" ["product_code"]=&gt; string(8) "RF12000F" ["product_published"]=&gt; string(1) "1"

I just don't know how to access product_quantity.
When I try with $this-&gt;element-&gt;main-&gt;product_quantity my page isn't loaded well and the layout disapears so there seams to be an error.

So my question is:
How to get the product quantity of the main product so I can hide &lt;?php echo JText::_('PRODUCT_QUANTITY'); ?&gt; under &lt;div id="hikashop_product_quantity_main" class="hikashop_product_quantity_main"&gt; in the product view.

Thanks in advance

Last edit: 11 years 10 months ago by [SG](/forum/user/12204-sg "View SG's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NzM5MTItaGlkZS1wcm9kdWN0LXF1YW50aXR5LWxhYmVsLXdoZW4tbm8tc3RvY2s/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[SG](/forum/user/12204-sg "View SG's Profile")**
- [![SG's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12204-sg "View SG's Profile") Topic Author
- [ Offline](/forum/user/12204-sg)

Less More

- Posts: 101
- Thank you received: 12
-
-

11 years 10 months ago [\#184785](#184785) by [SG](/forum/user/12204-sg "View SG's Profile")  Replied by *[SG](/forum/user/12204-sg "View SG's Profile")* on topic *[hide product quantity label when no stock](/forum/26-product-category-display/873912-hide-product-quantity-label-when-no-stock#184785 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 2.5.27  Hi,  How can I get the product quantity for the main product that has variants. I'm in PRODUCT / SHOW&#95;DEFAULT and I want to hide  Otherwise you get the following on the site:  I just want to show NO STOCK which resides in QUANTITY view if I'm not mistaken.  So I tried to use $this-&gt;row-&gt;product&#95;quantity but this doesn't give the right quantity. I think this has to do with the fact that the product has variants.  When I do var&#95;dump($this-&gt;element-&gt;main) I can see the  I just don't know how to access product&#95;quantity. When I try with $this-&gt;element-&gt;main-&gt;product&#95;quantity my page isn't loaded well and the layout disapears so there seams to be an error.  So my question is: How to get the product quantity of the main product so I can hide  under  in the product view.  Thanks in advance")*

Hi,

I apologize, it seems that **$this-&gt;element-&gt;main-&gt;product\_quantity** **DOES** work.

My problem was that during testing I tried the following: Code:

echo "prod quantity: $this-&gt;element-&gt;main-&gt;product_quantity";

With $this-&gt;element-&gt;main-&gt;product_quantity inside the double quotes.
And this gave a semi blank page and when I set the debug on maximum, I could see an error with:
**object of class stdclass could not be converted to string**

So when I changed the echo to: Code:

echo "prod quantity: " . $this-&gt;element-&gt;main-&gt;product_quantity;

I did get a result for the product_quantity when it was from the product with variants.

So now I used the following test:
Code:

if (($this-&gt;element-&gt;main-&gt;product_quantity != 0 or $this-&gt;element-&gt;main-&gt;product_quantity == NULL) and ($this-&gt;row-&gt;product_quantity != 0)){ echo JText::_('PRODUCT_QUANTITY'); }

Is this the correct way of showing the Quantity Label?

Thanks

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NzM5MTItaGlkZS1wcm9kdWN0LXF1YW50aXR5LWxhYmVsLXdoZW4tbm8tc3RvY2s/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86584
- Thank you received: 14325
-
-

11 years 10 months ago [\#184791](#184791) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[hide product quantity label when no stock](/forum/26-product-category-display/873912-hide-product-quantity-label-when-no-stock#184791 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 2.5.27  Hi,  How can I get the product quantity for the main product that has variants. I'm in PRODUCT / SHOW&#95;DEFAULT and I want to hide  Otherwise you get the following on the site:  I just want to show NO STOCK which resides in QUANTITY view if I'm not mistaken.  So I tried to use $this-&gt;row-&gt;product&#95;quantity but this doesn't give the right quantity. I think this has to do with the fact that the product has variants.  When I do var&#95;dump($this-&gt;element-&gt;main) I can see the  I just don't know how to access product&#95;quantity. When I try with $this-&gt;element-&gt;main-&gt;product&#95;quantity my page isn't loaded well and the layout disapears so there seams to be an error.  So my question is: How to get the product quantity of the main product so I can hide  under  in the product view.  Thanks in advance")*

Hi,

Yes.
It's always best to keep the variable outside of the strings, like in any other language. Because when you deal with complex variables you need extra curly brackets to have the variables properly recognized by PHP in the strings. But if you leave them outside of the strings, you never get such problems.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NzM5MTItaGlkZS1wcm9kdWN0LXF1YW50aXR5LWxhYmVsLXdoZW4tbm8tc3RvY2s/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[SG](/forum/user/12204-sg "View SG's Profile")**
- [![SG's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12204-sg "View SG's Profile") Topic Author
- [ Offline](/forum/user/12204-sg)

Less More

- Posts: 101
- Thank you received: 12
-
-

11 years 10 months ago [\#184846](#184846) by [SG](/forum/user/12204-sg "View SG's Profile")  Replied by *[SG](/forum/user/12204-sg "View SG's Profile")* on topic *[hide product quantity label when no stock](/forum/26-product-category-display/873912-hide-product-quantity-label-when-no-stock#184846 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 2.5.27  Hi,  How can I get the product quantity for the main product that has variants. I'm in PRODUCT / SHOW&#95;DEFAULT and I want to hide  Otherwise you get the following on the site:  I just want to show NO STOCK which resides in QUANTITY view if I'm not mistaken.  So I tried to use $this-&gt;row-&gt;product&#95;quantity but this doesn't give the right quantity. I think this has to do with the fact that the product has variants.  When I do var&#95;dump($this-&gt;element-&gt;main) I can see the  I just don't know how to access product&#95;quantity. When I try with $this-&gt;element-&gt;main-&gt;product&#95;quantity my page isn't loaded well and the layout disapears so there seams to be an error.  So my question is: How to get the product quantity of the main product so I can hide  under  in the product view.  Thanks in advance")*

Thanks Nicolas for the tip.

Is the IF-structure correct? Or should I perform the test in a different way?
Code:

if (($this-&gt;element-&gt;main-&gt;product_quantity != 0 or $this-&gt;element-&gt;main-&gt;product_quantity == NULL) and ($this-&gt;row-&gt;product_quantity != 0)

Cheers

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NzM5MTItaGlkZS1wcm9kdWN0LXF1YW50aXR5LWxhYmVsLXdoZW4tbm8tc3RvY2s/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

11 years 10 months ago [\#184853](#184853) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[hide product quantity label when no stock](/forum/26-product-category-display/873912-hide-product-quantity-label-when-no-stock#184853 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 2.5.27  Hi,  How can I get the product quantity for the main product that has variants. I'm in PRODUCT / SHOW&#95;DEFAULT and I want to hide  Otherwise you get the following on the site:  I just want to show NO STOCK which resides in QUANTITY view if I'm not mistaken.  So I tried to use $this-&gt;row-&gt;product&#95;quantity but this doesn't give the right quantity. I think this has to do with the fact that the product has variants.  When I do var&#95;dump($this-&gt;element-&gt;main) I can see the  I just don't know how to access product&#95;quantity. When I try with $this-&gt;element-&gt;main-&gt;product&#95;quantity my page isn't loaded well and the layout disapears so there seams to be an error.  So my question is: How to get the product quantity of the main product so I can hide  under  in the product view.  Thanks in advance")*

Hello,
Using something like this will probably be better : Code:

if (($this-&gt;element-&gt;main-&gt;product_quantity != 0 &#124;&#124; $this-&gt;element-&gt;main-&gt;product_quantity == NULL) &amp;&amp; ($this-&gt;row-&gt;product_quantity != 0)){ }

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NzM5MTItaGlkZS1wcm9kdWN0LXF1YW50aXR5LWxhYmVsLXdoZW4tbm8tc3RvY2s/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[oxido](/forum/user/29793-oxido "View oxido's Profile")**
- [![oxido's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/29793-oxido "View oxido's Profile")
- [ Offline](/forum/user/29793-oxido)

Less More

- Posts: 285
- Thank you received: 42
-
-

4 years 6 months ago -  4 years 6 months ago [\#341472](#341472) by [oxido](/forum/user/29793-oxido "View oxido's Profile")  Replied by *[oxido](/forum/user/29793-oxido "View oxido's Profile")* on topic *[hide product quantity label when no stock](/forum/26-product-category-display/873912-hide-product-quantity-label-when-no-stock#341472 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 2.5.27  Hi,  How can I get the product quantity for the main product that has variants. I'm in PRODUCT / SHOW&#95;DEFAULT and I want to hide  Otherwise you get the following on the site:  I just want to show NO STOCK which resides in QUANTITY view if I'm not mistaken.  So I tried to use $this-&gt;row-&gt;product&#95;quantity but this doesn't give the right quantity. I think this has to do with the fact that the product has variants.  When I do var&#95;dump($this-&gt;element-&gt;main) I can see the  I just don't know how to access product&#95;quantity. When I try with $this-&gt;element-&gt;main-&gt;product&#95;quantity my page isn't loaded well and the layout disapears so there seams to be an error.  So my question is: How to get the product quantity of the main product so I can hide  under  in the product view.  Thanks in advance")*

**UPDATE FOR HIKASHOP v4.5.1**

Display &gt; Views &gt; product / quantity
Around line 126 you will find this: Code:

if(($add_to_cart &#124;&#124; $add_to_wishlist) &amp;&amp; $display_quantity_field)

Add one more condition "&amp;&amp; $in_stock", like this: Code:

if(($add_to_cart &#124;&#124; $add_to_wishlist) &amp;&amp; $display_quantity_field &amp;&amp; $in_stock)

Last edit: 4 years 6 months ago by [oxido](/forum/user/29793-oxido "View oxido's Profile"). Reason: code line correction

The following user(s) said Thank You: [nicolas](/forum/user/63-nicolas "View nicolas's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NzM5MTItaGlkZS1wcm9kdWN0LXF1YW50aXR5LWxhYmVsLXdoZW4tbm8tc3RvY2s/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.059 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
