Last active
August 17, 2017 20:15
-
-
Save kilbot/8cc2aa618209e5dea8e9bb8a7e60d537 to your computer and use it in GitHub Desktop.
Changing the product regular_price for WC REST API v2 output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// the code below goes in your functions.php file | |
function my_custom_prepare_shop_order_object($response, $order, $request) { | |
if( is_pos() ) { | |
$data = $response->get_data(); | |
$data['regular_price'] = get_post_meta( $data['id'], 'wholesale_customer_wholesale_price', true ); | |
$response->set_data($data); | |
} | |
return $response; | |
} | |
add_filter( 'woocommerce_rest_prepare_product_object', 'my_custom_prepare_product_object', 20, 3 ); | |
add_filter( 'woocommerce_rest_prepare_product_variation_object', 'my_custom_prepare_product_object', 20, 3 ); |
Sorry, my mistake, I copied the add_filter
lines from my plugin code ... it should be a slightly different format for the functions.php file. I've just corrected the code.
Cool. Does there need to be the word "function" in front of line 5?
yes, just updated
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code above had some problems, so I tried to troubleshoot and came up with this...it's not giving an error, but no products display in the POS.