Adding a link in cart to allow user to edit existing + open orders for same OC

This commit is contained in:
Rob Harrington
2017-04-12 14:15:52 +10:00
parent 0dd8959bf7
commit ae28d7a96b
2 changed files with 12 additions and 3 deletions

View File

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

View File

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