• Resolved babakras

    (@babakras)


    Hi,
    I am trying to limit customers to buy only one unit of a specific item per order. I know I can do this by going to PRODUCT and under SIMPLE PRODUCT go to INVENTORY and check the box next to “Enable this to only allow one of this item to be bought in a single order”

    However, Does anyone know how I can achieve the same result by using PHP code where I can place in function.php ?

    Many thanks in advance ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi @babakras

    While I haven’t tested this code specifically, you could look into using the following: https://nicolamustone.blog/2018/06/17/limit-purchases-one-per-order/

    Please note that if you are unfamiliar with customizations like these, I would recommend using the Code Snippets plugin to more safely add this code: https://www.ads-software.com/plugins/code-snippets/

    Hope this helps!

    Thread Starter babakras

    (@babakras)

    Hello @laceyrod thanks for your response,however the link you provided is showing how limit customers to buy 1 product per order.

    What I want to achieve is limit customers to buy 1 unit of each product per order.
    For example I have 3 products in my shop; product 1 is a jean, product 2 is a shirt and product 3 is a had. What I want to do is limit my customers so they can add only 1 jean to basket and not anymore but be able to add 2 or more shirt or hat and once checked out they can come back and order 1 more jean if they want.

    Basically this can be done with the option inside woocommerce by check the box in inventory section of product for “Enable this to only allow one of this item to be bought in a single order” I would like to know how I can enable this option using PHP snippet and not from woocommerce product page.

    Thank you

    laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi @babakras

    Thanks for your reply!

    I’ve been running a search for any snippets out there that would achieve this, but my search is coming up short, likely because it is a feature already included in WooCommerce core.

    I’ll go ahead and leave this thread open for a while in case anyone else wants to chime in, but in the meantime, I can also recommend the following resources for more development-oriented questions:

    – WooCommerce Slack Community: https://woocommerce.com/community-slack/
    – Advanced WooCommerce group on Facebook: https://www.facebook.com/groups/advanced.woocommerce/

    Hope this helps!

    laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi @babakras

    This thread has been inactive for a bit, so I’m going to mark it as Resolved now for the overall health of the forums. Please feel free to check out the resources listed above for help.

    Alternatively, you could look into hiring someone for help with this: https://woocommerce.com/customizations/

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘limit customers to buy only one unit of a specific item per order’ is closed to new replies.