Vendic / hyva-checkout-google-address-autocomplete

Hyvä checkout compatibility module for vendic/magento2-google-address-autocomplete
MIT License
9 stars 4 forks source link

Too many requests #8

Closed pjw345 closed 11 months ago

pjw345 commented 11 months ago

We had a quota set to 10 request per user per minute and we've now set that to 100 requests per user per minute (Google Places), yet after typing in about half of the address we'd start getting errors in the console

You have exceeded your rate-limit for this API. For more information on usage limits and the Google Maps JavaScript API services please see: https://developers.google.com/maps/documentation/javascript/usage

Can you confirm you are using the Google Places and how many requests per address lookup are you actually performing?

Tjitse-E commented 11 months ago

Are you sure you've entered your billing details at Google? I didn't had this error myself and we're actively using this module in production.

pjw345 commented 11 months ago

I am going to repeat the testing and document the steps 1) install the module via composer, setup:upgrade et al 2) uninstall Mirasvit - Google Tag Manager (as it creates livewire: multiple root elements) 3) uninstall Fetchify - does not work with Hyva Checkout 4) Store -> Configuration -> Vendic -> Google Autocomplete -> API Key 5) Store -> Configuration -> Hyva Themes -> Hyva One Page 6) Store -> Configuration -> Hyva Themes -> Checkout -> Shipping Address Forms company - 100% street.0 - 100% street.1 - 100% city - 50% region - 50% postcode - 50% county_id - 100%

With that set and having previously set the limit to 100 requests, I am now not getting the too many requests error in the console, however the city is not being populated and the State/Province (shows England instead of the county, ie Cheshire)

pjw345 commented 11 months ago

Add just to complete this issue I have now created a module create our own frontend/di.xml for those wanting to use this in the UK the following might be useful information

<type name="Vendic\HyvaCheckoutGoogleAddressAutocomplete\ViewModel\FieldMapping">
    <arguments>
        <argument name="fieldMapping" xsi:type="array">
            <!-- in this case, route is street name key from the API response, it's mapped to the input street.0 -->
            <item name="street_address" xsi:type="string">street.0</item>
            <item name="company" xsi:type="string">company</item>
            <item name="postal_town" xsi:type="string">city</item>
            <item name="postal_code" xsi:type="string">postcode</item>
            <item name="administrative_area_level_2" xsi:type="string">region</item>
            <item name="country" xsi:type="string">country_id</item>
        </argument>
    </arguments>
</type>
Tjitse-E commented 11 months ago

@pjw345 does it make sense to use that mapping in the main module? Did you test if it also works for other countries?

Also are the request limits resolved?

pjw345 commented 11 months ago

To be honest I have only tested this for UK addresses and not any other international addresses.

With regards to address lookups and address format each country is dealt differently. Other packages use the Royalmail PAF file which has a fixed address format and hence makes UK based address lookups "easier".

And yes, setting the limit to 100 requests has resolved the too many request issue, previously set to 10 requests was obviously too low for it to work properly.

On a side note, any intention of expanding this out into the admin area, sales order, customer address, etc?