I defined a table rates like that:
ESP,*,*,1.0000,0.0000
ESP,Ceuta,*,1.0000,15.0000
ESP,Ceuta,*,2.0000,20.0000
...
The functionality is working correctly. But I don't like the user experience on checkout, because the default country is Spain but nothing else is filled, so on the shipping methods displays no method. Then when the user fills the form, it finally displays a shipping method depends on what region/zip code especified.
I want, by default, display the 0€ shipping method, because it's selected Spain. Then if the user chooses Ceuta it will display the 15€.
Is it possible to do that?
PS: I tried to trigger the estimate-shipping-methods JS function, on the change event for country dropdown... but I did not know how to do it, and neither know if it would work.
Tried to do something like that:
require([
'jquery',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/shipping-rate-registry',
'Magento_Checkout/js/model/shipping-rate-processor/new-address'
], function($, quote, rateRegistry, newAddressProcessor) {
var address = quote.shippingAddress();
console.log('address', address);
rateRegistry.set(address.getCacheKey(), null);
newAddressProcessor.getRates(address);
});