<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <!-- Calle en 4 líneas como la PWA: tipo de vía (select) / calle / número / resto.
         Chile: ciudad como desplegable de comunas de la región -->
    <type name="Hyva\Checkout\Model\Form\EntityForm\EavAttributeShippingAddressForm">
        <arguments>
            <argument name="entityFormModifiers" xsi:type="array">
                <item name="elg_street" sortOrder="550" xsi:type="object">Yeboyebo\CheckoutShopify\Model\Form\EntityFormModifier\WithElgStreetModifier</item>
                <item name="elg_chile_city" sortOrder="560" xsi:type="object">Yeboyebo\CheckoutShopify\Model\Form\EntityFormModifier\WithElgChileCityModifier</item>
            </argument>
        </arguments>
    </type>
    <type name="Hyva\Checkout\Model\Form\EntityForm\EavAttributeBillingAddressForm">
        <arguments>
            <argument name="entityFormModifiers" xsi:type="array">
                <item name="elg_street" sortOrder="550" xsi:type="object">Yeboyebo\CheckoutShopify\Model\Form\EntityFormModifier\WithElgStreetModifier</item>
                <item name="elg_chile_city" sortOrder="560" xsi:type="object">Yeboyebo\CheckoutShopify\Model\Form\EntityFormModifier\WithElgChileCityModifier</item>
            </argument>
        </arguments>
    </type>
    <!-- Invitado: al guardar el email se recalculan los totales (reglas que dependen del email); el envío
         inmediato del email lo hace Yeboyebo_CheckoutShopify::checkout/email-invitado.phtml -->
    <type name="Hyva\Checkout\Magewire\Checkout\GuestDetails">
        <plugin name="elg_recalcular_totales_email_invitado" type="Yeboyebo\CheckoutShopify\Plugin\Hyva\RecalcularTotalesEmailInvitadoPlugin"/>
    </type>
    <!-- Invitado: un email que Magento no acepta no se guarda en el carrito (si no, salía el popup de error) -->
    <!-- Recogida: sin la casilla "facturación igual que envío" -->
    <type name="Hyva\Checkout\ViewModel\Checkout\AddressView">
        <plugin name="elg_pickup_sin_casilla_misma_direccion"
                type="Yeboyebo\CheckoutShopify\Plugin\Hyva\PickupSinCasillaMismaDireccionPlugin"/>
    </type>
    <type name="Hyva\Checkout\Model\Form\EntityFormSaveService\GuestDetails">
        <plugin name="elg_no_guardar_email_invitado_invalido" type="Yeboyebo\CheckoutShopify\Plugin\Hyva\NoGuardarEmailInvitadoInvalidoPlugin"/>
    </type>
</config>
