From acbbb74095472a54e28f4111f0562ed073ba85bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Tue, 23 Jul 2019 12:06:40 +0200 Subject: [PATCH] Hide order by select if ratings are disabled --- assets/js/blocks/reviews-by-product/block.js | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/assets/js/blocks/reviews-by-product/block.js b/assets/js/blocks/reviews-by-product/block.js index 407e19e17fe..40e0bc0eec3 100644 --- a/assets/js/blocks/reviews-by-product/block.js +++ b/assets/js/blocks/reviews-by-product/block.js @@ -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 ) { @@ -145,7 +146,7 @@ class ReviewsByProduct extends Component { } renderOrderBySelect() { - if ( wc_product_block_data.enableReviewRating ) { + if ( ! wc_product_block_data.enableReviewRating ) { return null; }