Woocommerce global percentage discount on simple products if customer is logged in Woocommerce global percentage discount on simple products if customer is logged in wordpress wordpress

Woocommerce global percentage discount on simple products if customer is logged in


Here you don't need the init hook and your IF statement needs to be inside the hooked function, so try that instead (for simple products):

add_filter('woocommerce_product_get_price', 'assign_tier_pricing', 90, 2 );add_filter('woocommerce_product_get_regular_price', 'assign_tier_pricing', 90, 2 );function assign_tier_pricing( $price, $product ) {    if ( is_user_logged_in() && $product->is_type('simple') ) {         $price *= 0.5; // Set all prices for simple products to 50% off.        }       return $price;   }