Created
December 20, 2017 21:12
-
-
Save coderkevin/f56d649e38d1f214c76e109bad41395c to your computer and use it in GitHub Desktop.
WooCommerce Data Store Demo - Product Inventory - Read
This file contains hidden or 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
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