<%= f.field_container :name do %>
<%= f.label :name, class: 'required' %>
<%= f.text_field :name, class: 'fullwidth title', required: true %>
<%= f.error_message_on :name %>
<% end %>
<%= f.field_container :slug do %>
<%= f.label :slug, class: ('required' if !f.object.new_record?) %>
<%= f.text_field :slug, class: 'fullwidth title', required: !f.object.new_record?, disabled: f.object.new_record? %>
<%= f.error_message_on :slug %>
<% end %>
<%= f.field_container :description do %>
<%= f.label :description %>
<%= f.text_area :description, {rows: "#{unless @product.has_variants? then '22' else '15' end}", class: 'fullwidth'} %>
<%= f.error_message_on :description %>
<% end %>
<%= f.field_container :price do %>
<%= f.label :price, class: Spree::Config.require_master_price ? 'required' : '' %>
<% if f.object.new_record? || f.object.has_default_price? %>
<%= render "spree/admin/shared/number_with_currency",
f: f,
amount_attr: :price,
required: Spree::Config.require_master_price,
currency: Spree::Config.default_pricing_options.currency %>
<%= f.error_message_on :price %>
<% else %>
<%= t('spree.product_without_default_price_info',
default_currency: Spree::Config.default_pricing_options.currency) %>
<%= link_to t('spree.product_without_default_price_cta'),
spree.admin_product_prices_url(@product) %>
<% end %>
<% end %>
<% if show_rebuild_vat_checkbox? %>
<%= render "spree/admin/shared/rebuild_vat_prices_checkbox", form: f, model_name: "product" %>
<% end %>
<%= f.field_container :cost_price do %>
<%= f.label :cost_price %>
<%= render "spree/admin/shared/number_with_currency", f: f, amount_attr: :cost_price, currency_attr: :cost_currency %>
<%= f.error_message_on :cost_price %>
<%= f.error_message_on :cost_currency %>
<% end %>
<%= f.field_container :available_on do %>
<%= f.label :available_on %>
<%= f.field_hint :available_on %>
<%= render "spree/admin/shared/datepicker", f: f, date_attr: :available_on %>
<%= f.error_message_on :available_on %>
<% end %>
<%= f.field_container :discontinue_on do %>
<%= f.label :discontinue_on %>
<%= f.field_hint :discontinue_on %>
<%= render "spree/admin/shared/datepicker", f: f, date_attr: :discontinue_on %>
<%= f.error_message_on :discontinue_on %>
<% end %>
<%= f.field_container :promotionable do %>
<%= f.field_hint :promotionable %>
<% end %>
<%= f.field_container :sku do %>
<%= f.label :sku, t('spree.master_sku') %>
<%= f.text_field :sku, size: 16 %>
<% end %>
<% if @product.has_variants? %>
<%= f.label :skus, t('spree.skus') %>
<%= t('spree.info_product_has_multiple_skus', count: @product.variants.count) %>
<% @product.variants.first(5).each do |variant| %>
- <%= link_to variant.sku, spree.edit_admin_product_variant_path(@product, variant) %>
<% end %>
<% if @product.variants.count > 5 %>
<%= t('spree.info_number_of_skus_not_shown', count: @product.variants.count - 5) %>
<% end %>
<% if can?(:admin, Spree::Variant) %>
<%= link_to_with_icon 'th-large', t('spree.manage_variants'), admin_product_variants_url(@product) %>
<% end %>
<% else %>
<% [:height, :width, :depth, :weight].each_with_index do |field, index| %>
<%= f.label field %>
<%= f.text_field field, value: number_with_precision(@product.send(field), precision: 2) %>
<% end %>
<% end %>
<%= f.field_container :shipping_categories do %>
<%= f.label :shipping_category_id, Spree::ShippingCategory.model_name.human, class: 'required' %>
<%= f.field_hint :shipping_category %>
<%= f.collection_select(:shipping_category_id, @shipping_categories, :id, :name, { include_blank: t('spree.match_choices.none') }, { class: 'custom-select' , required: true}) %>
<%= f.error_message_on :shipping_category %>
<% end %>
<%= f.field_container :tax_category do %>
<%= f.label :tax_category_id, Spree::TaxCategory.model_name.human %>
<%= f.field_hint :tax_category, default_tax_category: @default_tax_category&.name %>
<%= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { include_blank: t('spree.match_choices.none'), selected: @default_tax_category&.id }, { class: 'custom-select' }) %>
<%= f.error_message_on :tax_category %>
<% end %>