Extract the bulk of the confirmation emails into partials, eliminating a lot of duplication

This commit is contained in:
Rohan Mitchell
2015-04-02 16:00:48 +11:00
parent 2914990444
commit 4bd1ff2011
6 changed files with 134 additions and 257 deletions

View File

@@ -0,0 +1,46 @@
%table.order-summary{:width => "100%"}
%thead
%tr
%th{:align => "left"}
%h4 Item
%th{:align => "right", :width => "25%"}
%h4 Qty
%th{:align => "right", :width => "25%"}
%h4 Price
%tbody
- @order.line_items.each do |item|
%tr
%td
- if item.variant.product.name == item.variant.name_to_display
%strong= "#{raw(item.variant.product.name)}"
- else
%strong
%span= "#{raw(item.variant.product.name)}"
%span= "- " + "#{raw(item.variant.name_to_display)}"
- if item.variant.options_text
= "(" + "#{raw(item.variant.options_text)}" + ")"
%br
%small
%em= raw(item.variant.product.supplier.name)
%td{:align => "right"}
= item.quantity
%td{:align => "right"}
= item.display_amount_with_adjustments
%tfoot
%tr
%td{:align => "right", :colspan => "2"}
Subtotal:
%td{:align => "right"}
= display_checkout_subtotal(@order)
- checkout_adjustments_for(@order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment|
%tr
%td{:align => "right", :colspan => "2"}
= "#{raw(adjustment.label)}:"
%td{:align => "right"}
= adjustment.display_amount
%tr
%td{:align => "right", :colspan => "2"}
%strong Total:
%td{:align => "right"}
%strong= @order.display_total
%p  

View File

@@ -0,0 +1,14 @@
- if @order.payments.first.andand.payment_method.andand.type == "Spree::PaymentMethod::Check" and @order.payments.first.andand.payment_method.andand.description
%p.callout
%span{:style => "float:right;"}
- if @order.paid?
PAID
- else
NOT PAID
%strong Payment summary
%h4
Paying via:
%strong= @order.payments.first.andand.payment_method.andand.name.andand.html_safe
%p
%em= @order.payments.first.andand.payment_method.andand.description.andand.html_safe
%p  

View File

@@ -0,0 +1,59 @@
- if @order.shipping_method.andand.require_ship_address
/ Delivery details
%p.callout
%strong
- if @order.shipping_method.andand.name
#{@order.shipping_method.name.html_safe}
- else
Delivery details
- if @order.order_cycle.andand.pickup_time_for(@order.distributor)
%h4
Delivery on:
%strong #{@order.order_cycle.pickup_time_for(@order.distributor)}
- if @order.shipping_method.andand.description
%p
%em #{@order.shipping_method.description.html_safe}
%br  
- if @order.ship_address
%h4 Delivery address:
%p
#{@order.ship_address.full_name}
%br
#{@order.ship_address.full_address}
%br
#{@order.ship_address.phone}
%br  
- else
/ Collection details
%p.callout
%strong
- if @order.shipping_method.andand.name
#{@order.shipping_method.name.html_safe}
- else
Collection details
- if @order.order_cycle.andand.pickup_time_for(@order.distributor).present?
%h4
Ready for collection:
%strong #{@order.order_cycle.pickup_time_for(@order.distributor)}
- if @order.shipping_method.andand.description.present?
%p
%em #{@order.shipping_method.description.html_safe}
%br  
- if @order.ship_address.full_address
%p
%strong Collecting from:
%br
#{@order.ship_address.full_address}
- if @order.order_cycle.andand.pickup_instructions_for(@order.distributor).present?
%p
%strong Collection instructions:
%br
#{@order.order_cycle.pickup_instructions_for(@order.distributor)}

View File

@@ -0,0 +1,7 @@
- if @order.special_instructions.present?
%br
%p
%small
%strong Your notes:
%br
#{@order.special_instructions}

View File

@@ -23,135 +23,10 @@
Here are your order details from
%strong= "#{@order.distributor.name}:"
%table.order-summary{:width => "100%"}
%thead
%tr
%th{:align => "left"}
%h4 Item
%th{:align => "right", :width => "25%"}
%h4 Qty
%th{:align => "right", :width => "25%"}
%h4 Price
%tbody
- @order.line_items.each do |item|
%tr
%td
- if item.variant.product.name == item.variant.name_to_display
%strong= "#{raw(item.variant.product.name)}"
- else
%strong
%span= "#{raw(item.variant.product.name)}"
%span= "- " + "#{raw(item.variant.name_to_display)}"
- if item.variant.options_text
= "(" + "#{raw(item.variant.options_text)}" + ")"
%br
%small
%em= raw(item.variant.product.supplier.name)
%td{:align => "right"}
= item.quantity
%td{:align => "right"}
= item.display_amount_with_adjustments
%tfoot
%tr
%td{:align => "right", :colspan => "2"}
Subtotal:
%td{:align => "right"}
= display_checkout_subtotal(@order)
- checkout_adjustments_for(@order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment|
%tr
%td{:align => "right", :colspan => "2"}
= "#{raw(adjustment.label)}:"
%td{:align => "right"}
= adjustment.display_amount
%tr
%td{:align => "right", :colspan => "2"}
%strong Total:
%td{:align => "right"}
%strong= @order.display_total
%p  
- if @order.payments.first.andand.payment_method.andand.type == "Spree::PaymentMethod::Check" and @order.payments.first.andand.payment_method.andand.description
%p.callout
%span{:style => "float:right;"}
- if @order.paid?
PAID
- else
NOT PAID
%strong Payment summary
%h4
Paying via:
%strong= @order.payments.first.andand.payment_method.andand.name.andand.html_safe
%p
%em= @order.payments.first.andand.payment_method.andand.description.andand.html_safe
%p  
- if @order.shipping_method.andand.require_ship_address
/ Delivery details
%p.callout
%strong
- if @order.shipping_method.andand.name
#{@order.shipping_method.name.html_safe}
- else
Delivery details
- if @order.order_cycle.andand.pickup_time_for(@order.distributor)
%h4
Delivery on:
%strong #{@order.order_cycle.pickup_time_for(@order.distributor)}
- if @order.shipping_method.andand.description
%p
%em #{@order.shipping_method.description.html_safe}
%br  
- if @order.ship_address
%h4 Delivery address:
%p
#{@order.ship_address.full_name}
%br
#{@order.ship_address.full_address}
%br
#{@order.ship_address.phone}
%br  
- else
/ Collection details
%p.callout
%strong
- if @order.shipping_method.andand.name
#{@order.shipping_method.name.html_safe}
- else
Collection details
- if @order.order_cycle.andand.pickup_time_for(@order.distributor).present?
%h4
Ready for collection:
%strong #{@order.order_cycle.pickup_time_for(@order.distributor)}
- if @order.shipping_method.andand.description.present?
%p
%em #{@order.shipping_method.description.html_safe}
%br  
- if @order.ship_address.full_address
%p
%strong Collecting from:
%br
#{@order.ship_address.full_address}
- if @order.order_cycle.andand.pickup_instructions_for(@order.distributor).present?
%p
%strong Collection instructions:
%br
#{@order.order_cycle.pickup_instructions_for(@order.distributor)}
- if @order.special_instructions.present?
%br
%p
%small
%strong Your notes:
%br
#{@order.special_instructions}
= render 'order_summary'
= render 'payment'
= render 'shipping'
= render 'special_instructions'
%br
%p.callout

View File

@@ -23,134 +23,10 @@
%strong= "#{@order.bill_address.firstname} #{@order.bill_address.lastname}"
completed the following order at your shopfront:
%table.order-summary{:width => "100%"}
%thead
%tr
%th{:align => "left"}
%h4 Item
%th{:align => "right", :width => "25%"}
%h4 Qty
%th{:align => "right", :width => "25%"}
%h4 Price
%tbody
- @order.line_items.each do |item|
%tr
%td
- if item.variant.product.name == item.variant.name_to_display
%strong= "#{raw(item.variant.product.name)}"
- else
%strong
%span= "#{raw(item.variant.product.name)}"
%span= "- " + "#{raw(item.variant.name_to_display)}"
- if item.variant.options_text
= "(" + "#{raw(item.variant.options_text)}" + ")"
%br
%small
%em= raw(item.variant.product.supplier.name)
%td{:align => "right"}
= item.quantity
%td{:align => "right"}
= item.display_amount_with_adjustments
%tfoot
%tr
%td{:align => "right", :colspan => "2"}
Subtotal:
%td{:align => "right"}
= display_checkout_subtotal(@order)
- checkout_adjustments_for(@order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment|
%tr
%td{:align => "right", :colspan => "2"}
= "#{raw(adjustment.label)}:"
%td{:align => "right"}
= adjustment.display_amount
%tr
%td{:align => "right", :colspan => "2"}
%strong Total:
%td{:align => "right"}
%strong= @order.display_total
%p  
- if @order.payments.first.andand.payment_method.andand.type == "Spree::PaymentMethod::Check" and @order.payments.first.andand.payment_method.andand.description
%p.callout
%span{:style => "float:right;"}
- if @order.paid?
PAID
- else
NOT PAID
%strong Payment summary
%h4
Paying via:
%strong= @order.payments.first.andand.payment_method.andand.name.andand.html_safe
%p
%em= @order.payments.first.andand.payment_method.andand.description.andand.html_safe
%p  
- if @order.shipping_method.andand.require_ship_address
/ Delivery details
%p.callout
%strong
- if @order.shipping_method.andand.name
#{@order.shipping_method.name.html_safe}
- else
Delivery details
- if @order.order_cycle.andand.pickup_time_for(@order.distributor)
%h4
Delivery on:
%strong #{@order.order_cycle.pickup_time_for(@order.distributor)}
- if @order.shipping_method.andand.description
%p
%em #{@order.shipping_method.description.html_safe}
%br  
- if @order.ship_address
%h4 Delivery address:
%p
#{@order.ship_address.full_name}
%br
#{@order.ship_address.full_address}
%br
#{@order.ship_address.phone}
%br  
- else
/ Collection details
%p.callout
%strong
- if @order.shipping_method.andand.name
#{@order.shipping_method.name.html_safe}
- else
Collection details
- if @order.order_cycle.andand.pickup_time_for(@order.distributor).present?
%h4
Ready for collection:
%strong #{@order.order_cycle.pickup_time_for(@order.distributor)}
- if @order.shipping_method.andand.description.present?
%p
%em #{@order.shipping_method.description.html_safe}
%br  
- if @order.ship_address.full_address
%p
%strong Collecting from:
%br
#{@order.ship_address.full_address}
- if @order.order_cycle.andand.pickup_instructions_for(@order.distributor).present?
%p
%strong Collection instructions:
%br
#{@order.order_cycle.pickup_instructions_for(@order.distributor)}
- if @order.special_instructions.present?
%br
%p
%small
%strong Customer notes:
%br
#{@order.special_instructions}
= render 'order_summary'
= render 'payment'
= render 'shipping'
= render 'special_instructions'
%p  
= render 'shared/mailers/signoff'