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

#   Discount Only

##

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

Less More

- Posts: 24
- Thank you received: 0
-
-

9 years 4 months ago [\#273330](#273330) by [eduardkoks](/forum/user/39037-eduardkoks "View eduardkoks's Profile")  *[Discount Only](/forum/26-product-category-display/891009-discount-only#273330 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.7.0 -- PHP version -- : 7 -- Browser(s) name and version -- : chrome  Hello,  I've an issue with product listings which have the option 'discount only' turned on.  When I have products on discounts, the product listing is showing only those products with discounts. This is what I ask with the 'discounted only' option. However, when I haven't any product at all in discount, the listing is showing me ALL my products (which are not discounted). In that case the discounted option is not working. When I don;t have any discounted products, I don;t want to see anything when the option 'discounted only' is on....  Is this a bug ?  best regards, Eduard Koks")* was created by *[eduardkoks](/forum/user/39037-eduardkoks "View eduardkoks's Profile")*

-- HikaShop version -- : 3.0.1
-- Joomla version -- : 3.7.0
-- PHP version -- : 7
-- Browser(s) name and version -- : chrome

Hello,

I've an issue with product listings which have the option 'discount only' turned on.

When I have products on discounts, the product listing is showing only those products with discounts. This is what I ask with the 'discounted only' option. However, when I haven't any product at all in discount, the listing is showing me ALL my products (which are not discounted). In that case the discounted option is not working.
When I don;t have any discounted products, I don;t want to see anything when the option 'discounted only' is on....

Is this a bug ?

best regards,
Eduard Koks

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

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

Less More

- Posts: 24
- Thank you received: 0
-
-

9 years 4 months ago -  9 years 4 months ago [\#273333](#273333) by [eduardkoks](/forum/user/39037-eduardkoks "View eduardkoks's Profile")  Replied by *[eduardkoks](/forum/user/39037-eduardkoks "View eduardkoks's Profile")* on topic *[Discount Only](/forum/26-product-category-display/891009-discount-only#273333 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.7.0 -- PHP version -- : 7 -- Browser(s) name and version -- : chrome  Hello,  I've an issue with product listings which have the option 'discount only' turned on.  When I have products on discounts, the product listing is showing only those products with discounts. This is what I ask with the 'discounted only' option. However, when I haven't any product at all in discount, the listing is showing me ALL my products (which are not discounted). In that case the discounted option is not working. When I don;t have any discounted products, I don;t want to see anything when the option 'discounted only' is on....  Is this a bug ?  best regards, Eduard Koks")*

I've two possible solutions for this problem :

the first one is a 'dirty' workaround.... the second is a workaround in the core hikashop code. Maybe you can integrate this in the next release.
1. create an emtpy category (without products) and further create a discount for this empty category which is alway valid. In this way, the code which generate the discount filters in the query WILL generate filters, however without any products because the only valid discount has no products
2. I've created an extra filter in the com_hikashop\views\product\view.html.php which will result in an empty resultset when no discounts are found at all.... The latter else part '1=0' is added by me. Code:

if(!empty($discounts-&gt;max_product_id) &#124;&#124; !empty($discounts-&gt;max_category_id) &#124;&#124; !empty($discounts-&gt;max_category_children) &#124;&#124; !empty($discounts-&gt;max_zone_id)) { $on .= ' LEFT JOIN '.hikashop_table('discount').' AS discount '. ' ON (('. implode(') OR (', $join_discount_links) . '))'; $filters[] = 'discount.discount_type = ' . $database-&gt;Quote('discount'); $filters[] = 'discount.discount_published = 1'; $filters[] = '(discount.discount_quota = 0 OR discount.discount_quota &gt; discount.discount_used_times)'; $filters[] = 'discount.discount_start &lt; '.time().''; $filters[] = '(discount.discount_end = 0 OR discount.discount_end &gt; '.time().')'; hikashop_addACLFilters($filters, 'discount_access', 'discount', 2, false); if(!empty($discounts-&gt;max_zone_id)) { $zones = array(); $zone_id = hikashop_getZone(null); $zoneClass = hikashop_get('class.zone'); $zones = $zoneClass-&gt;getZoneParents($zone_id); if(!empty($zones)) { foreach($zones as &amp;$zone) { $zone = hikashop_getEscaped($zone, true); } unset($zone); $filters[] = '(discount.discount_zone_id = \'\' OR discount.discount_zone_id LIKE \'%,' .implode(',%\' OR discount.discount_zone_id LIKE \'%,', $zones) . ',%\')'; } else { $filters[] = 'discount.discount_zone_id = \'\''; } } } else { $filters[] = '1=0'; }

Last edit: 9 years 4 months ago by [eduardkoks](/forum/user/39037-eduardkoks "View eduardkoks's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84OTEwMDktZGlzY291bnQtb25seT90bXBsPW1hcmtkb3du) 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: 86583
- Thank you received: 14324
-
-

9 years 4 months ago [\#273361](#273361) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Discount Only](/forum/26-product-category-display/891009-discount-only#273361 "-- HikaShop version -- : 3.0.1 -- Joomla version -- : 3.7.0 -- PHP version -- : 7 -- Browser(s) name and version -- : chrome  Hello,  I've an issue with product listings which have the option 'discount only' turned on.  When I have products on discounts, the product listing is showing only those products with discounts. This is what I ask with the 'discounted only' option. However, when I haven't any product at all in discount, the listing is showing me ALL my products (which are not discounted). In that case the discounted option is not working. When I don;t have any discounted products, I don;t want to see anything when the option 'discounted only' is on....  Is this a bug ?  best regards, Eduard Koks")*

Hi,

The code modification won't work in all cases as far as I can see.
Suppose that you only have one published discount which apply without any restriction on the categories, products or zones (so it applies to all the products).
With your modification, the listing won't display any product even though all the products should appear.
That's actually done like that to properly handle this case. And this creates the side effect of seeing all the products when you don't have any discounted products that should appear.
The only solution I see would be to add an extra query in your additional else which would load all the discounts without these restrictions but with still the $discount_filter conditions in the query. And you would have the 1=0 added to the products loading query only if that query wouldn't return any result.
What do you think ?
Could you try it ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84OTEwMDktZGlzY291bnQtb25seT90bXBsPW1hcmtkb3du) 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.045 seconds

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