Artikelnummer wird bei der Auswahl der Varianten nicht mit angezeigt

  • Posts: 18
  • Thank you received: 0
  • Hikashop Business
3 years 9 months ago #333498

-- HikaShop version -- : 4.4.2
-- Joomla version -- : 3.9.27
-- PHP version -- : 8.0

Hallo.
Ich habe unter Anzeige/Ansichten/product/show_block_custom_main folgende Befehle stehen:

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.6.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2016 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%">
	<tr class="hikashop_product_custom_<?php echo $oneExtraField->field_namekey;?>_line">
			<td class="key">
				<span>
					<?php echo "Artikelnummer";?>
				</span>
			</td>
			<td>
				<span id="hikashop_product_custom_value_<?php echo $oneExtraField->field_id;?>" class="hikashop_product_custom_value">
					<?php echo $this->element->product_code; ?>
				</span>
			</td>
		</tr>
		<?php echo $specifFields; ?>
	</table>
</div>
<?php }
Dadurch wird wenn ich auf das Produkt gehe, Versandzeit und Artikelnummer angezeigt.


Sobald ich mir aber ein anderes Gewicht des Produktes auswähle (also eine andere Produktvariante), verschwindet die Artikelnummer und es wird nur noch die Versandzeit angezeigt.


Allerdings soll bei der anderen Produktvariante auch die Artikelnummer angezeigt werden, und zwar diese welche zur Variante dazugehört.
Was muss ich bei der Datei noch eingeben, dass die Artikelnummer immer mit angezeigt wird? Was muss ich anders machen? Was habe ich falsch gemacht?

Vielen Dank für Eure schnelle Hilfe.
Liebe Grüße

Attachments:
Last edit: 3 years 9 months ago by nicolas.

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

  • Posts: 83403
  • Thank you received: 13497
  • MODERATOR
3 years 9 months ago #333507

Hi,

In the file product / show.php you have this block of code:

if(!empty($this->fields)) {
?>
	<div id="hikashop_product_custom_info_<?php echo $variant_name; ?>" style="display:none;">
<?php
			if($this->productlayout != 'show_tabular') {
?>
		<h4><?php echo JText::_('SPECIFICATIONS');?></h4>
<?php
			}
?>
		<table class="hikashop_product_custom_info_<?php echo $variant_name; ?>">
<?php

			$this->fieldsClass->prefix = '';
			foreach($this->fields as $fieldName => $oneExtraField) {
				if(empty($variant->$fieldName) && !empty($this->element->main->$fieldName)) {
					$variant->$fieldName = $this->element->main->$fieldName;
				}
				if(!empty($variant->$fieldName))
					$variant->$fieldName = trim($variant->$fieldName);

				if(!empty($variant->$fieldName) || (isset($variant->$fieldName) && $variant->$fieldName === '0')) {
?>
			<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; ?>_<?php echo $variant_name; ?>" 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; ?>_<?php echo $variant_name; ?>" class="hikashop_product_custom_value"><?php echo $this->fieldsClass->show($oneExtraField,$variant->$fieldName); ?></span>
				</td>
			</tr>
<?php
				}
			}
?>
		</table>
	</div>
<?php
		}
This display the custom product field area's HTML for each variant of the product. That way, you can configure different values in the custom product fields for each variant of the product, and the HTML from product / show.php for the currently selected variant would then replace the HTML of the default variant.
So either you want to apply your changes to that piece of code in product / show.php or, more easily, you can just delete that piece of code so that only the main variant HTML would be on the page. In that last case, no replacing would occur and thus your changes would always be used.

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

  • Posts: 18
  • Thank you received: 0
  • Hikashop Business
3 years 9 months ago #333536

Hallo.
Und wie muss ich es konfigurieren, damit die Artikelnummer auch bei allen Varianten immer mit angezeigt wird?
Ich habe das Codeschnipsel jetzt direkt in der product / show.php gelöscht. Allerdings wird die Artikelnummer in den Varianten in meiner gewünschten Tabellendarstellung noch nicht mit angezeigt.
Könnten Sie mir es eventuell mit php gleich so programmieren das es funktioniert?

Vielen Dank für Ihre Hilfe.
Liebe Grüße
Kristina

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

  • Posts: 83403
  • Thank you received: 13497
  • MODERATOR
3 years 9 months ago #333538

Hi,

It will work like you want if you delete the code I told you about.
To check that the modification is taken into account, you can see in the block of code I gave this line:

<div id="hikashop_product_custom_info_<?php echo $variant_name; ?>" style="display:none;">
And if I check the HTML of the product page, I can see that this div is still there:
i.imgur.com/tX1J4U7.png
So I can conclude that either you deleted it for another template than the one you're using, or you have some caching on your pages preventing you from seeing the change or you didn't delete the code.

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

  • Posts: 18
  • Thank you received: 0
  • Hikashop Business
3 years 9 months ago #333545

Vielen Dank.
Jetzt hat es funktioniert.

Ich habe es einfach nochmal gelöscht.
Liebe Grüße

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

Time to create page: 0.075 seconds
Powered by Kunena Forum