mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
Merge pull request #1510 from woocommerce/PCP-1873-complex-form-fields
Handle complex form fields when submitting checkout form
This commit is contained in:
commit
24a40a283c
4 changed files with 29 additions and 15 deletions
|
@ -50,8 +50,6 @@ class CheckoutActionHandler {
|
|||
|
||||
const formSelector = this.config.context === 'checkout' ? 'form.checkout' : 'form#order_review';
|
||||
const formData = new FormData(document.querySelector(formSelector));
|
||||
// will not handle fields with multiple values (checkboxes, <select multiple>), but we do not care about this here
|
||||
const formJsonObj = Object.fromEntries(formData.entries());
|
||||
|
||||
const createaccount = jQuery('#createaccount').is(":checked") ? true : false;
|
||||
|
||||
|
@ -72,7 +70,8 @@ class CheckoutActionHandler {
|
|||
order_id:this.config.order_id,
|
||||
payment_method: paymentMethod,
|
||||
funding_source: fundingSource,
|
||||
form: formJsonObj,
|
||||
// send as urlencoded string to handle complex fields via PHP functions the same as normal form submit
|
||||
form_encoded: new URLSearchParams(formData).toString(),
|
||||
createaccount: createaccount
|
||||
})
|
||||
}).then(function (res) {
|
||||
|
|
|
@ -6,7 +6,6 @@ export default class FormValidator {
|
|||
|
||||
async validate(form) {
|
||||
const formData = new FormData(form);
|
||||
const formJsonObj = Object.fromEntries(formData.entries());
|
||||
|
||||
const res = await fetch(this.url, {
|
||||
method: 'POST',
|
||||
|
@ -16,7 +15,7 @@ export default class FormValidator {
|
|||
credentials: 'same-origin',
|
||||
body: JSON.stringify({
|
||||
nonce: this.nonce,
|
||||
form: formJsonObj,
|
||||
form_encoded: new URLSearchParams(formData).toString(),
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue