Display "Price from"

  • Posts: 75
  • Thank you received: 1
6 years 8 months ago #275592

-- url of the page with the problem -- : animaloutfitters.nz
-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.4
-- PHP version -- : 7.1
-- Browser(s) name and version -- : Chrome

Hi. is it possible on the product page to display "Price(s) from" (rather than simply "Price") for products where there are multiple variants with different prices.

I don't want to prefix all prices in this way as some of my products have only a single variant where the price is always the same. So I guess I'm trying to understand if Hikashop applies a different class to products with multiple variants so I can apply a language override / separate css styling etc.

Can you please advise if this possible. Thanks

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
6 years 8 months ago #275602

Hi,

On the product page, the price displayed is the price of the current variant. So when you select the variant you want, you'll see the price update for the one of the selected variant.
It would be weird to have a "price from" text there even though it's the exact price the customer will pay when clicking on the add to cart button.
Now if you want to add that, you can edit the file "listing_price" of the view "product" via the menu Display>Views. But as you said, it won't be simple as if you just add your text at the top of the file, it will add it for all the products. So you will have to add some kind of condition for the display of your text based on your needs.

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

  • Posts: 75
  • Thank you received: 1
6 years 8 months ago #275652

Hi Nicolas. It's actually one level up from the product page - at the "hikashop_product_image" level. i.e. before you see the variants. This is because it can be misleading for a customer to click on a product at this level only to find the prices increase with size. This page is an example:
www.animaloutfitters.nz/outerwear/fleece-dog-robes

When you say: "So you will have to add some kind of condition for the display of your text based on your needs" is this easy to do or will it require PHP knowledge?

Thanks

Last edit: 6 years 8 months ago by mterry2.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
6 years 8 months ago #275671

Hi,

Then you're talking about the products listing page, not the product page.
That makes indeed more sense to add it there.
You'll still need to edit the file "listing_price" of the view "product" via the menu Display>Views for that.
The code should be quite simple but even simple code requires PHP knowledge.
If you want to add that text only for products with variants you can easily do it like that:

<?php if($this->row->has_options) echo 'Price from '; ?>
because that condition is already precalculated by HikaShop for other needs.
However, if you want to add that text only for products with more than one variant, then you'll have to run some MySQL query to count the variants of the current product. So it will require a developer to work on that for you. It's not complex for a developer but still it requires proper development.
You can potentially contact our partners for such customization job:
www.hikashop.com/home/our-partners.html

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

  • Posts: 37
  • Thank you received: 3
  • Hikaserial Standard Hikashop Business
6 years 5 months ago #282440

Hi,

Thank you for this very interesting solution.

If you want to add that text only for products with variants you can easily do it like that:

<?php if($this->row->has_options) echo 'Price from '; ?>
because that condition is already precalculated by HikaShop for other needs.


But if the variants have all the same price, the 'Price from' become useless.

For other needs, do you have another precalculated condition to indicate that the product is sold at multiple prices to replace your 'has_options'? It would be more efficient.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
6 years 5 months ago #282442

Hi,

There is no such precalculated data.
When you reach the listing views, the prices have already been calculated and there is no easy way to know from there if the price you're displaying comes from a main product or a variant and if there are other prices in other variants, etc.
That would require running MySQL queries.

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

  • Posts: 37
  • Thank you received: 3
  • Hikaserial Standard Hikashop Business
6 years 5 months ago #282502

Thank you Nicolas,

Too bad because when you only display the lowest price, the buyer may feel betrayed. Maybe we will find this feature in a future release! ;-)

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

  • Posts: 28
  • Thank you received: 3
  • Hikashop Business
2 years 5 months ago #337308

Hi Nicolas
Is there already an update/new feature for this problem? I also want to show "price from" on product listing page – but only, if there are different prices for the variants.

Thanks,
Alexandra

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
2 years 5 months ago #337310

Hi,

While there is no easy option for that, we did add some improvements in the code.
You now have the variable $this->row->all_prices which contains the list of all the prices loaded from the database before being filtered out.
So you don't need anymore to run a MySQL query to know whether the product has several prices or not.
You can directly add such code in the listing_price view file:

<?php
if(count($this->row->all_prices) > 1) {
 echo "price from ";
}
?>

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

  • Posts: 28
  • Thank you received: 3
  • Hikashop Business
2 years 5 months ago #337336

Thanks a lot, Nicolas, for very fast reply and solution – it works perfectly.
Alexandra

The following user(s) said Thank You: Philip

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

  • Posts: 28
  • Thank you received: 3
  • Hikashop Business
2 months 3 weeks ago #358748

Hi Nicolas
It seems as this way to display "Price from" in the Product listing for products with variants (with different prices) no longer works (Hikashop Business 5.0.3). Is there another way to do this?

Thanks, Alexandra

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
2 months 3 weeks ago #358751

Hi,

It should still work the same. I don't see why it wouldn't anymore.
Why do you think it doesn't work anymore ?

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

  • Posts: 28
  • Thank you received: 3
  • Hikashop Business
2 months 2 weeks ago #358886

Sorry, I just realised, that I put the code into the wrong view file – in the correct one, it's still working.

Alexandra

The following user(s) said Thank You: nicolas

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

  • Posts: 28
  • Thank you received: 3
  • Hikashop Business
2 months 1 week ago #359035

There is a problem with this solution, I just found out: Text "price from" is displayed correctly, but when clicking on the product, the product detail page is not loading, but the following error:
Count(): Argument #1 (Value) must be of type countable/array, null given

What am I doing wrong? It's with Helix Ultimate Template.

Alexandra

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
2 months 1 week ago #359037

Hi,

It might indicate that some variants of your product don't have any price.
What you can do is to adapt the code like this:

<?php
if(!empty($this->row->all_prices) && count($this->row->all_prices) > 1) {
 echo "price from ";
}
?>

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

  • Posts: 28
  • Thank you received: 3
  • Hikashop Business
2 months 1 week ago #359054

That did the trick, thanks a lot.
Alexandra

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

Time to create page: 0.096 seconds
Powered by Kunena Forum