From 475cfdc8f0c41712bbfa79405cfbccb0040bc4bb Mon Sep 17 00:00:00 2001 From: Ashish Gaur Date: Mon, 7 Apr 2025 23:35:30 +0530 Subject: [PATCH] Show cannot add item to shipped order in the Add products section --- app/models/spree/order.rb | 4 ---- app/views/spree/admin/orders/_add_product.html.haml | 2 ++ app/views/spree/admin/orders/_shipment_manifest.html.haml | 2 +- app/views/spree/admin/orders/edit.html.haml | 2 +- config/locales/en.yml | 1 + 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index f8d388c7fc..909cb1a529 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -643,10 +643,6 @@ module Spree voucher.rate(self) end - def can_modify? - !shipped? && !canceled? - end - private def reapply_tax_on_changed_address diff --git a/app/views/spree/admin/orders/_add_product.html.haml b/app/views/spree/admin/orders/_add_product.html.haml index bb1ec09a73..e641eadfb5 100644 --- a/app/views/spree/admin/orders/_add_product.html.haml +++ b/app/views/spree/admin/orders/_add_product.html.haml @@ -6,6 +6,8 @@ - if @order.canceled? = t(".cannot_add_item_to_canceled_order") + - elsif @order.shipped? + = t(".cannot_add_item_to_shipped_order") - else .field.nine.columns.alpha = label_tag :add_variant_id, Spree.t(:name_or_sku) diff --git a/app/views/spree/admin/orders/_shipment_manifest.html.haml b/app/views/spree/admin/orders/_shipment_manifest.html.haml index 326818c59e..d08cf371c9 100644 --- a/app/views/spree/admin/orders/_shipment_manifest.html.haml +++ b/app/views/spree/admin/orders/_shipment_manifest.html.haml @@ -18,7 +18,7 @@ = line_item_shipment_price(line_item, item.quantity) %td.cart-item-delete.actions - - if shipment.can_modify? && can?(:update, shipment) && shipment.can_modify? + - if shipment.can_modify? && can?(:update, shipment) = link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => t('actions.save'), :style => 'display: none' = link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => t('actions.cancel'), :style => 'display: none' = link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => t('actions.edit') diff --git a/app/views/spree/admin/orders/edit.html.haml b/app/views/spree/admin/orders/edit.html.haml index 8a3a832be3..8d9023581d 100644 --- a/app/views/spree/admin/orders/edit.html.haml +++ b/app/views/spree/admin/orders/edit.html.haml @@ -24,7 +24,7 @@ = admin_inject_order_cycles(@order_cycles) %div{"ng-controller" => "orderCtrl", "ofn-distributor-id" => @order.distributor_id, "ofn-order-cycle-id" => @order.order_cycle_id} - = render :partial => 'add_product' if can?(:update, @order) && @order.can_modify? + = render :partial => 'add_product' if can?(:update, @order) - if @order.line_items.empty? .no-objects-found diff --git a/config/locales/en.yml b/config/locales/en.yml index b752d6a9fa..f4a3fe6745 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -4441,6 +4441,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using orders: add_product: cannot_add_item_to_canceled_order: "Cannot add item to canceled order" + cannot_add_item_to_shipped_order: "Cannot add item to shipped order" include_out_of_stock_variants: "Include variants with no available stock" shipment: mark_as_shipped_message_html: "This will mark the order as Shipped.
Are you sure you want to proceed?"