How Get correct Custom Field value on Variants ecosystem

  • Posts: 138
  • Thank you received: 4
8 months 3 weeks ago #360034

-- HikaShop version -- : 5.0.3
-- Joomla version -- : 5
-- PHP version -- : 8.2

Hello,
I try customize template for my client.
i need get correct value of CF when change characteristics on Product page.
I try get value by this:

$this->element->shipping_time;
but alwayes return main product value.


Joomla Developer | am.ebrahimzadeh[at]gmail.com

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

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
8 months 3 weeks ago #360035

Hi,

That's not that simple to do.
You'll have to do 3 things:
1. In the product / show.php view file, you need to add the display for each variant:

	<div id="hikashop_product_shipping_<?php echo $variant_name; ?>" style="display:none;"><?php
		echo $variant->shipping_time;
	?></div>
2. In your product layout (probably product / show_default.php ), you want to add the main display:
	<div id="hikashop_product_shipping_main"><?php
		echo $this->element->shipping_time;
	?></div>
3. In the product / show_block_characteristic.php you want to change the line:
var names = ['id','name','code','image','price','quantity','description','weight','url','width','length','height','contact','custom_info','files'];
in order to add your new div name, like this:
var names = ['id','name','code','image','price','quantity','description','weight','url','width','length','height','contact','custom_info','files','shipping'];
This will allow the javascript system of the characteristics to copy the HTML in the div of the currently selected variant, to the main div.

The following user(s) said Thank You: aminweb

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

  • Posts: 138
  • Thank you received: 4
8 months 3 weeks ago #360045

wow! amazing, thank you Nicolas


Joomla Developer | am.ebrahimzadeh[at]gmail.com
The following user(s) said Thank You: Philip

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

Time to create page: 0.058 seconds
Powered by Kunena Forum