facetwp re-add woocommerce post clauses for sort by price

<?php

/**
 * re-add post-clause for woocommerce after facetwp updates the query vars
 */
add_action( 'pre_get_posts', function( $query ) {
	if ( 'product_query' == $query->get('wc_query') && true == $query->get('facetwp' ) && 'price' == $query->get('orderby') ) {
		if ( 'DESC' == $query->get('order') ) {
			add_filter( 'posts_clauses', array( wc()->query, 'order_by_price_desc_post_clauses' ) );
		} else {
			add_filter( 'posts_clauses', array( wc()->query, 'order_by_price_asc_post_clauses' ) );
		}
	}
}, 1000 );