Skip to content

Instantly share code, notes, and snippets.

@coderkevin
Created December 20, 2017 21:12
Show Gist options
  • Save coderkevin/f56d649e38d1f214c76e109bad41395c to your computer and use it in GitHub Desktop.
Save coderkevin/f56d649e38d1f214c76e109bad41395c to your computer and use it in GitHub Desktop.
WooCommerce Data Store Demo - Product Inventory - Read
public function read( &$product ) {
$this->parent_instance->read( $product );
$inventory_url = 'http://localhost:8080/api/inventory/' . $product->get_sku();
$request = wp_remote_get( $inventory_url );
$response = wp_remote_retrieve_body( $request );
$data = json_decode( $response );
$product->set_stock_quantity( $data );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment