Sayed
Sayed

Reputation: 631

How to trigger custom SMS/email on new order in OpenCart?

I'm developing API for my app which is a manager app for OpenCart stores. I want the webhook of my API to receive a notification on every order that is placed on a store connected to my app so that I can inform the store-manager via SMS or push notification.

So far, I've been able to achieve most of the managerial tasks since none of it required to interact with the core controllers of the OpenCart. Now, I cannot change the existing controllers but I can add my own controllers and models. I don't have much experience with OpenCart but I do understand the structure. Any suggestions? I couldn't find much except the paid plugins, which are out of scope of this question.

One possible solution I can think of is to ping the OpenCart server of the connected store via my API and log new orders every minute and inform the respective user every time there's change in log from previous minute and next minute.

Update:

Another solution I could think of is to extend the library class Mail with my custom class so every time a mail is fired for new order, my class will be triggered and my APIs will be notified! This will obviously fail in case someone else changed the library file again. Moreover, changing the library file doesn't seem like a good solution to me.

Upvotes: 1

Views: 646

Answers (1)

Paul Feakins
Paul Feakins

Reputation: 727

The problem you'll have is that different payment gateways will confirm the order has been paid for in different ways, for example PayPal use an IPN request to a callback URL in the PayPal gateway code.

So using a cron to regularly check orders as you suggest is not necessarily a bad solution here.

Upvotes: 1

Related Questions