From b494cd2f8ba7bbd403bdaf030cb04121edd87d79 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Fri, 5 Mar 2021 10:57:46 +0100 Subject: [PATCH] Add unit price field to New Product form - Add a new i18n key for the content of the tooltip: js.shopfront.unit_price_tooltip.admin - Display unit price readonly field near the price field - Still fake values, needs to be updated --- app/views/spree/admin/products/new.html.haml | 35 ++++++++++++++------ config/locales/en.yml | 3 ++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/app/views/spree/admin/products/new.html.haml b/app/views/spree/admin/products/new.html.haml index 5bc7530619..d51a363344 100644 --- a/app/views/spree/admin/products/new.html.haml +++ b/app/views/spree/admin/products/new.html.haml @@ -45,33 +45,48 @@ .sixteen.columns.alpha .eight.columns.alpha = render 'spree/admin/products/primary_taxon_form', f: f - .three.columns + .four.columns = f.field_container :price do = f.label :price, t(".price") %span.required * %br/ = f.text_field :price, class: 'fullwidth' = f.error_message_on :price + - if feature? :unit_price, spree_current_user + .four.columns{ ng: { app: 'ofn.admin'}} + = f.field_container :unit_price do + = f.label :unit_price, t(".unit_price") + %question-mark-with-tooltip{"question-mark-with-tooltip" => "_", + "question-mark-with-tooltip-append-to-body" => "true", + "question-mark-with-tooltip-placement" => "top", + "question-mark-with-tooltip-animation" => true, + key: "'js.shopfront.unit_price_tooltip.admin'"} + %br/ + = f.text_field :price, class: '', disabled: true, value: "value" + %span{style: "color: #757575"} + unit + %div{style: "color: black"} + = t(".unit_price_legend") + .sixteen.columns.alpha .three.columns + - if Spree::TaxCategory.any? + = render 'spree/admin/products/tax_category_form', f: f + - else +   + .five.columns.omega + = render 'spree/admin/products/shipping_category_form', f: f + .five.columns = f.field_container :on_hand do = f.label :on_hand, t(".on_hand") %br/ = f.text_field :on_hand, class: 'fullwidth' = f.error_message_on :on_hand - .two.columns.omega + .three.columns.omega = f.field_container :on_demand do = f.label :on_demand, t(".on_demand") %br/ = f.check_box :on_demand = f.error_message_on :on_demand - .sixteen.columns.alpha - .four.columns - - if Spree::TaxCategory.any? - = render 'spree/admin/products/tax_category_form', f: f - - else -   - .four.columns.omega - = render 'spree/admin/products/shipping_category_form', f: f .sixteen.columns.alpha = f.field_container :description do diff --git a/config/locales/en.yml b/config/locales/en.yml index 91718b176f..dc394f165e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2784,6 +2784,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using price_breakdown: "Price breakdown" unit_price_tooltip: shopfront: "This is the unit price of this product. It allows you to compare the price of products independent of packaging sizes & weights." + admin: "The unit price increases transparency by allowing your customers to easily compare prices between different products and packaging sizes. Note, that the final unit price displayed in the shopfront might differ as it is includes taxes & fees." variants: on_demand: "yes": "On demand" @@ -3478,6 +3479,8 @@ See the %{link} to find out more about %{sitename}'s features and to start using value: "Value" unit_name: "Unit name" price: "Price" + unit_price: "Unit Price" + unit_price_legend: "Calculated based on the item price" on_hand: "On Hand" on_demand: "On Demand" product_description: "Product Description"