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

#   what is right way i show coupon badge on my own component records?

##

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

Less More

- Posts: 221
- Thank you received: 8
-

2 years 10 months ago [\#357977](#357977) by [sadaf3d](/forum/user/46256-sadaf3d "View sadaf3d's Profile")  *[what is right way i show coupon badge on my own component records?](/forum/46-discount-coupon/907530-what-is-right-way-i-show-coupon-badge-on-my-own-component-records#357977 "hi. i create my own component and show my record and user do some process and finally go to hikashop to checkout process. i want show badge on my own component object (each record separately) which this record has or has not coupon. 1-can you give me sample code or any advise to look some php file as a pattern? (yes i can query to hikashop discount table but i want use safe way) 2- is there any way to use some setting to show some coupon and hide some of that? for example i want add yes/no option to my vendor discount/add page, for when my vendor want to create a coupon if he want show his coupon then select yes or if he don't want show as a public , then he select no. i have an answer to my question but i want understand your answer maybe you give me better or maybe correct me: 1- i must change HikaMarket - discountmarket / show.php to add &quot;show coupon to public: yes/no&quot;, 2- add appropriate column to hikashop discount table. am i right? thank you")* was created by *[sadaf3d](/forum/user/46256-sadaf3d "View sadaf3d's Profile")*

hi.
i create my own component and show my record and user do some process and finally go to hikashop to checkout process. i want show badge on my own component object (each record separately) which this record has or has not coupon.
1-can you give me sample code or any advise to look some php file as a pattern? (yes i can query to hikashop discount table but i want use safe way)
2- is there any way to use some setting to show some coupon and hide some of that? for example i want add yes/no option to my vendor discount/add page, for when my vendor want to create a coupon if he want show his coupon then select yes or if he don't want show as a public , then he select no. i have an answer to my question but i want understand your answer maybe you give me better or maybe correct me:
1- i must change HikaMarket - discountmarket / show.php to add "show coupon to public: yes/no",
2- add appropriate column to hikashop discount table.
am i right?
thank you

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ2LWRpc2NvdW50LWNvdXBvbi85MDc1MzAtd2hhdC1pcy1yaWdodC13YXktaS1zaG93LWNvdXBvbi1iYWRnZS1vbi1teS1vd24tY29tcG9uZW50LXJlY29yZHM/dG1wbD1tYXJrZG93bg==) 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: 14304
-
-

2 years 10 months ago [\#357981](#357981) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[what is right way i show coupon badge on my own component records?](/forum/46-discount-coupon/907530-what-is-right-way-i-show-coupon-badge-on-my-own-component-records#357981 "hi. i create my own component and show my record and user do some process and finally go to hikashop to checkout process. i want show badge on my own component object (each record separately) which this record has or has not coupon. 1-can you give me sample code or any advise to look some php file as a pattern? (yes i can query to hikashop discount table but i want use safe way) 2- is there any way to use some setting to show some coupon and hide some of that? for example i want add yes/no option to my vendor discount/add page, for when my vendor want to create a coupon if he want show his coupon then select yes or if he don't want show as a public , then he select no. i have an answer to my question but i want understand your answer maybe you give me better or maybe correct me: 1- i must change HikaMarket - discountmarket / show.php to add &quot;show coupon to public: yes/no&quot;, 2- add appropriate column to hikashop discount table. am i right? thank you")*

Hi,

1. I indeed think you want to directly run a MySQL query to the hikashop_discount table in order to adapt it to your needs.
Loading of the coupons data is done in the file administrator/components/com_hikashop/classes/discount.php
In there, the load function loads the data of a coupon, and the check function checks that a coupon is allowed to be used.

2. Yes, you want to customize the disocuntmarket / show.php view file to add the HTML for the extra option.
However, you'll also need to implement the onBeforeDiscountCreate and onBeforeDiscountUpdate events in a plugin of the group "hikashop" in order to add the selection done by the user in that setting to the discount object being saved.
And yes, you'll also need to add the appropriate column to the hikashop_discount table.
Finally, in your plugin, you also need to implement the onBeforeCouponCheck event to check the extra setting in order to make sure the coupon can be used. If not, you want to set the $do variable to false and the text of the error message to be displayed to the customer in the $error_message variable.

You can read more about all of these events here:
[ www.hikashop.com/support/documentation/6...entation.html#coupon](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#coupon)

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

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

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