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

  • Posts: 170
  • Thank you received: 7
3 months 3 weeks ago #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 "show coupon to public: yes/no",
2- add appropriate column to hikashop discount table.
am i right?
thank you

Please Log in or Create an account to join the conversation.

  • Posts: 81563
  • Thank you received: 13071
  • MODERATOR
3 months 3 weeks ago #357981

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

The following user(s) said Thank You: sadaf3d

Please Log in or Create an account to join the conversation.

Time to create page: 0.058 seconds
Powered by Kunena Forum