N
N
nortonouls2018-08-17 01:16:43
WordPress
nortonouls, 2018-08-17 01:16:43

Woocommerce - how to make it so that the user can only order a product once?

Greetings! Please tell me how to make it so that one user (registered on the site) can order a specific product only once. Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan Hasanli, 2018-08-17
@nortonouls

Hello!
When adding a product, check the "Sell individually" box in the "Inventory" tab
https://screenshots.firefox.com/Cdiu2tnpOOLbGUM9/t...

A
Alexander Tokmakov, 2019-07-09
@calliko

Maybe someone will need this:

/*человек добавляет в корзину товар А. Ходит по сайту и через какое-то время добавляет товар Б. При этом товар А должен автоматически быть удален из корзины.*/
add_filter( 'woocommerce_add_cart_item_data', 'my_empty_cart_before_add', 10, 3);
function my_empty_cart_before_add( $cart_item_data, $product_id, $variation_id )
{
    global $woocommerce;
    $woocommerce->cart->empty_cart();

    return $cart_item_data;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question