Error: User status is required!
-
Hello,
On the WooCommerce order page, I’am getting message ‘Error: User status is required!’;
I searched for where the problem could come from…1 – This hook adds extra fields in checkout page:
add_filter( 'woocommerce_checkout_fields', array( $mangopayWCMain, 'custom_override_checkout_fields' ), 99999 );
In the method custom_override_checkout_fields, we can see that user_mp_status field is not added if all buyers are either and if user meta exists (that’s my case).if('either' == $this->options['default_buyer_status']): if(!get_user_meta( get_current_user_id(), 'user_mp_status', true )): $fields = $this->add_usermpstatus_field($fields); endif; endif;
2 – This hook validates extra fields in the checkout page:
add_action( 'woocommerce_checkout_process', array( $mangopayWCMain, 'wooc_validate_extra_register_fields_checkout' ));
The method wooc_validate_extra_register_fields_checkout calls validate_status method.3 – The method validate_status displays error on my WooCommerce order page because there is no ‘user_mp_status’ field and no ‘user_id’ field in the checkout form.
//get the data $isset = false; $value = false; if(isset($data['data_post']['user_mp_status'])): /* THERE IS NO 'user_mp_status' FIELD IN CHECKOUT FORM : $isset = false */ $value = $data['data_post']['user_mp_status']; $isset = true; endif; //in case of edition $user_to_test = false; if(isset($data['data_post']['user_id'])): /* THERE IS NO 'user_id' FIELD IN CHECKOUT FORM : $user_to_test = false */ $user_to_test = get_user_meta( $data['data_post']['user_id'], 'user_mp_status', true ); endif; if(!$isset && !$user_to_test): //error $data['message'][] = __( 'User status', 'mangopay' ); $data['message'][] = __( 'is required!', 'mangopay' ); /* DISPLAYS ERROR ON WOOCOMMERCE ORDER PAGE */ $this->send_message_format($data); return; endif;
4 – My solution: adding this code in theme function.php file
if ( get_user_meta( get_current_user_id(), 'user_mp_status', true ) ) add_filter( 'woocommerce_checkout_fields', 'user_mp_status_checkout_field', 99999 ); function user_mp_status_checkout_field( $fields ) { $fields['billing']['user_mp_status'] = array( 'type' => 'text', 'value' => get_user_meta( get_current_user_id(), 'user_mp_status', true ), 'class' => array('hidden'), ); return $fields; }
Can you confirm if that is a bug or a misconfiguration? If this is a bug, will it be corrected to the next update?
My Mangopay settings:
All buyers are either
All vendors are either
All businesses are eitherMy Mangopay status:
Current environment: Sandbox
Client ID: Present!
Passphrase: Present!
MANGOPAY API Connection: Success!
MANGOPAY-WooCommerce plugin version: 2.2.1
Required WooCommerce plugin present & activated: Success!
WooCommerce plugin version: 3.0.8
MANGOPAY enabled as a WooCommerce payment gateway: Enabled
At least one card type or payment method is enabled: Success!
WooCommerce guest checkout should be disabled Disabled
Current WooCommerce currency is supported by MANGOPAY: EUR Supported
Required WC-Vendors plugin present & activated: Success!
WC-Vendors plugin version: 1.9.11
PHP mcrypt library available: Success!
Keyfile directory is writable: Success!
Temporary directory is writable: Success!
All active vendors have a MANGOPAY account: Success!Other plugins:
WooCommerce Bookings
WC Vendors WooCommerce Bookings
- The topic ‘Error: User status is required!’ is closed to new replies.