How to create a couponcode from PHP code?


  • Default avatar
    paypal4    
     3 years ago
    0

    Hi,

    I created a Hikashop plugin and from that plugin I subscribe customers to our external list server when an orderstatus changes to confirmed.

    Now, I want to generate a coupon code right before I send the name and e-mail address to our list server so that I can send this code, the start date and the end date along.

    Maybe create a code based on a template?

    Can someone give some code examples?

    Thank you,
    Maurice

  • Your avatar
    seyi    
     3 years ago
    0

    Hello,

    You can use www/administrator/components/com_awocoupon/helpers/plgautogenerate.php to duplicate a template.
  • Default avatar
    paypal4    
     3 years ago
    0

    Hi Seyi, thank you.

    After some more discussion here, we decided that we need to do it in a different way. Using a template does not give enough flexibility.

    We need to be able to create new coupons with a future start date and a future end date. We have a script that already generates coupon codes and star en expire dates so we only need to know where to put them in the DB.

    Do you have documentation which tables and fields are involved for 'injecting' a brand new coupon directly into the DB?

    Thank you,
    Maurice

  • Your avatar
    seyi    
     3 years ago
    0

    Hi Maurice,

    No, there is no documentation on database structure of AwoCoupon.

    For expiration/start date, this goes into the main table: #__awoucoupon, columns startdate, expiration.

    Not sure how your logic is, but if the start date is from the moment the coupon is generated, then you could use the expiration field when generating a coupon using a template. This will automatically set the expiration date.