Consultar carrinhos abandonados na API Magento 2

Como consultar os carrinhos abandonados pela API do Magento 2

https://wwww.sualoja.com.br/rest/V1/carts/search?searchCriteria[filter_groups][0][filters][0][field]=is_active&searchCriteria[filter_groups][0][filters][0][value]=1&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&searchCriteria[pageSize]=10&searchCriteria[filter_groups][1][filters][0][field]=store_id&searchCriteria[filter_groups][1][filters][0][value]=0&searchCriteria[filter_groups][1][filters][0][condition_type]=neq&searchCriteria[filter_groups][2][filters][0][field]=items_count&searchCriteria[filter_groups][2][filters][0][value]=0&searchCriteria[filter_groups][2][filters][0][condition_type]=gt&searchCriteria[filter_groups][3][filters][0][field]=customer_id&searchCriteria[filter_groups][3][filters][0][value]=null&searchCriteria[filter_groups][3][filters][0][condition_type]=neq&searchCriteria[sortOrders][0][field]=updated_at&searchCriteria[sortOrders][0][direction]=DESC

Execute a consulta acima no Postman,

carrinhos abandonados na API do Magento 2

Obviamente e necessário configurar o Bearer Token antes..

Exemplo PHP Curl:

$requestUrl='https://www.sualoja.com.br/rest/V1/carts/search?searchCriteria[filter_groups][0][filters][0][field]=is_active&searchCriteria[filter_groups][0][filters][0][value]=1&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&searchCriteria[pageSize]=10&searchCriteria[filter_groups][1][filters][0][field]=store_id&searchCriteria[filter_groups][1][filters][0][value]=0&searchCriteria[filter_groups][1][filters][0][condition_type]=neq&searchCriteria[filter_groups][2][filters][0][field]=items_count&searchCriteria[filter_groups][2][filters][0][value]=0&searchCriteria[filter_groups][2][filters][0][condition_type]=gt&searchCriteria[filter_groups][3][filters][0][field]=customer_id&searchCriteria[filter_groups][3][filters][0][value]=null&searchCriteria[filter_groups][3][filters][0][condition_type]=neq&searchCriteria[sortOrders][0][field]=updated_at&searchCriteria[sortOrders][0][direction]=DESC';


$ch = curl_init();
$ch = curl_init($requestUrl); 

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   

$result = curl_exec($ch);

$result=  json_decode($result);

echo "CARTS: " . sizeof( $result->items ) . PHP_EOL;

foreach($result->items as $quote){
/* Seu código ... */
}

Dúvidas? Faça um comentário logo abaixo ou envie uma mensagem clicando aqui.

O seu endereço de e-mail não será publicado.