By default this is not really possible with the plugin I'm afraid. The way it normally works is that subaccounts inherit the dynamic rules of their parent account (so that subaccounts always get the same prices and conditions as the parent account).
Could you share more details: what dynamic rule are you trying to set this up for, and generally what would be the purpose / use case? I am trying to think of any possible alternatives or workarounds, perhaps also a code snippet could be used to change how it works.
I've tried writing a code snippet to achieve it, only for subaccounts. You can add this PHP snippet to the site:
add_action( 'woocommerce_before_cart' , 'b2bking_dynamic_minmax_order_amount');
add_action( 'woocommerce_before_checkout_form' , 'b2bking_dynamic_minmax_order_amount');
function b2bking_dynamic_minmax_order_amount(){
if (!function_exists('b2bking')){
return;
}
$howmuch = 500;
$cart = WC()->cart;
if (is_object($cart)) {
$user_id = get_current_user_id();
$account_type = get_user_meta($user_id, 'b2bking_account_type', true);
if ($account_type === 'subaccount'){
$order_total_calc_basis = apply_filters('b2bking_minmax_order_total_calculation_basis', WC()->cart->cart_contents_total + WC()->cart->tax_total);
if ( floatval($order_total_calc_basis) < $howmuch ) {
$notice_text = sprintf( esc_html__('Your current order total is %s — you must have an order with a minimum of %s to place your order','b2bking') ,
wc_price( $order_total_calc_basis ),
apply_filters('b2bking_minmax_value_display', wc_price( $howmuch ))
);
if (! b2bking()->has_notice($notice_text)){
if( is_cart() ) {
wc_print_notice( $notice_text, 'error' );
} else {
wc_add_notice ($notice_text, 'error');
}
}
}
}
}
}
It should apply only for subaccounts, and set that limit to a 500 min order.
Hello, would it be possible to set a dynamic rule that only applies to subaccounts?
Hello Loranz,
By default this is not really possible with the plugin I'm afraid. The way it normally works is that subaccounts inherit the dynamic rules of their parent account (so that subaccounts always get the same prices and conditions as the parent account).
Could you share more details: what dynamic rule are you trying to set this up for, and generally what would be the purpose / use case? I am trying to think of any possible alternatives or workarounds, perhaps also a code snippet could be used to change how it works.
Kind regards,
Stefan
so i need to create a rule that minum order is 500€, but valid only for subaccounts and not for parent account
thanks
Thanks for clarifying that,
I've tried writing a code snippet to achieve it, only for subaccounts. You can add this PHP snippet to the site:
It should apply only for subaccounts, and set that limit to a 500 min order.