I am using woo-commerce REST API for getting shipping methods Woocommerce REST API
I have called $woocommerce->get('shipping/zones/3/methods')
but not receiving any output it's given errorUncaught Automattic\WooCommerce\HttpClient\HttpClientException following is my code
<?php
include('../wp-load.php');
require_once( 'woo-lib/autoload.php' );
require_once( 'auth_keys.php' );
use Automattic\WooCommerce\Client;
if(isset($keys) && !empty($keys)){
$woocommerce = new Client(
$keys['siteurl'],
$keys['consumer_key'],
$keys['consumer_secret'],
[
'wp_api' => true,
'version' => 'wc/v2',
]
);
}
print_r($woocommerce->get('shipping/zones/3/methods'));
die;
If someone know about Woocommerce REST API then please let me know how could i get all shipping methods with it's cost (also zone vise)
The error means that your code produced a "HttpClientException" exception and you did not handled it. To catch an exception you can use an try/catch bloc.
With your code it could be look like this: