Auto hide weight, width, height and length

  • Impression eStudio
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
3 years 5 months ago - 3 years 5 months ago #139054 by Impression eStudio
Auto hide weight, width, height and length was created by Impression eStudio
Hi,

I think it would be nice to have the product info weight, width, height and length to be automatically hidden when there is no value (zero value) to them.
They should work the same as for example the manufacturer.

There are some products that have known values for weight, width, height and length but there are others that don't have.
So there is no need to show something like: Dimensions 0.00cm x 0.00cm x 0.00cm

For example, for the EShop version 3.3.1 in the file "components/com_eshop/themes/default/views/product/default.php"
the code that controls if the weight should be displayed could be changed from:
Code:
if (EshopHelper::getConfigValue('show_product_weight'))
to
Code:
if (EshopHelper::getConfigValue('show_product_weight') && $this->item->product_weight>0)
or
Code:
if (EshopHelper::getConfigValue('show_product_weight') && !empty($this->item->product_weight) && $this->item->product_weight>0)

Also the code for the dimensions can change from:
Code:
if (EshopHelper::getConfigValue('show_product_dimensions'))
to:
Code:
if (EshopHelper::getConfigValue('show_product_dimensions') && ((!empty($this->item->product_length) && $this->item->product_length>0) || (!empty($this->item->product_width) && $this->item->product_width>0) || (!empty($this->item->product_height) && $this->item->product_height>0)))

and the code:
Code:
<?php echo number_format($eshopLength->convert($this->item->product_length, $productLengthId, $lengthId), 2).EshopHelper::getLengthUnit($lengthId, JFactory::getLanguage()->getTag()) . ' x ' . number_format($eshopLength->convert($this->item->product_width, $productLengthId, $lengthId), 2).EshopHelper::getLengthUnit($lengthId, JFactory::getLanguage()->getTag()) . ' x ' . number_format($eshopLength->convert($this->item->product_height, $productLengthId, $lengthId), 2).EshopHelper::getLengthUnit($lengthId, JFactory::getLanguage()->getTag()); ?>
to:
Code:
<?php if (!empty($this->item->product_length) && $this->item->product_length>0) { echo number_format($eshopLength->convert($this->item->product_length, $productLengthId, $lengthId), 2).EshopHelper::getLengthUnit($lengthId, JFactory::getLanguage()->getTag()); } if (!empty($this->item->product_length) && $this->item->product_length>0 && !empty($this->item->product_width) && $this->item->product_width>0) { echo ' x '; } if (!empty($this->item->product_width) && $this->item->product_width>0) { echo number_format($eshopLength->convert($this->item->product_width, $productLengthId, $lengthId), 2).EshopHelper::getLengthUnit($lengthId, JFactory::getLanguage()->getTag()); } if ((!empty($this->item->product_length) && $this->item->product_length>0) || (!empty($this->item->product_width) && $this->item->product_width>0 && !empty($this->item->product_height) && $this->item->product_height>0)) { echo ' x '; } if (!empty($this->item->product_height) && $this->item->product_height>0) { echo number_format($eshopLength->convert($this->item->product_height, $productLengthId, $lengthId), 2).EshopHelper::getLengthUnit($lengthId, JFactory::getLanguage()->getTag()); } ?>

Thanks
Last edit: 3 years 5 months ago by Impression eStudio. Reason: Add an example for the code chnage

Please Log in or Create an account to join the conversation.

  • Giang Dinh Truong
  • Offline
  • Administrator
  • Administrator
More
3 years 1 month ago #142255 by Giang Dinh Truong
Replied by Giang Dinh Truong on topic Auto hide weight, width, height and length
Thank you!

This was already implemented in the latest version 3.3.2 of EShop.

Sincerely, Giang

Please Log in or Create an account to join the conversation.

Moderators: Giang Dinh Truong