From da3b811522dcb5876c2b44e90e24505edb8a7503 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 9d2c79195e..10dc76c2f0 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -634,10 +634,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 4230a78c73..fd95d95dbc 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 8203eeed0d..d1d0dc73a9 100644 --- a/app/views/spree/admin/orders/edit.html.haml +++ b/app/views/spree/admin/orders/edit.html.haml @@ -22,7 +22,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 f81b6232ee..dedfbe616e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -4418,6 +4418,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?"