php 更改WC REST API v2输出的产品regular_price

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 更改WC REST API v2输出的产品regular_price相关的知识,希望对你有一定的参考价值。

<?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 );

以上是关于php 更改WC REST API v2输出的产品regular_price的主要内容,如果未能解决你的问题,请参考以下文章