woocommerce-extra-checkout-fields-for-brazil icon indicating copy to clipboard operation
woocommerce-extra-checkout-fields-for-brazil copied to clipboard

Preenchimento de campos via API

Open andremorganti opened this issue 3 years ago • 5 comments

Olá, estou fazendo a migração de um loja proprietária para o woocommerce, como consigo enviar os campos brasileiros como CPF, CNPJ entre outros via API?

Obrigado André

andremorganti avatar May 03 '21 13:05 andremorganti

Aí é na API do próprio WP, vc fará a inserção nos campos criados por esse plugin normalmente

danilowm avatar Aug 25 '21 22:08 danilowm

estou tentando enviar via META DATA mas sem sucesso.

billing_cpf cpf _billing_cpf

fhferreira avatar Oct 12 '21 17:10 fhferreira

$wc_data = [ 'email' => '', 'first_name' => '', 'last_name' => '', 'username' => '', 'password' => 'texto plano', 'billing' => [ 'first_name' => '', 'last_name' => '', 'company' => '', 'address_1' => '', 'address_2' => '', 'city' => '', 'state' => '', 'postcode' => '', 'country' => 'BR', 'email' => '', 'phone' => '', ], 'meta_data' => [ [ 'key' => 'billing_persontype', 'value' => 2 // 2 = PF (CPF) ], [ 'key' => 'billing_cpf', 'value' => '00000000000', ], [ 'key' => '_billing_cpf', 'value' => '00000000000', ], [ 'key' => '_billing_persontype', 'value' => 2 // 2 = PF (CPF) ], [ 'key' => 'cpf', 'value' => '00000000000', ], [ 'id' => 3931, 'key' => 'billing_cpf', 'value' => '00000000000', ], ], 'shipping' => [ 'first_name' => '', 'last_name' => '', 'company' => '', 'address_1' => '', 'address_2' => '', 'city' => '', 'state' => '', 'postcode' => '', 'country' => 'BR' ] ]; //print_r($woocommerce->post('customers', $wc_data)); $resp_woocommerce = $woocommerce->post('customers', $wc_data);

	tentei todos os formatos no meta_data mas continua sem exibir.
	
	

image image

fhferreira avatar Oct 12 '21 18:10 fhferreira

tenta com o update_post_meta

update_post_meta($order->id, '_billing_cpf', '0000000');

danilowm avatar Oct 13 '21 15:10 danilowm

consegui via API @danilowm obrigado.

$order['meta_data'] = [['key' => '_billing_cpf', value = 'cpf']];

no endpoint /orders

fhferreira avatar Oct 15 '21 00:10 fhferreira