I am facing an issue where I need to set #billing-postcode to a specific value using a JS script.
When I input jQuery('#billing-postcode').val('2222') on the checkout page, the input displays the value 2222 with the Postcode label above it. However, clicking on the postcode input clears the value.
I attempted adding the is-active class to the parent element, which resolved the problem of displaying the label above the field value, but clicking on the input still resulted in the value being cleared.
Upon checking the DOM, I noticed that no value was set, so I added the attribute value with 2222, and this time, the value remained.
The issue persists as submitting the form empties the postcode field, causing the value to be lost.
I also tried posting to /wp-json/wc/store/v1/batch?_locale=user, path /wc/store/v1/cart/update-customer, which maintained the value upon refresh. However, modifying the value from the console caused it to flicker between the old and new values.
[UPDATE] Disabling all event listeners on input fields resolved the issue, but created new problems such as live validation not working and countries dropdown malfunctioning.
Has anyone encountered this problem and discovered a solution?
**In a clean WP installation without additional plugins and using the default theme, the field value remains unfilled.**
- Adding is-active class to the parent
- Posting value to /wp-json/wc/store/v1/batch?_locale=user
- Removing all event listeners
- Setting the value via attribute