跳到内容

Required Products Coupons for WooCommerce

v1.3.1

runthings.dev · 2025年2月22日 上架

Restrict the usage of WooCommerce coupons unless required products are in the cart.

正在使用
10 以下
评分
暂无
累计下载
940
最近更新
2026年11月16日
需要 WordPress 6.4+已测试到 7.1.5PHP 8.0+

贡献者

截图

Coupon settings page with required products fields.
Coupon settings page with required products fields.
Example denied coupon usage due to missing required products.
Example denied coupon usage due to missing required products.
Example denied coupon usage due to missing required products, with custom message.
Example denied coupon usage due to missing required products, with custom message.

This plugin allows you to restrict the usage of WooCommerce coupons unless specific products or variations are in the cart.

You can specify which products are required for a coupon to be valid, providing more control over your discount strategies.

Features

  • Restrict coupon usage based on all required products (including variations) being in the cart.
  • Customize the error message via a filter.

Filters

runthings_wc_coupons_required_products_missing_products

This filter allows third-party plugins to alter the missing required products before the coupon is rejected.

For detailed documentation and advanced examples, see the full documentation on GitHub.

Parameters:

  1. $missing_products (array): The missing products in the cart, in the format [product_id => quantity].
  2. $coupon (WC_Coupon): The coupon object being validated.
  3. $required_products (array): The required products for the coupon, in the format [product_id => quantity].
  4. $cart_products (array): Products found in the cart, in the format [product_id => quantity].
  5. $cart (WC_Cart): The cart instance.

runthings_wc_coupons_required_products_error_message

This filter allows customization of the error message shown when a coupon is not valid due to missing required products.

For detailed documentation and advanced examples, see the full documentation on GitHub.

Parameters:

  1. $message (string): The default error message, e.g., "This coupon requires specific products in the cart.".
  2. $coupon (WC_Coupon): The coupon object being validated.
  3. $required_products (array): The required products for the coupon, in the format [product_id => quantity].
  4. $missing_products (array): The missing products in the cart, in the format [product_id => quantity].

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/gpl-3.0.html.

Icon – Discount by Gregor Cresnar, from Noun Project, https://thenounproject.com/browse/icons/term/discount/ (CC BY 3.0)

Icon – restriction by Puspito, from Noun Project, https://thenounproject.com/browse/icons/term/restriction/ (CC BY 3.0)

Plums

按场景查找 WordPress 插件。安装量、评分和兼容版本来自官方目录。

导航

说明

WordPress 是 WordPress Foundation 的商标。本站与 WordPress Foundation、Automattic 没有隶属关系。这里不托管插件文件,下载和安装以 WordPress.org 上的页面为准。

© 2026 Plums