Hide empty specifications

  • Posts: 154
  • Thank you received: 10
10 years 9 months ago #164801

Hi there!

I'm having trouble with a webshop:
The product view shows specifications such as condition, shipping cost etcetera.
The fields that I leave blank also appear in the product view.

Another webshop i created (my own) doesnt show these fields when left blank.

The only difference is that the other shop is on joomla 2.5.X and this one is on joomla 3

Anyone know where to edit this?


Proud of my website www.hetcomputerwinkeltje.nl

Currently just running catalog mode, but hope to go live soon again :)
Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
10 years 9 months ago #164803

Hi,

Thanks to check if your view "product / show_block_custom_main" has not been edited.
There is indeed a code in that view which check if the value is empty or not, if empty, we skip the display.

	$value = '';
	if(empty($this->element->$fieldName) && !empty($this->element->main->$fieldName))$this->element->$fieldName = $this->element->main->$fieldName;
	if(isset($this->element->$fieldName))
		$value = trim($this->element->$fieldName);

	if (!empty ($value) || $value == 0) {
...

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

  • Posts: 154
  • Thank you received: 10
10 years 9 months ago #164901

Hello Xavier, Thanx for your answer, this is what the file looks like:

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.3.2
 * @author	hikashop.com
 * @copyright	(C) 2010-2014 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
$this->fieldsClass->prefix = '';
$displayTitle = false;
ob_start();
foreach ($this->fields as $fieldName => $oneExtraField) {
	$value = '';
	if(empty($this->element->$fieldName) && !empty($this->element->main->$fieldName))$this->element->$fieldName = $this->element->main->$fieldName;
	if(isset($this->element->$fieldName))
		$value = trim($this->element->$fieldName);

	if (!empty ($value) || $value == 0) {
		$displayTitle = true;
	?>
		<tr class="hikashop_product_custom_<?php echo $oneExtraField->field_namekey;?>_line">
			<td class="key">
				<span id="hikashop_product_custom_name_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_name">
					<?php echo $this->fieldsClass->getFieldName($oneExtraField);?>
				</span>
			</td>
			<td>
				<span id="hikashop_product_custom_value_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_value">
					<?php echo $this->fieldsClass->show($oneExtraField,$value); ?>
				</span>
			</td>
		</tr>
	<?php
	}
}
$specifFields = ob_get_clean();
if($displayTitle){
?>

<div id="hikashop_product_custom_info_main" class="hikashop_product_custom_info_main">
	<h4><?php echo JText::_('SPECIFICATIONS');?></h4>
	<table width="100%">
		<?php echo $specifFields; ?>
	</table>
</div>
<?php }

I'm no programmer but I think the code is there? It still shows empty fields :(


Proud of my website www.hetcomputerwinkeltje.nl

Currently just running catalog mode, but hope to go live soon again :)

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

  • Posts: 13201
  • Thank you received: 2322
10 years 9 months ago #164940

Hi,

Are you sure that you don't have spaces, or anything else in the field ?
Is it really empty ?

Are these fields custom fields you created, or default fields or the product edition page ?

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

  • Posts: 18
  • Thank you received: 0
10 years 9 months ago #165551

Hey,

Same problem here. All empty custom fields appeared in the front end after updating to 2.3.2
"product / show_block_custom_main" looks fine and all fields are indeed empty (no spaces etc.)

Please advise! Thank you

Last edit: 10 years 9 months ago by Superpsychics.

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

  • Posts: 83746
  • Thank you received: 13549
  • MODERATOR
10 years 9 months ago #165582

You can see the check :
if (!empty ($value) || $value == 0) {
which makes sure that product fields only display if something was entered in them.
So I don't see how that's possible that the custom field displays without value in them.
I've checked on our end and could not reproduce the problem.
So either you have something in the fields (a space, or some other kind of blank character) or you have modified the code in some way and you're not looking at the view file for the correct template.

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

  • Posts: 18
  • Thank you received: 0
10 years 9 months ago #165662

Hey again,

I just did a quick check in my backup before updating to 2.3.2 and the php code in "show_block_custom_main" was

if (!empty ($value)) {

I changed it to that instead of the: if (!empty ($value) || $value == 0) { you suggested which was already in the view file "show_block_custom_main" after the update, and it now works.

The " || $value == 0) " part of your suggestion seems to be wrong.

Thank you for your prompt reply regardless.

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

  • Posts: 96
  • Thank you received: 4
  • Hikashop Business
10 years 8 months ago #168503

business_v2.3.2_2014-08-11_18-22-19 - Joomla 3.3.0

I also had the same issue, where a custom product field was specified, that the heading Specifications and the extra field title were showing, even when the value field was empty. The suggested change to products/show/block_custom_main.php solved that problem for me also.

The Specifications Div now only displays when the extra field is populated.

Thank you to Superpsychics

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

  • Posts: 26232
  • Thank you received: 4035
  • MODERATOR
10 years 8 months ago #168507

Hi,

Thanks for your feedback.
We are investigating on that problem in order to fix it in the next release.
The most difficult part will be to reproduce your problem ; so having details about your configuration could help us to reproduce it and be sure of the fix.
The other possibility is to let you test a potential fix.
Can you please test with the code

if(!empty($value) || $value === '0') {
and tell us if the result is good for you ?

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 10 years 8 months ago by Jerome.
The following user(s) said Thank You: anypc, krir

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

  • Posts: 96
  • Thank you received: 4
  • Hikashop Business
10 years 8 months ago #168636

Hi Jerome,

I tested with " if(!empty($value) || $value === '0') { " - that code works fine and the Specifications Header and fields are not visible when there is no content in the extra field. If the extra field is populated with a value of '0' or any other value, then the Div with header 'Specifications' and the field Title are visible with the input value also showing.

Should you wish to replicate for testing - I added a single custom product field 'Pallet Quantity' set to show on both frontend and backend - it is not set as a required field as it only applies to a small number of products.

Best Regards

Chris

The following user(s) said Thank You: Jerome

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

  • Posts: 154
  • Thank you received: 10
10 years 8 months ago #169822

Thank you Jerome!

Replacing

if (!empty ($value) || $value == 0) {
with
if(!empty($value) || $value === '0') {
Did the trick!

It now ignores empty fields!


Proud of my website www.hetcomputerwinkeltje.nl

Currently just running catalog mode, but hope to go live soon again :)

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

  • Posts: 43
  • Thank you received: 3
9 years 11 months ago #203394

Besides the custom values within the product page, there is also the compare page, which shows these custom values.
For some reason, I guess it must be in views -> compare.php, the empty values(their titles, as the values are empty!) are shown.

Is there something we could add in order not to show them as well in the compare page?

Thank you

Last edit: 9 years 11 months ago by uteco. Reason: Thnak -> Thank

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

  • Posts: 83746
  • Thank you received: 13549
  • MODERATOR
9 years 11 months ago #203402

Hi,

You could add the code:

$display = false;
			foreach($this->elements as $element) {
				if(!empty($element->$fieldName) || $element->$fieldName === '0') {
					$display = true;
				}
			}
			if(!$display) continue;
after the code:
if($oneExtraField->field_type != "customtext") {
in the file "compare" via the menu Display>Views.

The following user(s) said Thank You: uteco

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

  • Posts: 43
  • Thank you received: 3
9 years 11 months ago #203522

the solution worked perfectly. thank you very much.

I think this option could be implemented in future releases, tough i know this thread is not the whishing section!

However, I am very happy as it solves allot of problems in my case.
Michael

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

Time to create page: 0.170 seconds
Powered by Kunena Forum