- Posts: 75
- Thank you received: 1
Display "Price from"
-- 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.
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.
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
Please Log in or Create an account to join the conversation.
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:
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
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:
because that condition is already precalculated by HikaShop for other needs.Code:<?php if($this->row->has_options) echo 'Price from '; ?>
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.
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
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.
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.
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:
Please Log in or Create an account to join the conversation.
Alexandra
Please Log in or Create an account to join the conversation.
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.
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.
Alexandra
Please Log in or Create an account to join the conversation.
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.
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:
Please Log in or Create an account to join the conversation.
Alexandra
Please Log in or Create an account to join the conversation.