Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Product review And Variation Fix Store Api
Browse files Browse the repository at this point in the history
  • Loading branch information
shm379 committed Sep 14, 2023
1 parent 74320a5 commit a6c11b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/StoreApi/Routes/V1/ProductReviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ protected function get_route_response( \WP_REST_Request $request ) {
'order' => $request['order'],
'number' => $request['per_page'],
'post__in' => $request['product_id'],
'parent' => (int) $request['parent'],
);

/**
Expand Down
1 change: 1 addition & 0 deletions src/StoreApi/Schemas/V1/ProductReviewSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public function get_item_response( $review ) {
'rating' => $rating,
'verified' => wc_review_is_from_verified_owner( $review->comment_ID ),
'reviewer_avatar_urls' => rest_get_avatar_urls( $review->comment_author_email ),
'parent_id'=> (int) $review->comment_parent,
];

if ( 'view' === $context ) {
Expand Down
7 changes: 7 additions & 0 deletions src/StoreApi/Schemas/V1/ProductSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,15 @@ function( $values, $data ) use ( $default_variation_meta_keys ) {
}
}

$variation = wc_get_product($variation_id);
$variations[] = (object) [
'id' => $variation_id,
'images' => $this->get_images($variation),
'prices' => (object) $this->prepare_product_price_response($variation),
'is_purchasable' => $variation->is_purchasable(),
'is_in_stock' => $variation->is_in_stock(),
'is_on_backorder' => 'onbackorder' === $variation->get_stock_status(),
'low_stock_remaining' => $this->get_low_stock_remaining( $variation ),
'attributes' => array_values( $attribute_data ),
];
}
Expand Down

0 comments on commit a6c11b0

Please sign in to comment.