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

#   Coupon for only in stock items

##

- **[vseva](/forum/user/39330-vseva "View vseva's Profile")**
- [![vseva's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar39330.jpg)](/forum/user/39330-vseva "View vseva's Profile") Topic Author
- [ Offline](/forum/user/39330-vseva)

Less More

- Posts: 56
- Thank you received: 2
-
-

8 years 11 months ago [\#284502](#284502) by [vseva](/forum/user/39330-vseva "View vseva's Profile")  *[Coupon for only in stock items](/forum/46-discount-coupon/893196-coupon-for-only-in-stock-items#284502 "-- HikaShop version -- : 2.6.4 -- Joomla version -- : 3.6.5 -- PHP version -- : 5.6.25 -- Browser(s) name and version -- : Firefox Dev edition -- Error-message(debug-mod must be tuned on) -- : n.a  HI Hikacrew !!  OK my problem is quite unique as this company manufactures their own clothing, from beginning to end. So they make the materials (latex sheeting) then cut it up and make clothing out of it.  Now, they do have quite a few clothing items in stock (over a hundred), but it's just impossible to have everything item of clothing they can make in stock (too many styles and colors), so if they don't have it, they will make it - although it can take 4~6 weeks.  So Boxing day is coming and they want to make a coupons that will give a certain percentage off all &quot;In stock&quot; items ONLY.  Now I have read this , and so that has show me how to fix the view in .../product/quantity.php. So that's all good. (see attachments) So I have set the &quot;out of stock&quot; value to 1000 (anything over 1000 means &quot;in stock&quot;, as specified in that post).  So I guess I have alter the coupon code and throw in basic conditional statement/ or create a function that I could then add to the coupon function. Soething roughly a long these lines:  (sorry haven't looked up the variables yet)  Now my only problem is : Where would i add such a statement? OR in which file does the code reside?  I know the best way would be to add a new field/params to the coupon/discount section of Hikashop... But as I'm running out of time quick, I thought a core hack would do for now.  Any help or hint will do.  Thx in advance.  V.")* was created by *[vseva](/forum/user/39330-vseva "View vseva's Profile")*

-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.6.25
-- Browser(s) name and version -- : Firefox Dev edition
-- Error-message(debug-mod must be tuned on) -- : n.a

HI Hikacrew !!

OK my problem is quite unique as this company manufactures their own clothing, from beginning to end.
So they make the materials (latex sheeting) then cut it up and make clothing out of it.

Now, they do have quite a few clothing items in stock (over a hundred), but it's just impossible to have everything item of clothing they can make in stock (too many styles and colors), so if they don't have it, they will make it - although it can take 4~6 weeks.

So Boxing day is coming and they want to make a coupons that will give a certain percentage off all "In stock" items ONLY.

Now I have read this [ post](https://www.hikashop.com/support/forum/product-category-display/873334-sell-products-even-if-they-are-out-of-stock.html) , and so that has show me how to fix the view in .../product/quantity.php. So that's all good.
(see attachments)
So I have set the "out of stock" value to 1000 (anything over 1000 means "in stock", as specified in that post).

So I guess I have alter the coupon code and throw in basic conditional statement/ or create a function that I could then add to the coupon function. Soething roughly a long these lines: Code:

If quantity &gt; 1000 then apply coupon else don't apply coupon ! (break;)

(sorry haven't looked up the variables yet)

Now my only problem is :
Where would i add such a statement? OR in which file does the code reside?

I know the best way would be to add a new field/params to the coupon/discount section of Hikashop...
But as I'm running out of time quick, I thought a core hack would do for now.

Any help or hint will do.

Thx in advance.

V.

- [ ![1-item-in-stock.jpg](/forum/attachment/41844) ](/forum/attachment/41844 "...m-in-stock.jpg") [ ](/forum/attachment/41844?download=1 "...m-in-stock.jpg")
- [ ![out-of-stock.jpg](/forum/attachment/41845) ](/forum/attachment/41845 "out-of-stock.jpg") [ ](/forum/attachment/41845?download=1 "out-of-stock.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ2LWRpc2NvdW50LWNvdXBvbi84OTMxOTYtY291cG9uLWZvci1vbmx5LWluLXN0b2NrLWl0ZW1zP3RtcGw9bWFya2Rvd24=) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

8 years 11 months ago -  8 years 11 months ago [\#284507](#284507) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Coupon for only in stock items](/forum/46-discount-coupon/893196-coupon-for-only-in-stock-items#284507 "-- HikaShop version -- : 2.6.4 -- Joomla version -- : 3.6.5 -- PHP version -- : 5.6.25 -- Browser(s) name and version -- : Firefox Dev edition -- Error-message(debug-mod must be tuned on) -- : n.a  HI Hikacrew !!  OK my problem is quite unique as this company manufactures their own clothing, from beginning to end. So they make the materials (latex sheeting) then cut it up and make clothing out of it.  Now, they do have quite a few clothing items in stock (over a hundred), but it's just impossible to have everything item of clothing they can make in stock (too many styles and colors), so if they don't have it, they will make it - although it can take 4~6 weeks.  So Boxing day is coming and they want to make a coupons that will give a certain percentage off all &quot;In stock&quot; items ONLY.  Now I have read this , and so that has show me how to fix the view in .../product/quantity.php. So that's all good. (see attachments) So I have set the &quot;out of stock&quot; value to 1000 (anything over 1000 means &quot;in stock&quot;, as specified in that post).  So I guess I have alter the coupon code and throw in basic conditional statement/ or create a function that I could then add to the coupon function. Soething roughly a long these lines:  (sorry haven't looked up the variables yet)  Now my only problem is : Where would i add such a statement? OR in which file does the code reside?  I know the best way would be to add a new field/params to the coupon/discount section of Hikashop... But as I'm running out of time quick, I thought a core hack would do for now.  Any help or hint will do.  Thx in advance.  V.")*

Hi,

As a quick fix, you can add that in the check function of the file administrator/components/com_hikashop/classes/discount.php

Better would be the develop a small plugin of the group "hikashop" and implement the onBeforeCouponCheck or onAfterCouponCheck triggers to add your condition thanks to the $do parameter in them:
[ www.hikashop.com/support/documentation/6...entation.html#coupon](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#coupon)

Last edit: 8 years 11 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

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

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