Show cannot add item to shipped order in the Add products section

This commit is contained in:
Ashish Gaur
2025-04-07 23:35:30 +05:30
parent 42e2d3cdd5
commit 475cfdc8f0
5 changed files with 5 additions and 6 deletions

View File

@@ -643,10 +643,6 @@ module Spree
voucher.rate(self)
end
def can_modify?
!shipped? && !canceled?
end
private
def reapply_tax_on_changed_address

View File

@@ -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)

View File

@@ -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')

View File

@@ -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

View File

@@ -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.<br />Are you sure you want to proceed?"