{% extends "vend/_layouts/settings" %} {% import "_includes/forms" as forms %} {% from "vend/_includes/macros.html" import configWarning %} {% block content %} {% if oauthAppMissing %}

You are not connected to Vend, please connect to your Vend store first.

{% elseif not oauthToken or not oauthProvider %}

Your OAuth app needs a token generating, you can do this here.

{% endif %} {% if not oauthAppMissing and oauthToken and oauthProvider %}

{{ "Shipping Settings"|t('vend') }}

{{ redirectInput('vend/settings/shipping') }} {{ csrfInput() }} {% set params = { label: 'Shipping Product Type'|t, instructions: 'Choose the Vend Product Type that contains your shipping products.'|t, id: 'shippingMap-productType', name: 'shippingMap[productType]', options: vendProductTypes, value: settings.shippingMap and settings.shippingMap.productType is defined ? settings.shippingMap.productType : null, required: true, } %} {% set input %} {{ forms.select(params) }} {% endset %} {{ forms.field(params, input) }}
{% endif %} {% endblock %} {% js %} var $productTypeInput = $("#shippingMap-productType"), $spinner = $('#vendShippingProductType-spinner'), $shippingMapFields = $('#shippingMapFields'); $productTypeInput.change(function(e) { var typeId = $(this).val(); $spinner.removeClass('hidden'); var data = { 'typeId': typeId }; Craft.postActionRequest('vend/settings/get-shipping-products', data, function(response, textStatus) { $spinner.addClass('hidden'); if (textStatus === 'success') { $.each($shippingMapFields.find('.field.products'), function(index, field) { var $select = $(field).find('select'); $select.html(''); $(field).parents('tr').find('td.price').text(''); for (var i = 0; i < response.products.length; i++) { $('').appendTo($select); } }); $shippingMapFields.removeClass('hidden'); } }); }); {% endjs %}