wording after the price

  • Posts: 71
  • Thank you received: 0
  • Hikashop Business Hikashop Essential
1 year 3 months ago #348408

-- HikaShop version -- : 4.7.0
-- Joomla version -- : 3.10.11
-- PHP version -- : 8.0.27
-- Browser(s) name and version -- : Firefox

Hello, my customer has asked if it is possible to have a per product setting for the product unit. For example, some products might be $5 each and some might be $5 per set or $5 per quangle or whatever.

We're running Essential version so I guess we could add a custom back-end field but how would this appear on all parts of the transaction such product, cart, checkout etc. I might be missing something here but I can't seem to find the answer, sorry if it is obvious!

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
1 year 3 months ago #348409

Hi,

There is by default a "per unit" text after the price on the product page. You can indeed use a custom field of the table "product", combined with a view modification to do that. There is a section "I sell packed products, how can I change "each" text in the product page ?" on this FAQ which explains how to do it:
www.hikashop.com/support/documentation/106-faq.html#tran

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

  • Posts: 71
  • Thank you received: 0
  • Hikashop Business Hikashop Essential
1 year 3 months ago #348435

Thanks, almost there. If I set the field in each product, I can see either option which is great. However, if nothing is saved, the fallback is display nothing it seems. trying to read the PHP, it looks like the script doesn't work for me. I have added the following;

if(isset($this->element->main)) echo JText::_($this->element->main->pertype);
					elseif(isset($this->row)) echo JText::_($this->row->pertype);
					else echo JText::_($this->element->pertype); 
Where 'pertype' is my column name in the Custom Field. this works but only if I have set the field in each product. Do I need to run a Mass Action over the products? where 'pertype' is null?

This is a product unsaved - staging.bridgenz.co.nz/shop/home-bridge-...-luncheon-serviettes and this is a product with a defined 'pertype' - staging.bridgenz.co.nz/component/hikasho...ding-pads-gift-set-4

Nick

Last edit: 1 year 3 months ago by nicolas.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
1 year 3 months ago #348436

Hi,

This code indeed supposes that you selected something in the custom field for each product of the shop.
You can indeed use a mass action to set the value in each product with the custom field empty. That way, you won't have to set it manually for each product.

Otherwise, you could try changing that code to:

					if(!empty($this->element->main->pertype)) echo JText::_($this->element->main->pertype);
					elseif(!empty($this->row->pertype)) echo JText::_($this->row->pertype);
					elseif(!empty($this->element->pertype)) echo JText::_($this->element->pertype);
					else echo JText::_('PER_UNIT');

The following user(s) said Thank You: triotech

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

Time to create page: 0.059 seconds
Powered by Kunena Forum