{# @var product \craft\commerce\elements\Product #} {% extends "commerce/_layouts/cp" %} {% set selectedSubnavItem = "products" %} {% set bodyClass = (bodyClass is defined ? bodyClass~' ' : '') ~ "commerceproducts commerceproductsedit" %} {% set crumbs = [ { label: "Products"|t('commerce'), url: url('commerce/products') }, { label: productType.name|t('commerce'), url: url('commerce/products/'~productType.handle) } ] %} {% set fullPageForm = true %} {% set saveShortcutRedirect = continueEditingUrl %} {% do view.setIsDeltaRegistrationActive(true) %} {% set formActions = [ { label: 'Save and continue editing'|t('commerce'), redirect: continueEditingUrl|hash, shortcut: true, retainScroll: true, } ] %} {% if product.id %} {% set formActions = formActions|push({ label: 'Save as a new {type}'|t('app', { type: product.lowerDisplayName() }), redirect: '{cpEditUrl}'|hash, action: 'commerce/products/duplicate-product' }) %} {% set formActions = formActions|push({ action: 'commerce/products/delete-product', confirm: 'Are you sure you want to delete this product?'|t('commerce'), redirect: 'commerce/products'|hash, label: 'Delete'|t('commerce'), destructive: true, }) %} {% endif %} {% import "_includes/forms" as forms %} {% import "commerce/products/_fields" as productFields %} {% block header %}
{{ block('pageTitle') }} {{ block('contextMenu') }}
{% if showPreviewBtn or shareUrl is defined %}
{% if showPreviewBtn %}
{{ 'Preview'|t('app') }}
{% endif %} {% if shareUrl is defined %} {% endif %}
{% endif %} {{ block('actionButton') }}
{% endblock %} {% block contextMenu %} {% if craft.app.getIsMultiSite() %} {% endif %} {% endblock %} {% block actionButton %}
{% if formActions|length %} {% include '_layouts/components/form-action-menu' %} {% endif %}
{% endblock %} {% block content %} {% if product.id %}{% endif %} {% if craft.app.getIsMultiSite() %} {% endif %} {{ redirectInput('commerce/products') }} {{ csrfInput() }}
{{ fieldsHtml|raw }}
{% hook "cp.commerce.product.edit.content" %} {% endblock %} {% block details %}
{{ productFields.generalMetaFields(product) }} {{ forms.lightswitchField({ label: "Enabled"|t('commerce'), id: 'enabled', name: 'enabled', on: product.enabled }) }} {% if craft.app.getIsMultiSite() %} {{ forms.lightswitchField({ label: "Enabled for site"|t('commerce'), id: 'enabledForSite', name: 'enabledForSite', on: product.enabledForSite }) }} {% endif %}
{{ productFields.behavioralMetaFields(product) }}
{% if not productType.hasVariants %} {% namespace 'variants['~(product.defaultVariant.id ?: 'new1')~']' %}
{{ productFields.generalVariantFields(product.defaultVariant, product) }}
{% if productType.hasDimensions %}
{{ productFields.dimensionVariantFields(product.defaultVariant) }}
{% endif %} {% endnamespace %} {% endif %} {% if product.id %}
{# Related Sales #} {# TODO allow viewing of sales when a view promotions permission is introduced #} {% if currentUser.can('commerce-managePromotions') and not craft.app.request.isAjax %} {{ productFields.relatedSales(product.defaultVariant.id, productType.hasVariants) }} {{ productFields.relatedDiscounts(product.defaultVariant.id, product.defaultVariant) }} {% endif %}
{{ "Date Created"|t('commerce') }}
{{ product.dateCreated|date('short') }} {{ product.dateCreated|time('short') }}
{{ "Date Updated"|t('commerce') }}
{{ product.dateUpdated|date('short') }} {{ product.dateUpdated|time('short') }}
{% hook "cp.commerce.product.edit.details" %} {% endif %} {% endblock %} {% if not product.slug %} {% js %} window.slugGenerator = new Craft.SlugGenerator('#title', '#slug'); {% endjs %} {% elseif product.id %} {% js %} new Craft.Commerce.ProductEdit({ id: {{ product.id|raw }}, hasVariants: {{ productType.hasVariants ? 'true' : 'false' }}, purchasables: {{ product.getVariants()|map(v => {id: v.id, title: v.title, sku: v.sku})|json_encode|raw }} }); {% endjs %} {% endif %}