Woocommerce rest api


#1

I want to know how to get my products from wordpress to ionic

simple way


#2

See: https://developer.wordpress.org/rest-api/


#3

Add this code on your functions.php

<?php
/**
* Add REST API support to an already registered post type
* http://v2.wp-api.org/extending/custom-content-types/
* Access this post type at yoursite.com/wp-json/wp/v2/post_type_name
*/
add_action( 'init', 'appp_post_type_rest_support', 999 );

function appp_post_type_rest_support() {

	global $wp_post_types;

	//be sure to set this to the name of your post type!
	$post_type_name = 'product';
	if( isset( $wp_post_types[ $post_type_name ] ) ) {
		$wp_post_types[$post_type_name]->show_in_rest = true;
		$wp_post_types[$post_type_name]->rest_base = $post_type_name;
		$wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
	}

}

?>

#4

@soomit what about Woocommerce rest api ?


#5

did you put the above code in your fundtions.php file after that put url on browser yoursite.com/wp-json/wp/v2/product and you’ll get response.