<?php
// this goes in your theme functions.php file
function my_custom_product_response( $response, $product ) {
// early exit if user is not in the POS
if( ! is_pos() ) {
return $response;
}
// get the old product data
$data = $response->get_data();
// get the current logged in store id
$store_id = get_user_option( 'woocommerce_pos_store' );
// change the price based on store id
if( $store_id == 1234 ) {
$data['price'] = '2.99';
}
// reset the new response data
$response->set_data($data);
return $response;
}
// filter the WC REST API response
add_filter( 'woocommerce_rest_prepare_product_object', 'my_custom_product_response', 10, 2 );
add_filter( 'woocommerce_rest_prepare_product_variation_object', 'my_custom_product_response', 10, 2 );