This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Automattic\WooCommerce\Client; | |
class Custom_Endpoints_Woocommerce_API | |
{ | |
protected function get_client() { | |
return new Client( | |
get_site_url(), | |
'woocommerce_consumer_key', | |
'woocommerce_consumer_secret', | |
[ | |
'wp_api' => true, | |
'version' => 'wc/v1', | |
] | |
); | |
} | |
public function register_woocommerce_routes() { | |
register_rest_route( 'customroutes', '/products', array( | |
'methods' => 'GET', | |
'callback' => array( $this, 'view_products' ) | |
)); | |
} | |
public function view_products( WP_REST_Request $request ) { | |
$woocommerce = $this->get_client(); | |
return $woocommerce->get( 'products/categories' ); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@marekka @fahmifan @DMezhenskyi You can find full document in this link :
https://packagist.org/packages/automattic/woocommerce#3.0.0