{% extends "_market/_layouts/main" %} {% set currentVendor = market.vendors.getCurrentVendor() %} {% set vendorSettings = market.plugin.getVendorSettings().getSettings() %} {% set shippingZones = craft.commerce.getShippingZones().getAllShippingZones() %} {% set currentCurrency = craft.commerce.getPaymentCurrencies().primaryPaymentCurrency %} {% set site = craft.app.getSites().currentSite %} {% set title = 'Create new shipping profile'|t('market') %} {% if profileId is defined and profileId != null %} {% if shippingProfile is not defined %} {% set shippingProfile = market.plugin.shippingProfiles.getShippingProfileById(profileId) %} {% endif %} {% if not shippingProfile %}{% exit 404 %}{% endif %} {% set title = shippingProfile.name %} {% elseif shippingProfile is not defined %} {% set shippingProfile = create({ class: 'angellco\\market\\models\\ShippingProfile', vendorId: currentVendor.id }) %} {% endif %} {% set breadcrumbs = [ { url: url('market/shipping'), label: 'Shipping'|t('market') }, { url: craft.app.request.getUrl, label: title } ] %} {% block content %}
{{ csrfInput() }} {{ actionInput('market/shipping/save-shipping-profile') }} {% if shippingProfile is defined and shippingProfile.id %}{{ hiddenInput('profileId', shippingProfile.id) }}{% endif %} {{ hiddenInput('vendorId', currentVendor.id) }} {{ hiddenInput('originCountryId', vendorSettings.shippingOriginId) }}
{# Header #}

{{ title }}

{# Actions #}
{# Save #}
{# Main #}
{# Left col #}
{# Name #}

{{ 'What this shipping profile will be called, this will be seen by customers during checkout.'|t('market') }}

{# Processing Time #}

{{ 'How long it takes you to ship this item.'|t('market') }}

{# Right col #}
{% set generalDestinationErrors = shippingProfile.getErrors('shippingDestinations') %}
{% if generalDestinationErrors %}
{% for error in generalDestinationErrors %}

{{ error }}

{% endfor %}
{# Heroicon name: solid/exclamation-circle #}
{% endif %}

{{ 'Add a shipping cost for each destination you ship to.'|t('market') }}

{% set count = 0 %} {% for destination in shippingProfile.getShippingDestinations() %} {% if destination.id %} {% set destinationKey = destination.id %} {% else %} {% set count = count + 1 %} {% set destinationKey = 'new'~count %} {% endif %} {% set destinationErrors = destination.getErrors() %}
{% if destinationErrors %} {% endif %} {% include '_market/_includes/shipping-destination-block.html' %}
{% endfor %}
{{ sprig('_market/_components/add-destination', { startingCount: shippingProfile.getShippingDestinations()|length, _limit: shippingZones|length }, { 'id': 'add-destinations', 'class': 'mt-6' }) }}
{# Delete action #} {% if shippingProfile.id %}
{{ sprig('_market/_components/delete-shipping-profile', { _profileId: shippingProfile.id }) }}
{% endif %}
{% endblock %}