[Skip to main content](#vessel-content)

#   "Unit price only" doesn't show default variant

##

- **[ydingilski](/forum/user/37980-ydingilski "View ydingilski's Profile")**
- [![ydingilski's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar37980.png)](/forum/user/37980-ydingilski "View ydingilski's Profile") Topic Author
- [ Offline](/forum/user/37980-ydingilski)

Less More

- Posts: 52
- Thank you received: 0
-
-
-
- [](http://www.filkab.solar)
-

11 years 1 week ago [\#219310](#219310) by [ydingilski](/forum/user/37980-ydingilski "View ydingilski's Profile")  *["Unit price only" doesn't show default variant](/forum/26-product-category-display/880229-unit-price-only-doesnt-show-default-variant#219310 "-- url of the page with the problem -- :   www.filkab.solar  -- HikaShop version -- : 2.6.0  Hi, I have set Price display method to &quot;Unit price only&quot;. It works fine when I have different price for quantities without variants. When I have variants it doesn't show the default variant price but the cheapest one (or the price of the first variant, I'm not quite sure which). Is it supposed to be like this and how can I change it to show the price of the default variant.  P.S. It get's a little confusing for a customer seeing one price on the products listing and after that different price on the product page. It should be the same price before choosing another variant. At the same time the default variant is chosen based on different and sometimes complicated criteria so we cannot keep it the cheapest one or the first one in the list.")* was created by *[ydingilski](/forum/user/37980-ydingilski "View ydingilski's Profile")*

-- url of the page with the problem -- : [ www.filkab.solar](http://www.filkab.solar)
-- HikaShop version -- : 2.6.0

Hi,
I have set Price display method to "Unit price only". It works fine when I have different price for quantities without variants.
When I have variants it doesn't show the default variant price but the cheapest one (or the price of the first variant, I'm not quite sure which). Is it supposed to be like this and how can I change it to show the price of the default variant.

P.S. It get's a little confusing for a customer seeing one price on the products listing and after that different price on the product page. It should be the same price before choosing another variant. At the same time the default variant is chosen based on different and sometimes complicated criteria so we cannot keep it the cheapest one or the first one in the list.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODAyMjktdW5pdC1wcmljZS1vbmx5LWRvZXNudC1zaG93LWRlZmF1bHQtdmFyaWFudD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[goldian](/forum/user/39378-goldian "View goldian's Profile")**
- [![goldian's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/39378-goldian "View goldian's Profile")
- [ Offline](/forum/user/39378-goldian)

Less More

- Posts: 5
- Thank you received: 0
-
-

11 years 1 week ago [\#219388](#219388) by [goldian](/forum/user/39378-goldian "View goldian's Profile")  Replied by *[goldian](/forum/user/39378-goldian "View goldian's Profile")* on topic *["Unit price only" doesn't show default variant](/forum/26-product-category-display/880229-unit-price-only-doesnt-show-default-variant#219388 "-- url of the page with the problem -- :   www.filkab.solar  -- HikaShop version -- : 2.6.0  Hi, I have set Price display method to &quot;Unit price only&quot;. It works fine when I have different price for quantities without variants. When I have variants it doesn't show the default variant price but the cheapest one (or the price of the first variant, I'm not quite sure which). Is it supposed to be like this and how can I change it to show the price of the default variant.  P.S. It get's a little confusing for a customer seeing one price on the products listing and after that different price on the product page. It should be the same price before choosing another variant. At the same time the default variant is chosen based on different and sometimes complicated criteria so we cannot keep it the cheapest one or the first one in the list.")*

I am having the same problem exactly too and would like to know the solution as well ![:)](/media/kunena/emoticons/3.png ":)")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODAyMjktdW5pdC1wcmljZS1vbmx5LWRvZXNudC1zaG93LWRlZmF1bHQtdmFyaWFudD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86556
- Thank you received: 14305
-
-

11 years 1 week ago [\#219412](#219412) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *["Unit price only" doesn't show default variant](/forum/26-product-category-display/880229-unit-price-only-doesnt-show-default-variant#219412 "-- url of the page with the problem -- :   www.filkab.solar  -- HikaShop version -- : 2.6.0  Hi, I have set Price display method to &quot;Unit price only&quot;. It works fine when I have different price for quantities without variants. When I have variants it doesn't show the default variant price but the cheapest one (or the price of the first variant, I'm not quite sure which). Is it supposed to be like this and how can I change it to show the price of the default variant.  P.S. It get's a little confusing for a customer seeing one price on the products listing and after that different price on the product page. It should be the same price before choosing another variant. At the same time the default variant is chosen based on different and sometimes complicated criteria so we cannot keep it the cheapest one or the first one in the list.")*

Hi,

When you select "unit price only", it will first look at the prices of the main product and will use the unit price there if any.
If none, then it will load the prices of the variants and will take the first one which is a unit price. It's not really random, it's in the order of creation of the prices in the database. But it sure can seem random.
The solution is to simply set the price that you want to display on the listing in the main product.

The following user(s) said Thank You: [goldian](/forum/user/39378-goldian "View goldian's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODAyMjktdW5pdC1wcmljZS1vbmx5LWRvZXNudC1zaG93LWRlZmF1bHQtdmFyaWFudD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ydingilski](/forum/user/37980-ydingilski "View ydingilski's Profile")**
- [![ydingilski's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar37980.png)](/forum/user/37980-ydingilski "View ydingilski's Profile") Topic Author
- [ Offline](/forum/user/37980-ydingilski)

Less More

- Posts: 52
- Thank you received: 0
-
-
-
- [](http://www.filkab.solar)
-

11 years 1 week ago [\#219602](#219602) by [ydingilski](/forum/user/37980-ydingilski "View ydingilski's Profile")  Replied by *[ydingilski](/forum/user/37980-ydingilski "View ydingilski's Profile")* on topic *["Unit price only" doesn't show default variant](/forum/26-product-category-display/880229-unit-price-only-doesnt-show-default-variant#219602 "-- url of the page with the problem -- :   www.filkab.solar  -- HikaShop version -- : 2.6.0  Hi, I have set Price display method to &quot;Unit price only&quot;. It works fine when I have different price for quantities without variants. When I have variants it doesn't show the default variant price but the cheapest one (or the price of the first variant, I'm not quite sure which). Is it supposed to be like this and how can I change it to show the price of the default variant.  P.S. It get's a little confusing for a customer seeing one price on the products listing and after that different price on the product page. It should be the same price before choosing another variant. At the same time the default variant is chosen based on different and sometimes complicated criteria so we cannot keep it the cheapest one or the first one in the list.")*

Hi nicolas,
The problem in my case is that I have custom fields related with the SKU number of our products. Since we have ERP system in our company I'm trying to integrate Hikashop with it as much as possible. For that reason I don't want to mess up with the main product, because it would be very difficult for me to update automatically stock availabilities and prices later. Having redundant data in the database would only introduce more troubles for me.
Please advise me how to change the php code in order to display the default variant price if that is possible.
Thank you in advance.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODAyMjktdW5pdC1wcmljZS1vbmx5LWRvZXNudC1zaG93LWRlZmF1bHQtdmFyaWFudD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86556
- Thank you received: 14305
-
-

11 years 1 week ago [\#219638](#219638) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *["Unit price only" doesn't show default variant](/forum/26-product-category-display/880229-unit-price-only-doesnt-show-default-variant#219638 "-- url of the page with the problem -- :   www.filkab.solar  -- HikaShop version -- : 2.6.0  Hi, I have set Price display method to &quot;Unit price only&quot;. It works fine when I have different price for quantities without variants. When I have variants it doesn't show the default variant price but the cheapest one (or the price of the first variant, I'm not quite sure which). Is it supposed to be like this and how can I change it to show the price of the default variant.  P.S. It get's a little confusing for a customer seeing one price on the products listing and after that different price on the product page. It should be the same price before choosing another variant. At the same time the default variant is chosen based on different and sometimes complicated criteria so we cannot keep it the cheapest one or the first one in the list.")*

Hi,

The thing is that the variants data of each product is not loaded on the products listings.
We avoid doing that as it would make the page processing crash on a lot of websites.
Suppose that you have 100 variants for each product. That's already a lot but it's manageable on the product page.
But if you display a products listing and need to load the data of all the variants of all the products, even with only 20 products on your listing, that's already 2020 product entities loaded and processed.
That's just too much data for the resources restrictions in place on normal hostings.
So that will make your job more difficult as you first need to load the variants data to know which variant is the default one and then load its price.
You want to edit the getListingPrices function of the file administrator/components/com_hikashop/classes/currency.php
There, you'll find two main blocks of code. The first one load the prices of the main product and get the cheapest/unit/range one(s). The second load load the prices of the variants of the product and get the cheapest/unit/range one(s).
So in between these two blocks, right after the line Code:

if(!empty($variantSearch)){

you want to:
- first to do a MySQL query in the hikashop_variant table in order to get the characteristic_ids linked to the main products product_id.
- second, to do a MySQL query in the hikashop_product table in order to load the product_ids of all the variants of the main products based on the product_parent_id being equal to the product_id of the main products
- third, to do a MySQL query in the hiakshop_variant table in order to get the entries matching the characteristic_ids of your first query with the product_ids of your second query. That will give you the product_ids of the default variants of the main products
- fourth, to do a MySQL query in the hikashop_price table in order to load the prices of these default variants based on their product_ids
- fifth, to do the same PHP processing on them and get the cheapest/unit/range one(s).

So it's not just a few lines of code to add and will make the loading of the page a bit slower. That's why we decided not to do it by default and use the trick of providing the price for the listing in the main product instead.

The following user(s) said Thank You: [ydingilski](/forum/user/37980-ydingilski "View ydingilski's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODAyMjktdW5pdC1wcmljZS1vbmx5LWRvZXNudC1zaG93LWRlZmF1bHQtdmFyaWFudD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ydingilski](/forum/user/37980-ydingilski "View ydingilski's Profile")**
- [![ydingilski's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar37980.png)](/forum/user/37980-ydingilski "View ydingilski's Profile") Topic Author
- [ Offline](/forum/user/37980-ydingilski)

Less More

- Posts: 52
- Thank you received: 0
-
-
-
- [](http://www.filkab.solar)
-

11 years 1 week ago [\#219801](#219801) by [ydingilski](/forum/user/37980-ydingilski "View ydingilski's Profile")  Replied by *[ydingilski](/forum/user/37980-ydingilski "View ydingilski's Profile")* on topic *["Unit price only" doesn't show default variant](/forum/26-product-category-display/880229-unit-price-only-doesnt-show-default-variant#219801 "-- url of the page with the problem -- :   www.filkab.solar  -- HikaShop version -- : 2.6.0  Hi, I have set Price display method to &quot;Unit price only&quot;. It works fine when I have different price for quantities without variants. When I have variants it doesn't show the default variant price but the cheapest one (or the price of the first variant, I'm not quite sure which). Is it supposed to be like this and how can I change it to show the price of the default variant.  P.S. It get's a little confusing for a customer seeing one price on the products listing and after that different price on the product page. It should be the same price before choosing another variant. At the same time the default variant is chosen based on different and sometimes complicated criteria so we cannot keep it the cheapest one or the first one in the list.")*

Hi nicolas,
Thank you for explaining the issue so thoroughly. Seeing the problem from that point of view it's clear why my request cannot be fulfilled.
At least everybody with the same issue would know why they have to use the workaround and how to organize their listings.
Once again thank you ![:)](/media/kunena/emoticons/3.png ":)")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODAyMjktdW5pdC1wcmljZS1vbmx5LWRvZXNudC1zaG93LWRlZmF1bHQtdmFyaWFudD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.061 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
