diff --git a/app/assets/stylesheets/darkswarm/cart-page.scss b/app/assets/stylesheets/darkswarm/cart-page.scss index 7f715f4aab..5d0f833759 100644 --- a/app/assets/stylesheets/darkswarm/cart-page.scss +++ b/app/assets/stylesheets/darkswarm/cart-page.scss @@ -44,6 +44,12 @@ } } + .unit-price { + color: $grey-500; + font-size: $text-xs; + } + + input { &.ng-invalid-stock, &.ng-invalid-number { diff --git a/app/assets/stylesheets/darkswarm/variables.scss b/app/assets/stylesheets/darkswarm/variables.scss index b5039804e1..2a799ed935 100644 --- a/app/assets/stylesheets/darkswarm/variables.scss +++ b/app/assets/stylesheets/darkswarm/variables.scss @@ -45,3 +45,5 @@ $shop-sidebar-overlay: rgba(0, 0, 0, 0.5); $transition-sidebar: 250ms ease-in-out 0s; $padding-small: 0.5rem; + +$text-xs: 0.75rem; diff --git a/app/models/spree/line_item.rb b/app/models/spree/line_item.rb index c2da5814d6..0098c31a4a 100644 --- a/app/models/spree/line_item.rb +++ b/app/models/spree/line_item.rb @@ -219,6 +219,12 @@ module Spree final_weight_volume / quantity end + def unit_price_price_and_unit + price = Spree::Money.new((rand * 10).round(2), currency: currency) + unit = ["item", "kg"].sample + price.to_html + " / " + unit + end + def scoper @scoper ||= OpenFoodNetwork::ScopeVariantToHub.new(order.distributor) end diff --git a/app/views/spree/orders/_line_item.html.haml b/app/views/spree/orders/_line_item.html.haml index 19292cb219..6ac6c9a7ff 100644 --- a/app/views/spree/orders/_line_item.html.haml +++ b/app/views/spree/orders/_line_item.html.haml @@ -18,6 +18,10 @@ %td.text-right.cart-item-price{"data-hook" => "cart_item_price"} = line_item.single_display_amount_with_adjustments.to_html + - if feature? :unit_price, spree_current_user + %br + %span.unit-price + = line_item.unit_price_price_and_unit %td.text-center.cart-item-quantity{"data-hook" => "cart_item_quantity"} - finalized_quantity = @order.completed? ? line_item.quantity : 0 = item_form.number_field :quantity,