Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erro: Campo "Distric" não pode ficar em branco #3

Open
v-verner opened this issue Jun 8, 2022 · 0 comments
Open

Erro: Campo "Distric" não pode ficar em branco #3

v-verner opened this issue Jun 8, 2022 · 0 comments

Comments

@v-verner
Copy link

v-verner commented Jun 8, 2022

Utilizando o WooCommerce Subscriptions, ao tentar realizar o pagamento via cartão de crédito a API retorna o erro abaixo na request ao endpoint "customers"

{"errors":{"district":["n\u00e3o pode ficar em branco"]}}

//=============

Como medida palhativa implementamos um filtro para preencher a informação, mas acredito que seja de rápida implementação no código original do plugin, Filtro abaixo:

add_filter('iugu_woocommerce_customer_data', function( array $data = [] ){
if (!isset($data['district'])) :
$user = isset($data['email']) && $data['email'] ? get_user_by('email', $data['email']) : false;

	if ($user) : 
		$customer = new WC_Customer( $user->ID );
		$district = $customer->get_meta('billing_neighborhood') ? $customer->get_meta('billing_neighborhood') : $customer->get_meta('_billing_neighborhood');
		$data['district'] = $district;
	endif;
endif;

return $data;

});

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

No branches or pull requests

1 participant