Skip to content

Commit

Permalink
send shipment email optionally from orders#edit page
Browse files Browse the repository at this point in the history
  • Loading branch information
binarygit committed Nov 21, 2023
1 parent c71b0e8 commit 23b55b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/reflexes/admin/orders_reflex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def capture
def ship
@order.send_shipment_email = true if params[:send_shipment_email]
if @order.ship
return set_param_for_controller if request.url.match?('edit')

morph dom_id(@order), render(partial: "spree/admin/orders/table_row",
locals: { order: @order.reload, success: true })
else
Expand Down Expand Up @@ -98,5 +100,9 @@ def success(i18n_key, count)
def editable_orders
Permissions::Order.new(current_user).editable_orders
end

def set_param_for_controller
params[:id] = @order.number
end
end
end
11 changes: 10 additions & 1 deletion app/views/spree/admin/orders/_shipment.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
= Spree.t("shipment_states.#{shipment.state}")
- if shipment.ready? and can? :update, shipment
= "-"
= link_to t(:ship), '#', :class => 'ship button icon-arrow-right', :data => { 'shipment-number' => shipment.number }
%button{"class": "ship button icon-arrow-right","data-controller": "modal-link",
"data-action": "click->modal-link#open", "data-modal-link-target-value": "ship_order" }= t(:ship)
%form
= render ConfirmModalComponent.new(id: "ship_order", confirm_reflexes: "click->Admin::OrdersReflex#ship", controller: "orders", reflex: "Admin::Orders#ship") do
%div{class: "margin-bottom-30"}
%p This will mark the order as Shipped
%div{class: "margin-bottom-30"}
= hidden_field_tag :id, order.id
= check_box_tag :send_shipment_email
= label_tag :send_shipment_email, "Send email confirmation to customer"
%table.stock-contents.index
%colgroup
Expand Down

0 comments on commit 23b55b6

Please sign in to comment.