please refer below code.you are passing only 1 parameters instead of 3 parameter.
function filter_woocommerce_add_to_cart_validation( $passed, $product_id, $quantity ) {
if ( $quantity>2 )) {
wc_add_notice( __( 'You are not allowed to add more than 2 product for category..', 'woocommerce' ), 'error' );
$passed = false;
}
return $passed;
};
// add the filter
add_filter( 'woocommerce_add_to_cart_validation', 'filter_woocommerce_add_to_cart_validation', 10, 3 );
reference:
http://hookr.io/filters/woocommerce_add_to_cart_validation/
Related Posts:
- WP E-Commerce VS Shopp VS WooCommerce VS JigoShop [closed]
- Can I use Woocommerce to take orders but not handle payment? [closed]
- how to change displaying order of products in wp ecommerce
- All permalinks go to products page with WP E-Commerce plugin?
- Shopping Cart Solution [closed]
- WP e-commerce: getting products by SKU
- Recommend plugins for member’s only e-commerce website [closed]
- MarketPress vs. other WP ecommerce solutions [closed]
- Can we import Magento products to the WordPress?
- Getting started with e-commerce sites on WordPress
- WP e-commerce: How to select the shipping costs calculation method according to delivery location
- get the product list from wp estore plugin
- How to enable a custom stripe payment form in wordpress? [closed]
- How do I add pricing fields to a Gravity Form? [closed]
- Display product SKU on page with Jigoshop
- E commerce on WordPress [closed]
- Could WordPress be used/extended as a medium-size ecommerce site?
- Jigoshop – change the order in which products show up in a grid
- How to show Best Selling WP E-Commerce Products
- can i have shopping carts without plugin? [closed]
- Using Jigoshop, how can I add a custom post type to the cart via code?
- GetShopped Ecommerce: hide checkout form from customer until shipping country selected [closed]
- WP-e-commerce (getshopped) Hebrew language files – where can I get them? [closed]
- Clear Cart with WordPress E-commerce plugin
- e-commerce, customizing checkout process based on product
- Add class to woocommerce_before_shop_loop_item
- create parent and child product structure
- E-commerce solution
- woocommerce questions – trying to pic an ecommerce solution
- How to make that google wont follow some of the wordpress pages?
- Is wordpress good enough for ecommerce? [closed]
- How to adjust the Cartpress e-commerce plugin?
- Is it possible to set individual shipping prices in Woocommerce? [closed]
- how to add weight field on checkout page in Jigoshop Plugin
- Shipping charge by country & product weight? [closed]
- Wp e-commerce shipping problem
- How can I bring the price in my website?
- WordPress how to remove blocksy theme price and put my own price
- How do I get WooCommerce to automatically recreate pages? [closed]
- Enabling free shipping on Woo Commerce by specific items [closed]
- Pros/Cons of “WP e-commerce” and “Shopp” plugins [closed]
- WooCommerce – How to Add a Custom Field to Cart Items and Cart Totals [closed]
- Scaling a WP eCommerce site
- Recommended eCommerce Plugin for a T-Shirt Sales Business? [closed]
- Is there a limit on how much is customizable on WordPress? [closed]
- WP_Query for WooCommerce Products
- WP E-commerce: Showing 3 random products from current category when viewing product
- Automattic’s eCommerce Plugin
- Convert WordPress posts to products in WooCommerce
- How to get the original price of the product in woocommerce?
- What are WooCommerce starter themes? [closed]
- Need Help Finding a WordPress E-Commerce Plugin That Utilises Custom Post Types [closed]
- Display specific widgets in different area’s around the page
- eBooks download website, page or post?
- Shopping Cart Integration — Experiences with Popular eCommerce Solutions [closed]
- WooCommerce – Adding Custom Order Without No Product [closed]
- WordPress shopping cart that supports 2 tier product variation options
- WooCommerce: Translation lost on AJAX call in Checkout page [closed]
- WordPress Create Post from front-end
- Is it possible to set up multistore in Woocommerce? [closed]
- woocommerce Add custom field set like billing fields
- How To Hide Filters On Specific Categories with WooCommerce Products Filter(WOOF)
- How To Create WooCommerce Custom Template For Specific Product?
- How to structure sales of reports [closed]
- Does a wordpress plugin (not a membership one) exist for selling access to some webpages? [closed]
- Adding my own “add to cart button”
- Only Homepage not loading properly
- How to display empty stars on products with woocommerce?
- Integrating non-WooCommerce and WooCommerce Orders together [closed]
- Remove the link from the thumbnail and product title on woocommerce
- Add a captcha form to the woocommerce register form
- Check Paypal Purchase is Success or Not in Easy Digital Download Plugin
- WooCommerce – Want to show multiple currency for a single product [closed]
- Simple Online Payment for Event Registration [closed]
- Navigational drop-down lists in WordPress?
- How to send an automated email to the customers when product is added woocommerce
- How can I pass a custom/dynamic product to the Woocommerce cart?
- How to make products with no cost in WooCommerce
- Product queue for my subscription box
- Want to Show Sub categories under Categories section using Woo Commerce [closed]
- wp e-commerce sort by stock [closed]
- E-commerce for wordpress [closed]
- WooCommerce: multiple input field for multiple product variations
- Can the WP e-Commerce Plugin Support a Large Number of Products? [closed]
- Problems with migrating a WooCommerce orders [closed]
- Adjust Price Display for Variable Product in Woocommerce [closed]
- Transferring data to the end of a transaction with the Shopp Plugin
- WordPress User Post Products
- ecommerce plugin with “buy for a friend” feature [closed]
- wp e-commerce – theme problem – why won’t it load wpsc-single_product.php? [closed]
- Displaying custom post types as a gallery
- Let users sell video in my website [closed]
- Can’t Change WooCommerce Default Language to Spanish (Mexico)
- Change WooCommerce add_to_cart Button Text?
- Create a regular post for every WooCommerce order
- Woocommerce – Change Variable Product Add to Cart to behave like external product using Custom Field (link) [closed]
- Replace woocommerce | (pipe) separator in product variation to , or another character?
- Creating open content area and restricted content area
- WP-eComerce Advance Meta Tag data in descending order [closed]
- product export and import using xml