fluentcart-developer 1.1.0
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/.gitattributes +2 -0
- package/CLAUDE.md +22 -0
- package/CONTRIBUTING.md +73 -0
- package/LICENSE +21 -0
- package/README.md +127 -0
- package/SKILL.md +127 -0
- package/bin/index.js +281 -0
- package/copy-skills.js +43 -0
- package/package.json +38 -0
- package/skills/fluentcart-developer/SKILL.md +172 -0
- package/skills/fluentcart-developer/examples/README.md +25 -0
- package/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/fluent-cart/checkout.php +32 -0
- package/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/functions.php +40 -0
- package/skills/fluentcart-developer/examples/sample-custom-addon/fluentcart-custom-addon.php +114 -0
- package/skills/fluentcart-developer/examples/sample-custom-payment-gateway/fluentcart-custom-gateway-example.php +149 -0
- package/skills/fluentcart-developer/examples/sample-fee-surcharge-plugin/fluentcart-fee-surcharge.php +38 -0
- package/skills/fluentcart-developer/examples/sample-shipping-carrier/fluentcart-custom-shipping-carrier.php +62 -0
- package/skills/fluentcart-developer/references/action-hooks-admin-templates.md +787 -0
- package/skills/fluentcart-developer/references/action-hooks-cart-checkout.md +1355 -0
- package/skills/fluentcart-developer/references/action-hooks-customers-users.md +266 -0
- package/skills/fluentcart-developer/references/action-hooks-licenses.md +855 -0
- package/skills/fluentcart-developer/references/action-hooks-orders.md +631 -0
- package/skills/fluentcart-developer/references/action-hooks-payments-integrations.md +963 -0
- package/skills/fluentcart-developer/references/action-hooks-products-coupons.md +585 -0
- package/skills/fluentcart-developer/references/action-hooks-subscriptions.md +661 -0
- package/skills/fluentcart-developer/references/database-models-query-builder.md +194 -0
- package/skills/fluentcart-developer/references/database-models-reference.md +604 -0
- package/skills/fluentcart-developer/references/database-schema-reference.md +940 -0
- package/skills/fluentcart-developer/references/engineering-notes.md +154 -0
- package/skills/fluentcart-developer/references/fee-system-guide.md +449 -0
- package/skills/fluentcart-developer/references/filter-hooks-cart-checkout.md +1202 -0
- package/skills/fluentcart-developer/references/filter-hooks-customers-subscriptions.md +902 -0
- package/skills/fluentcart-developer/references/filter-hooks-integrations-advanced.md +1598 -0
- package/skills/fluentcart-developer/references/filter-hooks-orders-payments.md +1319 -0
- package/skills/fluentcart-developer/references/filter-hooks-products-pricing.md +628 -0
- package/skills/fluentcart-developer/references/filter-hooks-settings-configuration.md +1177 -0
- package/skills/fluentcart-developer/references/fluentcart-developer-guide.md +154 -0
- package/skills/fluentcart-developer/references/ghost-product-selling.md +458 -0
- package/skills/fluentcart-developer/references/modules-and-extensions-reference.md +224 -0
- package/skills/fluentcart-developer/references/paddle-gateway-case-study.md +1925 -0
- package/skills/fluentcart-developer/references/payment-gateway-integration.md +761 -0
- package/skills/fluentcart-developer/references/rest-api-checkout.md +286 -0
- package/skills/fluentcart-developer/references/rest-api-coupons.md +794 -0
- package/skills/fluentcart-developer/references/rest-api-customer-profile.md +190 -0
- package/skills/fluentcart-developer/references/rest-api-customers.md +1121 -0
- package/skills/fluentcart-developer/references/rest-api-dashboard-utilities.md +219 -0
- package/skills/fluentcart-developer/references/rest-api-email-notifications.md +619 -0
- package/skills/fluentcart-developer/references/rest-api-files.md +290 -0
- package/skills/fluentcart-developer/references/rest-api-integrations.md +324 -0
- package/skills/fluentcart-developer/references/rest-api-labels-attributes.md +321 -0
- package/skills/fluentcart-developer/references/rest-api-licensing.md +171 -0
- package/skills/fluentcart-developer/references/rest-api-order-bumps.md +200 -0
- package/skills/fluentcart-developer/references/rest-api-orders.md +1241 -0
- package/skills/fluentcart-developer/references/rest-api-overview.md +131 -0
- package/skills/fluentcart-developer/references/rest-api-products.md +2563 -0
- package/skills/fluentcart-developer/references/rest-api-public-shop.md +172 -0
- package/skills/fluentcart-developer/references/rest-api-reference.md +552 -0
- package/skills/fluentcart-developer/references/rest-api-reports.md +377 -0
- package/skills/fluentcart-developer/references/rest-api-roles-permissions.md +147 -0
- package/skills/fluentcart-developer/references/rest-api-settings.md +528 -0
- package/skills/fluentcart-developer/references/rest-api-shipping.md +800 -0
- package/skills/fluentcart-developer/references/rest-api-subscriptions.md +606 -0
- package/skills/fluentcart-developer/references/rest-api-tax.md +356 -0
- package/skills/fluentcart-developer/references/subscription-customization.md +197 -0
- package/skills/fluentcart-developer/scripts/cli.js +1 -0
- package/skills.sh.json +13 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# Action Hooks: Customers & Users
|
|
2
|
+
|
|
3
|
+
All hooks related to Customer lifecycle, user registration, and the customer-facing frontend portal.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Customer Status Changes
|
|
8
|
+
|
|
9
|
+
### `customer_status_to_{status}`
|
|
10
|
+
`fluent_cart/customer_status_to_{$newStatus}` — Fired when a customer's status changes to a specific status
|
|
11
|
+
|
|
12
|
+
* **When it runs:** This dynamic action fires immediately after a Customer's status is updated and saved to the database. A separate hook is dispatched for each target status, allowing you to listen for transitions to a single status (e.g., `active` or `inactive`) without inspecting the payload.
|
|
13
|
+
* **Available dynamic variants:** `active`, `inactive`
|
|
14
|
+
* **Source:** `app/Models/Customer.php`
|
|
15
|
+
|
|
16
|
+
#### Parameters:
|
|
17
|
+
`$data` *(array)*: Customer status transition data
|
|
18
|
+
```php
|
|
19
|
+
$data = [
|
|
20
|
+
'customer' => $customer, // \FluentCart\App\Models\Customer — The customer model instance (already updated)
|
|
21
|
+
'old_status' => 'inactive', // string — Previous status before the change
|
|
22
|
+
'new_status' => 'active', // string — The new status that was just applied
|
|
23
|
+
];
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### Usage Example:
|
|
27
|
+
```php
|
|
28
|
+
// Listen specifically for customers becoming active
|
|
29
|
+
add_action('fluent_cart/customer_status_to_active', function ($data) {
|
|
30
|
+
// Extract customer model instance
|
|
31
|
+
$customer = $data['customer'];
|
|
32
|
+
// Send a reactivation welcome-back email
|
|
33
|
+
wp_mail(
|
|
34
|
+
$customer->email,
|
|
35
|
+
'Welcome back!',
|
|
36
|
+
'Your account has been reactivated.'
|
|
37
|
+
);
|
|
38
|
+
}, 10, 1);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
### `customer_status_updated`
|
|
44
|
+
`fluent_cart/customer_status_updated` — Fired on any customer status change
|
|
45
|
+
|
|
46
|
+
* **When it runs:** This action fires immediately after the dynamic `fluent_cart/customer_status_to_{$newStatus}` hook for every customer status change. Use this hook when you need to respond to all status transitions regardless of the target status.
|
|
47
|
+
* **Source:** `app/Models/Customer.php`
|
|
48
|
+
|
|
49
|
+
#### Parameters:
|
|
50
|
+
`$data` *(array)*: Customer status transition data
|
|
51
|
+
```php
|
|
52
|
+
$data = [
|
|
53
|
+
'customer' => $customer, // \FluentCart\App\Models\Customer — The customer model instance (already updated)
|
|
54
|
+
'old_status' => 'active', // string — Previous status before the change
|
|
55
|
+
'new_status' => 'inactive', // string — The new status that was just applied
|
|
56
|
+
];
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### Usage Example:
|
|
60
|
+
```php
|
|
61
|
+
// Hook into any customer status change
|
|
62
|
+
add_action('fluent_cart/customer_status_updated', function ($data) {
|
|
63
|
+
// Extract customer model instance
|
|
64
|
+
$customer = $data['customer'];
|
|
65
|
+
// Log every status transition into FluentCart logs
|
|
66
|
+
fluent_cart_add_log(
|
|
67
|
+
'Customer Status Changed',
|
|
68
|
+
sprintf(
|
|
69
|
+
'Customer #%d (%s) status changed from %s to %s',
|
|
70
|
+
$customer->id,
|
|
71
|
+
$customer->email,
|
|
72
|
+
$data['old_status'],
|
|
73
|
+
$data['new_status']
|
|
74
|
+
),
|
|
75
|
+
'info'
|
|
76
|
+
);
|
|
77
|
+
}, 10, 1);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Customer Data
|
|
83
|
+
|
|
84
|
+
### `customer_email_changed`
|
|
85
|
+
`fluent_cart/customer_email_changed` — Fired when a customer's email is updated via WordPress profile
|
|
86
|
+
|
|
87
|
+
* **When it runs:** This action fires when a WordPress user updates their email address (via `profile_update`) and no existing FluentCart Customer record matches the new email. In that case the existing customer row is updated in place with the new email. If a customer record already exists for the new email, this hook does not fire -- instead, resources are moved and `fluent_cart/customer_resources_moved` fires.
|
|
88
|
+
* **Note:** Both `old_customer` and `new_customer` reference the same Customer model instance. The customer record has already been updated with the new email at the time this hook fires.
|
|
89
|
+
* **Source:** `app/Hooks/Handlers/UserHandler.php`
|
|
90
|
+
|
|
91
|
+
#### Parameters:
|
|
92
|
+
`$data` *(array)*: Email change data
|
|
93
|
+
```php
|
|
94
|
+
$data = [
|
|
95
|
+
'old_customer' => $oldCustomer, // \FluentCart\App\Models\Customer — The customer model (already updated with new email)
|
|
96
|
+
'new_customer' => $oldCustomer, // \FluentCart\App\Models\Customer — Same customer instance (already updated)
|
|
97
|
+
'old_email' => 'old@example.com', // string — The previous email address
|
|
98
|
+
'new_email' => 'new@example.com', // string — The new email address
|
|
99
|
+
'userId' => 42, // int — WordPress user ID
|
|
100
|
+
];
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Usage Example:
|
|
104
|
+
```php
|
|
105
|
+
// Hook when a customer's email is updated via WordPress profile
|
|
106
|
+
add_action('fluent_cart/customer_email_changed', function ($data) {
|
|
107
|
+
// Extract updated customer model
|
|
108
|
+
$customer = $data['old_customer'];
|
|
109
|
+
// Sync the email change to an external CRM
|
|
110
|
+
my_crm_update_email(
|
|
111
|
+
$customer->id,
|
|
112
|
+
$data['old_email'],
|
|
113
|
+
$data['new_email']
|
|
114
|
+
);
|
|
115
|
+
}, 10, 1);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### `customer_resources_moved`
|
|
121
|
+
`fluent_cart/customer_resources_moved` — Fired after all resources are moved between customers
|
|
122
|
+
|
|
123
|
+
* **When it runs:** This action fires after a WordPress user's email change triggers a merge between two Customer records. When the new email already belongs to an existing FluentCart customer, all resources (`Order`, `Subscription`, `AppliedCoupon`, `Cart`, customer meta, addresses, and download permissions) are transferred from the old customer to the existing customer. This hook fires once the migration is complete.
|
|
124
|
+
* **Migrated resources:** `OrderDownloadPermission`, `Order`, `AppliedCoupon`, `Cart`, `CustomerMeta`, `CustomerAddresses`, `Subscription`
|
|
125
|
+
* **Source:** `app/Hooks/Handlers/UserHandler.php`
|
|
126
|
+
|
|
127
|
+
#### Parameters:
|
|
128
|
+
`$data` *(array)*: Resource migration data
|
|
129
|
+
```php
|
|
130
|
+
$data = [
|
|
131
|
+
'from_customer_id' => 10, // int — The source customer ID (resources moved away)
|
|
132
|
+
'to_customer_id' => 25, // int — The target customer ID (resources moved to)
|
|
133
|
+
];
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Usage Example:
|
|
137
|
+
```php
|
|
138
|
+
// Hook after all resources are moved between merged customers
|
|
139
|
+
add_action('fluent_cart/customer_resources_moved', function ($data) {
|
|
140
|
+
// Extract source and target customer IDs
|
|
141
|
+
$fromId = $data['from_customer_id'];
|
|
142
|
+
$toId = $data['to_customer_id'];
|
|
143
|
+
|
|
144
|
+
// Sync merged customer data to system logs
|
|
145
|
+
fluent_cart_add_log(
|
|
146
|
+
'Customer Resources Merged',
|
|
147
|
+
sprintf('All resources moved from customer #%d to customer #%d', $fromId, $toId),
|
|
148
|
+
'info'
|
|
149
|
+
);
|
|
150
|
+
}, 10, 1);
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## User Registration
|
|
156
|
+
|
|
157
|
+
### `user/before_registration`
|
|
158
|
+
`fluent_cart/user/before_registration` — Fired before a new WordPress user is created during FluentCart registration
|
|
159
|
+
|
|
160
|
+
* **When it runs:** This action fires after the registration form data has been validated and processed, but before `wp_create_user()` is called. Use it to perform additional validation, modify the processed data, or trigger external pre-registration workflows.
|
|
161
|
+
* **Note:** This parameter is passed directly as an array, not wrapped inside a parent key.
|
|
162
|
+
* **Source:** `api/User.php`
|
|
163
|
+
|
|
164
|
+
#### Parameters:
|
|
165
|
+
`$processedData` *(array)*: Processed registration form data
|
|
166
|
+
```php
|
|
167
|
+
$processedData = [
|
|
168
|
+
'email' => 'user@example.com', // string — Sanitized email address
|
|
169
|
+
'password' => 'securepass123', // string — User-provided or auto-generated password
|
|
170
|
+
'first_name' => 'John', // string — Extracted from full name
|
|
171
|
+
'last_name' => 'Doe', // string — Extracted from full name
|
|
172
|
+
'username' => 'user@example.com', // string — Defaults to the email address
|
|
173
|
+
];
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### Usage Example:
|
|
177
|
+
```php
|
|
178
|
+
// Hook before a new WordPress user is created during FluentCart registration
|
|
179
|
+
add_action('fluent_cart/user/before_registration', function ($processedData) {
|
|
180
|
+
// Log registration attempts for incoming email
|
|
181
|
+
fluent_cart_add_log(
|
|
182
|
+
'User Registration Attempt',
|
|
183
|
+
sprintf('Registration initiated for %s', $processedData['email']),
|
|
184
|
+
'info'
|
|
185
|
+
);
|
|
186
|
+
}, 10, 1);
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
### `user/after_register`
|
|
192
|
+
`fluent_cart/user/after_register` — Fired after a new WordPress user is created during checkout registration
|
|
193
|
+
|
|
194
|
+
* **When it runs:** This action fires after `wp_insert_user()` succeeds during the checkout registration flow (handled by `AuthService`). At this point the WordPress user has been created, locale preferences have been saved, and the password change nag has been set if applicable. This hook fires before the standard WordPress `register_new_user` action.
|
|
195
|
+
* **Note:** This hook passes two arguments. Make sure to set the accepted argument count to 2 in `add_action`.
|
|
196
|
+
* **Source:** `app/Services/AuthService.php`
|
|
197
|
+
|
|
198
|
+
#### Parameters:
|
|
199
|
+
* `$user_id` *(int)* — The newly created WordPress user ID
|
|
200
|
+
* `$data` *(array)* — Additional context data:
|
|
201
|
+
```php
|
|
202
|
+
$data = [
|
|
203
|
+
'user_id' => 42, // int — Same WordPress user ID
|
|
204
|
+
];
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
#### Usage Example:
|
|
208
|
+
```php
|
|
209
|
+
// Hook after a new WordPress user is created during checkout registration
|
|
210
|
+
add_action('fluent_cart/user/after_register', function ($user_id, $data) {
|
|
211
|
+
// Auto-login the newly registered WordPress user
|
|
212
|
+
wp_set_current_user($user_id);
|
|
213
|
+
wp_set_auth_cookie($user_id);
|
|
214
|
+
|
|
215
|
+
// Send a custom welcome email to new user
|
|
216
|
+
$user = get_user_by('ID', $user_id);
|
|
217
|
+
wp_mail(
|
|
218
|
+
$user->user_email,
|
|
219
|
+
'Welcome to our store!',
|
|
220
|
+
'Your account has been created successfully.'
|
|
221
|
+
);
|
|
222
|
+
}, 10, 2);
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Customer Frontend
|
|
228
|
+
|
|
229
|
+
### `customer_menu`
|
|
230
|
+
`fluent_cart/customer_menu` — Renders the customer dashboard navigation menu
|
|
231
|
+
|
|
232
|
+
* **When it runs:** This output action fires inside the customer dashboard template, within the main container and before the content area. It is used to render the sidebar navigation menu for the customer portal. This is a rendering hook with no parameters.
|
|
233
|
+
* **Parameters:** None.
|
|
234
|
+
* **Source:** `app/Views/frontend/customer_app.php`
|
|
235
|
+
|
|
236
|
+
#### Usage Example:
|
|
237
|
+
```php
|
|
238
|
+
// Render custom menu items in customer dashboard navigation
|
|
239
|
+
add_action('fluent_cart/customer_menu', function () {
|
|
240
|
+
// Add a custom navigation link to the customer dashboard menu
|
|
241
|
+
echo '<a href="/my-account/custom-page/" class="fct-customer-nav-link">';
|
|
242
|
+
echo esc_html__('My Custom Page', 'my-plugin');
|
|
243
|
+
echo '</a>';
|
|
244
|
+
}, 20);
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### `customer_app`
|
|
250
|
+
`fluent_cart/customer_app` — Renders the customer dashboard main content area
|
|
251
|
+
|
|
252
|
+
* **When it runs:** This output action fires inside the customer dashboard template, within the main content container (`.fct-customer-dashboard-main-content`). It is used to render the primary content of the customer portal. This is a rendering hook with no parameters.
|
|
253
|
+
* **Parameters:** None.
|
|
254
|
+
* **Source:** `app/Views/frontend/customer_app.php`
|
|
255
|
+
|
|
256
|
+
#### Usage Example:
|
|
257
|
+
```php
|
|
258
|
+
// Render custom section in customer dashboard main content area
|
|
259
|
+
add_action('fluent_cart/customer_app', function () {
|
|
260
|
+
// Append custom HTML content block to customer dashboard
|
|
261
|
+
echo '<div class="my-custom-section">';
|
|
262
|
+
echo '<h3>' . esc_html__('My Custom Section', 'my-plugin') . '</h3>';
|
|
263
|
+
echo '<p>' . esc_html__('Additional dashboard content here.', 'my-plugin') . '</p>';
|
|
264
|
+
echo '</div>';
|
|
265
|
+
}, 20);
|
|
266
|
+
```
|