Display unit price on /cart page

- Use a new class to specify css customization
 - Add to `line_item.rb` a fake method: `unit_price_price_and_unit` @andrewpbrett will change it with real values.
 - Add a new variable: $text-xs to specify small font-size


squash "Display unit price on /cart page"
This commit is contained in:
Jean-Baptiste Bellet
2021-02-18 14:59:54 +01:00
parent 5914e6c885
commit ee4943f6e2
4 changed files with 18 additions and 0 deletions

View File

@@ -44,6 +44,12 @@
}
}
.unit-price {
color: $grey-500;
font-size: $text-xs;
}
input {
&.ng-invalid-stock,
&.ng-invalid-number {

View File

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

View File

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

View File

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