は、私のコードの例を下に確認してください。
function opal_varient_price($price, $variation) {
if ( $variation->product_type == 'variation' ) {
$user = $user ? new WP_User($user) : wp_get_current_user();
$role = $user->roles[0];
if($role == 'detailer'){$pricex = get_post_meta($variation->variation_id, 'dist',true);}
else if($role == 'reseller'){$pricex = get_post_meta($variation->variation_id, 'res',true);}
else{ $pricex = $price;}
}
return $pricex;
}
add_filter('woocommerce_product_variation_get_regular_price', 'opal_varient_price' , 99, 2);
add_filter('woocommerce_product_variation_get_sale_price', 'opal_varient_price' , 99, 2);
add_filter('woocommerce_product_variation_get_price', 'opal_varient_price', 99, 2);
あなたは試してみましたか?あなたのコードを表示します。 –