• Resolved mobileit

    (@mobileit)


    This Addon looks like it could work perfectly for us with a couple of modifications..

    We would like to limit purchases to 1 item per customer in a 28 Day or 1 month period (Whichever is easier to accomplish).

    This would give everyone a fair chance at a good deal (This is for an internal portal)

    ————————————————————–

    Ultimately we’d love to limit the purchases to 1 Item per 28 days if this product is from “Supplier A” and have no limits on any products that come from “Supplier B”. but this is getting a bit more in depth.

    • This topic was modified 4 years, 5 months ago by mobileit.
Viewing 1 replies (of 1 total)
  • Plugin Contributor Steve Grunwell

    (@stevegrunwell)

    If you’re trying to limit the number of orders per user (as opposed to the total number of orders on the store), the approach would need to be a little different: instead of saying “okay, how many orders have we received in this interval?”, you’ll probably want to focus on “has this user made an order in the current interval?”.

    To accomplish this, you might consider hooking into the “woocommerce_is_purchasable” filter and conditionally filter the response based on the current user (especially since it sounds like everyone accessing the store will be logged in), only returning TRUE if both of the following conditions are met:

    1. Is the user logged in?
    2. Has the currently logged-in user made a [qualifying] purchase in the last X days?

    You can query orders via the WC_Order_Query class, setting date and customer constraints.

    Best of luck!

Viewing 1 replies (of 1 total)
  • The topic ‘Customer Based Limit’ is closed to new replies.