Herşey için eklenti kurup siteyi yavaşlatmayın . Temanızın functions.php dosyasının yedeğini alıp bu kodları deneyin.
üye gruplarına özel indirim uygulama // Üye Gruplarına Özel İndirim Kodu
add_action( 'woocommerce_cart_calculate_fees', 'discount_based_on_user_role', 20, 1 );
function discount_based_on_user_role( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return; // Exit
//İndirim yapılacak üye grubu
if ( ! current_user_can('admin') ) return; // Exit
// indirim oranı
$percentage = 10;
$discount = $cart->get_subtotal() * $percentage / 100;
// indirimi uygula
$cart->add_fee( sprintf( __("Discount (%s)", "woocommerce"), $percentage . '%'), -$discount, true );
}
Üye olmayanlara fiyatı gizleme add_action( 'init', 'bbloomer_hide_price_add_cart_not_logged_in' );
function bbloomer_hide_price_add_cart_not_logged_in() {
if ( ! is_user_logged_in() ) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
add_action( 'woocommerce_single_product_summary', 'bbloomer_print_login_to_see', 31 );
add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_print_login_to_see', 11 );
}
}
function bbloomer_print_login_to_see() {
echo '<a href="' . get_permalink(wc_get_page_id('myaccount')) . '">' . __('Değerli ziyaretçimiz üye girişi yaparak fiyatları görebilirsiniz', 'theme_name') . '</a>';
}