mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/77061842/woocommerce-price-discount-for-logged-users-only-in-frontend
10 lines
500 B
Text
10 lines
500 B
Text
add_filter( 'woocommerce_product_get_price', 'products_custom_price', 10, 2 );
|
|
add_filter( 'woocommerce_product_variation_get_price', 'products_custom_price', 10, 2 );
|
|
add_filter( 'woocommerce_product_get_regular_price', 'products_custom_price', 10, 2 );
|
|
// add_filter( 'woocommerce_product_get_sale_price', 'products_custom_price', 10, 2 );
|
|
function products_custom_price( $price, $product ){
|
|
if ( is_user_logged_in() && ! is_admin() ) {
|
|
return $price * 0.03;
|
|
}
|
|
return $price;
|
|
}
|