country from Adres not correct
-
Hi,
When I select another country and I click on request shipping quote it still shows the previous country selected and not the current one, on the checkout page.
The page I need help with: [log in to see the link]
-
Hi @joel2019 ,
Thank you for giving feedback. The address field is prefilled for logged-in users. Users should update this field before requesting a shipping quote. This field will not update depending on the checkout fields. But the address field will update automatically if the user updates his/her shipping address and reloads the site.
Thanks,
ReponHi Repon,
Can you please clarify what you mean by ‘Users should update this field before requesting a shipping quote’?
I guess you mean users should change the value, since there is no button to update the data like there is on the cart for example.
A user will never refresh that page. It’s not logical to refresh the cart. Especially without being prompted to do so. We already had some issues with people removing the country when they where asking for a shipping quote.
If the shipping country and billing country is different, the billing country is used unless you refresh the page. After refreshing, the shipping country is indeed selected, but this is way too elaborate to be user-friendly.
Since the WooCommerce cart is using AJAX to update its fields, I feel there is no other option than using AJAX to update the selected value as well.
Cheers,
Joel
Actually the address field is not dynamic field. User need to enter shipping address manually.
You lost me now. I don’t get why you are reffering to dynamic fields.
Our issue is when new users (not logged on users) fill out their address and request a quote, the data isn’t passed to the popup screen where the actual request is being made.
Can I send you some screenshots to clarify?
Let me know after checking the new version. I added a feature to use the shipping address from the checkout page. Now customers don’t need to enter the shipping address of the popup form.
Thanks,
Hi Repon,
Thanks again for your swift reply.
Sadly, your solution isn’t working for us.
We are using an autocomplete plugin for addresses: https://www.ads-software.com/plugins/autocomplete-address-and-location-picker-for-woocommerce/
We updated the plugin, but now it only passes the part of the address you actually typed, not the autocompleted address.
To clarify. When your address is ‘Bay Ridge av’ in New York. The autocomplete plugin will offer you the completed address when you type ‘Bay Ri’ and autofills the address field when you click it.
After, when you ask for the shipping quote, only the part you actually typed (in the above example ‘Bay Ri’) is being passed to the popup.
I wrote a script myself last week to fix our issue.
The below script passes the complete information after you click the ‘ask a shipping quote’ button.
<script> jQuery(function($) { // Function to update fields based on the checkbox state function updateFieldsBasedOnShippingAddress() { // Check the checked state of the 'ship_to_different_address' checkbox var useBillingData = !$('#ship-to-different-address-checkbox').prop('checked'); // Determine which dataset (billing or shipping) to use var dataSet = useBillingData ? 'billing' : 'shipping'; // Map the field IDs for the selected dataset var fieldIds = { firstName:
#${dataSet}_first_name
, lastName:#${dataSet}_last_name
, street:#${dataSet}_address_1
, city:#${dataSet}_city
, postcode:#${dataSet}_postcode
, country:#${dataSet}_country
, email: '#billing_email', // Always use billing email phone: '#billing_phone' // Always use billing phone }; // Gather values from the selected dataset var firstName = $(fieldIds.firstName).val(); var lastName = $(fieldIds.lastName).val(); var street = $(fieldIds.street).val(); var city = $(fieldIds.city).val(); var postcode = $(fieldIds.postcode).val(); var country = $(fieldIds.country).find('option:selected').text(); var email = $(fieldIds.email).val(); var phone = $(fieldIds.phone).val(); // Update the target form fields with the gathered values $('#request-quote-form-field-first-name').val(firstName); $('#request-quote-form-field-last-name').val(lastName); $('#request-quote-form-field-email').val(email); $('#request-quote-form-field-phone-no').val(phone); $('#request-quote-form-field-address').val(${street}\n${postcode} ${city}\n${country}
); } // Execute the update function when the page loads updateFieldsBasedOnShippingAddress(); // Attach a change event handler to the 'ship_to_different_address' checkbox $('#ship-to-different-address-checkbox').on('change', function() { updateFieldsBasedOnShippingAddress(); // Update fields when checkbox state changes }); // Attach a change event handler to relevant input fields for billing and shipping data $('#billing_first_name, #billing_last_name, #billing_address_1, #billing_city, #billing_postcode, #billing_country, #shipping_first_name, #shipping_last_name, #shipping_address_1, #shipping_city, #shipping_postcode, #shipping_country').on('change', function() { updateFieldsBasedOnShippingAddress(); // Update fields when input values change }); // Attach a click event handler to elements with the class 'freight-shipping-quote-request-button' $('.freight-shipping-quote-request-button').on('click', function(e) { e.preventDefault(); // Prevent default click behavior // Execute a final update before using the form data (optional, depending on timing) updateFieldsBasedOnShippingAddress(); // Gather values from the form fields for AJAX submission var requestData = { firstName: $('#request-quote-form-field-first-name').val(), lastName: $('#request-quote-form-field-last-name').val(), email: $('#request-quote-form-field-email').val(), phone: $('#request-quote-form-field-phone-no').val(), address: $('#request-quote-form-field-address').val() }; }); }); </script>Thank you for your message. I have understood what you wanted to say. I’ll install the plugin and fix the problem soon.
Hi @joel2019 ,
Here, I wrote some information. I shared only for one time. I can not share that information publicly.
https://privnote.com/kZ6mJ9vl#jP2eJcgfSPlease read it and let me know.
- The topic ‘country from Adres not correct’ is closed to new replies.