|
@@ 203-205 (lines=3) @@
|
| 200 |
|
public function get_items( $request ) { |
| 201 |
|
$product_id = (int) $request['product_id']; |
| 202 |
|
|
| 203 |
|
if ( 'product' !== get_post_type( $product_id ) ) { |
| 204 |
|
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
| 205 |
|
} |
| 206 |
|
|
| 207 |
|
$reviews = get_approved_comments( $product_id ); |
| 208 |
|
$data = array(); |
|
@@ 228-230 (lines=3) @@
|
| 225 |
|
$id = (int) $request['id']; |
| 226 |
|
$product_id = (int) $request['product_id']; |
| 227 |
|
|
| 228 |
|
if ( 'product' !== get_post_type( $product_id ) ) { |
| 229 |
|
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
| 230 |
|
} |
| 231 |
|
|
| 232 |
|
$review = get_comment( $id ); |
| 233 |
|
|
|
@@ 254-256 (lines=3) @@
|
| 251 |
|
public function create_item( $request ) { |
| 252 |
|
$product_id = (int) $request['product_id']; |
| 253 |
|
|
| 254 |
|
if ( 'product' !== get_post_type( $product_id ) ) { |
| 255 |
|
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
| 256 |
|
} |
| 257 |
|
|
| 258 |
|
$prepared_review = $this->prepare_item_for_database( $request ); |
| 259 |
|
|
|
@@ 309-311 (lines=3) @@
|
| 306 |
|
$product_review_id = (int) $request['id']; |
| 307 |
|
$product_id = (int) $request['product_id']; |
| 308 |
|
|
| 309 |
|
if ( 'product' !== get_post_type( $product_id ) ) { |
| 310 |
|
return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) ); |
| 311 |
|
} |
| 312 |
|
|
| 313 |
|
$review = get_comment( $product_review_id ); |
| 314 |
|
|