Information of the products

  • Posts: 12
  • Thank you received: 1
2 weeks 1 day ago #372721

-- HikaShop version -- : ‎5.4.7
-- Joomla version -- : 6.3.0

Hi,

Webshop: prnt.sc/Z1nhfxYexISM
Shopping cart: prnt.sc/DG-NYgydkO4C
Hikashop: prnt.sc/3Lq8_KULuqb_

The accompanying product texts containing product information are not displayed in the shopping cart or in Hikashop. I would like to see all the information so that we can make the correct product. How can I enable this?

See the difference in the photos above.

Thank you in advance!

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

  • Posts: 85989
  • Thank you received: 14163
  • MODERATOR
2 weeks 11 hours ago #372726

Hi,

The lines you are missing are "Custom text" item fields. Unlike the other custom item fields, they are display only: they hold no value that the customer enters, so HikaShop does not store them on the cart line or on the order. That is also why, for a Custom text field, the "Display" section of the field edit page only offers three targets: "Front-end Product Listing", "Front-end order details page" and "Invoice". The cart and the back-end order page are deliberately not in that list.

So you have two ways to get that information where you need it.

1) Without any code (recommended for order handling)

Edit each Custom text field (menu Display > Custom fields) and turn on:
- "Front-end order details page", so the text shows on the order the customer sees,
- "Invoice", so the text shows on the invoice you print to produce the item.

For most workshops the invoice already contains everything needed to "make the correct product", so this is often enough.

2) With a view override, to also show the text inside the cart and on other pages

To know which view file draws a given area, go to System > Configuration > Advanced and set "Display view files" to "With extra parameter in the URL". Then add tp=1 to the URL of the page you are looking at (the cart, the order, etc.) and HikaShop will print the name of each view file right where it is used. That tells you exactly which entry to edit under Display > Views, where you can override any view file safely (your changes are kept when you update HikaShop).

For the cart, the view is "checkout / show_block_cart". Replace the existing item fields loop (the block using $this->extraFields) with this one:

if(hikashop_level(2)) {
	$item = $cart->cart_products[$i];
	$fClass = !empty($this->fieldClass) ? $this->fieldClass : hikashop_get('class.field');

	// Start from the item fields already flagged for the checkout, add the display-only
	// "custom text" ones, then reorder everything by field ordering so the texts stay
	// interleaved with the other fields, exactly like on the product page.
	$itemFields = !empty($this->extraFields['item']) ? $this->extraFields['item'] : array();
	foreach($fClass->getFields('all', $product, 'item') as $namekey => $f) {
		if($f->field_type == 'customtext')
			$itemFields[$namekey] = $f;
	}
	uasort($itemFields, function($a, $b){ return ((int)@$a->field_ordering) - ((int)@$b->field_ordering); });

	foreach($itemFields as $field) {
		$namekey = $field->field_namekey;
		if($field->field_type == 'customtext') {
			$label = $fClass->getFieldName($field);
			$html .= '<p class="hikashop_cart_item_'.$namekey.'">'.($label !== '' ? $label.': ' : '').$fClass->show($field, '').'</p>';
			continue;
		}
		if(empty($item->$namekey) || !strlen($item->$namekey))
			continue;
		$field->currentElement = $item;
		$edit = true;
		$html .= '<p class="hikashop_cart_item_'.$namekey.'">'.$fClass->getFieldName($field).': '.$fClass->show($field, $item->$namekey).'</p>';
	}
}

The same idea works on the other views that list the item fields (for instance "order / edit_products" for the back-end order page): start from the fields the view already loads, add the "custom text" ones, and sort the whole list by field_ordering before printing. Keep in mind this text is the same for every order of that product, so if it is only meant as a reference for your own production, option 1 with the invoice is usually the cleaner choice.

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

  • Posts: 12
  • Thank you received: 1
2 weeks 7 minutes ago #372749

Hi Nicolas,

Thank you for responding.

prnt.sc/qwsff7QJdN1g

As you can see in the printscreen, I already turned on everything possible in the custom fields.
What am I doing wrong?

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

  • Posts: 85989
  • Thank you received: 14163
  • MODERATOR
1 week 6 days ago #372754

Hi,

What do you mean ? You're not doing anything wrong.
As I said in my previous message, "custom text" custom fields don't display on the cart / checkout and thus there is no display setting for these. As I said, you would need custom code to add their display there.

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

  • Posts: 12
  • Thank you received: 1
1 week 6 days ago #372770

I did something wrong and now all custom fields are gone, so I'll try to get the back up running now first :)

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

Time to create page: 0.061 seconds
Powered by Kunena Forum