The “Maximum Products per User” plugin for WooCommerce offers an advanced feature called “Limits by Formula.” This empowers you to define purchase limits using shortcodes and custom logic.
Enabling Formulas
- Enable: Check this box to activate the “Limits by Formula” section.
Formula Construction
- Formula: This is where you define your limit logic using shortcodes. Each shortcode is written on a separate line.
Important Notes
- [alg_wc_mppu] Shortcode: This is the core shortcode you’ll use within your formulas.
- Matching Logic: The algorithm stops when it encounters the first matching shortcode, reading from top to bottom.
- Available Attributes: The plugin provides various attributes within the shortcode to target specific user groups, products, and purchase conditions.
Here are some key attributes
- user_id: Define limits for specific user IDs (comma-separated).
- user_role: Set limits based on user roles (e.g., administrator, customer).
- membership_plan, memberpress_plan_id, etc.: (Requires additional membership plugins) Define limits based on membership plans.
- payment_method: Set limits based on the chosen payment method (requires enabling “Count by current payment method”).
- product_id, product_sku, is_downloadable, is_virtual: Define limits for specific products or product types (requires enabling “Per product”).
- term_id: Set limits for products within specific categories or tags (requires enabling “Per product category” or “Per product tag”).
Additional Considerations
- The limit attribute is mandatory and specifies the maximum purchase quantity allowed.
- You can set start and end dates for the shortcode to define limited-time offers or restrictions.
- The product_limit_meta attribute allows you to use custom product meta data in your formulas (only combined with product_id).
Examples
- [alg_wc_mppu limit=”18″ user_id=”2,5″]: This sets a maximum limit of 18 for users with IDs 2 and 5.
- [alg_wc_mppu limit=”18″ user_id=”2,5″ product_id=”100,110″]: This sets a maximum limit of 18 for products 100 and 110 for users with IDs 2 and 5.
By leveraging “Limits by Formula,” you can create highly customized purchase restrictions, catering to various user segments, product types, and promotional periods within your WooCommerce store.