<?php
// this goes in your functions.php file
function my_custom_pre_get_posts( $query ) {
// early exit if user is not in the POS
if( ! is_pos() ) {
return;
}
// a hard coded map of Store IDs => array of product categories
$restrict = array(
1524 => '52,863', // ie: Store ID 1524 restricted to category ids 52 and 863
6252 => '-64,-863' // ie: Store ID 6252 excludes category ids 64 and 863
);
// get current logged in POS store
$store_id = get_user_option( 'woocommerce_pos_store' );
// if store is in restrict array, limit the products to mapped categories
if( ! isset( $restrict[$store_id] ) ) {
$query->set( 'cat', $restrict[$store_id] );
}
}
add_action( 'pre_get_posts', 'my_custom_pre_get_posts' );