- Posts: 3
- Thank you received: 0
Add custom field per_unit to category view
I am trying to get a custom field of "per_unit" or "per_case" into the category view next to the price. I have the correct "per_unit" in the product view, but for the life of me I can't figure out how to get into the category view. So I was wondering if this is possible.
Thank you for the help!
Please Log in or Create an account to join the conversation.
If you do it as explained in the section "I sell packed products, how can I change "each" text in the product page ?" of the FAQ it will work on both :
www.hikashop.com/en/support/documentation/106-faq.html
Please Log in or Create an account to join the conversation.
thanks for the reply. I have already seen the FAQ's and changed the necessary information on the site, but for some reason the "per_unit" does not show up in the category view. I've attached two images to explain what I mean.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
The settings for the custom product field looks like this:
image missing http://www.imperialarrows.co.uk/salesunit.jpg
product/listing_price.php:
en_GB.com_hikashop.ini:
Please Log in or Create an account to join the conversation.
Is this safe?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
In that case, the code will have to be a bit more complex:
if(isset($this->element->main)) echo JText::_($this->element->main->salesunit);
else echo JText::_($this->element->salesunit);
That way it will work on both pages.
Please Log in or Create an account to join the conversation.
It didn't quite work as the units were not displayed on the ctegories page by I changed the code as follows and it did work:
if(isset($this->element->main)) echo JText::_($this->element->main->salesunit);
else echo JText::_($this->row->salesunit);
Trevor
Please Log in or Create an account to join the conversation.
Thank you for the help!
nicolas wrote: Can you also do a screenshot of the code modification you made and of your custom product field ?
Please Log in or Create an account to join the conversation.
I had the same problem but have now managed to get it working. Nicolas has now updated the FAQ . . .
In the menu Display -> Views, edit the product / listing_price.php file.
In this file, replace:
echo JText::_('PER_UNIT');
By:
if(isset($this->element->main)) echo JText::_($this->element->main->salemethod);
elseif(isset($this->row)) echo JText::_($this->row->salemethod);
else echo JText::_($this->element->salemethod);
Please Log in or Create an account to join the conversation.