简体   繁体   中英

How to disable a specific mailer on Rails?

So I'm building an e-commerce platform using Shoppe 1.0.7.

Basically, I'd like my customers to get an e-mail with their order confirmation, their item listing, etc, so I built a mailer that does just that.

When I got it working, I found out Shoppe actually sends out its own confirmation e-mails, but these are way more generic and uninformative than mine are (also they're in English and I need mine in another language). So as it is, my customers are actually getting two e-mails when they make an order, which is obviously undesirable.

How do I disable Shoppe's mailer without disabling Shoppe as a whole (which I obviously need)?

I'm not familiar with Shoppe but I can't see any configuration options around the mail on first glance. There are four actions in the OrderMailer and they only seem to be used here and here . An option would be to open up the mailer class and redefine the methods.

module Shoppe
  class OrderMailer
    def received(order)
      true
    end
  end
end

It's not the best solution to have to monkey patch like this, a better option would be to use an action mailer interceptor . Alternatively you could see if any issues for this have been raised on their repo and if not submit one, or a PR that would allow mail to be configured. Might be a nice feature to push upstream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM