Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WC Marketplace › Limit the amount of products an user can buy
- This topic has 4 replies, 2 voices, and was last updated 4 years, 8 months ago by Ramamurthy Krishnan.
- AuthorPosts
- April 16, 2020 at 5:26 pm #119755jimbo.kuskynParticipant
Hi,
I’m trying to build a website where people can buy items, but I need to limit the amount of products bought to a maximum of 4 per month.
Is there a way to do this? And if so I would be interested in:
1 – Functionality
– Functionality on frontend where I can do this OR
– CSS code to add the limitation2 Message to user: something like “[Example: We are sorry but you have reached the amount of products you can order per month]”
Thank you so much for all of your help and having an awesome platform!!!
- April 16, 2020 at 5:35 pm #119757jimbo.kuskynParticipant
Hi again,
While searching for more, I can see that there were others searching to do the same, so I was wondering if you could help me customise the code below (I am rubbish as a coder! 🙂
The website I found this is here – https://forums.envato.com/t/woocommerce-limit-a-product-to-only-be-purchased-once-per-user/75797/7
// Don't run on parents of variations, // this will already check variations separately if ( $product->is_type( 'variable' ) ) { return $purchasable; } // Get the ID for the current product (passed in) $product_id = $product->is_type( 'variation' ) ? $product->variation_id : $product->id; // return false if the customer has bought the product / variation if ( wc_customer_bought_product( wp_get_current_user()->user_email, get_current_user_id(), $product_id ) ) { $purchasable = false; } // Double-check for variations: if parent is not purchasable, then variation is not if ( $purchasable && $product->is_type( 'variation' ) ) { $purchasable = $product->parent->is_purchasable(); } return $purchasable;
Once again, thanks a lot for all your help!
- April 17, 2020 at 4:37 pm #120008Ramamurthy KrishnanKeymaster
Hi,
Sorry we don’t have this feature but you can try this plugin: https://wordpress.org/plugins/maximum-products-per-user-for-woocommerce/
Thanks,
- April 18, 2020 at 5:32 pm #120313jimbo.kuskynParticipant
Thanks a lot! This worked
- April 21, 2020 at 5:09 pm #121337Ramamurthy KrishnanKeymaster
Great. 🙂
- AuthorPosts
- You must be logged in to reply to this topic.