Skip to content

Trigger a country select change on initial load#21733

Merged
claudiulodro merged 1 commit intomasterfrom
fix/21642
Oct 30, 2018
Merged

Trigger a country select change on initial load#21733
claudiulodro merged 1 commit intomasterfrom
fix/21642

Conversation

@kloon
Copy link
Copy Markdown
Contributor

@kloon kloon commented Oct 29, 2018

All Submissions:

Changes proposed in this Pull Request:

This PR fixes an issue where the address-i18n.js was not firing on initial page loads due to it only being tied to the country on change event causing priority and other local info to be missing.

To remedy this I simply trigger an onchange event on page load to ensure it fires and apply the correct locale info.

Closes #21642

How to test the changes in this Pull Request:

  1. Add the following code to your theme's functions.php file
add_filter("woocommerce_checkout_fields", "custom_override_checkout_fields", 1 );
function custom_override_checkout_fields($fields) {
	$fields['billing']['billing_email']['priority'] = 1;
	return $fields;
}
  1. Add something to cart and load the checkout page.
  2. Ensure the email field is displayed right at the top.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Changelog entry

Fix - Address locale info was not being applied on checkout on initial page load.

Copy link
Copy Markdown
Contributor

@claudiulodro claudiulodro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me and works well. Other than whitespace, the only real difference is the addition of $( '#billing_country' ).trigger( 'change' );, correct? Just want to make sure I didn't miss anything when comparing the diffs.

@kloon
Copy link
Copy Markdown
Contributor Author

kloon commented Oct 30, 2018

Yes, that line is the actual fix. I had to fix a bunch of linting errors as well as it was failing hence all the other indentation fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3.5.0 custom fields on the checkout page are not sorted by attribute data-priority

2 participants