Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'Voucher:' before voucher code on order confirmation emails #12998

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/views/spree/order_mailer/_order_summary.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
- checkout_adjustments_for(@order, exclude: [:line_item]).reverse_each do |adjustment|
%tr
%td{align: "right", colspan: "3"}
= "#{adjustment.label}:"
- if adjustment.originator_type == "Voucher"
= t(:email_order_summary_voucher_label, code: adjustment.label)
- else
= "#{adjustment.label}:"
%td{align: "right"}
= adjustment.display_amount
%tr
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
email_order_summary_subtotal: "Subtotal:"
email_order_summary_total: "Total:"
email_order_summary_includes_tax: "(includes tax):"
email_order_summary_voucher_label: "Voucher (%{code}):"
email_payment_paid: PAID
email_payment_not_paid: NOT PAID
email_payment_description: Payment Description at Checkout
Expand Down
26 changes: 26 additions & 0 deletions spec/mailers/order_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,30 @@
end
end
end

context "display adjustments" do
let(:order) { create(:order_with_totals_and_distribution, :completed) }
let(:voucher) { create(:voucher, enterprise: order.distributor) }

before do
voucher.create_adjustment(voucher.code, order)
OrderManagement::Order::Updater.new(order).update_voucher
end

let!(:confirmation_email_for_customer) { Spree::OrderMailer.confirm_email_for_customer(order) }
let!(:confirmation_email_for_shop) { Spree::OrderMailer.confirm_email_for_shop(order) }
let!(:cancellation_email) { Spree::OrderMailer.cancel_email(order) }

it "includes Voucher text with label" do
expect(confirmation_email_for_customer.body).to include("Voucher (#{voucher.code}):")
expect(confirmation_email_for_shop.body).to include("Voucher (#{voucher.code}):")
expect(cancellation_email.body).to include("Voucher (#{voucher.code}):")
end

it "includes Shipping label" do
expect(confirmation_email_for_customer.body).to include("Shipping:")
expect(confirmation_email_for_shop.body).to include("Shipping:")
expect(cancellation_email.body).to include("Shipping:")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the shipping fee comes from the factory order_with_totals_and_distribution. Maybe it's worth a comment here explaining that, but never mind :)

end
end
end
Loading