AdminOrderCreationPlugin icon indicating copy to clipboard operation
AdminOrderCreationPlugin copied to clipboard

Missing province when create order

Open hmonglee opened this issue 7 years ago • 4 comments

When I create an order, I have a form error, there is no province for shipping and billing address

hmonglee avatar Nov 22 '18 22:11 hmonglee

Could you, please, provide any more details? What exactly data you're passing? What is your store configuration?

Zales0123 avatar Nov 26 '18 07:11 Zales0123

I face the same issue. missing province field on addresses.

jcgdjob avatar Feb 06 '20 05:02 jcgdjob

I faced the same issue here is what I have done to make it work: I'm using symfony encore/webpack workflow

Override the form template to use the @SyliusAdmin/Common/Form/_address.html.twig template for addresses forms

// templates/bundles/SyliusAdminOrderCreationPlugin/Order/Create/_form.html.twig
<div class="ui segment">
    {{ form_start(form, {'action': action, 'attr': {'class': 'ui loadable form', 'novalidate': 'novalidate'}}) }}

    <div class="ui styled fluid accordion">
        <div class="title active">
            <i class="dropdown icon"></i> {{ 'sylius.ui.items'|trans }}
        </div>
        <div id="items" class="content active">
            {{ form_row(form.items) }}
        </div>

        <div class="title">
            <i class="dropdown icon"></i> {{ 'sylius.ui.shipping_address'|trans }} &amp; {{ 'sylius.ui.billing_address'|trans }}
        </div>
        <div class="content">
            <div class="ui horizontal segments">
                <div class="ui segment">
                    {% include '@SyliusAdmin/Common/Form/_address.html.twig' with {'form': form.shippingAddress} %}
                </div>
                <div class="ui segment">
                    {% include '@SyliusAdmin/Common/Form/_address.html.twig' with {'form': form.billingAddress} %}
                </div>
            </div>
        </div>

        <div id="localeTab" class="title">
            <i class="dropdown icon"></i> {{ 'sylius.ui.locale'|trans }} & {{ 'sylius.ui.currency'|trans }}
        </div>
        <div id="locale" class="content">
            <div class="ui horizontal segments">
                <div class="ui segment">{{ form_row(form.localeCode) }}</div>
                <div class="ui segment">{{ form_row(form.currencyCode) }}</div>
            </div>
        </div>

        <div id="shipmentsAndPaymentsTab" class="title">
            <i class="dropdown icon"></i> {{ 'sylius.ui.shipments'|trans }} &amp; {{ 'sylius.ui.payments'|trans }}
        </div>
        <div id="shipmentsAndPayments" class="content">
            <div class="ui segments">
                <div class="ui segment">
                    <div class="invalid-data-message">{{ 'sylius_admin_order_creation.ui.shipping_methods_selection_requirement'|trans }}</div>
                    {{ form_row(form.shipments) }}
                </div>
                <div class="ui segment">
                    {{ form_row(form.payments) }}
                </div>
            </div>
        </div>
    </div>

    {% include '@SyliusUi/Form/Buttons/_create.html.twig' with {'paths': {'cancel': path('sylius_admin_order_index')}} %}

    {{ form_row(form._token) }}
    {{ form_end(form, {'render_rest': false}) }}
</div>

Import sylius province field

// assets/admin/entry.js
import 'sylius/bundle/AdminBundle/Resources/private/entry';
import 'sylius/bundle/ShopBundle/Resources/private/js/sylius-province-field';
if ($('form[name=sylius_admin_order_creation_new_order]').length > 0) {
  $(document).provinceField();
}

@Zales0123 do you think that this should be added as PR or just mentioned in the doc?

htaoufikallah avatar Sep 20 '20 03:09 htaoufikallah

Still facing the bug. If I choose a country on billing/shipping which have more than one province, it will not ask the user to choose a province, so after submitting the form, we got the error message "Please choose a province" but we're not able anymore to do it.

Loocos avatar Apr 12 '23 15:04 Loocos