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.
Files changed (65) hide show
  1. package/CLAUDE.md +22 -22
  2. package/LICENSE +21 -21
  3. package/README.md +169 -127
  4. package/SKILL.md +127 -127
  5. package/bin/index.js +281 -281
  6. package/package.json +48 -37
  7. package/skills/fluentcart-developer/SKILL.md +172 -172
  8. package/skills/fluentcart-developer/examples/README.md +25 -25
  9. package/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/fluent-cart/checkout.php +32 -32
  10. package/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/functions.php +40 -40
  11. package/skills/fluentcart-developer/examples/sample-custom-addon/fluentcart-custom-addon.php +114 -114
  12. package/skills/fluentcart-developer/examples/sample-custom-payment-gateway/fluentcart-custom-gateway-example.php +149 -149
  13. package/skills/fluentcart-developer/examples/sample-fee-surcharge-plugin/fluentcart-fee-surcharge.php +38 -38
  14. package/skills/fluentcart-developer/examples/sample-shipping-carrier/fluentcart-custom-shipping-carrier.php +62 -62
  15. package/skills/fluentcart-developer/references/action-hooks-admin-templates.md +787 -787
  16. package/skills/fluentcart-developer/references/action-hooks-cart-checkout.md +1355 -1355
  17. package/skills/fluentcart-developer/references/action-hooks-customers-users.md +266 -266
  18. package/skills/fluentcart-developer/references/action-hooks-licenses.md +855 -855
  19. package/skills/fluentcart-developer/references/action-hooks-orders.md +631 -631
  20. package/skills/fluentcart-developer/references/action-hooks-payments-integrations.md +963 -963
  21. package/skills/fluentcart-developer/references/action-hooks-products-coupons.md +585 -585
  22. package/skills/fluentcart-developer/references/action-hooks-subscriptions.md +661 -661
  23. package/skills/fluentcart-developer/references/database-models-query-builder.md +194 -194
  24. package/skills/fluentcart-developer/references/database-models-reference.md +604 -604
  25. package/skills/fluentcart-developer/references/database-schema-reference.md +940 -940
  26. package/skills/fluentcart-developer/references/engineering-notes.md +154 -154
  27. package/skills/fluentcart-developer/references/fee-system-guide.md +449 -449
  28. package/skills/fluentcart-developer/references/filter-hooks-cart-checkout.md +1202 -1202
  29. package/skills/fluentcart-developer/references/filter-hooks-customers-subscriptions.md +902 -902
  30. package/skills/fluentcart-developer/references/filter-hooks-integrations-advanced.md +1598 -1598
  31. package/skills/fluentcart-developer/references/filter-hooks-orders-payments.md +1319 -1319
  32. package/skills/fluentcart-developer/references/filter-hooks-products-pricing.md +628 -628
  33. package/skills/fluentcart-developer/references/filter-hooks-settings-configuration.md +1177 -1177
  34. package/skills/fluentcart-developer/references/fluentcart-developer-guide.md +154 -154
  35. package/skills/fluentcart-developer/references/ghost-product-selling.md +458 -458
  36. package/skills/fluentcart-developer/references/modules-and-extensions-reference.md +224 -224
  37. package/skills/fluentcart-developer/references/payment-gateway-integration.md +761 -761
  38. package/skills/fluentcart-developer/references/rest-api-checkout.md +286 -286
  39. package/skills/fluentcart-developer/references/rest-api-coupons.md +794 -794
  40. package/skills/fluentcart-developer/references/rest-api-customer-profile.md +190 -190
  41. package/skills/fluentcart-developer/references/rest-api-customers.md +1121 -1121
  42. package/skills/fluentcart-developer/references/rest-api-dashboard-utilities.md +219 -219
  43. package/skills/fluentcart-developer/references/rest-api-email-notifications.md +619 -619
  44. package/skills/fluentcart-developer/references/rest-api-files.md +290 -290
  45. package/skills/fluentcart-developer/references/rest-api-integrations.md +324 -324
  46. package/skills/fluentcart-developer/references/rest-api-labels-attributes.md +321 -321
  47. package/skills/fluentcart-developer/references/rest-api-licensing.md +171 -171
  48. package/skills/fluentcart-developer/references/rest-api-order-bumps.md +200 -200
  49. package/skills/fluentcart-developer/references/rest-api-orders.md +1241 -1241
  50. package/skills/fluentcart-developer/references/rest-api-overview.md +131 -131
  51. package/skills/fluentcart-developer/references/rest-api-products.md +2563 -2563
  52. package/skills/fluentcart-developer/references/rest-api-public-shop.md +172 -172
  53. package/skills/fluentcart-developer/references/rest-api-reference.md +552 -552
  54. package/skills/fluentcart-developer/references/rest-api-reports.md +377 -377
  55. package/skills/fluentcart-developer/references/rest-api-roles-permissions.md +147 -147
  56. package/skills/fluentcart-developer/references/rest-api-settings.md +528 -528
  57. package/skills/fluentcart-developer/references/rest-api-shipping.md +799 -799
  58. package/skills/fluentcart-developer/references/rest-api-subscriptions.md +606 -606
  59. package/skills/fluentcart-developer/references/rest-api-tax.md +356 -356
  60. package/skills/fluentcart-developer/references/subscription-customization.md +197 -197
  61. package/skills/fluentcart-developer/scripts/cli.js +1 -1
  62. package/.gitattributes +0 -2
  63. package/CONTRIBUTING.md +0 -73
  64. package/copy-skills.js +0 -43
  65. package/skills.sh.json +0 -13
@@ -1,114 +1,114 @@
1
- <?php
2
- /**
3
- * Plugin Name: FluentCart Custom Extension Starter
4
- * Plugin URI: https://example.com/fluentcart-extension
5
- * Description: Starter boilerplate plugin for building custom FluentCart extensions, hooks, and REST endpoints.
6
- * Version: 1.0.0
7
- * Author: Developer Team
8
- * Text Domain: fc-custom-extension
9
- */
10
-
11
- if (!defined('ABSPATH')) {
12
- exit; // Exit if accessed directly
13
- }
14
-
15
- // Initialize extension after WordPress plugins loaded and FluentCart active
16
- add_action('plugins_loaded', function () {
17
- // Check if FluentCart core plugin is active
18
- if (!defined('FLUENT_CART')) {
19
- return;
20
- }
21
-
22
- // Register post-payment event listener
23
- add_action('fluent_cart/order_paid_done', 'fc_custom_handle_order_paid', 10, 1);
24
-
25
- // Register custom dynamic fee surcharge
26
- add_filter('fluent_cart/fee_items', 'fc_custom_add_cart_handling_fee', 10, 2);
27
-
28
- // Register custom REST API route
29
- add_action('rest_api_init', 'fc_custom_register_rest_routes');
30
- });
31
-
32
- /**
33
- * Process order completion asynchronously
34
- *
35
- * @param array $data Contains 'order' and 'customer' models
36
- */
37
- function fc_custom_handle_order_paid($data) {
38
- // Extract Order model instance from payload
39
- $order = $data['order'];
40
-
41
- // Extract Customer model instance from payload
42
- $customer = $data['customer'];
43
-
44
- // Save custom processing flag into order metadata
45
- $order->updateMeta('custom_processed_at', current_time('mysql'));
46
-
47
- // Log order completion event in FluentCart system log
48
- fluent_cart_add_log(
49
- 'Custom Addon Event',
50
- 'Successfully processed order #' . $order->id . ' for ' . $customer->email,
51
- 'info'
52
- );
53
- }
54
-
55
- /**
56
- * Add custom handling fee ($5.00 = 500 cents) to checkout cart
57
- *
58
- * @param array $fees Existing cart fee items
59
- * @param object $cart Active Cart instance
60
- * @return array Updated fees array
61
- */
62
- function fc_custom_add_cart_handling_fee($fees, $cart) {
63
- // Append $5.00 handling fee (500 cents)
64
- $fees[] = [
65
- 'id' => 'express_handling',
66
- 'title' => __('Express Order Processing Fee', 'fc-custom-extension'),
67
- 'amount' => 500, // Monetary values stored as integer cents ($5.00 = 500)
68
- 'taxable' => false,
69
- ];
70
-
71
- return $fees;
72
- }
73
-
74
- /**
75
- * Register custom REST API endpoint for third-party extensions
76
- */
77
- function fc_custom_register_rest_routes() {
78
- register_rest_route('fc-custom/v1', '/order-status/(?P<id>\d+)', [
79
- 'methods' => 'GET',
80
- 'callback' => 'fc_custom_get_order_status',
81
- 'permission_callback' => function () {
82
- // Restrict endpoint to store managers
83
- return current_user_can('fluent_cart_admin');
84
- },
85
- ]);
86
- }
87
-
88
- /**
89
- * REST Endpoint Callback: Retrieve custom order status
90
- *
91
- * @param WP_REST_Request $request
92
- * @return WP_REST_Response
93
- */
94
- function fc_custom_get_order_status($request) {
95
- // Extract order ID parameter from request
96
- $orderId = $request->get_param('id');
97
-
98
- // Retrieve order record using FluentCart Eloquent Model
99
- $order = \FluentCart\App\Models\Order::find($orderId);
100
-
101
- // Return 404 response if order not found
102
- if (!$order) {
103
- return new WP_REST_Response(['message' => 'Order not found'], 404);
104
- }
105
-
106
- // Return structured order status response
107
- return new WP_REST_Response([
108
- 'order_id' => $order->id,
109
- 'status' => $order->status,
110
- 'payment_status' => $order->payment_status,
111
- 'total_amount' => $order->total_amount, // Returned in cents
112
- 'processed_at' => $order->getMeta('custom_processed_at', 'N/A'),
113
- ], 200);
114
- }
1
+ <?php
2
+ /**
3
+ * Plugin Name: FluentCart Custom Extension Starter
4
+ * Plugin URI: https://example.com/fluentcart-extension
5
+ * Description: Starter boilerplate plugin for building custom FluentCart extensions, hooks, and REST endpoints.
6
+ * Version: 1.0.0
7
+ * Author: Developer Team
8
+ * Text Domain: fc-custom-extension
9
+ */
10
+
11
+ if (!defined('ABSPATH')) {
12
+ exit; // Exit if accessed directly
13
+ }
14
+
15
+ // Initialize extension after WordPress plugins loaded and FluentCart active
16
+ add_action('plugins_loaded', function () {
17
+ // Check if FluentCart core plugin is active
18
+ if (!defined('FLUENT_CART')) {
19
+ return;
20
+ }
21
+
22
+ // Register post-payment event listener
23
+ add_action('fluent_cart/order_paid_done', 'fc_custom_handle_order_paid', 10, 1);
24
+
25
+ // Register custom dynamic fee surcharge
26
+ add_filter('fluent_cart/fee_items', 'fc_custom_add_cart_handling_fee', 10, 2);
27
+
28
+ // Register custom REST API route
29
+ add_action('rest_api_init', 'fc_custom_register_rest_routes');
30
+ });
31
+
32
+ /**
33
+ * Process order completion asynchronously
34
+ *
35
+ * @param array $data Contains 'order' and 'customer' models
36
+ */
37
+ function fc_custom_handle_order_paid($data) {
38
+ // Extract Order model instance from payload
39
+ $order = $data['order'];
40
+
41
+ // Extract Customer model instance from payload
42
+ $customer = $data['customer'];
43
+
44
+ // Save custom processing flag into order metadata
45
+ $order->updateMeta('custom_processed_at', current_time('mysql'));
46
+
47
+ // Log order completion event in FluentCart system log
48
+ fluent_cart_add_log(
49
+ 'Custom Addon Event',
50
+ 'Successfully processed order #' . $order->id . ' for ' . $customer->email,
51
+ 'info'
52
+ );
53
+ }
54
+
55
+ /**
56
+ * Add custom handling fee ($5.00 = 500 cents) to checkout cart
57
+ *
58
+ * @param array $fees Existing cart fee items
59
+ * @param object $cart Active Cart instance
60
+ * @return array Updated fees array
61
+ */
62
+ function fc_custom_add_cart_handling_fee($fees, $cart) {
63
+ // Append $5.00 handling fee (500 cents)
64
+ $fees[] = [
65
+ 'id' => 'express_handling',
66
+ 'title' => __('Express Order Processing Fee', 'fc-custom-extension'),
67
+ 'amount' => 500, // Monetary values stored as integer cents ($5.00 = 500)
68
+ 'taxable' => false,
69
+ ];
70
+
71
+ return $fees;
72
+ }
73
+
74
+ /**
75
+ * Register custom REST API endpoint for third-party extensions
76
+ */
77
+ function fc_custom_register_rest_routes() {
78
+ register_rest_route('fc-custom/v1', '/order-status/(?P<id>\d+)', [
79
+ 'methods' => 'GET',
80
+ 'callback' => 'fc_custom_get_order_status',
81
+ 'permission_callback' => function () {
82
+ // Restrict endpoint to store managers
83
+ return current_user_can('fluent_cart_admin');
84
+ },
85
+ ]);
86
+ }
87
+
88
+ /**
89
+ * REST Endpoint Callback: Retrieve custom order status
90
+ *
91
+ * @param WP_REST_Request $request
92
+ * @return WP_REST_Response
93
+ */
94
+ function fc_custom_get_order_status($request) {
95
+ // Extract order ID parameter from request
96
+ $orderId = $request->get_param('id');
97
+
98
+ // Retrieve order record using FluentCart Eloquent Model
99
+ $order = \FluentCart\App\Models\Order::find($orderId);
100
+
101
+ // Return 404 response if order not found
102
+ if (!$order) {
103
+ return new WP_REST_Response(['message' => 'Order not found'], 404);
104
+ }
105
+
106
+ // Return structured order status response
107
+ return new WP_REST_Response([
108
+ 'order_id' => $order->id,
109
+ 'status' => $order->status,
110
+ 'payment_status' => $order->payment_status,
111
+ 'total_amount' => $order->total_amount, // Returned in cents
112
+ 'processed_at' => $order->getMeta('custom_processed_at', 'N/A'),
113
+ ], 200);
114
+ }
@@ -1,149 +1,149 @@
1
- <?php
2
- /**
3
- * Plugin Name: FluentCart Custom Payment Gateway Example
4
- * Plugin URI: https://github.com/atifjubaer/skills
5
- * Description: Production-ready starter template for creating a custom FluentCart payment gateway extension.
6
- * Version: 1.0.0
7
- * Author: Fastrsoft
8
- * License: MIT
9
- */
10
-
11
- if (!defined('ABSPATH')) {
12
- exit; // Exit if accessed directly
13
- }
14
-
15
- // Register custom payment gateway after FluentCart initializes
16
- add_action('fluent_cart/loaded', function() {
17
- if (!class_exists('\FluentCart\App\Modules\PaymentMethods\Core\AbstractPaymentGateway')) {
18
- return; // Return early if FluentCart core payment gateway abstract class is missing
19
- }
20
-
21
- // Register our custom gateway slug and implementation class via filter
22
- add_filter('fluent_cart/payment_gateways', function($gateways) {
23
- $gateways['sample_gateway'] = \FluentCartCustomGatewayExample\SampleGateway::class;
24
- return $gateways;
25
- });
26
- });
27
-
28
- namespace FluentCartCustomGatewayExample;
29
-
30
- use FluentCart\App\Modules\PaymentMethods\Core\AbstractPaymentGateway;
31
- use FluentCart\App\Modules\PaymentMethods\Core\BaseGatewaySettings;
32
- use FluentCart\App\Models\Order;
33
-
34
- // Custom Gateway Implementation Class
35
- class SampleGateway extends AbstractPaymentGateway
36
- {
37
- // Unique identifier slug for this payment gateway
38
- public function getSlug(): string
39
- {
40
- return 'sample_gateway';
41
- }
42
-
43
- // Display title of payment gateway in admin and checkout
44
- public function getTitle(): string
45
- {
46
- return __('Sample Payment Gateway', 'fluentcart');
47
- }
48
-
49
- // Icon URL or class for checkout payment method selector
50
- public function getIcon(): string
51
- {
52
- return plugin_dir_url(__FILE__) . 'assets/icon.png';
53
- }
54
-
55
- // Process customer charge during checkout submission
56
- public function makePayment(array $data, Order $order): array
57
- {
58
- // Sanitize payment token or transaction input from customer
59
- $paymentToken = sanitize_text_field($data['payment_token'] ?? '');
60
-
61
- // Fetch configured API credentials from gateway settings
62
- $apiKey = $this->getSetting('api_key');
63
- $isSandbox = $this->getSetting('test_mode') === 'yes';
64
-
65
- // Perform external API call to process payment transaction
66
- // Example mock API response handling:
67
- $success = !empty($paymentToken) || $isSandbox;
68
-
69
- if ($success) {
70
- // Generate mock transaction ID for demonstration
71
- $transactionId = 'tx_sample_' . time() . '_' . rand(1000, 9999);
72
-
73
- // Record transaction details in FluentCart order record
74
- $this->addPaymentNote($order, sprintf(__('Payment processed via Sample Gateway. Transaction ID: %s', 'fluentcart'), $transactionId));
75
-
76
- // Return success payload containing redirect URL or receipt details
77
- return [
78
- 'status' => 'success',
79
- 'transaction_id' => $transactionId,
80
- 'redirect_url' => $this->getReturnUrl($order),
81
- 'message' => __('Payment successful!', 'fluentcart')
82
- ];
83
- }
84
-
85
- // Return error payload if payment authorization failed
86
- return [
87
- 'status' => 'error',
88
- 'message' => __('Payment failed. Please check your card details and try again.', 'fluentcart')
89
- ];
90
- }
91
-
92
- // Handle partial or full refund execution from FluentCart admin
93
- public function refund(Order $order, float $amount, string $reason = ''): array
94
- {
95
- // Get original transaction ID attached to order
96
- $transactionId = $order->transaction_id;
97
-
98
- // Perform API request to refund payment gateway provider
99
- // Example mock refund success return:
100
- $refundId = 'ref_sample_' . time();
101
-
102
- // Log refund note in FluentCart order notes
103
- $this->addPaymentNote($order, sprintf(__('Refund of %s processed. Refund ID: %s. Reason: %s', 'fluentcart'), $amount, $refundId, $reason));
104
-
105
- return [
106
- 'status' => 'success',
107
- 'refund_id' => $refundId,
108
- 'amount' => $amount,
109
- 'message' => __('Refund issued successfully', 'fluentcart')
110
- ];
111
- }
112
-
113
- // Return admin settings schema class instance
114
- public function getSettingsClass(): string
115
- {
116
- return SampleGatewaySettings::class;
117
- }
118
- }
119
-
120
- // Admin Settings Configuration Class
121
- class SampleGatewaySettings extends BaseGatewaySettings
122
- {
123
- // Render settings schema fields for FluentCart Payment Settings panel
124
- public function getFields(): array
125
- {
126
- return [
127
- 'enabled' => [
128
- 'type' => 'checkbox',
129
- 'label' => __('Enable Sample Gateway', 'fluentcart'),
130
- 'default' => 'no'
131
- ],
132
- 'title' => [
133
- 'type' => 'text',
134
- 'label' => __('Method Title', 'fluentcart'),
135
- 'default' => __('Sample Gateway', 'fluentcart')
136
- ],
137
- 'test_mode' => [
138
- 'type' => 'checkbox',
139
- 'label' => __('Sandbox / Test Mode', 'fluentcart'),
140
- 'default' => 'yes'
141
- ],
142
- 'api_key' => [
143
- 'type' => 'password',
144
- 'label' => __('API Key', 'fluentcart'),
145
- 'description' => __('Enter your API key provided by the payment gateway dashboard.', 'fluentcart')
146
- ]
147
- ];
148
- }
149
- }
1
+ <?php
2
+ /**
3
+ * Plugin Name: FluentCart Custom Payment Gateway Example
4
+ * Plugin URI: https://github.com/atifjubaer/skills
5
+ * Description: Production-ready starter template for creating a custom FluentCart payment gateway extension.
6
+ * Version: 1.0.0
7
+ * Author: Fastrsoft
8
+ * License: MIT
9
+ */
10
+
11
+ if (!defined('ABSPATH')) {
12
+ exit; // Exit if accessed directly
13
+ }
14
+
15
+ // Register custom payment gateway after FluentCart initializes
16
+ add_action('fluent_cart/loaded', function() {
17
+ if (!class_exists('\FluentCart\App\Modules\PaymentMethods\Core\AbstractPaymentGateway')) {
18
+ return; // Return early if FluentCart core payment gateway abstract class is missing
19
+ }
20
+
21
+ // Register our custom gateway slug and implementation class via filter
22
+ add_filter('fluent_cart/payment_gateways', function($gateways) {
23
+ $gateways['sample_gateway'] = \FluentCartCustomGatewayExample\SampleGateway::class;
24
+ return $gateways;
25
+ });
26
+ });
27
+
28
+ namespace FluentCartCustomGatewayExample;
29
+
30
+ use FluentCart\App\Modules\PaymentMethods\Core\AbstractPaymentGateway;
31
+ use FluentCart\App\Modules\PaymentMethods\Core\BaseGatewaySettings;
32
+ use FluentCart\App\Models\Order;
33
+
34
+ // Custom Gateway Implementation Class
35
+ class SampleGateway extends AbstractPaymentGateway
36
+ {
37
+ // Unique identifier slug for this payment gateway
38
+ public function getSlug(): string
39
+ {
40
+ return 'sample_gateway';
41
+ }
42
+
43
+ // Display title of payment gateway in admin and checkout
44
+ public function getTitle(): string
45
+ {
46
+ return __('Sample Payment Gateway', 'fluentcart');
47
+ }
48
+
49
+ // Icon URL or class for checkout payment method selector
50
+ public function getIcon(): string
51
+ {
52
+ return plugin_dir_url(__FILE__) . 'assets/icon.png';
53
+ }
54
+
55
+ // Process customer charge during checkout submission
56
+ public function makePayment(array $data, Order $order): array
57
+ {
58
+ // Sanitize payment token or transaction input from customer
59
+ $paymentToken = sanitize_text_field($data['payment_token'] ?? '');
60
+
61
+ // Fetch configured API credentials from gateway settings
62
+ $apiKey = $this->getSetting('api_key');
63
+ $isSandbox = $this->getSetting('test_mode') === 'yes';
64
+
65
+ // Perform external API call to process payment transaction
66
+ // Example mock API response handling:
67
+ $success = !empty($paymentToken) || $isSandbox;
68
+
69
+ if ($success) {
70
+ // Generate mock transaction ID for demonstration
71
+ $transactionId = 'tx_sample_' . time() . '_' . rand(1000, 9999);
72
+
73
+ // Record transaction details in FluentCart order record
74
+ $this->addPaymentNote($order, sprintf(__('Payment processed via Sample Gateway. Transaction ID: %s', 'fluentcart'), $transactionId));
75
+
76
+ // Return success payload containing redirect URL or receipt details
77
+ return [
78
+ 'status' => 'success',
79
+ 'transaction_id' => $transactionId,
80
+ 'redirect_url' => $this->getReturnUrl($order),
81
+ 'message' => __('Payment successful!', 'fluentcart')
82
+ ];
83
+ }
84
+
85
+ // Return error payload if payment authorization failed
86
+ return [
87
+ 'status' => 'error',
88
+ 'message' => __('Payment failed. Please check your card details and try again.', 'fluentcart')
89
+ ];
90
+ }
91
+
92
+ // Handle partial or full refund execution from FluentCart admin
93
+ public function refund(Order $order, float $amount, string $reason = ''): array
94
+ {
95
+ // Get original transaction ID attached to order
96
+ $transactionId = $order->transaction_id;
97
+
98
+ // Perform API request to refund payment gateway provider
99
+ // Example mock refund success return:
100
+ $refundId = 'ref_sample_' . time();
101
+
102
+ // Log refund note in FluentCart order notes
103
+ $this->addPaymentNote($order, sprintf(__('Refund of %s processed. Refund ID: %s. Reason: %s', 'fluentcart'), $amount, $refundId, $reason));
104
+
105
+ return [
106
+ 'status' => 'success',
107
+ 'refund_id' => $refundId,
108
+ 'amount' => $amount,
109
+ 'message' => __('Refund issued successfully', 'fluentcart')
110
+ ];
111
+ }
112
+
113
+ // Return admin settings schema class instance
114
+ public function getSettingsClass(): string
115
+ {
116
+ return SampleGatewaySettings::class;
117
+ }
118
+ }
119
+
120
+ // Admin Settings Configuration Class
121
+ class SampleGatewaySettings extends BaseGatewaySettings
122
+ {
123
+ // Render settings schema fields for FluentCart Payment Settings panel
124
+ public function getFields(): array
125
+ {
126
+ return [
127
+ 'enabled' => [
128
+ 'type' => 'checkbox',
129
+ 'label' => __('Enable Sample Gateway', 'fluentcart'),
130
+ 'default' => 'no'
131
+ ],
132
+ 'title' => [
133
+ 'type' => 'text',
134
+ 'label' => __('Method Title', 'fluentcart'),
135
+ 'default' => __('Sample Gateway', 'fluentcart')
136
+ ],
137
+ 'test_mode' => [
138
+ 'type' => 'checkbox',
139
+ 'label' => __('Sandbox / Test Mode', 'fluentcart'),
140
+ 'default' => 'yes'
141
+ ],
142
+ 'api_key' => [
143
+ 'type' => 'password',
144
+ 'label' => __('API Key', 'fluentcart'),
145
+ 'description' => __('Enter your API key provided by the payment gateway dashboard.', 'fluentcart')
146
+ ]
147
+ ];
148
+ }
149
+ }
@@ -1,38 +1,38 @@
1
- <?php
2
- /**
3
- * Plugin Name: FluentCart Fee Surcharge Addon
4
- * Description: Example plugin demonstrating dynamic conditional fee surcharges (e.g. Gift Wrapping & Heavy Freight fees) in FluentCart.
5
- * Version: 1.0.0
6
- * Author: Developer Team
7
- */
8
-
9
- if (!defined('ABSPATH')) {
10
- exit;
11
- }
12
-
13
- // Hook into FluentCart fee calculation lifecycle
14
- add_filter('fluent_cart/fee_items', function ($fees, $cart) {
15
- // Calculate subtotal in cents
16
- $subtotal = $cart->getSubTotal();
17
-
18
- // Condition 1: Add $3.50 (350 cents) Gift Wrapping Fee for orders under $50.00 (5000 cents)
19
- if ($subtotal < 5000) {
20
- $fees[] = [
21
- 'id' => 'gift_wrap_fee',
22
- 'title' => __('Optional Gift Packaging', 'fc-fee-addon'),
23
- 'amount' => 350, // 350 cents = $3.50
24
- 'taxable' => false,
25
- ];
26
- }
27
-
28
- // Condition 2: Add 2% Payment Surcharge (percentage fee)
29
- $surchargeAmount = (int) round($subtotal * 0.02); // 2% calculation in cents
30
- $fees[] = [
31
- 'id' => 'payment_surcharge',
32
- 'title' => __('Payment Processing Surcharge (2%)', 'fc-fee-addon'),
33
- 'amount' => $surchargeAmount,
34
- 'taxable' => false,
35
- ];
36
-
37
- return $fees;
38
- }, 10, 2);
1
+ <?php
2
+ /**
3
+ * Plugin Name: FluentCart Fee Surcharge Addon
4
+ * Description: Example plugin demonstrating dynamic conditional fee surcharges (e.g. Gift Wrapping & Heavy Freight fees) in FluentCart.
5
+ * Version: 1.0.0
6
+ * Author: Developer Team
7
+ */
8
+
9
+ if (!defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
+ // Hook into FluentCart fee calculation lifecycle
14
+ add_filter('fluent_cart/fee_items', function ($fees, $cart) {
15
+ // Calculate subtotal in cents
16
+ $subtotal = $cart->getSubTotal();
17
+
18
+ // Condition 1: Add $3.50 (350 cents) Gift Wrapping Fee for orders under $50.00 (5000 cents)
19
+ if ($subtotal < 5000) {
20
+ $fees[] = [
21
+ 'id' => 'gift_wrap_fee',
22
+ 'title' => __('Optional Gift Packaging', 'fc-fee-addon'),
23
+ 'amount' => 350, // 350 cents = $3.50
24
+ 'taxable' => false,
25
+ ];
26
+ }
27
+
28
+ // Condition 2: Add 2% Payment Surcharge (percentage fee)
29
+ $surchargeAmount = (int) round($subtotal * 0.02); // 2% calculation in cents
30
+ $fees[] = [
31
+ 'id' => 'payment_surcharge',
32
+ 'title' => __('Payment Processing Surcharge (2%)', 'fc-fee-addon'),
33
+ 'amount' => $surchargeAmount,
34
+ 'taxable' => false,
35
+ ];
36
+
37
+ return $fees;
38
+ }, 10, 2);