• I want to sell few local gift codes to customers. When they complete payment , the saved codes from spreadsheet automatically will be delivered via email. How to do this ?

    • This topic was modified 3 years, 8 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    It’s really inefficient to have a web server read file data in order to perform a function like send an email. It is possible to do so, especially if the spreadsheet is in XML format instead of a legacy format. But not recommended. It’s best to keep the data in the WP database, either as WP data of some sort, or as a custom table.

    But then, needing to import spreadsheet data every time the sheet is updated is not a good option either. You’d want to be able to maintain the data right in the database without involving the original sheet at all. The database becomes the primary, up to date source.

    Anyway, however you decide to get the data, you’d compile an email message and send it with wp_mail() after the payment has been confirmed. How and where you call wp_mail() depends on your e-commerce plugin. There would hopefully be some sort of action that fires after payment confirmation which you can hook into in order to execute your code that fetches data and sends email.

    Your e-commerce plugin might already send an order confirmation email after payment confirmation. There might be a filter you could hook into so you can modify that email message instead of sending a separate email.

    For specifics of what hooks may be available, you should ask in the dedicated support channel of your e-commerce plugin.

Viewing 1 replies (of 1 total)
  • The topic ‘How to deliver saved gift codes automatically after order ?’ is closed to new replies.