dsjz1119 2013-02-01 10:44
浏览 122
已采纳

电子邮件确认自动发票

I need to programmatically invoice orders in Magento on certain product types when an order has been successfully placed. This is for a virtual giftcard, and in order for the giftcard number to be emailed out the order has to be invoiced in the admin backend.

I think that there is functionality like this for "virtual goods" already, but my product has the type 'giftcard', not 'virtual' and I therefore had to do this myself.

So far I've managed to make sure that the product can only be ordered alone, so no physical products mixed in into the order. Also I have been able to detect the giftcard at checkout to hide any non-direct or non-assured payment methods.

Now all I had to do was to add an observer to check the order status change to "payment received (reserved on account)" or just "payment recieved" from any previous order statuses, like "payment pending". It's just that there is no such event in Magento - at least as far as I can tell by searching.

So I figured that I'd connect the auto-invoice code to where Magento sends out the order confirmation email - but I simply can not find where that is.

Any suggestions on where I can insert my code to auto invoice the order? Preferably as "safe" as possible in regards to payment received - but I'd settle with anything and can always go back manually and block giftcards connected to suspected frauds and orders where the payment is somehow not received.

Thanks in advance for any hints on how to accomplish this!

  • 写回答

1条回答 默认 最新

  • dongzha2525 2013-02-01 14:27
    关注

    I think the best option is to observe event sales_order_place_after, sales_order_payment_place_end, which are fired when an order payment is placed (see here). To be 100% sure add a code to your observer to check that the order due is equal zero $order->getTotalDue() == 0

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 惠普360g9的最新bios
  • ¥15 配置hadoop时start-all.sh老是启动失败
  • ¥30 这个功能用什么软件发合适?
  • ¥60 微信小程序,取消订单,偶尔订单没有改变状态
  • ¥15 用pytorch实现PPO算法
  • ¥15 关于调制信号的星座图?
  • ¥30 前端传参时,后端接收不到参数
  • ¥15 这是有什么问题吗,我检查许可证了但是显示有呢
  • ¥15 机器学习预测遇到的目标函数问题
  • ¥15 Fluent,液体进入旋转区域体积分数不连续