Change 'each' in product listing, but not in product detail

  • Posts: 42
  • Thank you received: 0
7 years 10 months ago #273832

-- HikaShop version -- : 3.1.1.
-- Joomla version -- : 3.7.3
-- PHP version -- : 7.1.1
-- Browser(s) name and version -- : Firefox Chrome Safari
-- Error-message(debug-mod must be tuned on) -- : no error message

Hi,
I hope you can help me with this.
I have made products with custom fields that calculate the price (we sell per m2). By the way I used Moonsoft Calc Builder which integrates really well with Hikashop.
Now on the product listing the products have a price label xx € each, but this should be xx € per m2.
On the product details page where I calculate the price per product, it should remain as is, meaning xx € each.
How can I accomplish this?
Thanks!

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

  • Posts: 26233
  • Thank you received: 4036
  • MODERATOR
7 years 10 months ago #273850

Hello,

If it will always be "per m2" instead of "each", you can just change the translation.
www.hikashop.com/download/languages.html

But if it's more complicated than that, it will require a view override for the "listing_price" view to change the used translation depending a context.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 42
  • Thank you received: 0
7 years 10 months ago #273882

Thanks for your quick reply!
It is indeed more complex and I have tried to to an override, but can not manage.
The listing_price view is used both in the product listing as well as in the product detail.
I do not know which overrides to make such that there is a difference between the listings (where all products are displayed) and the detail page (for only one product).
Hope you can help or point to the documentation where I can find this.
(have read about overrides, but this does not seem to cover this exact issue since one view is used for both situation, if I have understood correctly ?).
Thanks!

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

  • Posts: 4820
  • Thank you received: 654
  • MODERATOR
7 years 10 months ago #273885

Hello,

In order to better help you, can you precise your idea :
- Do you have 1 listing with only product that required xx € per m2 or there is too some classic product that required "each" ?

Awaiting news from you.

Regards

Last edit: 7 years 10 months ago by Philip.

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

  • Posts: 42
  • Thank you received: 0
7 years 10 months ago #273958

Thanks for your interest!
All the products I have are sold per m2.
This means in product listing it would be nice to have 'per m2'.
On the product page I do some calculations and the results are displayed in the product price, so here it should be called 'each' because now it is valid per product as configured.
Hope this can be done without too many problems.
Thanks!

By the way, maybe I have a similar question about the layout. I made the price field bigger in the css file (on hikashop backend where you made this possible, which I believe is an excellent idea!) ut now it is also big in the cart and checkout, where it should be small. I did not see how I should change the size of the price numbers only on the listing and product pages?

Thanks a lot!!

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

  • Posts: 83799
  • Thank you received: 13571
  • MODERATOR
7 years 10 months ago #273967

In the listing_price view file, you can replace the line:

echo '<span class="hikashop_product_price_per_unit">'.JText::_('PER_UNIT').'</span>';
by:
if(!empty($this->element->product_id)) echo '<span class="hikashop_product_price_per_unit">'.JText::_('PER_UNIT').'</span>';
else echo '<span class="hikashop_product_price_per_unit">per m2</span>';
and that will do it.

It's really easy to do it only on some pages ; just prefix your CSS with a class or id only used on the page where you want to apply your change.
For example, to change the color of the prices only on the checkout, you can add such CSS:
.hikashop_checkout_page .hikashop_product_price_full{
color: green !important;
}

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

  • Posts: 42
  • Thank you received: 0
7 years 10 months ago #274116

Thanks a lot!!
This is working perfectly.
Thanks also for the other tip. I had seen this in the documentation, but somehow did not connect it to what I needed to do.
Thanks!

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

Time to create page: 0.046 seconds
Powered by Kunena Forum