mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #10744 from jibees/10556-remove-ofn-header-banner-in-order-confirmation-emails
White Label: remove OFN banner from order confirmation emails when `hide_ofn_navigation` is activated for the shop
This commit is contained in:
@@ -28,6 +28,7 @@ module Spree
|
||||
|
||||
def confirm_email_for_customer(order_or_order_id, resend = false)
|
||||
@order = find_order(order_or_order_id)
|
||||
@hide_ofn_navigation = @order.distributor.hide_ofn_navigation
|
||||
I18n.with_locale valid_locale(@order.user) do
|
||||
subject = mail_subject(t('spree.order_mailer.confirm_email.subject'), resend)
|
||||
mail(to: @order.email,
|
||||
|
||||
@@ -11,6 +11,7 @@ class SubscriptionMailer < ApplicationMailer
|
||||
def confirmation_email(order)
|
||||
@type = 'confirmation'
|
||||
@order = order
|
||||
@hide_ofn_navigation = @order.distributor.hide_ofn_navigation
|
||||
send_mail(order)
|
||||
end
|
||||
|
||||
|
||||
@@ -7,19 +7,20 @@
|
||||
= Spree::Config[:site_name]
|
||||
= stylesheet_pack_tag 'mail'
|
||||
%body{:bgcolor => "#FFFFFF" }
|
||||
%table.head-wrap{:bgcolor => "#f2f2f2"}
|
||||
%tr
|
||||
%td
|
||||
%td.header.container
|
||||
.content
|
||||
%table{:bgcolor => "#f2f2f2"}
|
||||
%tr
|
||||
%td
|
||||
%img{src: ContentConfig.url_for(:footer_logo), width: "144", height: "50"}/
|
||||
%td{:align => "right"}
|
||||
%h6.collapse
|
||||
= Spree::Config[:site_name]
|
||||
%td
|
||||
- unless @hide_ofn_navigation
|
||||
%table.head-wrap{:bgcolor => "#f2f2f2"}
|
||||
%tr
|
||||
%td
|
||||
%td.header.container
|
||||
.content
|
||||
%table{:bgcolor => "#f2f2f2"}
|
||||
%tr
|
||||
%td
|
||||
%img{src: ContentConfig.url_for(:footer_logo), width: "144", height: "50"}/
|
||||
%td{:align => "right"}
|
||||
%h6.collapse
|
||||
= Spree::Config[:site_name]
|
||||
%td
|
||||
|
||||
%table.body-wrap
|
||||
%tr
|
||||
|
||||
@@ -44,6 +44,20 @@ describe Spree::OrderMailer do
|
||||
described_class.confirm_email_for_customer(order.id).deliver_now
|
||||
}.to_not raise_error
|
||||
end
|
||||
|
||||
it "display the OFN header by default" do
|
||||
expect(email.body).to include(ContentConfig.url_for(:footer_logo))
|
||||
end
|
||||
|
||||
context 'when hide OFN navigation is enabled for the distributor of the order' do
|
||||
before do
|
||||
allow(order.distributor).to receive(:hide_ofn_navigation).and_return(true)
|
||||
end
|
||||
|
||||
it 'does not display the OFN navigation' do
|
||||
expect(email.body).to_not include(ContentConfig.url_for(:footer_logo))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#confirm_email_for_shop' do
|
||||
|
||||
7
spec/mailers/previews/order_mailer_preview.rb
Normal file
7
spec/mailers/previews/order_mailer_preview.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class OrderMailerPreview < ActionMailer::Preview
|
||||
def confirm_email_for_customer
|
||||
Spree::OrderMailer.confirm_email_for_customer(Spree::Order.complete.last)
|
||||
end
|
||||
end
|
||||
7
spec/mailers/previews/subscription_mailer_preview.rb
Normal file
7
spec/mailers/previews/subscription_mailer_preview.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SubscriptionMailerPreview < ActionMailer::Preview
|
||||
def confirmation_email
|
||||
SubscriptionMailer.confirmation_email(Spree::Order.complete.last)
|
||||
end
|
||||
end
|
||||
@@ -117,6 +117,10 @@ describe SubscriptionMailer, type: :mailer do
|
||||
expect(body).to include "This order was automatically placed for you"
|
||||
end
|
||||
|
||||
it "display the OFN header by default" do
|
||||
expect(email.body).to include(ContentConfig.url_for(:footer_logo))
|
||||
end
|
||||
|
||||
describe "linking to order page" do
|
||||
let(:order_link_href) { "href=\"#{order_url(order)}\"" }
|
||||
|
||||
@@ -152,6 +156,16 @@ describe SubscriptionMailer, type: :mailer do
|
||||
expect(email.body).to include('NOT PAID')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when hide OFN navigation is enabled for the distributor of the order' do
|
||||
before do
|
||||
allow(order.distributor).to receive(:hide_ofn_navigation).and_return(true)
|
||||
end
|
||||
|
||||
it 'does not display the OFN navigation' do
|
||||
expect(email.body).to_not include(ContentConfig.url_for(:footer_logo))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "empty order notification" do
|
||||
|
||||
Reference in New Issue
Block a user