[WordPress] 外掛分享: Coupons Role Restriction for WooCommerce

首頁外掛目錄 › Coupons Role Restriction for WooCommerce
WordPress 外掛 Coupons Role Restriction for WooCommerce 的封面圖片
50+
安裝啟用
尚無評分
71 天前
最後更新
問題解決
WordPress 6.4+ PHP 7.4+ v1.1.3 上架:2024-07-14

內容簡介

總結:此外掛可根據使用者角色限制 WooCommerce 優惠券的使用,使用者可以指定允許或排除使用優惠券的角色,提供更多對折扣策略的控制。提供針對使用者角色限制優惠券使用、指定允許或排除的角色、透過篩選器自訂錯誤訊息的功能。

問題與答案:
1. 這個外掛的功能是什麼?
- 可根據使用者角色限制 WooCommerce 優惠券的使用。

2. 使用者可以做什麼?
- 使用者可以指定哪些角色可以或不可以使用優惠券,從而更精確地控制折扣策略。

3. 如何自訂錯誤訊息?
- 使用者可以透過篩選器 `runthings_wc_coupons_role_restrict_error_message` 自訂當優惠券對使用者帳戶類型無效時顯示的錯誤訊息。示例:
```
add_filter('runthings_wc_coupons_role_restrict_error_message', 'custom_coupon_error_message');

function custom_coupon_error_message($message) {
return 'Custom error message for invalid coupon.';
}
```

4. 這個外掛的授權是什麼?
- 此程式是自由軟體,可以在 Free Software Foundation 發布的 GNU 通用公共授權條款下重新發行或修改,請參閱 GNU 通用公共授權條款。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.1.3) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Coupons Role Restriction for WooCommerce」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This plugin allows you to restrict the usage of WooCommerce coupons based on user roles, including guest users.
You can specify which roles (including guests) are allowed or excluded from using a coupon, providing more control over your discount strategies.
Features

Restrict coupon usage based on user roles.
Option to specify both allowed and excluded roles.
Support for guest users with a “Customer Is A Guest” pseudo-role.
Customize the error message via a filter.

Filters
runthings_wc_coupons_role_restrict_error_message
This filter allows customization of the error message shown when a coupon is not valid for the user’s account type.
For detailed documentation and advanced examples, see the full documentation on GitHub.
Parameters:

$message (string): The default error message, e.g., "Sorry, this coupon is not valid for your account type.".
$context (array): Additional context for the error, including the coupon, user roles, and guest status.

$context object format:
The $context array contains the following keys:
– coupon (WC_Coupon): The coupon object being validated.
– is_guest (bool): Whether the current user is a guest (not logged in).
– user (WP_User): The current user object. For guests, this will be an empty user object.
– allowed_roles (array): Roles explicitly allowed to use the coupon, in the format [role_id => role_name].
– excluded_roles (array): Roles explicitly excluded from using the coupon, in the format [role_id => role_name].
– effective_allowed_roles (array): The final calculated roles allowed to use the coupon, after considering exclusions, in the format [role_id => role_name]. This is the set of roles that can use the coupon.
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)

文章
Filter
Mastodon