Set decimal step for administrators

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #104375
    JC solvignon
    Participant

    Hi,
    Is there a way to set decimal step (ex : 0,001) only for administrator ?
    Thanks for your help

    #104376
    WPWhale
    Moderator

    Hello,

    Sorry but that’s not an option currently, we might look into it in a future update.

    Omar

    #104377
    JC solvignon
    Participant

    ok thanks
    i was thinking your developers tab talk about that ?

    For example, you may want to modify quantities by user role – in this case you will need to add something like this to your (child) theme’s functions.php file:

    add_filter( ‘alg_wc_pq_get_product_qty_min’, ‘my_product_qty_min_by_user_role’, 10, 2 );
    function my_product_qty_min_by_user_role( $qty, $product_id ) {
    $current_user = wp_get_current_user();
    return ( in_array( ‘administrator’, $current_user->roles ) ? 5 : $qty );
    }

    #104378
    WPWhale
    Moderator

    Hi JC,

    To make it work, you have to add this to your child theme functions.php:

    add_filter( ‘alg_wc_pq_get_product_qty_step’, ‘my_product_qty_min_by_user_role’, 99, 2 );
    function my_product_qty_min_by_user_role( $qty, $product_id ) {
    $current_user = wp_get_current_user();
    return ( in_array( ‘administrator’, $current_user->roles ) ? 0.001 : $qty );
    }

    Let me know how it goes.

    Omar

    #104379
    JC solvignon
    Participant

    Great it works !!
    thanks a lot

    #104380
    WPWhale
    Moderator

    Awesome! Glad to know this.

    If you found the plugin and/or support useful, please consider reviewing it.

    Thank you,
    Omar

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.