Price orderby shortcode functionality

This commit is contained in:
claudiulodro 2018-03-16 09:43:25 -07:00
parent 6eba00b97a
commit c3354c6363
2 changed files with 20 additions and 6 deletions

View File

@ -936,9 +936,16 @@ registerBlockType('woocommerce/products', {
}
}
// @todo Add support for price_desc and price_asc to shortcode.
if (!['specific', 'price_desc', 'price_asc'].includes(display)) {
shortcode_atts.set('orderby', orderby);
if ('specific' !== display) {
if ('price_desc' === orderby) {
shortcode_atts.set('orderby', 'price');
shortcode_atts.set('order', 'DESC');
} else if ('price_asc' === orderby) {
shortcode_atts.set('orderby', 'price');
shortcode_atts.set('order', 'ASC');
} else {
shortcode_atts.set('orderby', orderby);
}
}
// Build the shortcode string out of the set shortcode attributes.

View File

@ -663,9 +663,16 @@ registerBlockType( 'woocommerce/products', {
}
}
// @todo Add support for price_desc and price_asc to shortcode.
if ( ! ['specific', 'price_desc', 'price_asc'].includes( display ) ) {
shortcode_atts.set( 'orderby', orderby );
if ( 'specific' !== display ) {
if ( 'price_desc' === orderby ) {
shortcode_atts.set( 'orderby', 'price' );
shortcode_atts.set( 'order', 'DESC' )
} else if ( 'price_asc' === orderby ) {
shortcode_atts.set( 'orderby', 'price' );
shortcode_atts.set( 'order', 'ASC' )
} else {
shortcode_atts.set( 'orderby', orderby );
}
}
// Build the shortcode string out of the set shortcode attributes.