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

Commit

Permalink
Hide order by select if ratings are disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu committed Jul 23, 2019
1 parent 22e26bf commit acbbb74
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions assets/js/blocks/reviews-by-product/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,25 @@ class ReviewsByProduct extends Component {
const selectedOrder = isPreview ? attributes.orderby :
orderValue || this.state.orderby || attributes.orderby;

switch ( selectedOrder ) {
case 'lowest-rating':
if ( wc_product_block_data.enableReviewRating ) {
if ( selectedOrder === 'lowest-rating' ) {
return {
order: 'asc',
orderby: 'rating',
};
case 'highest-rating':
}
if ( selectedOrder === 'highest-rating' ) {
return {
order: 'desc',
orderby: 'rating',
};
case 'most-recent':
default:
return {
order: 'desc',
orderby: 'date_gmt',
};
}
}

return {
order: 'desc',
orderby: 'date_gmt',
};
}

getReviews( orderValue, page = 1 ) {
Expand Down Expand Up @@ -145,7 +146,7 @@ class ReviewsByProduct extends Component {
}

renderOrderBySelect() {
if ( wc_product_block_data.enableReviewRating ) {
if ( ! wc_product_block_data.enableReviewRating ) {
return null;
}

Expand Down

0 comments on commit acbbb74

Please sign in to comment.