0

Have differing prices between offline and online using Square (woocommerce plugin) and Woocommerce.

To get around this I was considering a new category for offline and filtering them out of the website and vice versa on the export to Square. Yes there would be duplication of product but independent pricing. Is there a way to hook into the product filter over all website product queries?

I am assuming if so there would be a method for the Square plugin to hook in for the export to do the opposite way.

Which would be the best filter to hook into for Woocommerce?

1 Answer 1

2

You can use the pre_get_posts hook for Woocommerce product query, but here the example is for the main query.

function wpse_306252_query( $query ) {
    if($query->is_main_query()) {
        $query->set( 'category__not_in', YOUR_CAT_ID);
    }
}
add_action( 'pre_get_posts', 'wpse_306252_query' );

If you want the opposite of it, I think the best is to add a SquareExport parameter to check when you want your products.

function wpse_306252_query( $query ) {
    if(!isset($_REQUEST['SquareExport'])) {
        $query->set( 'category__not_in', YOUR_CAT_ID);
    }
}
add_action( 'pre_get_posts', 'wpse_306252_query' );

The last one will always exclude products from YOUR_CAT_ID, custom queries, or main query. Hope it fit's your needs :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.