Display characteristics name and value in list form in checkout

  • Posts: 13
  • Thank you received: 0
7 years 7 months ago #268197

Greetings, Currently I'm in the process of building an online store and my client wants that in the checkout table, the name and the value of the characteristics/variants appears as a list and not in the title.

Currently, the variants appear like this:
PRODUCT 01: GREEN XL Men

And what the client wants is something like this:
PRODUCT 01

  • Color: Green
  • Size: XL
  • Style: Men

While I was searching through this forum I found this topic with a similar question:
https://www.hikashop.com/forum/4-how-to/53060-display-characteristics-name-in-checkout.html

I tried to use the code that thewebtailors suggest at the end of the topic but it didn't work.

Can you help me out?

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

  • Posts: 4748
  • Thank you received: 644
  • MODERATOR
7 years 7 months ago #268204

Hello,

I have a look on the forum link you use, and from my point of view everything is here and well explain, so why do you means by it didn't work ?
Can you precise your idea with more elements like screenshot or other way to explain what you get with the modification.

Awaiting news from you.

Regards

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

  • Posts: 13
  • Thank you received: 0
7 years 7 months ago #268281

Hello Phillip,

I'm adding a screenshot of what I'm trying to do. Basically each product in the cart table of the checkout page has to show details of the characteristics/variants chosen by the user in a list format or something similar.



i tried to use the following code suggested by thewebtailors in the checkout / show_block_cart.php view
<?php foreach($row->characteristics as $characteristic){
echo "<br /><span class='characteristic'>".$this->orderInfos->products[$i-1]->characteristics[$characteristic->characteristic_parent_id]->characteristic_value.": ".$characteristic->characteristic_value."</span>";
} ?>

But after reloading the page the following message appears:



However if I change this line:
foreach($row->characteristics as $characteristic)

to
foreach($product->characteristics as $characteristic)

The values of the characteristic appears but not their name, instead I get this message.



This message repeats itself depending of the number of variants of a product. So the full page looks like this:

Attachments:

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
7 years 6 months ago #268324

Hi,

This code was for the old checkout system 4 years ago.
It's normal that it doesn't work with the new one in show_block_cart.
The characteristic name is actually not loaded in that view.
You would have to load it from the database like that:

$class = hikashop_get('class.characteristic');
$char = $class->get($characteristic->characteristic_parent_id);
echo $char->characteristic_value;

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

  • Posts: 13
  • Thank you received: 0
7 years 6 months ago #268355

Thanks Nicolas, it works with no problems. This how the code looks now in case someone needs it.

<?php foreach($product->characteristics as $characteristic){
	$class = hikashop_get('class.characteristic');
	$char = $class->get($characteristic->characteristic_parent_id);
	echo '<p class="caracteristica-producto">' . '<span class="nombre-caracteristicas">' . $char->characteristic_value . ': </span><span class="valor-caracteristicas">' .  $characteristic->characteristic_value . "</span></p><br/>";
} ?>

But I have another question, can I use this code in other views like the order page(frontend and backend), invoices and email messages?

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
7 years 6 months ago #268374

Hi,

Thanks for sharing.
No. It will require a different code.
In the show_block_cart view, you're dealing with a cart. But in the other pages you're talking about, you're dealing with an order. So the data in it is different and the code will have to be adapted.

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

  • Posts: 13
  • Thank you received: 0
7 years 6 months ago #268477

Thanks Nicolas, I made a little change in the previous code for the invoice, order and email views and now every table shows the characteristics.

foreach($item->order_product_options as $characteristic){
			$class = hikashop_get('class.characteristic');
			$char = $class->get($characteristic->characteristic_parent_id);
			$t .= '<p>' . $char->characteristic_value . ': ' .  $characteristic->characteristic_value . "</p>";
		}

I have another question. How can I remove the contents inside "hikashop_product_variant_subname"?

Attachments:

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
7 years 6 months ago #268517

Hi,

What I usually recommend is to leave it there and just add some CSS to the page with a display:none on that class name so that the span is not displayed.

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

  • Posts: 13
  • Thank you received: 0
7 years 6 months ago #268790

The problem I'm having is with the emails. I can't figure it out how to hide this information.

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

  • Posts: 4748
  • Thank you received: 644
  • MODERATOR
7 years 6 months ago #268798

Hello,

In order to add some Css in your Email you can process like this, follow me step by step :
1°) Go to Components => HikaShop => Configuration, then in System dropdown select Emails to see Emails type listing.
Then select your required Emails to edit it.

2°) If I follow you, you want remove this element :

<span class="hikashop_product_variant_subname">
   ...
</span>
So, click on the little pen icon close to Email template :



You will see a popup window that display your email Css, you have just to add this kind of Css code :
Span_class_name {
   display: none;
}

Hope this will help you.

Regards

Attachments:
Last edit: 7 years 6 months ago by Philip.

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

Time to create page: 0.102 seconds
Powered by Kunena Forum