How to use Woocommerce API to display product from other Woocommerce Website?

Fetch product from third party using Woocommerce API

You need to get consumer and and secret key from the Website whose product need to fetch.

Put this code snippet in functions.php file with required details like consumer key and secret key.


<?php
function curl_helper() {
$ch = curl_init();
$c_key = 'CONSUMER KEY';
$c_secret = 'SECRET KEY';
$ch = curl_init('DOMAIN NAME/wc-api/v1/products/?consumer_key='.$c_key.'&consumer_secret='.$c_secret);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
curl_close($ch);
return json_decode($data);
}

$products = curl_helper();
echo "

";
	/*List Product from the Domain you are requesting */
	print_r($products);
	echo "

";
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s