mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-01 21:47:16 +00:00
Adding a link in cart to allow user to edit existing + open orders for same OC
This commit is contained in:
@@ -16,5 +16,13 @@ module Spree
|
||||
def cart_count
|
||||
current_order.andand.line_items.andand.count || 0
|
||||
end
|
||||
|
||||
def changeable_orders
|
||||
return [] unless spree_current_user && current_distributor && current_order_cycle
|
||||
Spree::Order.complete.where(
|
||||
user_id: spree_current_user.id,
|
||||
distributor_id: current_distributor.id,
|
||||
order_cycle_id: current_order_cycle.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
%tr
|
||||
%td.toggle-bought{ colspan: 2, ng: { click: 'showBought=!showBought' } }
|
||||
%h5.brick
|
||||
%i{ ng: { class: "{ 'ofn-i_007-caret-right': !showBought, 'ofn-i_005-caret-down': showBought}"}}
|
||||
%i{ ng: { class: "{ 'ofn-i_007-caret-right': !showBought, 'ofn-i_005-caret-down': showBought}"} }
|
||||
= t(:orders_bought_items_notice, count: @order.finalised_line_items.count)
|
||||
%td.text-right{ colspan: 3}
|
||||
%a.edit-finalised.button.radius.expand.small{ href: 'javascript:void(0)', ng: { class: "{secondary: !showBought, primary: showBought}" } }
|
||||
%td.text-right{ colspan: 3 }
|
||||
- edit_path = changeable_orders.count > 1 ? spree.user_path : spree.order_path(changeable_orders.first)
|
||||
%a.edit-finalised.button.radius.expand.small{ href: edit_path, ng: { class: "{secondary: !showBought, primary: showBought}" } }
|
||||
= t(:orders_bought_edit_button)
|
||||
%i.ofn-i_007-caret-right
|
||||
|
||||
|
||||
Reference in New Issue
Block a user