wordpress - WooCommerce REST API filter 'woocommerce_rest_prepare_product' -
i creating plugin returns customer-specific price each product.
to this, have implemented filter --
add_filter( 'woocommerce_rest_prepare_product', array( $this, 'return_personalised_catalog_data_to_api' ), 999, 3 ); -- gets price each product, given customer id through rest api:
- https://{{hostname}}/wp-json/wc/v1/products?customer_id=1234
the function this:
public function return_personalised_catalog_data_to_api( $product, $post, $request ) { $product_id = $product->data['id']; $customer_id = $request['customer_id']; // customer-specific price database table return $product; } unfortunately, appears $request variable not contain expect (i.e. customer_id). children (components) of bundled/composite products, $request variable contains parent product id.
is there better way of passing , getting custom url parameter customer_id, or how can ensure variable passed along no matter what?
thanks in advance!
Comments
Post a Comment