[WordPress] 外掛分享: Mr. J Dev Smart Discount Rules

首頁外掛目錄 › Mr. J Dev Smart Discount Rules
全新外掛
安裝啟用
尚無評分
8 天前
最後更新
問題解決
WordPress 5.8+ PHP 7.4+ v1.0.0 上架:2026-05-18

外掛標籤

開發者團隊

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

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Mr. J Dev Smart Discount Rules」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Mr. J Dev Smart Discount Rules gives you a flexible, priority-based discount engine on top of WooCommerce. Rules are evaluated automatically at cart/checkout — no coupon code needed.
Discount Types:

Percentage — e.g. “10% off the entire cart”
Fixed Amount — e.g. “₹100 off cart”
Buy X Get Y — e.g. “Buy 2, get 1 free” (cheapest eligible items are discounted)

Conditions (can be combined):

Minimum cart spend
User role (customer, wholesale, subscriber, etc.)
Product category slug present in cart
Day(s) of the week (time-based deals like weekend sales)

Rule Control:

Priority system — only the highest-priority matching rule fires (no stacking)
Enable / disable rules without deleting them
Delete rules permanently

The discount appears as a cart fee line item with the rule name as its label, keeping the cart transparent to customers.
Usage Examples
Weekend 15% sale for all users:

Type: Percentage | Value: 15
Conditions → Days: Saturday, Sunday

₹500 spend → ₹50 off for Wholesale customers:

Type: Fixed | Value: 50
Min Spend: 500 | Conditions → Role: wholesale_customer

Buy 2 T-shirts, get 1 free (cheapest):

Type: Buy X Get Y | Buy: 2 | Get: 1
Conditions → Category: t-shirts

How Buy X Get Y Works
The Buy X Get Y rule uses a group-based algorithm that always gives the cheapest qualifying items for free.
Algorithm (step by step):

All items in the cart are flattened into individual unit prices.
e.g. Cart: 2× T-shirt @ ₹200, 1× Jeans @ ₹800, 1× Cap @ ₹150
→ unit prices: [200, 200, 800, 150]

Prices are sorted cheapest-first:
→ [150, 200, 200, 800]

The number of complete qualifying groups is calculated:
group size = Buy + Get = 3 + 1 = 4
total items = 4 → floor(4 ÷ 4) = 1 group qualifies

For each group, the cheapest Get items are free:
→ ₹150 (cap) is free → discount applied = −₹150

The discount is added as a negative cart fee line item labelled with the rule name, keeping the breakdown transparent to customers.
Why cheapest-first?
This prevents customers from gaming the rule by adding one cheap item to get an expensive item free. The cheapest item always fills the free slot.
Only complete groups qualify:
With Buy 2 Get 1 and 5 items in the cart:
→ floor(5 ÷ 3) = 1 complete group → 1 item free (the cheapest)
The leftover 2 items do not form a group and get no discount.
Configuration examples:

Buy 1 Get 1 Free → Buy: 1, Get: 1
Buy 2 Get 1 Free → Buy: 2, Get: 1
Buy 3 Get 2 Free → Buy: 3, Get: 2
Buy 4 Get 1 Free (BOGO4)→ Buy: 4, Get: 1

Combine with a Product Category condition to restrict the rule to specific product lines (e.g. only T-shirts, only Electronics).

延伸相關外掛

文章
Filter
Apply Filters
Mastodon