- Posts: 101
- Thank you received: 12
hide product quantity label when no stock
11 years 10 months ago - 11 years 10 months ago #184736
by SG
hide product quantity label when no stock was created by SG
-- 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
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->row->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->element->main) I can see the
I just don't know how to access product_quantity.
When I try with $this->element->main->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 <?php echo JText::_('PRODUCT_QUANTITY'); ?> under <div id="hikashop_product_quantity_main" class="hikashop_product_quantity_main"> in the product view.
Thanks in advance
-- 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:
<?php echo JText::_('PRODUCT_QUANTITY'); ?>
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->row->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->element->main) I can see the
Code:
object(stdClass)#831 (58) { ["product_id"]=> string(4) "4469" ["product_parent_id"]=> string(1) "0" ["product_name"]=> string(23) "Geschenkpapier RF12000F" ["product_description"]=> string(26) "Geschenkpapier test" ["product_quantity"]=> string(1) "0" ["product_code"]=> string(8) "RF12000F" ["product_published"]=> string(1) "1"
I just don't know how to access product_quantity.
When I try with $this->element->main->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 <?php echo JText::_('PRODUCT_QUANTITY'); ?> under <div id="hikashop_product_quantity_main" class="hikashop_product_quantity_main"> in the product view.
Thanks in advance
Last edit: 11 years 10 months ago by SG.
Please Log in or Create an account to join the conversation.
11 years 10 months ago #184785
by SG
Replied by SG on topic hide product quantity label when no stock
Hi,
I apologize, it seems that $this->element->main->product_quantity DOES work.
My problem was that during testing I tried the following:
With $this->element->main->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:
I did get a result for the product_quantity when it was from the product with variants.
So now I used the following test:
Is this the correct way of showing the Quantity Label?
Thanks
I apologize, it seems that $this->element->main->product_quantity DOES work.
My problem was that during testing I tried the following:
Code:
echo "prod quantity: $this->element->main->product_quantity";
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->element->main->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->element->main->product_quantity != 0 or $this->element->main->product_quantity == NULL) and ($this->row->product_quantity != 0)){
echo JText::_('PRODUCT_QUANTITY');
}
Is this the correct way of showing the Quantity Label?
Thanks
Please Log in or Create an account to join the conversation.
11 years 10 months ago #184791
by nicolas
Replied by nicolas on topic hide product quantity label when no stock
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.
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 or Create an account to join the conversation.
11 years 10 months ago #184846
by SG
Replied by SG on topic hide product quantity label when no stock
Thanks Nicolas for the tip.
Is the IF-structure correct? Or should I perform the test in a different way?
Cheers
Is the IF-structure correct? Or should I perform the test in a different way?
Code:
if (($this->element->main->product_quantity != 0 or $this->element->main->product_quantity == NULL) and ($this->row->product_quantity != 0)
Cheers
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
11 years 10 months ago #184853
by Mohamed Thelji
Replied by Mohamed Thelji on topic hide product quantity label when no stock
Hello,
Using something like this will probably be better :
Using something like this will probably be better :
Code:
if (($this->element->main->product_quantity != 0 || $this->element->main->product_quantity == NULL) && ($this->row->product_quantity != 0)){
}
Please Log in or Create an account to join the conversation.
4 years 5 months ago - 4 years 5 months ago #341472
by oxido
Replied by oxido on topic hide product quantity label when no stock
UPDATE FOR HIKASHOP v4.5.1
Display > Views > product / quantity
Around line 126 you will find this:
Add one more condition "&& $in_stock", like this:
Display > Views > product / quantity
Around line 126 you will find this:
Code:
if(($add_to_cart || $add_to_wishlist) && $display_quantity_field)
Code:
if(($add_to_cart || $add_to_wishlist) && $display_quantity_field && $in_stock)
Last edit: 4 years 5 months ago by oxido. Reason: code line correction
The following user(s) said Thank You: nicolas
Please Log in or Create an account to join the conversation.
Time to create page: 0.078 seconds