fluentcart-developer 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +22 -22
- package/LICENSE +21 -21
- package/README.md +169 -127
- package/SKILL.md +127 -127
- package/bin/index.js +281 -281
- package/package.json +48 -37
- package/skills/fluentcart-developer/SKILL.md +172 -172
- package/skills/fluentcart-developer/examples/README.md +25 -25
- package/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/fluent-cart/checkout.php +32 -32
- package/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/functions.php +40 -40
- package/skills/fluentcart-developer/examples/sample-custom-addon/fluentcart-custom-addon.php +114 -114
- package/skills/fluentcart-developer/examples/sample-custom-payment-gateway/fluentcart-custom-gateway-example.php +149 -149
- package/skills/fluentcart-developer/examples/sample-fee-surcharge-plugin/fluentcart-fee-surcharge.php +38 -38
- package/skills/fluentcart-developer/examples/sample-shipping-carrier/fluentcart-custom-shipping-carrier.php +62 -62
- package/skills/fluentcart-developer/references/action-hooks-admin-templates.md +787 -787
- package/skills/fluentcart-developer/references/action-hooks-cart-checkout.md +1355 -1355
- package/skills/fluentcart-developer/references/action-hooks-customers-users.md +266 -266
- package/skills/fluentcart-developer/references/action-hooks-licenses.md +855 -855
- package/skills/fluentcart-developer/references/action-hooks-orders.md +631 -631
- package/skills/fluentcart-developer/references/action-hooks-payments-integrations.md +963 -963
- package/skills/fluentcart-developer/references/action-hooks-products-coupons.md +585 -585
- package/skills/fluentcart-developer/references/action-hooks-subscriptions.md +661 -661
- package/skills/fluentcart-developer/references/database-models-query-builder.md +194 -194
- package/skills/fluentcart-developer/references/database-models-reference.md +604 -604
- package/skills/fluentcart-developer/references/database-schema-reference.md +940 -940
- package/skills/fluentcart-developer/references/engineering-notes.md +154 -154
- package/skills/fluentcart-developer/references/fee-system-guide.md +449 -449
- package/skills/fluentcart-developer/references/filter-hooks-cart-checkout.md +1202 -1202
- package/skills/fluentcart-developer/references/filter-hooks-customers-subscriptions.md +902 -902
- package/skills/fluentcart-developer/references/filter-hooks-integrations-advanced.md +1598 -1598
- package/skills/fluentcart-developer/references/filter-hooks-orders-payments.md +1319 -1319
- package/skills/fluentcart-developer/references/filter-hooks-products-pricing.md +628 -628
- package/skills/fluentcart-developer/references/filter-hooks-settings-configuration.md +1177 -1177
- package/skills/fluentcart-developer/references/fluentcart-developer-guide.md +154 -154
- package/skills/fluentcart-developer/references/ghost-product-selling.md +458 -458
- package/skills/fluentcart-developer/references/modules-and-extensions-reference.md +224 -224
- package/skills/fluentcart-developer/references/payment-gateway-integration.md +761 -761
- package/skills/fluentcart-developer/references/rest-api-checkout.md +286 -286
- package/skills/fluentcart-developer/references/rest-api-coupons.md +794 -794
- package/skills/fluentcart-developer/references/rest-api-customer-profile.md +190 -190
- package/skills/fluentcart-developer/references/rest-api-customers.md +1121 -1121
- package/skills/fluentcart-developer/references/rest-api-dashboard-utilities.md +219 -219
- package/skills/fluentcart-developer/references/rest-api-email-notifications.md +619 -619
- package/skills/fluentcart-developer/references/rest-api-files.md +290 -290
- package/skills/fluentcart-developer/references/rest-api-integrations.md +324 -324
- package/skills/fluentcart-developer/references/rest-api-labels-attributes.md +321 -321
- package/skills/fluentcart-developer/references/rest-api-licensing.md +171 -171
- package/skills/fluentcart-developer/references/rest-api-order-bumps.md +200 -200
- package/skills/fluentcart-developer/references/rest-api-orders.md +1241 -1241
- package/skills/fluentcart-developer/references/rest-api-overview.md +131 -131
- package/skills/fluentcart-developer/references/rest-api-products.md +2563 -2563
- package/skills/fluentcart-developer/references/rest-api-public-shop.md +172 -172
- package/skills/fluentcart-developer/references/rest-api-reference.md +552 -552
- package/skills/fluentcart-developer/references/rest-api-reports.md +377 -377
- package/skills/fluentcart-developer/references/rest-api-roles-permissions.md +147 -147
- package/skills/fluentcart-developer/references/rest-api-settings.md +528 -528
- package/skills/fluentcart-developer/references/rest-api-shipping.md +799 -799
- package/skills/fluentcart-developer/references/rest-api-subscriptions.md +606 -606
- package/skills/fluentcart-developer/references/rest-api-tax.md +356 -356
- package/skills/fluentcart-developer/references/subscription-customization.md +197 -197
- package/skills/fluentcart-developer/scripts/cli.js +1 -1
- package/.gitattributes +0 -2
- package/CONTRIBUTING.md +0 -73
- package/copy-skills.js +0 -43
- package/skills.sh.json +0 -13
|
@@ -1,197 +1,197 @@
|
|
|
1
|
-
# Subscription Customization
|
|
2
|
-
|
|
3
|
-
Customization guides for FluentCart's subscription system — grace periods, custom billing intervals, and gateway compatibility.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Grace Periods
|
|
8
|
-
|
|
9
|
-
### What is a grace period?
|
|
10
|
-
|
|
11
|
-
When a subscription renewal payment fails or is delayed, FluentCart does not immediately mark the subscription as expired. Instead it waits a configurable number of days — the **grace period** — before changing the status to `expired`.
|
|
12
|
-
|
|
13
|
-
This matters because some payment methods are asynchronous. The payment may have been initiated and will succeed, but confirmation arrives hours or days later. Expiring the subscription the moment a payment is not instantly confirmed would incorrectly cut off access for customers who have already paid.
|
|
14
|
-
|
|
15
|
-
### Default grace periods by billing interval:
|
|
16
|
-
|
|
17
|
-
| Interval | Default grace (days) |
|
|
18
|
-
|----------|---------------------|
|
|
19
|
-
| Daily | 1 |
|
|
20
|
-
| Weekly | 3 |
|
|
21
|
-
| Monthly | 7 |
|
|
22
|
-
| Quarterly | 15 |
|
|
23
|
-
| Half-yearly | 15 |
|
|
24
|
-
| Yearly | 15 |
|
|
25
|
-
|
|
26
|
-
### When should you extend the grace period?
|
|
27
|
-
|
|
28
|
-
The clearest case: **SEPA Direct Debit.**
|
|
29
|
-
|
|
30
|
-
SEPA bank transfers can take 2–3 business days to confirm. For a monthly subscriber paying via SEPA, the default 7-day grace period is sufficient — but only if the payment was initiated on time. If your site processes renewals late (e.g. a missed cron run), or if a weekend is involved, a 7-day window can become tight. Extending it to 10–14 days eliminates false expiries for SEPA customers.
|
|
31
|
-
|
|
32
|
-
**Other cases where you should extend:**
|
|
33
|
-
|
|
34
|
-
- **ACH / bank transfers** — US bank transfers can take 3–5 business days.
|
|
35
|
-
- **Slow-processing gateways** — Some regional gateways in emerging markets batch-process overnight.
|
|
36
|
-
- **High-value subscriptions** — For yearly plans where incorrectly expiring a subscription has a large customer impact, a 21–30 day window is safer.
|
|
37
|
-
|
|
38
|
-
```php
|
|
39
|
-
add_filter('fluent_cart/subscription/grace_period_days', function (array $gracePeriods): array {
|
|
40
|
-
// Extend monthly grace period to 14 days to safely cover SEPA debit delays
|
|
41
|
-
$gracePeriods['monthly'] = 14;
|
|
42
|
-
|
|
43
|
-
// Give yearly subscribers a full month before expiry
|
|
44
|
-
$gracePeriods['yearly'] = 30;
|
|
45
|
-
|
|
46
|
-
return $gracePeriods;
|
|
47
|
-
});
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### When should you reduce the grace period?
|
|
51
|
-
|
|
52
|
-
If your product delivers time-sensitive value (live access, daily content, seat-based software), you may want stricter expiry — cut off access as soon as a payment has clearly failed, not 7–15 days later.
|
|
53
|
-
|
|
54
|
-
```php
|
|
55
|
-
add_filter('fluent_cart/subscription/grace_period_days', function (array $gracePeriods): array {
|
|
56
|
-
// Tight grace for daily content — expire after 1 missed day regardless of interval
|
|
57
|
-
$gracePeriods['monthly'] = 1;
|
|
58
|
-
$gracePeriods['quarterly'] = 1;
|
|
59
|
-
$gracePeriods['half_yearly'] = 1;
|
|
60
|
-
$gracePeriods['yearly'] = 3;
|
|
61
|
-
|
|
62
|
-
return $gracePeriods;
|
|
63
|
-
});
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
> [!WARNING]
|
|
67
|
-
> Reducing grace periods below 3 days for bank-based payment methods (SEPA, ACH) will cause valid customers to lose access before their payment has had time to settle. Only do this when your payment methods are card-only or instant-confirm.
|
|
68
|
-
|
|
69
|
-
### Targeting grace period by payment method
|
|
70
|
-
|
|
71
|
-
If you accept both instant (card) and delayed (SEPA/ACH) payment methods, you can apply different grace periods per customer:
|
|
72
|
-
|
|
73
|
-
```php
|
|
74
|
-
add_filter('fluent_cart/subscription/grace_period_days', function (array $gracePeriods): array {
|
|
75
|
-
// Default stays for card-based subscriptions.
|
|
76
|
-
// Individual subscriptions using SEPA need more time — handled in grace_period_days_for_subscription.
|
|
77
|
-
return $gracePeriods;
|
|
78
|
-
});
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
> [!TIP]
|
|
82
|
-
> The `fluent_cart/subscription/grace_period_days` filter applies globally across all subscriptions of a given billing interval. If you need per-subscription overrides (e.g. by payment method), use the subscription's `current_payment_method` field to conditionally adjust values in your filter callback, by loading the specific subscription from context.
|
|
83
|
-
|
|
84
|
-
### Reference
|
|
85
|
-
|
|
86
|
-
- **Filter:** `fluent_cart/subscription/grace_period_days`
|
|
87
|
-
- **Source:** `app/Services/Payments/SubscriptionHelper.php`
|
|
88
|
-
- **Full filter reference:** [Customers & Subscriptions filters](filter-hooks-customers-subscriptions.md)
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Custom Subscription Intervals
|
|
93
|
-
|
|
94
|
-
FluentCart ships with `daily`, `weekly`, `monthly`, `quarterly`, `half_yearly`, and `yearly`. You can register additional intervals through filters.
|
|
95
|
-
|
|
96
|
-
The example below adds an **every 10th day** interval. Swap in your own values as needed.
|
|
97
|
-
|
|
98
|
-
### 1. Register the interval option
|
|
99
|
-
|
|
100
|
-
Adds the interval to the product editor dropdown. All three fields are required.
|
|
101
|
-
|
|
102
|
-
```php
|
|
103
|
-
add_filter('fluent_cart/available_subscription_interval_options', function ($options) {
|
|
104
|
-
// Add custom "Every 10th day" interval to the product editor dropdown
|
|
105
|
-
return array_merge($options, [
|
|
106
|
-
[
|
|
107
|
-
'label' => __('Every 10th day', 'fluent-cart'), // shown in dropdown
|
|
108
|
-
'value' => 'every_tenth_day', // stored in database
|
|
109
|
-
'map_value' => '10th Day', // readable format
|
|
110
|
-
],
|
|
111
|
-
]);
|
|
112
|
-
});
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### 2. Define the interval in days
|
|
116
|
-
|
|
117
|
-
Used internally for trial day calculations and renewal scheduling.
|
|
118
|
-
|
|
119
|
-
```php
|
|
120
|
-
add_filter('fluent_cart/subscription_interval_in_days', function ($days, $args) {
|
|
121
|
-
// Return 10 days for our custom interval
|
|
122
|
-
if ($args['interval'] === 'every_tenth_day') {
|
|
123
|
-
return 10;
|
|
124
|
-
}
|
|
125
|
-
return $days;
|
|
126
|
-
}, 10, 2);
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### 3. Map to gateway billing period
|
|
130
|
-
|
|
131
|
-
Required for built-in gateways (Stripe, PayPal). If you own the gateway code, handle this directly in your processor instead.
|
|
132
|
-
|
|
133
|
-
```php
|
|
134
|
-
add_filter('fluent_cart/subscription_billing_period', function ($billingPeriod, $args) {
|
|
135
|
-
// Only handle our custom interval
|
|
136
|
-
if ($args['subscription_interval'] !== 'every_tenth_day') {
|
|
137
|
-
return $billingPeriod;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Map to Stripe billing period format (10 days)
|
|
141
|
-
if ($args['payment_method'] === 'stripe') {
|
|
142
|
-
$billingPeriod['interval_unit'] = 'day';
|
|
143
|
-
$billingPeriod['interval_frequency'] = 10;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Map to PayPal billing period format (10 days)
|
|
147
|
-
if ($args['payment_method'] === 'paypal') {
|
|
148
|
-
$billingPeriod['interval_unit'] = 'day';
|
|
149
|
-
$billingPeriod['interval_frequency'] = 10;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return $billingPeriod;
|
|
153
|
-
}, 10, 2);
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### 4. Set max trial days (optional)
|
|
157
|
-
|
|
158
|
-
Caps how many trial days can be assigned to this interval.
|
|
159
|
-
|
|
160
|
-
```php
|
|
161
|
-
add_filter('fluent_cart/max_trial_days_allowed', function ($days, $args) {
|
|
162
|
-
// Cap trial days at the interval length for our custom interval
|
|
163
|
-
if ($args['repeat_interval'] === 'every_tenth_day') {
|
|
164
|
-
return min($args['existing_trial_days'] + $args['interval_in_days'], 10);
|
|
165
|
-
}
|
|
166
|
-
return $days;
|
|
167
|
-
}, 10, 2);
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### 5. License validity (Pro — licensed products only)
|
|
171
|
-
|
|
172
|
-
If the product uses the licensing module, set the expiry period for the custom interval.
|
|
173
|
-
|
|
174
|
-
```php
|
|
175
|
-
add_filter('fluent_cart/license/default_validity_by_variation', function ($validity, $args) {
|
|
176
|
-
// Set license validity to 10 days for our custom interval
|
|
177
|
-
$interval = Arr::get($args['variation']->other_info, 'repeat_interval');
|
|
178
|
-
if ($interval === 'every_tenth_day') {
|
|
179
|
-
return ['unit' => 'day', 'value' => 10];
|
|
180
|
-
}
|
|
181
|
-
return $validity;
|
|
182
|
-
}, 10, 2);
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### Gateway compatibility
|
|
186
|
-
|
|
187
|
-
- **Stripe** accepts any positive integer with `day`, `week`, `month`, or `year`.
|
|
188
|
-
- **PayPal** supports the same units but has frequency limits — check PayPal's billing plan docs for your interval.
|
|
189
|
-
|
|
190
|
-
---
|
|
191
|
-
|
|
192
|
-
## Related Documentation
|
|
193
|
-
|
|
194
|
-
- [Subscription Hooks](action-hooks-subscriptions.md) - Subscription lifecycle action hooks
|
|
195
|
-
- [Subscription Filters](filter-hooks-customers-subscriptions.md) - Customer & subscription filter hooks
|
|
196
|
-
- [Payment Gateway Integration](payment-gateway-integration.md) - Custom payment gateway development
|
|
197
|
-
- [Database Models](database-models-reference.md) - Data model documentation
|
|
1
|
+
# Subscription Customization
|
|
2
|
+
|
|
3
|
+
Customization guides for FluentCart's subscription system — grace periods, custom billing intervals, and gateway compatibility.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Grace Periods
|
|
8
|
+
|
|
9
|
+
### What is a grace period?
|
|
10
|
+
|
|
11
|
+
When a subscription renewal payment fails or is delayed, FluentCart does not immediately mark the subscription as expired. Instead it waits a configurable number of days — the **grace period** — before changing the status to `expired`.
|
|
12
|
+
|
|
13
|
+
This matters because some payment methods are asynchronous. The payment may have been initiated and will succeed, but confirmation arrives hours or days later. Expiring the subscription the moment a payment is not instantly confirmed would incorrectly cut off access for customers who have already paid.
|
|
14
|
+
|
|
15
|
+
### Default grace periods by billing interval:
|
|
16
|
+
|
|
17
|
+
| Interval | Default grace (days) |
|
|
18
|
+
|----------|---------------------|
|
|
19
|
+
| Daily | 1 |
|
|
20
|
+
| Weekly | 3 |
|
|
21
|
+
| Monthly | 7 |
|
|
22
|
+
| Quarterly | 15 |
|
|
23
|
+
| Half-yearly | 15 |
|
|
24
|
+
| Yearly | 15 |
|
|
25
|
+
|
|
26
|
+
### When should you extend the grace period?
|
|
27
|
+
|
|
28
|
+
The clearest case: **SEPA Direct Debit.**
|
|
29
|
+
|
|
30
|
+
SEPA bank transfers can take 2–3 business days to confirm. For a monthly subscriber paying via SEPA, the default 7-day grace period is sufficient — but only if the payment was initiated on time. If your site processes renewals late (e.g. a missed cron run), or if a weekend is involved, a 7-day window can become tight. Extending it to 10–14 days eliminates false expiries for SEPA customers.
|
|
31
|
+
|
|
32
|
+
**Other cases where you should extend:**
|
|
33
|
+
|
|
34
|
+
- **ACH / bank transfers** — US bank transfers can take 3–5 business days.
|
|
35
|
+
- **Slow-processing gateways** — Some regional gateways in emerging markets batch-process overnight.
|
|
36
|
+
- **High-value subscriptions** — For yearly plans where incorrectly expiring a subscription has a large customer impact, a 21–30 day window is safer.
|
|
37
|
+
|
|
38
|
+
```php
|
|
39
|
+
add_filter('fluent_cart/subscription/grace_period_days', function (array $gracePeriods): array {
|
|
40
|
+
// Extend monthly grace period to 14 days to safely cover SEPA debit delays
|
|
41
|
+
$gracePeriods['monthly'] = 14;
|
|
42
|
+
|
|
43
|
+
// Give yearly subscribers a full month before expiry
|
|
44
|
+
$gracePeriods['yearly'] = 30;
|
|
45
|
+
|
|
46
|
+
return $gracePeriods;
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### When should you reduce the grace period?
|
|
51
|
+
|
|
52
|
+
If your product delivers time-sensitive value (live access, daily content, seat-based software), you may want stricter expiry — cut off access as soon as a payment has clearly failed, not 7–15 days later.
|
|
53
|
+
|
|
54
|
+
```php
|
|
55
|
+
add_filter('fluent_cart/subscription/grace_period_days', function (array $gracePeriods): array {
|
|
56
|
+
// Tight grace for daily content — expire after 1 missed day regardless of interval
|
|
57
|
+
$gracePeriods['monthly'] = 1;
|
|
58
|
+
$gracePeriods['quarterly'] = 1;
|
|
59
|
+
$gracePeriods['half_yearly'] = 1;
|
|
60
|
+
$gracePeriods['yearly'] = 3;
|
|
61
|
+
|
|
62
|
+
return $gracePeriods;
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
> [!WARNING]
|
|
67
|
+
> Reducing grace periods below 3 days for bank-based payment methods (SEPA, ACH) will cause valid customers to lose access before their payment has had time to settle. Only do this when your payment methods are card-only or instant-confirm.
|
|
68
|
+
|
|
69
|
+
### Targeting grace period by payment method
|
|
70
|
+
|
|
71
|
+
If you accept both instant (card) and delayed (SEPA/ACH) payment methods, you can apply different grace periods per customer:
|
|
72
|
+
|
|
73
|
+
```php
|
|
74
|
+
add_filter('fluent_cart/subscription/grace_period_days', function (array $gracePeriods): array {
|
|
75
|
+
// Default stays for card-based subscriptions.
|
|
76
|
+
// Individual subscriptions using SEPA need more time — handled in grace_period_days_for_subscription.
|
|
77
|
+
return $gracePeriods;
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
> [!TIP]
|
|
82
|
+
> The `fluent_cart/subscription/grace_period_days` filter applies globally across all subscriptions of a given billing interval. If you need per-subscription overrides (e.g. by payment method), use the subscription's `current_payment_method` field to conditionally adjust values in your filter callback, by loading the specific subscription from context.
|
|
83
|
+
|
|
84
|
+
### Reference
|
|
85
|
+
|
|
86
|
+
- **Filter:** `fluent_cart/subscription/grace_period_days`
|
|
87
|
+
- **Source:** `app/Services/Payments/SubscriptionHelper.php`
|
|
88
|
+
- **Full filter reference:** [Customers & Subscriptions filters](filter-hooks-customers-subscriptions.md)
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Custom Subscription Intervals
|
|
93
|
+
|
|
94
|
+
FluentCart ships with `daily`, `weekly`, `monthly`, `quarterly`, `half_yearly`, and `yearly`. You can register additional intervals through filters.
|
|
95
|
+
|
|
96
|
+
The example below adds an **every 10th day** interval. Swap in your own values as needed.
|
|
97
|
+
|
|
98
|
+
### 1. Register the interval option
|
|
99
|
+
|
|
100
|
+
Adds the interval to the product editor dropdown. All three fields are required.
|
|
101
|
+
|
|
102
|
+
```php
|
|
103
|
+
add_filter('fluent_cart/available_subscription_interval_options', function ($options) {
|
|
104
|
+
// Add custom "Every 10th day" interval to the product editor dropdown
|
|
105
|
+
return array_merge($options, [
|
|
106
|
+
[
|
|
107
|
+
'label' => __('Every 10th day', 'fluent-cart'), // shown in dropdown
|
|
108
|
+
'value' => 'every_tenth_day', // stored in database
|
|
109
|
+
'map_value' => '10th Day', // readable format
|
|
110
|
+
],
|
|
111
|
+
]);
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 2. Define the interval in days
|
|
116
|
+
|
|
117
|
+
Used internally for trial day calculations and renewal scheduling.
|
|
118
|
+
|
|
119
|
+
```php
|
|
120
|
+
add_filter('fluent_cart/subscription_interval_in_days', function ($days, $args) {
|
|
121
|
+
// Return 10 days for our custom interval
|
|
122
|
+
if ($args['interval'] === 'every_tenth_day') {
|
|
123
|
+
return 10;
|
|
124
|
+
}
|
|
125
|
+
return $days;
|
|
126
|
+
}, 10, 2);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 3. Map to gateway billing period
|
|
130
|
+
|
|
131
|
+
Required for built-in gateways (Stripe, PayPal). If you own the gateway code, handle this directly in your processor instead.
|
|
132
|
+
|
|
133
|
+
```php
|
|
134
|
+
add_filter('fluent_cart/subscription_billing_period', function ($billingPeriod, $args) {
|
|
135
|
+
// Only handle our custom interval
|
|
136
|
+
if ($args['subscription_interval'] !== 'every_tenth_day') {
|
|
137
|
+
return $billingPeriod;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Map to Stripe billing period format (10 days)
|
|
141
|
+
if ($args['payment_method'] === 'stripe') {
|
|
142
|
+
$billingPeriod['interval_unit'] = 'day';
|
|
143
|
+
$billingPeriod['interval_frequency'] = 10;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Map to PayPal billing period format (10 days)
|
|
147
|
+
if ($args['payment_method'] === 'paypal') {
|
|
148
|
+
$billingPeriod['interval_unit'] = 'day';
|
|
149
|
+
$billingPeriod['interval_frequency'] = 10;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return $billingPeriod;
|
|
153
|
+
}, 10, 2);
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### 4. Set max trial days (optional)
|
|
157
|
+
|
|
158
|
+
Caps how many trial days can be assigned to this interval.
|
|
159
|
+
|
|
160
|
+
```php
|
|
161
|
+
add_filter('fluent_cart/max_trial_days_allowed', function ($days, $args) {
|
|
162
|
+
// Cap trial days at the interval length for our custom interval
|
|
163
|
+
if ($args['repeat_interval'] === 'every_tenth_day') {
|
|
164
|
+
return min($args['existing_trial_days'] + $args['interval_in_days'], 10);
|
|
165
|
+
}
|
|
166
|
+
return $days;
|
|
167
|
+
}, 10, 2);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 5. License validity (Pro — licensed products only)
|
|
171
|
+
|
|
172
|
+
If the product uses the licensing module, set the expiry period for the custom interval.
|
|
173
|
+
|
|
174
|
+
```php
|
|
175
|
+
add_filter('fluent_cart/license/default_validity_by_variation', function ($validity, $args) {
|
|
176
|
+
// Set license validity to 10 days for our custom interval
|
|
177
|
+
$interval = Arr::get($args['variation']->other_info, 'repeat_interval');
|
|
178
|
+
if ($interval === 'every_tenth_day') {
|
|
179
|
+
return ['unit' => 'day', 'value' => 10];
|
|
180
|
+
}
|
|
181
|
+
return $validity;
|
|
182
|
+
}, 10, 2);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Gateway compatibility
|
|
186
|
+
|
|
187
|
+
- **Stripe** accepts any positive integer with `day`, `week`, `month`, or `year`.
|
|
188
|
+
- **PayPal** supports the same units but has frequency limits — check PayPal's billing plan docs for your interval.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Related Documentation
|
|
193
|
+
|
|
194
|
+
- [Subscription Hooks](action-hooks-subscriptions.md) - Subscription lifecycle action hooks
|
|
195
|
+
- [Subscription Filters](filter-hooks-customers-subscriptions.md) - Customer & subscription filter hooks
|
|
196
|
+
- [Payment Gateway Integration](payment-gateway-integration.md) - Custom payment gateway development
|
|
197
|
+
- [Database Models](database-models-reference.md) - Data model documentation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
// Empty
|
|
1
|
+
// Empty
|
package/.gitattributes
DELETED
package/CONTRIBUTING.md
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# Contributing to Atif Jubaer's Agent Skills
|
|
2
|
-
|
|
3
|
-
Thank you for your interest in contributing to this skills repository! We welcome contributions for new custom AI agent skills, updates to existing references, and improvements to our installer.
|
|
4
|
-
|
|
5
|
-
Here is a guide on how you (or your AI coding assistant) can add new skills and submit improvements.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 1. How to Add a New Skill
|
|
10
|
-
|
|
11
|
-
To submit a new skill to the repository, follow these directory and file guidelines:
|
|
12
|
-
|
|
13
|
-
### Step A: Create your Skill Folder
|
|
14
|
-
Skills are grouped under categories under the main `skills/` folder. Create a new directory matching your category and skill name:
|
|
15
|
-
```bash
|
|
16
|
-
mkdir -p skills/skills/<category-name>/<skill-slug>
|
|
17
|
-
```
|
|
18
|
-
*Example:* `skills/skills/productivity/wordpress-seo`
|
|
19
|
-
|
|
20
|
-
### Step B: Create the `SKILL.md` file
|
|
21
|
-
Inside your skill folder, create a `SKILL.md` file containing a YAML frontmatter header and the main instruction set:
|
|
22
|
-
```markdown
|
|
23
|
-
---
|
|
24
|
-
name: "WordPress SEO Specialist"
|
|
25
|
-
description: "Optimizes meta tags, schema structures, and handles sitemap configurations."
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
# WordPress SEO Specialist
|
|
29
|
-
|
|
30
|
-
Instructions for the AI assistant go here...
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
> [!IMPORTANT]
|
|
34
|
-
> The `name` and `description` string values in the YAML frontmatter **must be wrapped in double quotes** (`"`). Strict YAML parsers will fail if special characters (like colons `:`) are used without quotes.
|
|
35
|
-
|
|
36
|
-
### Step C: (Optional) Add Subdirectories
|
|
37
|
-
For Level 3 deep knowledge and presets, you can add:
|
|
38
|
-
* `references/` - For detailed developer manuals (linked from your main `SKILL.md` using relative paths).
|
|
39
|
-
* `assets/` - For boilerplate code, config templates, or resource assets.
|
|
40
|
-
* `scripts/` - For executable automation scripts (Node.js/Python).
|
|
41
|
-
|
|
42
|
-
### Step D: Register in `skills.sh.json`
|
|
43
|
-
To make sure your skill displays under the correct section on the public `skills.sh` website, register your skill slug under a grouping in `skills.sh.json` at the root of the repository:
|
|
44
|
-
```json
|
|
45
|
-
{
|
|
46
|
-
"title": "WordPress SEO",
|
|
47
|
-
"description": "Skills for search engine optimization.",
|
|
48
|
-
"skills": [
|
|
49
|
-
"wordpress-seo"
|
|
50
|
-
]
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## 2. Testing Your Changes Locally
|
|
57
|
-
|
|
58
|
-
Before submitting a Pull Request, verify your skill installer executes correctly:
|
|
59
|
-
|
|
60
|
-
1. Navigate to your repository root.
|
|
61
|
-
2. Run the local installer sync:
|
|
62
|
-
```bash
|
|
63
|
-
node bin/index.js init
|
|
64
|
-
```
|
|
65
|
-
3. Check that the skill files are compiled and successfully synced to your local editor profile directories (like Cursor, Claude, or Gemini).
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
## 3. Submitting a Pull Request
|
|
70
|
-
|
|
71
|
-
1. Fork the repository.
|
|
72
|
-
2. Commit your changes using clear commit summaries (e.g. `feat: add wordpress-seo skill`).
|
|
73
|
-
3. Push to your fork and submit a Pull Request to the `main` branch.
|
package/copy-skills.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const os = require('os');
|
|
4
|
-
|
|
5
|
-
function copyDir(src, dest) {
|
|
6
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
7
|
-
let entries = fs.readdirSync(src, { withFileTypes: true });
|
|
8
|
-
|
|
9
|
-
for (let entry of entries) {
|
|
10
|
-
let srcPath = path.join(src, entry.name);
|
|
11
|
-
let destPath = path.join(dest, entry.name);
|
|
12
|
-
|
|
13
|
-
if (entry.isDirectory()) {
|
|
14
|
-
copyDir(srcPath, destPath);
|
|
15
|
-
} else {
|
|
16
|
-
fs.copyFileSync(srcPath, destPath);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const packageRoot = __dirname;
|
|
22
|
-
const targetSkillDir = path.join(packageRoot, 'skills', 'fluentcart-developer');
|
|
23
|
-
const srcSkillMd = path.join(targetSkillDir, 'SKILL.md');
|
|
24
|
-
const srcReferences = path.join(targetSkillDir, 'references');
|
|
25
|
-
const srcExamples = path.join(targetSkillDir, 'examples');
|
|
26
|
-
|
|
27
|
-
const geminiGlobalSkillDir = path.join(os.homedir(), '.gemini', 'config', 'skills', 'fluentcart-developer');
|
|
28
|
-
|
|
29
|
-
console.log('Syncing skill files to global Gemini skills directory...');
|
|
30
|
-
try {
|
|
31
|
-
// Sync from skills/skills/fluentcart-developer to global Gemini skill dir
|
|
32
|
-
if (fs.existsSync(targetSkillDir)) {
|
|
33
|
-
fs.mkdirSync(geminiGlobalSkillDir, { recursive: true });
|
|
34
|
-
if (fs.existsSync(srcSkillMd)) fs.copyFileSync(srcSkillMd, path.join(geminiGlobalSkillDir, 'SKILL.md'));
|
|
35
|
-
if (fs.existsSync(srcReferences)) copyDir(srcReferences, path.join(geminiGlobalSkillDir, 'references'));
|
|
36
|
-
if (fs.existsSync(srcExamples)) copyDir(srcExamples, path.join(geminiGlobalSkillDir, 'examples'));
|
|
37
|
-
console.log('✓ Synced to global Gemini skills directory');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
console.log('✓ Build sync completed successfully!');
|
|
41
|
-
} catch (err) {
|
|
42
|
-
console.error('Error during build sync:', err.message);
|
|
43
|
-
}
|
package/skills.sh.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://skills.sh/schemas/skills.sh.schema.json",
|
|
3
|
-
"notGrouped": "bottom",
|
|
4
|
-
"groupings": [
|
|
5
|
-
{
|
|
6
|
-
"title": "WordPress & E-Commerce",
|
|
7
|
-
"description": "Skills for FluentCart theme and plugin development.",
|
|
8
|
-
"skills": [
|
|
9
|
-
"fluentcart-developer"
|
|
10
|
-
]
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
}
|