Hi @ashour
There isn’t anything in this plugin’s code that assigned a value of “undefined” to the address fields. “Undefined” usually indicates a value is being changed by Javascript on your checkout page.
I’d recommend checking other plugins that you have installed to see if they are causing that behavior. I have seen where cache plugins can cause that behavior.
Kind Regards,
Thread Starter
ashour
(@ashour)
Hi,
hmm… It doesn’t happen with the “Paypal Standard” gateway but happens with yours!
Can you please double check?
Regards!
Hi @ashour
hmm… It doesn’t happen with the “Paypal Standard” gateway but happens with yours!
We have a lot of merchants using this plugin and if it was a widespread issue with the plugin we’d be getting a lot of reports. I am also not able to reproduce your described issue on our development site.
Can you share a website url where this can be re-created? If the website can be placed in sandbox mode that’s the best for testing purposes.
Thanks,
Thread Starter
ashour
(@ashour)
Ok, It seems I had to check it myself in order to believe me :D.
here is the problem:
pymntpl-paypal-woocommerce/src/AjaxFrontendHandler.php : 50 ( private function get_update_data() )
You guys filter the checkout posted data. the problem is you hardcode these fields instead of using get_checkout_fields() function. specifically inside the condition ( if ( Utils::is_valid_address( $address ) ) { ) : line 72
It will work with “a lot of merchants” because they use the default fields as it is, but If someone like me don’t need some of these fields, It will fail like in “screenshots attached” with “undefined” value which is set by your plugin.
Kind Regards!
Hi @ashour
You guys filter the checkout posted data. the problem is you hardcode these fields instead of using get_checkout_fields() function. specifically inside the condition ( if ( Utils::is_valid_address( $address ) ) { ) : line 72
We don’t hardcode the fields, we map the Payer’s address to the $data associative array. Using the WC_Checkout::get_checkout_fields function wouldn’t make sense in that section of code.
It will work with “a lot of merchants” because they use the default fields as it is, but If someone like me don’t need some of these fields, It will fail like in “screenshots attached” with “undefined” value which is set by your plugin.
Can you please elaborate on what you mean by “don’t need some of these fields”. Are you removing WooCommerce Checkout fields using filters so they aren’t visible on the checkout page? If so, what fields exactly?
I would need to have you explain what your setup is to try and re-create what you’re describing.
Thanks
Thread Starter
ashour
(@ashour)
I use woocommerce_checkout_fields filter in order to remove checkout billing fields that I don’t need.
So, for example If you removed the “postal code” field using this filter. Your plugin will force setting it in the function mentioned above using this line:$data["{$prefix}postcode"] = $address->getPostalCode();
which returns undefined in this case because the field doesn’t exist in the submitted fields.
After debugging, the issue is caused because of the following reasons:
- When you unset a field using filter
woocommerce_checkout_fields, that doesn’t prevent WooCommerce from calling$('#billing_state).val(),$('#billing_address_1).val()etc when theupdate_order_reviewevent is triggered on the checkout page. - As a result, the
$_POSTobject is populated with values ofundefinedbecause anytime jQuery is used to fetch an element value that doesn’t exist, it returns “undefined”. - This results in WooCommerce populating the
WC_Customerobject with values of “undefined” in theWC_Ajax::update_order_reviewfunction. - When the order is submitted, the
Utils::is_valid_address( $address )line of code returns true in classAjaxFrontendHandlerbecause all of the address fields have a valid string value of “undefined” which has a string length greater than one.
We will have to make a change to account for the fact that WooCommerce sends a value of “undefined” to the server even when the field doesn’t exist and “undefined” is a legitimate string.
Thanks
You can use our contact us page if you want to use the updated version.
