Productos relacionados
$390.00
$340.00
$4,400.00
$390.00
$150.00
$390.00
// Función para obtener la cotización de la API de Pakke function pakke_get_shipping_quote($zipcode_from, $zipcode_to, $weight, $length, $width, $height, $api_key) { $url = 'https://seller.pakke.mx/api/v1/Shipments/rates'; $data = array( 'ZipCodeFrom' => $zipcode_from, 'ZipCodeTo' => $zipcode_to, 'Parcel' => array( 'Weight' => $weight, 'Length' => $length, 'Width' => $width, 'Height' => $height ) ); $args = array( 'headers' => array( 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'Authorization' => $api_key ), 'body' => json_encode($data) ); $response = wp_remote_post($url, $args); if (is_wp_error($response)) { return new WP_Error('api_error', 'Error al conectar con la API de Pakke: ' . $response->get_error_message()); } $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); // Registrar la respuesta en los logs del servidor para depuración error_log('Respuesta API de Pakke: ' . print_r($data, true)); // También enviar esta información como un log si es necesario if (isset($data['error'])) { return new WP_Error('api_error', 'Error en la API de Pakke: ' . $data['error']['message']); } if (empty($data)) { return new WP_Error('api_error', 'La API de Pakke no devolvió datos.'); } return $data; }
$340.00
Sin existencias