wcfm-santa

A deal you can't resist! Get upto 35% Off on this entire cyber week.

CLAIM OFFER
01Day 23Hr 42Min 55Sec
wcfm-santa

Limit the amount of products an user can buy

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Marketplace Limit the amount of products an user can buy

Viewing 4 reply threads
  • Author
    Posts
    • #119755
      jimbo.kuskyn
      Participant

      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 limitation

      2 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!!!

    • #119757
      jimbo.kuskyn
      Participant

      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!

    • #120008
      Molay Das
      Keymaster

      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,

    • #120313
      jimbo.kuskyn
      Participant

      Thanks a lot! This worked

    • #121337
      Molay Das
      Keymaster

      Great. 🙂

Viewing 4 reply threads
  • You must be logged in to reply to this topic.