fluentcart-developer 3.0.0 → 3.0.2
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/LICENSE.md +26 -26
- package/README.md +59 -59
- package/dist/cards/fluentcart/templates-native.js +1087 -1087
- package/dist/cards/fluentcart/tools.js +2309 -2309
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +37 -1
- package/dist/server.js.map +1 -1
- package/dist/skills/fluentcart-developer/SKILL.md +108 -108
- package/dist/skills/fluentcart-developer/examples/README.md +30 -30
- package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/fluent-cart/checkout.php +32 -32
- package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/functions.php +40 -40
- package/dist/skills/fluentcart-developer/examples/sample-custom-addon/fluentcart-custom-addon.php +113 -113
- package/dist/skills/fluentcart-developer/examples/sample-custom-payment-gateway/fluentcart-custom-gateway-example.php +148 -148
- package/dist/skills/fluentcart-developer/examples/sample-fee-surcharge-plugin/fluentcart-fee-surcharge.php +38 -38
- package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/README.md +22 -22
- package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/sample-plugin-with-licensing-sdk.php +79 -79
- package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/FluentLicensing.php +303 -303
- package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/LicenseSettings.php +566 -566
- package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/PluginUpdater.php +304 -304
- package/dist/skills/fluentcart-developer/examples/sample-shipping-carrier/fluentcart-custom-shipping-carrier.php +61 -61
- package/dist/skills/fluentcart-developer/references/api/authentication.md +452 -452
- package/dist/skills/fluentcart-developer/references/api/coupons.md +786 -786
- package/dist/skills/fluentcart-developer/references/api/customers.md +889 -889
- package/dist/skills/fluentcart-developer/references/api/files.md +609 -609
- package/dist/skills/fluentcart-developer/references/api/index.md +432 -432
- package/dist/skills/fluentcart-developer/references/api/licensing.md +633 -633
- package/dist/skills/fluentcart-developer/references/api/order-bump.md +384 -384
- package/dist/skills/fluentcart-developer/references/api/orders.md +814 -814
- package/dist/skills/fluentcart-developer/references/api/products.md +866 -866
- package/dist/skills/fluentcart-developer/references/api/roles-permissions.md +536 -536
- package/dist/skills/fluentcart-developer/references/api/subscriptions.md +827 -827
- package/dist/skills/fluentcart-developer/references/database/index.md +44 -44
- package/dist/skills/fluentcart-developer/references/database/models/activity.md +178 -178
- package/dist/skills/fluentcart-developer/references/database/models/applied-coupon.md +291 -291
- package/dist/skills/fluentcart-developer/references/database/models/attribute-group.md +239 -239
- package/dist/skills/fluentcart-developer/references/database/models/attribute-relation.md +181 -181
- package/dist/skills/fluentcart-developer/references/database/models/attribute-term.md +219 -219
- package/dist/skills/fluentcart-developer/references/database/models/cart.md +645 -645
- package/dist/skills/fluentcart-developer/references/database/models/coupon.md +427 -427
- package/dist/skills/fluentcart-developer/references/database/models/customer-addresses.md +348 -348
- package/dist/skills/fluentcart-developer/references/database/models/customer-meta.md +156 -156
- package/dist/skills/fluentcart-developer/references/database/models/customer.md +584 -584
- package/dist/skills/fluentcart-developer/references/database/models/dynamic-model.md +163 -163
- package/dist/skills/fluentcart-developer/references/database/models/label-relationship.md +155 -155
- package/dist/skills/fluentcart-developer/references/database/models/label.md +153 -153
- package/dist/skills/fluentcart-developer/references/database/models/license-activation.md +182 -182
- package/dist/skills/fluentcart-developer/references/database/models/license-meta.md +163 -163
- package/dist/skills/fluentcart-developer/references/database/models/license-site.md +208 -208
- package/dist/skills/fluentcart-developer/references/database/models/license.md +640 -640
- package/dist/skills/fluentcart-developer/references/database/models/meta.md +233 -233
- package/dist/skills/fluentcart-developer/references/database/models/order-address.md +391 -391
- package/dist/skills/fluentcart-developer/references/database/models/order-download-permission.md +144 -144
- package/dist/skills/fluentcart-developer/references/database/models/order-item.md +383 -383
- package/dist/skills/fluentcart-developer/references/database/models/order-meta.md +303 -303
- package/dist/skills/fluentcart-developer/references/database/models/order-operation.md +158 -158
- package/dist/skills/fluentcart-developer/references/database/models/order-promotion-stat.md +175 -175
- package/dist/skills/fluentcart-developer/references/database/models/order-promotion.md +250 -250
- package/dist/skills/fluentcart-developer/references/database/models/order-tax-rate.md +172 -172
- package/dist/skills/fluentcart-developer/references/database/models/order-transaction.md +440 -440
- package/dist/skills/fluentcart-developer/references/database/models/order.md +727 -727
- package/dist/skills/fluentcart-developer/references/database/models/product-detail.md +397 -397
- package/dist/skills/fluentcart-developer/references/database/models/product-download.md +258 -258
- package/dist/skills/fluentcart-developer/references/database/models/product-meta.md +153 -153
- package/dist/skills/fluentcart-developer/references/database/models/product-variation.md +556 -556
- package/dist/skills/fluentcart-developer/references/database/models/product.md +580 -580
- package/dist/skills/fluentcart-developer/references/database/models/relationships.md +427 -427
- package/dist/skills/fluentcart-developer/references/database/models/scheduled-action.md +175 -175
- package/dist/skills/fluentcart-developer/references/database/models/shipping-class.md +148 -148
- package/dist/skills/fluentcart-developer/references/database/models/shipping-method.md +280 -280
- package/dist/skills/fluentcart-developer/references/database/models/shipping-zone.md +205 -205
- package/dist/skills/fluentcart-developer/references/database/models/subscription-meta.md +173 -173
- package/dist/skills/fluentcart-developer/references/database/models/subscription.md +528 -528
- package/dist/skills/fluentcart-developer/references/database/models/tax-class.md +195 -195
- package/dist/skills/fluentcart-developer/references/database/models/tax-rate.md +225 -225
- package/dist/skills/fluentcart-developer/references/database/models/user-meta.md +166 -166
- package/dist/skills/fluentcart-developer/references/database/models/user.md +220 -220
- package/dist/skills/fluentcart-developer/references/database/models.md +404 -404
- package/dist/skills/fluentcart-developer/references/database/query-builder.md +860 -860
- package/dist/skills/fluentcart-developer/references/database/readme.md +276 -276
- package/dist/skills/fluentcart-developer/references/database/schema.md +1002 -1002
- package/dist/skills/fluentcart-developer/references/engineering/adding-custom-pages-to-the-customer-dashboard.md +395 -395
- package/dist/skills/fluentcart-developer/references/engineering/index.md +4 -4
- package/dist/skills/fluentcart-developer/references/engineering.md +4 -4
- package/dist/skills/fluentcart-developer/references/getting-started.md +249 -249
- package/dist/skills/fluentcart-developer/references/guides/frontend.md +519 -519
- package/dist/skills/fluentcart-developer/references/guides/index.md +107 -107
- package/dist/skills/fluentcart-developer/references/guides/integrations.md +600 -600
- package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/index.md +237 -237
- package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/labels-and-tracking.md +481 -481
- package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/live-rates.md +269 -269
- package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/reference.md +223 -223
- package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/settings.md +370 -370
- package/dist/skills/fluentcart-developer/references/guides/shipping-carrier.md +237 -237
- package/dist/skills/fluentcart-developer/references/guides/subscriptions.md +217 -217
- package/dist/skills/fluentcart-developer/references/hooks/actions/admin-and-templates.md +1079 -1079
- package/dist/skills/fluentcart-developer/references/hooks/actions/cart-and-checkout.md +1795 -1795
- package/dist/skills/fluentcart-developer/references/hooks/actions/customers-and-users.md +327 -327
- package/dist/skills/fluentcart-developer/references/hooks/actions/licenses.md +829 -829
- package/dist/skills/fluentcart-developer/references/hooks/actions/modules.md +81 -81
- package/dist/skills/fluentcart-developer/references/hooks/actions/orders.md +757 -757
- package/dist/skills/fluentcart-developer/references/hooks/actions/payments-and-integrations.md +1163 -1163
- package/dist/skills/fluentcart-developer/references/hooks/actions/pro-modules.md +219 -219
- package/dist/skills/fluentcart-developer/references/hooks/actions/products-and-coupons.md +1019 -1019
- package/dist/skills/fluentcart-developer/references/hooks/actions/subscriptions.md +1290 -1290
- package/dist/skills/fluentcart-developer/references/hooks/actions.md +16 -16
- package/dist/skills/fluentcart-developer/references/hooks/deprecated.md +60 -60
- package/dist/skills/fluentcart-developer/references/hooks/filters/cart-and-checkout.md +2032 -2032
- package/dist/skills/fluentcart-developer/references/hooks/filters/customers-and-subscriptions.md +1746 -1746
- package/dist/skills/fluentcart-developer/references/hooks/filters/integrations-and-advanced.md +2439 -2439
- package/dist/skills/fluentcart-developer/references/hooks/filters/modules.md +464 -464
- package/dist/skills/fluentcart-developer/references/hooks/filters/orders-and-payments.md +2658 -2658
- package/dist/skills/fluentcart-developer/references/hooks/filters/pro-modules.md +502 -502
- package/dist/skills/fluentcart-developer/references/hooks/filters/products-and-pricing.md +1785 -1785
- package/dist/skills/fluentcart-developer/references/hooks/filters/settings-and-configuration.md +2966 -2966
- package/dist/skills/fluentcart-developer/references/hooks/filters.md +14 -14
- package/dist/skills/fluentcart-developer/references/hooks/index.md +35 -35
- package/dist/skills/fluentcart-developer/references/index.md +625 -625
- package/dist/skills/fluentcart-developer/references/modules/fee-system.md +427 -427
- package/dist/skills/fluentcart-developer/references/modules/ghost-product-selling.md +440 -440
- package/dist/skills/fluentcart-developer/references/modules/index.md +484 -484
- package/dist/skills/fluentcart-developer/references/modules/licensing.md +342 -342
- package/dist/skills/fluentcart-developer/references/modules/order-bump.md +433 -433
- package/dist/skills/fluentcart-developer/references/modules/payment-methods.md +129 -129
- package/dist/skills/fluentcart-developer/references/modules/refunds.md +170 -170
- package/dist/skills/fluentcart-developer/references/modules/shipping.md +846 -846
- package/dist/skills/fluentcart-developer/references/modules/storage.md +986 -986
- package/dist/skills/fluentcart-developer/references/modules/subscription-vendor-ids.md +186 -186
- package/dist/skills/fluentcart-developer/references/modules/subscriptions.md +678 -678
- package/dist/skills/fluentcart-developer/references/payment-methods-integration/index.md +164 -164
- package/dist/skills/fluentcart-developer/references/payment-methods-integration/paddle-example.md +1648 -1648
- package/dist/skills/fluentcart-developer/references/payment-methods-integration/payment/setting/fields.md +353 -353
- package/dist/skills/fluentcart-developer/references/payment-methods-integration/quick-implementation.md +1079 -1079
- package/dist/skills/fluentcart-developer/references/payment-methods-integration.md +164 -164
- package/dist/skills/fluentcart-developer/references/restapi/checkout.md +573 -573
- package/dist/skills/fluentcart-developer/references/restapi/coupons.md +958 -958
- package/dist/skills/fluentcart-developer/references/restapi/customer-profile.md +1423 -1423
- package/dist/skills/fluentcart-developer/references/restapi/customers.md +1103 -1103
- package/dist/skills/fluentcart-developer/references/restapi/dashboard.md +1083 -1083
- package/dist/skills/fluentcart-developer/references/restapi/data-export.md +132 -132
- package/dist/skills/fluentcart-developer/references/restapi/email-notifications.md +846 -846
- package/dist/skills/fluentcart-developer/references/restapi/files.md +313 -313
- package/dist/skills/fluentcart-developer/references/restapi/index.md +127 -127
- package/dist/skills/fluentcart-developer/references/restapi/integrations.md +1000 -1000
- package/dist/skills/fluentcart-developer/references/restapi/inventory.md +192 -192
- package/dist/skills/fluentcart-developer/references/restapi/labels-and-attributes.md +797 -797
- package/dist/skills/fluentcart-developer/references/restapi/licensing.md +1733 -1733
- package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-available-shipping-methods.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-checkout-summary.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-country-info.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-order-info.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-shipping-methods-list-view.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/login.md +66 -66
- package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/place-order.md +179 -179
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/apply-coupon.md +83 -83
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/cancel-coupon.md +87 -87
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/check-product-eligibility.md +59 -59
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/create-coupon.md +230 -230
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/delete-coupon.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/get-coupon-settings.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/get-coupon.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/list-coupon-codes.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/list-coupons.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/re-apply-coupons.md +75 -75
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/store-coupon-settings.md +40 -40
- package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/update-coupon.md +133 -133
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/create-address-checkout.md +138 -138
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/create-profile-address.md +119 -119
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/dashboard-overview.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/delete-profile-address.md +46 -46
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-order-details.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-portal-sections.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-profile-details.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-transaction-billing-address.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-upgrade-paths.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/list-downloads.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/list-orders.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/make-profile-address-primary.md +55 -55
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/pause-subscription.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/resume-subscription.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/save-transaction-billing-address.md +92 -92
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/select-address-for-checkout.md +32 -32
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/update-profile-address.md +115 -115
- package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/update-profile-details.md +69 -69
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/attach-user.md +50 -50
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/bulk-actions.md +65 -65
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/create-address.md +135 -135
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/create-customer.md +108 -108
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/delete-address.md +62 -62
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/detach-user.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/find-customer-order.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-attachable-users.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-addresses.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-orders.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-stats.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer.md +32 -32
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/list-customers.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/recalculate-ltv.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/set-primary-address.md +72 -72
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-additional-info.md +55 -55
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-address.md +144 -144
- package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-customer.md +123 -123
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/attach-note-to-order.md +49 -49
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/create-all-pages.md +21 -21
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/create-single-page.md +55 -55
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/delete-activity.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-country-info.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-dashboard-stats.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-filter-options.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-onboarding-data.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-onboarding-settings.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-print-templates.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-search-options.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-widgets.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/initialize-app.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-activities.md +33 -33
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-attachments.md +21 -21
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-countries.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/mark-activity-read.md +53 -53
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/run-data-backfills.md +21 -21
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-onboarding-settings.md +54 -54
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-onboarding-tax-settings.md +73 -73
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-print-templates.md +64 -64
- package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/upload-attachment.md +42 -42
- package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-customers-batch.md +129 -129
- package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-licenses-batch.md +133 -133
- package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-orders-batch.md +129 -129
- package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-subscriptions-batch.md +129 -129
- package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-customers-export-schema.md +21 -21
- package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-licenses-export-schema.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-orders-export-schema.md +21 -21
- package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-subscriptions-export-schema.md +21 -21
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/enable-notification.md +57 -57
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-digest-settings.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-notification.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-reminders.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-settings.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-shortcodes.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/list-notifications.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/preview-default-template.md +66 -66
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/preview-notification.md +50 -50
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-digest-settings.md +101 -101
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-reminders.md +162 -162
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-settings.md +99 -99
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/send-digest-test.md +47 -47
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/send-manual-reminder.md +51 -51
- package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/update-notification.md +93 -93
- package/dist/skills/fluentcart-developer/references/restapi/operations/files/delete-file.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/files/get-bucket-list.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/files/list-files.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/files/upload-editor-file.md +32 -32
- package/dist/skills/fluentcart-developer/references/restapi/operations/files/upload-file.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/chained-data-request.md +46 -46
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/change-feed-status.md +51 -51
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/delete-feed.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-dynamic-options.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-feed-lists.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-feed-settings.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-global-feeds.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-global-settings.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/install-addon-plugin.md +49 -49
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/list-addons.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/save-feed-settings.md +52 -52
- package/dist/skills/fluentcart-developer/references/restapi/operations/integration/set-global-settings.md +50 -50
- package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/bulk-update-stock.md +94 -94
- package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/export-inventory.md +81 -81
- package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/get-adjustment-history.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/get-inventory-stats.md +21 -21
- package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/list-inventory.md +33 -33
- package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/update-stock.md +75 -75
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-attribute-group.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-label.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-terms.md +90 -90
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/delete-attribute-group.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/delete-attribute-term.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/get-attribute-group.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/get-attribute-library.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-attribute-groups.md +32 -32
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-attribute-terms.md +33 -33
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-labels.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/reorder-groups.md +51 -51
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/reorder-terms.md +56 -56
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-attribute-group.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-attribute-term.md +39 -39
- package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-label-selections.md +32 -32
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/activate-plugin-license.md +41 -41
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/activate-site-admin.md +60 -60
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-plugin-license.md +18 -18
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-site-admin.md +67 -67
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-site-customer.md +47 -47
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/delete-license.md +24 -24
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/extend-license-validity.md +47 -47
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-customer-license-details.md +25 -25
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-customer-licenses-admin.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-activations.md +25 -25
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-details.md +25 -25
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-site.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-plugin-license-status.md +18 -18
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-product-license-settings.md +24 -24
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-customer-licenses.md +25 -25
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-license-sites.md +33 -33
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-licenses.md +38 -38
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-activate-license.md +54 -54
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-check-license.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-deactivate-license.md +46 -46
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-download-license-package.md +23 -23
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-get-license-version.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/regenerate-license-key.md +24 -24
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/save-product-license-settings.md +193 -193
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/update-license-activation-limit.md +53 -53
- package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/update-license-status.md +52 -52
- package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/create-order-bump.md +47 -47
- package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/delete-order-bump.md +25 -25
- package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/get-order-bump.md +25 -25
- package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/list-order-bumps.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/update-order-bump.md +141 -141
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/accept-dispute.md +47 -47
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/bulk-actions.md +72 -72
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/calculate-shipping.md +67 -67
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/calculate-tax.md +98 -98
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/change-customer.md +50 -50
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/charge-now.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-and-change-customer.md +92 -92
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-custom-order-item.md +68 -68
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-order.md +351 -351
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-renewal-now.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/delete-order.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/generate-missing-licenses.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-order-transactions.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-order.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-renewal.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-shipping-methods.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-single-transaction.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-order-currencies.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-orders.md +42 -42
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-renewals.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/mark-as-paid.md +61 -61
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/price-order.md +135 -135
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/refund-order.md +72 -72
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/resend-renewal-invoice.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/skip-renewal.md +48 -48
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/sync-order-statuses.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/sync-pending-transaction.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order-address-id.md +60 -60
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order-address.md +98 -98
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order.md +172 -172
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-statuses.md +77 -77
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-subscription-details.md +84 -84
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-transaction-status.md +51 -51
- package/dist/skills/fluentcart-developer/references/restapi/operations/orders/void-renewal.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/create-pdf-template.md +42 -42
- package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/delete-pdf-template.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/download-pdf-preview.md +44 -44
- package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-factory-default-templates.md +19 -19
- package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-pdf-status.md +21 -21
- package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-pdf-template.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-saved-templates.md +21 -21
- package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-seller-details.md +19 -19
- package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/list-pdf-templates.md +19 -19
- package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/save-pdf-template.md +53 -53
- package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/save-seller-details.md +97 -97
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/add-product-terms.md +64 -64
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-edit-fetch.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-insert-products.md +62 -62
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-update-products.md +59 -59
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-update-variants.md +83 -83
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/change-integration-status.md +64 -64
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-dummy-products.md +45 -45
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-product.md +81 -81
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-variation.md +181 -181
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-downloadable-file.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-product-integration.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-product.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-taxonomy-term.md +55 -55
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-upgrade-path.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-variation.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/do-bulk-action.md +56 -56
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/duplicate-product.md +56 -56
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-products-by-ids.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-taxonomy-terms.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-terms-by-parent.md +60 -60
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-variations-by-ids.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/find-subscription-variants.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-bundle-info.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-downloadable-url.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-max-excerpt-word-count.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-pricing-widgets.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-integration-feeds.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-integration-settings.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-pricing.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-related-products.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-upgrade-settings.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-variation-upgrade-paths.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/group-bulk-update-variants.md +103 -103
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-all-variants.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-product-variations.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-products.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/remove-shipping-class.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/remove-tax-class.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-bundle-info.md +56 -56
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-product-integration.md +62 -62
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-upgrade-path.md +78 -78
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-product-variant-options.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-products-by-name.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-variants-by-name.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/set-variation-media.md +74 -74
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/suggest-sku.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/sync-downloadable-files.md +134 -134
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/sync-taxonomy-terms.md +61 -61
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/toggle-product-tax-exemption.md +56 -56
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-downloadable-file.md +98 -98
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-inventory.md +56 -56
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-long-desc-editor-mode.md +49 -49
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-manage-stock.md +53 -53
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-product-detail.md +58 -58
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-product-pricing.md +225 -225
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-shipping-class.md +49 -49
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-tax-class.md +49 -49
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-upgrade-path.md +78 -78
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variant-option.md +79 -79
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variant-tax-exemption.md +56 -56
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variation-pricing-table.md +49 -49
- package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variation.md +105 -105
- package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/get-product-views.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/list-products.md +42 -42
- package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/search-products.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/channel-rules.md +24 -24
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/country-heat-map.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/coupon-overview.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/coupons.md +36 -36
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-insights.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-overview.md +36 -36
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-repeat.md +35 -35
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-segment-customers.md +36 -36
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-segments.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-value.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/dashboard-stats.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/failed-orders.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-new-vs-returning-customer.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-report-by-day-and-hour.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-report-meta.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-top-sold-products.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/future-renewals.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/generate-retention-snapshots.md +24 -24
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-overview.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-recent-activities.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-recent-orders.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-revenue.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments-at-risk.md +35 -35
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments-variations.md +33 -33
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments.md +33 -33
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/item-count-distribution.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-chart.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-pie-chart.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-summary.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/locations.md +43 -43
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-chart.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-completion-time.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-mix.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-value-distribution.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods-disputes.md +38 -38
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods-methods.md +36 -36
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-comparison-launch.md +33 -33
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-comparison.md +40 -40
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-detail.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-sales.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/refunds-overview.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/retention-snapshots-step.md +45 -45
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/sales-growth-chart.md +35 -35
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/save-channel-rules.md +73 -73
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/source-channels.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/sources.md +49 -49
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-cohorts.md +33 -33
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-health.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-rebuys.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-retention.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-variations.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscriptions-overview.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/reports/weeks-between-refund.md +34 -34
- package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/assign-role.md +48 -48
- package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/delete-role-assignment.md +47 -47
- package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/get-role.md +25 -25
- package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/list-managers.md +18 -18
- package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/list-roles.md +18 -18
- package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/search-users.md +25 -25
- package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/update-role.md +43 -43
- package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/create-saved-view.md +106 -106
- package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/delete-saved-view.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/list-saved-views.md +25 -25
- package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/update-saved-view.md +83 -83
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/activate-payment-addon.md +44 -44
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/activate-plugin-addon.md +44 -44
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/change-storage-driver-status.md +56 -56
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/check-paypal-webhook.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/create-storage-bucket.md +63 -63
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/disconnect-payment-method.md +55 -55
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/exchange-paypal-seller-auth-token.md +62 -62
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-active-storage-drivers.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-checkout-fields.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-email-shortcodes.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-mcp-config-snippets.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-mcp-status.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-module-settings.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-payment-method-connection-info.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-payment-method-settings.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-permissions.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-plugin-addons.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-storage-driver-settings.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-store-settings.md +26 -26
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-mcp-adapter.md +21 -21
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-payment-addon.md +60 -60
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-plugin-addon.md +64 -64
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-all-payment-methods.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-all-storage-drivers.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-storage-buckets.md +67 -67
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/reorder-payment-methods.md +55 -55
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/reset-storage-driver-settings.md +45 -45
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-checkout-fields.md +133 -133
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-confirmation-settings.md +68 -68
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-module-settings.md +68 -68
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-payment-method-design.md +67 -67
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-payment-method-settings.md +58 -58
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-permissions.md +68 -68
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-storage-driver-settings.md +62 -62
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-store-settings.md +239 -239
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/setup-paypal-webhook.md +48 -48
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/toggle-mcp.md +40 -40
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/verify-storage-driver-connection.md +62 -62
- package/dist/skills/fluentcart-developer/references/restapi/operations/settings/verify-turnstile-keys.md +55 -55
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-class.md +73 -73
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-method.md +110 -110
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-zone.md +56 -56
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-class.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-method.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-zone.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-class-profile.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-class.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-packages.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-zone.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-zone-countries.md +22 -22
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-zone-states.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/list-shipping-classes.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/list-shipping-zones.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/save-shipping-packages.md +112 -112
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-class.md +79 -79
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-method.md +113 -113
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-zone.md +62 -62
- package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-zone-order.md +52 -52
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/cancel-auto-renew.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/cancel-subscription.md +52 -52
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/confirm-subscription-switch.md +70 -70
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/fetch-subscription-remote.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/generate-early-payment-link.md +29 -29
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-customer-subscription.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-or-create-plan.md +69 -69
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-setup-intent-attempts.md +30 -30
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-subscription.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/initiate-early-payment.md +31 -31
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/list-customer-subscriptions.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/list-subscriptions.md +39 -39
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/pause-subscription.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/reactivate-subscription.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/resume-subscription.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/switch-payment-method.md +70 -70
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/update-payment-method.md +69 -69
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/update-vendor-ids.md +56 -56
- package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/verify-vendor-ids.md +56 -56
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/create-tax-class.md +51 -51
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/create-tax-rate.md +117 -117
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-product-override.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-shipping-tax-override.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-tax-class.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-tax-rate.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-country-tax-id.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-country-tax-rates.md +28 -28
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-eu-vat-product-overrides.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-oss-country-rates.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-preconfigured-tax-rates.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-product-overrides.md +27 -27
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-tax-settings.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-all-tax-rates.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-tax-classes.md +20 -20
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-tax-records.md +37 -37
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/mark-taxes-as-filed.md +58 -58
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/reset-eu-vat-rates.md +21 -21
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-configured-countries.md +57 -57
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-country-tax-id.md +50 -50
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-eu-vat-cross-border-settings.md +127 -127
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-oss-country-rates.md +100 -100
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-product-override.md +110 -110
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-shipping-tax-override.md +52 -52
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-tax-settings.md +166 -166
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/update-country-status.md +54 -54
- package/dist/skills/fluentcart-developer/references/restapi/operations/tax/update-tax-rate.md +116 -116
- package/dist/skills/fluentcart-developer/references/restapi/order-bumps.md +433 -433
- package/dist/skills/fluentcart-developer/references/restapi/orders.md +1212 -1212
- package/dist/skills/fluentcart-developer/references/restapi/pdf-templates.md +212 -212
- package/dist/skills/fluentcart-developer/references/restapi/products.md +2485 -2485
- package/dist/skills/fluentcart-developer/references/restapi/public-shop.md +191 -191
- package/dist/skills/fluentcart-developer/references/restapi/reports.md +3773 -3773
- package/dist/skills/fluentcart-developer/references/restapi/roles.md +403 -403
- package/dist/skills/fluentcart-developer/references/restapi/saved-views.md +136 -136
- package/dist/skills/fluentcart-developer/references/restapi/settings.md +1423 -1423
- package/dist/skills/fluentcart-developer/references/restapi/shipping.md +905 -905
- package/dist/skills/fluentcart-developer/references/restapi/subscriptions.md +1169 -1169
- package/dist/skills/fluentcart-developer/references/restapi/tax.md +1551 -1551
- package/dist/skills/fluentcart-developer/references/restapi.md +127 -127
- package/dist/skills/fluentcart-developer/scripts/cli.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +66 -65
|
@@ -1,986 +1,986 @@
|
|
|
1
|
-
# Storage Drivers Module
|
|
2
|
-
|
|
3
|
-
The Storage Drivers module provides a flexible file storage abstraction layer in FluentCart. It allows you to store and manage digital products, files, and media across different storage providers including local storage and cloud services like Amazon S3.
|
|
4
|
-
|
|
5
|
-
## Architecture Overview
|
|
6
|
-
|
|
7
|
-
### Core Components
|
|
8
|
-
|
|
9
|
-
#### 1. **Storage Drivers**
|
|
10
|
-
|
|
11
|
-
Abstract implementations for different storage providers (Local, S3, etc.).
|
|
12
|
-
|
|
13
|
-
#### 2. **File Manager**
|
|
14
|
-
|
|
15
|
-
Central service for managing file operations across different storage drivers.
|
|
16
|
-
|
|
17
|
-
#### 3. **Base Driver**
|
|
18
|
-
|
|
19
|
-
Abstract base class that all storage drivers must extend.
|
|
20
|
-
|
|
21
|
-
#### 4. **Storage Settings**
|
|
22
|
-
|
|
23
|
-
Configuration management for each storage driver.
|
|
24
|
-
|
|
25
|
-
## Built-in Storage Drivers
|
|
26
|
-
|
|
27
|
-
### Local Storage Driver
|
|
28
|
-
|
|
29
|
-
Stores files locally on the server's file system.
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
use FluentCart\App\Modules\StorageDrivers\Local\Local;
|
|
33
|
-
|
|
34
|
-
class Local extends BaseStorageDriver
|
|
35
|
-
{
|
|
36
|
-
public function __construct()
|
|
37
|
-
{
|
|
38
|
-
parent::__construct(
|
|
39
|
-
__('Local', 'fluent-cart'),
|
|
40
|
-
'local',
|
|
41
|
-
'#136196'
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public function getDescription(): string
|
|
46
|
-
{
|
|
47
|
-
return esc_html__('Local allows to upload file in local file storage', 'fluent-cart');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public function getDriverClass(): string
|
|
51
|
-
{
|
|
52
|
-
return LocalDriver::class;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Amazon S3 Driver
|
|
58
|
-
|
|
59
|
-
Stores files in Amazon S3 buckets for scalable cloud storage.
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
use FluentCart\App\Modules\StorageDrivers\S3\S3;
|
|
63
|
-
|
|
64
|
-
class S3 extends BaseStorageDriver
|
|
65
|
-
{
|
|
66
|
-
public function __construct()
|
|
67
|
-
{
|
|
68
|
-
parent::__construct(
|
|
69
|
-
__('S3', 'fluent-cart'),
|
|
70
|
-
's3',
|
|
71
|
-
'#4f94d4'
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public function getDescription()
|
|
76
|
-
{
|
|
77
|
-
return esc_html__('S3 bucket allows to configure storage options and others for efficient and secure cloud-based file storage', 'fluent-cart');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public function getDriverClass(): string
|
|
81
|
-
{
|
|
82
|
-
return S3Driver::class;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Base Storage Driver
|
|
88
|
-
|
|
89
|
-
### BaseStorageDriver Class
|
|
90
|
-
|
|
91
|
-
All storage drivers extend this abstract class:
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
abstract class BaseStorageDriver implements BaseStorageInterface
|
|
95
|
-
{
|
|
96
|
-
public $slug;
|
|
97
|
-
public $title;
|
|
98
|
-
public $brandColor = '#ccc';
|
|
99
|
-
protected $driverHandler;
|
|
100
|
-
|
|
101
|
-
public function __construct($title, $slug, $brandColor)
|
|
102
|
-
{
|
|
103
|
-
$this->title = $title;
|
|
104
|
-
$this->slug = $slug;
|
|
105
|
-
$this->brandColor = $brandColor;
|
|
106
|
-
$this->driverHandler = 'fluent_cart_storage_settings_' . $slug;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
abstract public function getLogo();
|
|
110
|
-
abstract public function getDescription();
|
|
111
|
-
abstract public function getSettings();
|
|
112
|
-
abstract public function fields();
|
|
113
|
-
abstract public function hiddenSettingKeys(): array;
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### BaseStorageInterface
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
interface BaseStorageInterface
|
|
121
|
-
{
|
|
122
|
-
public function isEnabled(): bool;
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## File Manager
|
|
127
|
-
|
|
128
|
-
### FileManager Class
|
|
129
|
-
|
|
130
|
-
The central service for managing file operations:
|
|
131
|
-
|
|
132
|
-
```
|
|
133
|
-
use FluentCart\App\Services\FileSystem\FileManager;
|
|
134
|
-
|
|
135
|
-
class FileManager
|
|
136
|
-
{
|
|
137
|
-
private $driver;
|
|
138
|
-
protected ?string $dirPath;
|
|
139
|
-
protected ?string $dirName;
|
|
140
|
-
|
|
141
|
-
public function __construct(
|
|
142
|
-
string $driver = 'local',
|
|
143
|
-
?string $dirPath = null,
|
|
144
|
-
?string $dirName = null,
|
|
145
|
-
$inActiveMode = false
|
|
146
|
-
) {
|
|
147
|
-
$this->dirName = $dirName;
|
|
148
|
-
$this->dirPath = $dirPath;
|
|
149
|
-
$this->driver = $this->resolveDriver($driver, $inActiveMode);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
public function uploadFile(string $localFilePath, string $uploadToFilePath, $file, array $params = [])
|
|
153
|
-
{
|
|
154
|
-
return $this->driver->uploadFile($localFilePath, $uploadToFilePath, $file, $params);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
public function downloadFile(string $filePath, string $fileName, $bucket = null)
|
|
158
|
-
{
|
|
159
|
-
return $this->driver->downloadFile($filePath, $fileName, $bucket);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
public function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null): ?string
|
|
163
|
-
{
|
|
164
|
-
return $this->driver->getSignedDownloadUrl($filePath, $bucket, $productDownload);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
public function deleteFile(string $filePath, $bucket = null)
|
|
168
|
-
{
|
|
169
|
-
return $this->driver->deleteFile($filePath, $bucket);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public function listFiles(array $params = [])
|
|
173
|
-
{
|
|
174
|
-
return $this->driver->listFiles($params);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Base Driver Implementation
|
|
180
|
-
|
|
181
|
-
### BaseDriver Class
|
|
182
|
-
|
|
183
|
-
All storage driver implementations extend this class:
|
|
184
|
-
|
|
185
|
-
```
|
|
186
|
-
abstract class BaseDriver
|
|
187
|
-
{
|
|
188
|
-
protected ?string $dirPath;
|
|
189
|
-
protected ?string $dirName;
|
|
190
|
-
protected ?BaseStorageDriver $storageDriver;
|
|
191
|
-
|
|
192
|
-
public function __construct(?string $dirPath = null, ?string $dirName = null)
|
|
193
|
-
{
|
|
194
|
-
$this->dirName = $dirName;
|
|
195
|
-
$this->dirPath = $dirPath;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
public abstract function listFiles(array $params = []);
|
|
199
|
-
public abstract function uploadFile($localFilePath, $uploadToFilePath, $file, $params = []);
|
|
200
|
-
public abstract function downloadFile(string $filePath);
|
|
201
|
-
public abstract function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null);
|
|
202
|
-
public abstract function getFilePath(string $filePath);
|
|
203
|
-
public abstract function deleteFile(string $filePath, $bucket = null);
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
## Local Storage Implementation
|
|
208
|
-
|
|
209
|
-
### LocalDriver Class
|
|
210
|
-
|
|
211
|
-
```
|
|
212
|
-
class LocalDriver extends BaseDriver
|
|
213
|
-
{
|
|
214
|
-
public function __construct(string $dirPath = null, string $dirName = null)
|
|
215
|
-
{
|
|
216
|
-
parent::__construct($dirPath, $dirName);
|
|
217
|
-
$this->dirName = $dirName ?? 'fluent-cart';
|
|
218
|
-
$this->dirPath = $dirPath ?? $this->getDefaultDirPath();
|
|
219
|
-
$this->storageDriver = new LocalStorageDriver();
|
|
220
|
-
$this->ensureDirectoryExist();
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
protected function getDefaultDirPath(): string
|
|
224
|
-
{
|
|
225
|
-
return wp_get_upload_dir()['basedir'] . DIRECTORY_SEPARATOR . $this->getDirName();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
private function ensureDirectoryExist()
|
|
229
|
-
{
|
|
230
|
-
$uploadDirectory = $this->getDefaultDirPath();
|
|
231
|
-
if (!is_dir($uploadDirectory)) {
|
|
232
|
-
mkdir($uploadDirectory);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
public function uploadFile($localFilePath, $uploadToFilePath, $file, $params = [])
|
|
237
|
-
{
|
|
238
|
-
$destinationPath = $this->dirPath . DIRECTORY_SEPARATOR . $uploadToFilePath;
|
|
239
|
-
|
|
240
|
-
// Ensure directory exists
|
|
241
|
-
$destinationDir = dirname($destinationPath);
|
|
242
|
-
if (!is_dir($destinationDir)) {
|
|
243
|
-
mkdir($destinationDir, 0755, true);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (move_uploaded_file($localFilePath, $destinationPath)) {
|
|
247
|
-
return [
|
|
248
|
-
'success' => true,
|
|
249
|
-
'file_path' => $uploadToFilePath,
|
|
250
|
-
'file_url' => $this->getFileUrl($uploadToFilePath)
|
|
251
|
-
];
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return [
|
|
255
|
-
'success' => false,
|
|
256
|
-
'error' => 'Failed to move uploaded file'
|
|
257
|
-
];
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
public function downloadFile(string $filePath)
|
|
261
|
-
{
|
|
262
|
-
$fullPath = $this->dirPath . DIRECTORY_SEPARATOR . $filePath;
|
|
263
|
-
|
|
264
|
-
if (!file_exists($fullPath)) {
|
|
265
|
-
return [
|
|
266
|
-
'success' => false,
|
|
267
|
-
'error' => 'File not found'
|
|
268
|
-
];
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
$fileName = basename($filePath);
|
|
272
|
-
$fileSize = filesize($fullPath);
|
|
273
|
-
|
|
274
|
-
$this->setDownloadHeader($fileName, $fullPath, $fileSize);
|
|
275
|
-
|
|
276
|
-
readfile($fullPath);
|
|
277
|
-
exit;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
public function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null): ?string
|
|
281
|
-
{
|
|
282
|
-
// For local storage, return direct file URL
|
|
283
|
-
return $this->getFileUrl($filePath);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
public function getFilePath(string $filePath)
|
|
287
|
-
{
|
|
288
|
-
return $this->dirPath . DIRECTORY_SEPARATOR . $filePath;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
public function deleteFile(string $filePath, $bucket = null)
|
|
292
|
-
{
|
|
293
|
-
$fullPath = $this->dirPath . DIRECTORY_SEPARATOR . $filePath;
|
|
294
|
-
|
|
295
|
-
if (file_exists($fullPath)) {
|
|
296
|
-
return unlink($fullPath);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return false;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
private function getFileUrl(string $filePath): string
|
|
303
|
-
{
|
|
304
|
-
$uploadDir = wp_get_upload_dir();
|
|
305
|
-
return $uploadDir['baseurl'] . '/' . $this->getDirName() . '/' . $filePath;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
## S3 Storage Implementation
|
|
311
|
-
|
|
312
|
-
### S3Driver Class
|
|
313
|
-
|
|
314
|
-
```
|
|
315
|
-
class S3Driver extends BaseDriver
|
|
316
|
-
{
|
|
317
|
-
private string $accessKey;
|
|
318
|
-
private string $secretKey;
|
|
319
|
-
private string $bucket;
|
|
320
|
-
private string $region;
|
|
321
|
-
|
|
322
|
-
public function __construct(string $dirPath = null, string $dirName = null)
|
|
323
|
-
{
|
|
324
|
-
parent::__construct($dirPath, $dirName);
|
|
325
|
-
|
|
326
|
-
$getSettings = (new S3Settings())->get();
|
|
327
|
-
|
|
328
|
-
$this->secretKey = Arr::get($getSettings, 'secret_key', '');
|
|
329
|
-
$this->accessKey = Arr::get($getSettings, 'access_key', '');
|
|
330
|
-
$this->bucket = Arr::get($getSettings, 'bucket', '');
|
|
331
|
-
$this->region = Arr::get($getSettings, 'region', '');
|
|
332
|
-
$this->storageDriver = new S3StorageDriver();
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
public function uploadFile($localFilePath, $uploadToFilePath, $file, $params = [])
|
|
336
|
-
{
|
|
337
|
-
$fileSize = $file->toArray()['size_in_bytes'];
|
|
338
|
-
|
|
339
|
-
try {
|
|
340
|
-
$s3Client = new S3Client([
|
|
341
|
-
'version' => 'latest',
|
|
342
|
-
'region' => $this->region,
|
|
343
|
-
'credentials' => [
|
|
344
|
-
'key' => $this->accessKey,
|
|
345
|
-
'secret' => $this->secretKey,
|
|
346
|
-
],
|
|
347
|
-
]);
|
|
348
|
-
|
|
349
|
-
$result = $s3Client->putObject([
|
|
350
|
-
'Bucket' => $this->bucket,
|
|
351
|
-
'Key' => $uploadToFilePath,
|
|
352
|
-
'SourceFile' => $localFilePath,
|
|
353
|
-
'ContentType' => $file->getMimeType(),
|
|
354
|
-
'ACL' => 'private', // Private by default for security
|
|
355
|
-
]);
|
|
356
|
-
|
|
357
|
-
return [
|
|
358
|
-
'success' => true,
|
|
359
|
-
'file_path' => $uploadToFilePath,
|
|
360
|
-
'file_url' => $result['ObjectURL']
|
|
361
|
-
];
|
|
362
|
-
|
|
363
|
-
} catch (Exception $e) {
|
|
364
|
-
return [
|
|
365
|
-
'success' => false,
|
|
366
|
-
'error' => $e->getMessage()
|
|
367
|
-
];
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
public function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null): ?string
|
|
372
|
-
{
|
|
373
|
-
try {
|
|
374
|
-
$s3Client = new S3Client([
|
|
375
|
-
'version' => 'latest',
|
|
376
|
-
'region' => $this->region,
|
|
377
|
-
'credentials' => [
|
|
378
|
-
'key' => $this->accessKey,
|
|
379
|
-
'secret' => $this->secretKey,
|
|
380
|
-
],
|
|
381
|
-
]);
|
|
382
|
-
|
|
383
|
-
$bucket = $bucket ?? $this->bucket;
|
|
384
|
-
$expiration = '+1 hour'; // Default expiration
|
|
385
|
-
|
|
386
|
-
// Custom expiration for product downloads
|
|
387
|
-
if ($productDownload) {
|
|
388
|
-
$expiration = '+24 hours'; // Longer expiration for product downloads
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
$cmd = $s3Client->getCommand('GetObject', [
|
|
392
|
-
'Bucket' => $bucket,
|
|
393
|
-
'Key' => $filePath,
|
|
394
|
-
]);
|
|
395
|
-
|
|
396
|
-
$request = $s3Client->createPresignedRequest($cmd, $expiration);
|
|
397
|
-
|
|
398
|
-
return (string) $request->getUri();
|
|
399
|
-
|
|
400
|
-
} catch (Exception $e) {
|
|
401
|
-
return null;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
public function deleteFile(string $filePath, $bucket = null)
|
|
406
|
-
{
|
|
407
|
-
try {
|
|
408
|
-
$s3Client = new S3Client([
|
|
409
|
-
'version' => 'latest',
|
|
410
|
-
'region' => $this->region,
|
|
411
|
-
'credentials' => [
|
|
412
|
-
'key' => $this->accessKey,
|
|
413
|
-
'secret' => $this->secretKey,
|
|
414
|
-
],
|
|
415
|
-
]);
|
|
416
|
-
|
|
417
|
-
$bucket = $bucket ?? $this->bucket;
|
|
418
|
-
|
|
419
|
-
$result = $s3Client->deleteObject([
|
|
420
|
-
'Bucket' => $bucket,
|
|
421
|
-
'Key' => $filePath,
|
|
422
|
-
]);
|
|
423
|
-
|
|
424
|
-
return true;
|
|
425
|
-
|
|
426
|
-
} catch (Exception $e) {
|
|
427
|
-
return false;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
public function buckets()
|
|
432
|
-
{
|
|
433
|
-
return S3BucketList::get(
|
|
434
|
-
$this->secretKey,
|
|
435
|
-
$this->accessKey,
|
|
436
|
-
$this->region
|
|
437
|
-
);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
## Storage Settings
|
|
443
|
-
|
|
444
|
-
### BaseStorageSettings Class
|
|
445
|
-
|
|
446
|
-
```
|
|
447
|
-
abstract class BaseStorageSettings
|
|
448
|
-
{
|
|
449
|
-
protected $settings;
|
|
450
|
-
protected $driverHandler = 'fluent_cart_storage_settings_';
|
|
451
|
-
|
|
452
|
-
public function __construct($slug)
|
|
453
|
-
{
|
|
454
|
-
$settings = fluent_cart_get_option($this->driverHandler.$slug, []);
|
|
455
|
-
$this->settings = wp_parse_args($settings, $this->getDefaultSettings());
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
abstract protected function getDefaultSettings();
|
|
459
|
-
abstract public function isActive();
|
|
460
|
-
|
|
461
|
-
public function get()
|
|
462
|
-
{
|
|
463
|
-
return $this->settings;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
### Local Storage Settings
|
|
469
|
-
|
|
470
|
-
```
|
|
471
|
-
class LocalSettings extends BaseStorageSettings
|
|
472
|
-
{
|
|
473
|
-
protected function getDefaultSettings()
|
|
474
|
-
{
|
|
475
|
-
return [
|
|
476
|
-
'is_active' => 'no'
|
|
477
|
-
];
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
public function isActive()
|
|
481
|
-
{
|
|
482
|
-
return $this->settings['is_active'] === 'yes';
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
### S3 Storage Settings
|
|
488
|
-
|
|
489
|
-
```
|
|
490
|
-
class S3Settings extends BaseStorageSettings
|
|
491
|
-
{
|
|
492
|
-
protected function getDefaultSettings()
|
|
493
|
-
{
|
|
494
|
-
return [
|
|
495
|
-
'is_active' => 'no',
|
|
496
|
-
'access_key' => '',
|
|
497
|
-
'secret_key' => '',
|
|
498
|
-
'bucket' => '',
|
|
499
|
-
'region' => 'us-east-1',
|
|
500
|
-
'buckets' => []
|
|
501
|
-
];
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
public function isActive()
|
|
505
|
-
{
|
|
506
|
-
$isActive = $this->settings['is_active'] === 'yes';
|
|
507
|
-
$hasSelectedBuckets = !empty($this->settings['buckets']) &&
|
|
508
|
-
is_array($this->settings['buckets']) &&
|
|
509
|
-
count($this->settings['buckets']) > 0;
|
|
510
|
-
|
|
511
|
-
return $isActive && $hasSelectedBuckets;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
```
|
|
515
|
-
|
|
516
|
-
## Creating Custom Storage Drivers
|
|
517
|
-
|
|
518
|
-
### 1. Create Storage Driver Class
|
|
519
|
-
|
|
520
|
-
```
|
|
521
|
-
<?php
|
|
522
|
-
namespace FluentCart\App\Modules\StorageDrivers\CustomDriver;
|
|
523
|
-
|
|
524
|
-
use FluentCart\App\Modules\StorageDrivers\BaseStorageDriver;
|
|
525
|
-
use FluentCart\App\Vite;
|
|
526
|
-
|
|
527
|
-
class CustomDriver extends BaseStorageDriver
|
|
528
|
-
{
|
|
529
|
-
public function __construct()
|
|
530
|
-
{
|
|
531
|
-
parent::__construct(
|
|
532
|
-
__('Custom Storage', 'fluent-cart'),
|
|
533
|
-
'custom_driver',
|
|
534
|
-
'#your-brand-color'
|
|
535
|
-
);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
public function getLogo(): string
|
|
539
|
-
{
|
|
540
|
-
return Vite::getAssetUrl("images/storage-drivers/custom-logo.svg");
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
public function getDescription(): string
|
|
544
|
-
{
|
|
545
|
-
return esc_html__('Custom storage driver for your specific needs', 'fluent-cart');
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
public function isEnabled(): bool
|
|
549
|
-
{
|
|
550
|
-
return (new CustomDriverSettings())->isActive();
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
public function getSettings()
|
|
554
|
-
{
|
|
555
|
-
return (new CustomDriverSettings())->get();
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
public function fields(): array
|
|
559
|
-
{
|
|
560
|
-
return [
|
|
561
|
-
'view' => [
|
|
562
|
-
'title' => __('Custom Driver Settings', 'fluent-cart'),
|
|
563
|
-
'type' => 'section',
|
|
564
|
-
'disable_nesting' => true,
|
|
565
|
-
'columns' => [
|
|
566
|
-
'default' => 1,
|
|
567
|
-
'md' => 1,
|
|
568
|
-
'lg' => 1
|
|
569
|
-
],
|
|
570
|
-
'schema' => [
|
|
571
|
-
'is_active' => [
|
|
572
|
-
'value' => '',
|
|
573
|
-
'label' => __('Enable custom driver', 'fluent-cart'),
|
|
574
|
-
'type' => 'checkbox'
|
|
575
|
-
],
|
|
576
|
-
'api_key' => [
|
|
577
|
-
'value' => '',
|
|
578
|
-
'label' => __('API Key', 'fluent-cart'),
|
|
579
|
-
'type' => 'text',
|
|
580
|
-
'required' => true
|
|
581
|
-
],
|
|
582
|
-
'endpoint' => [
|
|
583
|
-
'value' => '',
|
|
584
|
-
'label' => __('Endpoint URL', 'fluent-cart'),
|
|
585
|
-
'type' => 'text',
|
|
586
|
-
'required' => true
|
|
587
|
-
]
|
|
588
|
-
]
|
|
589
|
-
]
|
|
590
|
-
];
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
public function getDriverClass(): string
|
|
594
|
-
{
|
|
595
|
-
return CustomDriverImplementation::class;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
public function hiddenSettingKeys(): array
|
|
599
|
-
{
|
|
600
|
-
return ['api_key', 'secret_key'];
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
public function verifyConnectInfo(array $data, $args = [])
|
|
604
|
-
{
|
|
605
|
-
// Implement connection verification logic
|
|
606
|
-
$apiKey = $data['api_key'] ?? '';
|
|
607
|
-
$endpoint = $data['endpoint'] ?? '';
|
|
608
|
-
|
|
609
|
-
if (empty($apiKey) || empty($endpoint)) {
|
|
610
|
-
return new \WP_Error('missing_credentials', 'API Key and Endpoint are required');
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
// Test connection
|
|
614
|
-
$response = wp_remote_get($endpoint . '/test', [
|
|
615
|
-
'headers' => [
|
|
616
|
-
'Authorization' => 'Bearer ' . $apiKey
|
|
617
|
-
],
|
|
618
|
-
'timeout' => 10
|
|
619
|
-
]);
|
|
620
|
-
|
|
621
|
-
if (is_wp_error($response)) {
|
|
622
|
-
return new \WP_Error('connection_failed', 'Failed to connect to custom storage service');
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
return true;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
```
|
|
629
|
-
|
|
630
|
-
### 2. Create Driver Implementation
|
|
631
|
-
|
|
632
|
-
```
|
|
633
|
-
<?php
|
|
634
|
-
namespace FluentCart\App\Services\FileSystem\Drivers\CustomDriver;
|
|
635
|
-
|
|
636
|
-
use FluentCart\App\Services\FileSystem\Drivers\BaseDriver;
|
|
637
|
-
use FluentCart\App\Modules\StorageDrivers\CustomDriver\CustomDriver as CustomStorageDriver;
|
|
638
|
-
|
|
639
|
-
class CustomDriverImplementation extends BaseDriver
|
|
640
|
-
{
|
|
641
|
-
private string $apiKey;
|
|
642
|
-
private string $endpoint;
|
|
643
|
-
|
|
644
|
-
public function __construct(string $dirPath = null, string $dirName = null)
|
|
645
|
-
{
|
|
646
|
-
parent::__construct($dirPath, $dirName);
|
|
647
|
-
|
|
648
|
-
$settings = (new CustomDriverSettings())->get();
|
|
649
|
-
$this->apiKey = $settings['api_key'] ?? '';
|
|
650
|
-
$this->endpoint = $settings['endpoint'] ?? '';
|
|
651
|
-
$this->storageDriver = new CustomStorageDriver();
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
public function uploadFile($localFilePath, $uploadToFilePath, $file, $params = [])
|
|
655
|
-
{
|
|
656
|
-
try {
|
|
657
|
-
$response = wp_remote_post($this->endpoint . '/upload', [
|
|
658
|
-
'headers' => [
|
|
659
|
-
'Authorization' => 'Bearer ' . $this->apiKey,
|
|
660
|
-
'Content-Type' => 'multipart/form-data'
|
|
661
|
-
],
|
|
662
|
-
'body' => [
|
|
663
|
-
'file' => new \CURLFile($localFilePath),
|
|
664
|
-
'path' => $uploadToFilePath,
|
|
665
|
-
'metadata' => json_encode([
|
|
666
|
-
'size' => filesize($localFilePath),
|
|
667
|
-
'type' => mime_content_type($localFilePath)
|
|
668
|
-
])
|
|
669
|
-
],
|
|
670
|
-
'timeout' => 60
|
|
671
|
-
]);
|
|
672
|
-
|
|
673
|
-
if (is_wp_error($response)) {
|
|
674
|
-
return [
|
|
675
|
-
'success' => false,
|
|
676
|
-
'error' => $response->get_error_message()
|
|
677
|
-
];
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
$body = wp_remote_retrieve_body($response);
|
|
681
|
-
$data = json_decode($body, true);
|
|
682
|
-
|
|
683
|
-
if ($data['success']) {
|
|
684
|
-
return [
|
|
685
|
-
'success' => true,
|
|
686
|
-
'file_path' => $uploadToFilePath,
|
|
687
|
-
'file_url' => $data['file_url']
|
|
688
|
-
];
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
return [
|
|
692
|
-
'success' => false,
|
|
693
|
-
'error' => $data['error'] ?? 'Upload failed'
|
|
694
|
-
];
|
|
695
|
-
|
|
696
|
-
} catch (Exception $e) {
|
|
697
|
-
return [
|
|
698
|
-
'success' => false,
|
|
699
|
-
'error' => $e->getMessage()
|
|
700
|
-
];
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
public function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null): ?string
|
|
705
|
-
{
|
|
706
|
-
try {
|
|
707
|
-
$response = wp_remote_post($this->endpoint . '/generate-url', [
|
|
708
|
-
'headers' => [
|
|
709
|
-
'Authorization' => 'Bearer ' . $this->apiKey,
|
|
710
|
-
'Content-Type' => 'application/json'
|
|
711
|
-
],
|
|
712
|
-
'body' => json_encode([
|
|
713
|
-
'file_path' => $filePath,
|
|
714
|
-
'expires_in' => $productDownload ? 86400 : 3600 // 24h for products, 1h for others
|
|
715
|
-
]),
|
|
716
|
-
'timeout' => 30
|
|
717
|
-
]);
|
|
718
|
-
|
|
719
|
-
if (is_wp_error($response)) {
|
|
720
|
-
return null;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
$body = wp_remote_retrieve_body($response);
|
|
724
|
-
$data = json_decode($body, true);
|
|
725
|
-
|
|
726
|
-
return $data['download_url'] ?? null;
|
|
727
|
-
|
|
728
|
-
} catch (Exception $e) {
|
|
729
|
-
return null;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
public function deleteFile(string $filePath, $bucket = null)
|
|
734
|
-
{
|
|
735
|
-
try {
|
|
736
|
-
$response = wp_remote_request($this->endpoint . '/delete', [
|
|
737
|
-
'method' => 'DELETE',
|
|
738
|
-
'headers' => [
|
|
739
|
-
'Authorization' => 'Bearer ' . $this->apiKey,
|
|
740
|
-
'Content-Type' => 'application/json'
|
|
741
|
-
],
|
|
742
|
-
'body' => json_encode([
|
|
743
|
-
'file_path' => $filePath
|
|
744
|
-
]),
|
|
745
|
-
'timeout' => 30
|
|
746
|
-
]);
|
|
747
|
-
|
|
748
|
-
if (is_wp_error($response)) {
|
|
749
|
-
return false;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
$body = wp_remote_retrieve_body($response);
|
|
753
|
-
$data = json_decode($body, true);
|
|
754
|
-
|
|
755
|
-
return $data['success'] ?? false;
|
|
756
|
-
|
|
757
|
-
} catch (Exception $e) {
|
|
758
|
-
return false;
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
public function listFiles(array $params = [])
|
|
763
|
-
{
|
|
764
|
-
try {
|
|
765
|
-
$response = wp_remote_get($this->endpoint . '/files', [
|
|
766
|
-
'headers' => [
|
|
767
|
-
'Authorization' => 'Bearer ' . $this->apiKey
|
|
768
|
-
],
|
|
769
|
-
'body' => $params,
|
|
770
|
-
'timeout' => 30
|
|
771
|
-
]);
|
|
772
|
-
|
|
773
|
-
if (is_wp_error($response)) {
|
|
774
|
-
return [];
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
$body = wp_remote_retrieve_body($response);
|
|
778
|
-
$data = json_decode($body, true);
|
|
779
|
-
|
|
780
|
-
return $data['files'] ?? [];
|
|
781
|
-
|
|
782
|
-
} catch (Exception $e) {
|
|
783
|
-
return [];
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
public function downloadFile(string $filePath)
|
|
788
|
-
{
|
|
789
|
-
$downloadUrl = $this->getSignedDownloadUrl($filePath);
|
|
790
|
-
|
|
791
|
-
if (!$downloadUrl) {
|
|
792
|
-
return [
|
|
793
|
-
'success' => false,
|
|
794
|
-
'error' => 'Failed to generate download URL'
|
|
795
|
-
];
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// Redirect to download URL
|
|
799
|
-
wp_redirect($downloadUrl);
|
|
800
|
-
exit;
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
public function getFilePath(string $filePath)
|
|
804
|
-
{
|
|
805
|
-
return $this->endpoint . '/files/' . $filePath;
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
```
|
|
809
|
-
|
|
810
|
-
### 3. Create Settings Class
|
|
811
|
-
|
|
812
|
-
```
|
|
813
|
-
<?php
|
|
814
|
-
namespace FluentCart\App\Modules\StorageDrivers\CustomDriver;
|
|
815
|
-
|
|
816
|
-
use FluentCart\App\Modules\StorageDrivers\BaseStorageSettings;
|
|
817
|
-
|
|
818
|
-
class CustomDriverSettings extends BaseStorageSettings
|
|
819
|
-
{
|
|
820
|
-
protected function getDefaultSettings()
|
|
821
|
-
{
|
|
822
|
-
return [
|
|
823
|
-
'is_active' => 'no',
|
|
824
|
-
'api_key' => '',
|
|
825
|
-
'endpoint' => ''
|
|
826
|
-
];
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
public function isActive()
|
|
830
|
-
{
|
|
831
|
-
return $this->settings['is_active'] === 'yes';
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
```
|
|
835
|
-
|
|
836
|
-
### 4. Register Custom Driver
|
|
837
|
-
|
|
838
|
-
```
|
|
839
|
-
// In your plugin's initialization
|
|
840
|
-
add_action('fluentcart_loaded', function($app) {
|
|
841
|
-
// Register custom storage driver
|
|
842
|
-
$customDriver = new \FluentCart\App\Modules\StorageDrivers\CustomDriver\CustomDriver();
|
|
843
|
-
$customDriver->init();
|
|
844
|
-
});
|
|
845
|
-
```
|
|
846
|
-
|
|
847
|
-
## File Operations
|
|
848
|
-
|
|
849
|
-
### Uploading Files
|
|
850
|
-
|
|
851
|
-
```
|
|
852
|
-
use FluentCart\App\Services\FileSystem\FileManager;
|
|
853
|
-
|
|
854
|
-
// Initialize file manager with specific driver
|
|
855
|
-
$fileManager = new FileManager('s3', 'products', 'digital-files');
|
|
856
|
-
|
|
857
|
-
// Upload a file
|
|
858
|
-
$result = $fileManager->uploadFile(
|
|
859
|
-
$localFilePath, // Local file path
|
|
860
|
-
'product-123/file.pdf', // Remote file path
|
|
861
|
-
$uploadedFile, // File object
|
|
862
|
-
['metadata' => 'value'] // Additional parameters
|
|
863
|
-
);
|
|
864
|
-
|
|
865
|
-
if ($result['success']) {
|
|
866
|
-
echo "File uploaded successfully: " . $result['file_url'];
|
|
867
|
-
} else {
|
|
868
|
-
echo "Upload failed: " . $result['error'];
|
|
869
|
-
}
|
|
870
|
-
```
|
|
871
|
-
|
|
872
|
-
### Downloading Files
|
|
873
|
-
|
|
874
|
-
```
|
|
875
|
-
// Generate signed download URL
|
|
876
|
-
$downloadUrl = $fileManager->getSignedDownloadUrl(
|
|
877
|
-
'product-123/file.pdf',
|
|
878
|
-
'my-bucket',
|
|
879
|
-
$productDownload // Optional: product download object
|
|
880
|
-
);
|
|
881
|
-
|
|
882
|
-
if ($downloadUrl) {
|
|
883
|
-
// Redirect user to download URL
|
|
884
|
-
wp_redirect($downloadUrl);
|
|
885
|
-
exit;
|
|
886
|
-
}
|
|
887
|
-
```
|
|
888
|
-
|
|
889
|
-
### Listing Files
|
|
890
|
-
|
|
891
|
-
```
|
|
892
|
-
// List files with search
|
|
893
|
-
$files = $fileManager->listFiles([
|
|
894
|
-
'search' => 'product-123',
|
|
895
|
-
'limit' => 50,
|
|
896
|
-
'offset' => 0
|
|
897
|
-
]);
|
|
898
|
-
|
|
899
|
-
foreach ($files as $file) {
|
|
900
|
-
echo "File: " . $file['name'] . " (" . $file['size'] . " bytes)\n";
|
|
901
|
-
}
|
|
902
|
-
```
|
|
903
|
-
|
|
904
|
-
### Deleting Files
|
|
905
|
-
|
|
906
|
-
```
|
|
907
|
-
// Delete a file
|
|
908
|
-
$success = $fileManager->deleteFile('product-123/file.pdf', 'my-bucket');
|
|
909
|
-
|
|
910
|
-
if ($success) {
|
|
911
|
-
echo "File deleted successfully";
|
|
912
|
-
} else {
|
|
913
|
-
echo "Failed to delete file";
|
|
914
|
-
}
|
|
915
|
-
```
|
|
916
|
-
|
|
917
|
-
## Hooks and Filters
|
|
918
|
-
|
|
919
|
-
### Storage Driver Hooks
|
|
920
|
-
|
|
921
|
-
```
|
|
922
|
-
// Modify file upload parameters
|
|
923
|
-
add_filter('fluent_cart/storage/upload_params', function($params, $file, $driver) {
|
|
924
|
-
// Add custom metadata
|
|
925
|
-
$params['custom_metadata'] = [
|
|
926
|
-
'uploaded_by' => get_current_user_id(),
|
|
927
|
-
'upload_time' => current_time('mysql')
|
|
928
|
-
];
|
|
929
|
-
|
|
930
|
-
return $params;
|
|
931
|
-
}, 10, 3);
|
|
932
|
-
|
|
933
|
-
// Modify download URL generation
|
|
934
|
-
add_filter('fluent_cart/storage/download_url', function($url, $filePath, $driver) {
|
|
935
|
-
// Add custom tracking parameters
|
|
936
|
-
$url .= '&tracking_id=' . wp_generate_uuid4();
|
|
937
|
-
|
|
938
|
-
return $url;
|
|
939
|
-
}, 10, 3);
|
|
940
|
-
|
|
941
|
-
// Custom file validation
|
|
942
|
-
add_filter('fluent_cart/storage/validate_file', function($isValid, $file, $driver) {
|
|
943
|
-
// Custom validation logic
|
|
944
|
-
if ($file->getSize() > 100 * 1024 * 1024) { // 100MB limit
|
|
945
|
-
return new \WP_Error('file_too_large', 'File size exceeds 100MB limit');
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
return $isValid;
|
|
949
|
-
}, 10, 3);
|
|
950
|
-
```
|
|
951
|
-
|
|
952
|
-
### Storage Driver Actions
|
|
953
|
-
|
|
954
|
-
```
|
|
955
|
-
// After file upload
|
|
956
|
-
add_action('fluent_cart/storage/file_uploaded', function($filePath, $driver, $result) {
|
|
957
|
-
// Log upload activity
|
|
958
|
-
error_log("File uploaded: {$filePath} using {$driver}");
|
|
959
|
-
|
|
960
|
-
// Send notification
|
|
961
|
-
wp_mail(
|
|
962
|
-
get_option('admin_email'),
|
|
963
|
-
'File Uploaded',
|
|
964
|
-
"A new file has been uploaded: {$filePath}"
|
|
965
|
-
);
|
|
966
|
-
}, 10, 3);
|
|
967
|
-
|
|
968
|
-
// Before file deletion
|
|
969
|
-
add_action('fluent_cart/storage/before_file_delete', function($filePath, $driver) {
|
|
970
|
-
// Create backup before deletion
|
|
971
|
-
$backupPath = 'backups/' . basename($filePath);
|
|
972
|
-
// Backup logic here
|
|
973
|
-
}, 10, 2);
|
|
974
|
-
|
|
975
|
-
// After file deletion
|
|
976
|
-
add_action('fluent_cart/storage/file_deleted', function($filePath, $driver) {
|
|
977
|
-
// Log deletion
|
|
978
|
-
error_log("File deleted: {$filePath} from {$driver}");
|
|
979
|
-
}, 10, 2);
|
|
980
|
-
```
|
|
981
|
-
|
|
982
|
-
---
|
|
983
|
-
|
|
984
|
-
**Next Steps:**
|
|
985
|
-
|
|
986
|
-
- [Modules Overview](./index.md) - Back to modules overview
|
|
1
|
+
# Storage Drivers Module
|
|
2
|
+
|
|
3
|
+
The Storage Drivers module provides a flexible file storage abstraction layer in FluentCart. It allows you to store and manage digital products, files, and media across different storage providers including local storage and cloud services like Amazon S3.
|
|
4
|
+
|
|
5
|
+
## Architecture Overview
|
|
6
|
+
|
|
7
|
+
### Core Components
|
|
8
|
+
|
|
9
|
+
#### 1. **Storage Drivers**
|
|
10
|
+
|
|
11
|
+
Abstract implementations for different storage providers (Local, S3, etc.).
|
|
12
|
+
|
|
13
|
+
#### 2. **File Manager**
|
|
14
|
+
|
|
15
|
+
Central service for managing file operations across different storage drivers.
|
|
16
|
+
|
|
17
|
+
#### 3. **Base Driver**
|
|
18
|
+
|
|
19
|
+
Abstract base class that all storage drivers must extend.
|
|
20
|
+
|
|
21
|
+
#### 4. **Storage Settings**
|
|
22
|
+
|
|
23
|
+
Configuration management for each storage driver.
|
|
24
|
+
|
|
25
|
+
## Built-in Storage Drivers
|
|
26
|
+
|
|
27
|
+
### Local Storage Driver
|
|
28
|
+
|
|
29
|
+
Stores files locally on the server's file system.
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
use FluentCart\App\Modules\StorageDrivers\Local\Local;
|
|
33
|
+
|
|
34
|
+
class Local extends BaseStorageDriver
|
|
35
|
+
{
|
|
36
|
+
public function __construct()
|
|
37
|
+
{
|
|
38
|
+
parent::__construct(
|
|
39
|
+
__('Local', 'fluent-cart'),
|
|
40
|
+
'local',
|
|
41
|
+
'#136196'
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public function getDescription(): string
|
|
46
|
+
{
|
|
47
|
+
return esc_html__('Local allows to upload file in local file storage', 'fluent-cart');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public function getDriverClass(): string
|
|
51
|
+
{
|
|
52
|
+
return LocalDriver::class;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Amazon S3 Driver
|
|
58
|
+
|
|
59
|
+
Stores files in Amazon S3 buckets for scalable cloud storage.
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
use FluentCart\App\Modules\StorageDrivers\S3\S3;
|
|
63
|
+
|
|
64
|
+
class S3 extends BaseStorageDriver
|
|
65
|
+
{
|
|
66
|
+
public function __construct()
|
|
67
|
+
{
|
|
68
|
+
parent::__construct(
|
|
69
|
+
__('S3', 'fluent-cart'),
|
|
70
|
+
's3',
|
|
71
|
+
'#4f94d4'
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public function getDescription()
|
|
76
|
+
{
|
|
77
|
+
return esc_html__('S3 bucket allows to configure storage options and others for efficient and secure cloud-based file storage', 'fluent-cart');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public function getDriverClass(): string
|
|
81
|
+
{
|
|
82
|
+
return S3Driver::class;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Base Storage Driver
|
|
88
|
+
|
|
89
|
+
### BaseStorageDriver Class
|
|
90
|
+
|
|
91
|
+
All storage drivers extend this abstract class:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
abstract class BaseStorageDriver implements BaseStorageInterface
|
|
95
|
+
{
|
|
96
|
+
public $slug;
|
|
97
|
+
public $title;
|
|
98
|
+
public $brandColor = '#ccc';
|
|
99
|
+
protected $driverHandler;
|
|
100
|
+
|
|
101
|
+
public function __construct($title, $slug, $brandColor)
|
|
102
|
+
{
|
|
103
|
+
$this->title = $title;
|
|
104
|
+
$this->slug = $slug;
|
|
105
|
+
$this->brandColor = $brandColor;
|
|
106
|
+
$this->driverHandler = 'fluent_cart_storage_settings_' . $slug;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
abstract public function getLogo();
|
|
110
|
+
abstract public function getDescription();
|
|
111
|
+
abstract public function getSettings();
|
|
112
|
+
abstract public function fields();
|
|
113
|
+
abstract public function hiddenSettingKeys(): array;
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### BaseStorageInterface
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
interface BaseStorageInterface
|
|
121
|
+
{
|
|
122
|
+
public function isEnabled(): bool;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## File Manager
|
|
127
|
+
|
|
128
|
+
### FileManager Class
|
|
129
|
+
|
|
130
|
+
The central service for managing file operations:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
use FluentCart\App\Services\FileSystem\FileManager;
|
|
134
|
+
|
|
135
|
+
class FileManager
|
|
136
|
+
{
|
|
137
|
+
private $driver;
|
|
138
|
+
protected ?string $dirPath;
|
|
139
|
+
protected ?string $dirName;
|
|
140
|
+
|
|
141
|
+
public function __construct(
|
|
142
|
+
string $driver = 'local',
|
|
143
|
+
?string $dirPath = null,
|
|
144
|
+
?string $dirName = null,
|
|
145
|
+
$inActiveMode = false
|
|
146
|
+
) {
|
|
147
|
+
$this->dirName = $dirName;
|
|
148
|
+
$this->dirPath = $dirPath;
|
|
149
|
+
$this->driver = $this->resolveDriver($driver, $inActiveMode);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
public function uploadFile(string $localFilePath, string $uploadToFilePath, $file, array $params = [])
|
|
153
|
+
{
|
|
154
|
+
return $this->driver->uploadFile($localFilePath, $uploadToFilePath, $file, $params);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public function downloadFile(string $filePath, string $fileName, $bucket = null)
|
|
158
|
+
{
|
|
159
|
+
return $this->driver->downloadFile($filePath, $fileName, $bucket);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null): ?string
|
|
163
|
+
{
|
|
164
|
+
return $this->driver->getSignedDownloadUrl($filePath, $bucket, $productDownload);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public function deleteFile(string $filePath, $bucket = null)
|
|
168
|
+
{
|
|
169
|
+
return $this->driver->deleteFile($filePath, $bucket);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
public function listFiles(array $params = [])
|
|
173
|
+
{
|
|
174
|
+
return $this->driver->listFiles($params);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Base Driver Implementation
|
|
180
|
+
|
|
181
|
+
### BaseDriver Class
|
|
182
|
+
|
|
183
|
+
All storage driver implementations extend this class:
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
abstract class BaseDriver
|
|
187
|
+
{
|
|
188
|
+
protected ?string $dirPath;
|
|
189
|
+
protected ?string $dirName;
|
|
190
|
+
protected ?BaseStorageDriver $storageDriver;
|
|
191
|
+
|
|
192
|
+
public function __construct(?string $dirPath = null, ?string $dirName = null)
|
|
193
|
+
{
|
|
194
|
+
$this->dirName = $dirName;
|
|
195
|
+
$this->dirPath = $dirPath;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public abstract function listFiles(array $params = []);
|
|
199
|
+
public abstract function uploadFile($localFilePath, $uploadToFilePath, $file, $params = []);
|
|
200
|
+
public abstract function downloadFile(string $filePath);
|
|
201
|
+
public abstract function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null);
|
|
202
|
+
public abstract function getFilePath(string $filePath);
|
|
203
|
+
public abstract function deleteFile(string $filePath, $bucket = null);
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Local Storage Implementation
|
|
208
|
+
|
|
209
|
+
### LocalDriver Class
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
class LocalDriver extends BaseDriver
|
|
213
|
+
{
|
|
214
|
+
public function __construct(string $dirPath = null, string $dirName = null)
|
|
215
|
+
{
|
|
216
|
+
parent::__construct($dirPath, $dirName);
|
|
217
|
+
$this->dirName = $dirName ?? 'fluent-cart';
|
|
218
|
+
$this->dirPath = $dirPath ?? $this->getDefaultDirPath();
|
|
219
|
+
$this->storageDriver = new LocalStorageDriver();
|
|
220
|
+
$this->ensureDirectoryExist();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
protected function getDefaultDirPath(): string
|
|
224
|
+
{
|
|
225
|
+
return wp_get_upload_dir()['basedir'] . DIRECTORY_SEPARATOR . $this->getDirName();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private function ensureDirectoryExist()
|
|
229
|
+
{
|
|
230
|
+
$uploadDirectory = $this->getDefaultDirPath();
|
|
231
|
+
if (!is_dir($uploadDirectory)) {
|
|
232
|
+
mkdir($uploadDirectory);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public function uploadFile($localFilePath, $uploadToFilePath, $file, $params = [])
|
|
237
|
+
{
|
|
238
|
+
$destinationPath = $this->dirPath . DIRECTORY_SEPARATOR . $uploadToFilePath;
|
|
239
|
+
|
|
240
|
+
// Ensure directory exists
|
|
241
|
+
$destinationDir = dirname($destinationPath);
|
|
242
|
+
if (!is_dir($destinationDir)) {
|
|
243
|
+
mkdir($destinationDir, 0755, true);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (move_uploaded_file($localFilePath, $destinationPath)) {
|
|
247
|
+
return [
|
|
248
|
+
'success' => true,
|
|
249
|
+
'file_path' => $uploadToFilePath,
|
|
250
|
+
'file_url' => $this->getFileUrl($uploadToFilePath)
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return [
|
|
255
|
+
'success' => false,
|
|
256
|
+
'error' => 'Failed to move uploaded file'
|
|
257
|
+
];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
public function downloadFile(string $filePath)
|
|
261
|
+
{
|
|
262
|
+
$fullPath = $this->dirPath . DIRECTORY_SEPARATOR . $filePath;
|
|
263
|
+
|
|
264
|
+
if (!file_exists($fullPath)) {
|
|
265
|
+
return [
|
|
266
|
+
'success' => false,
|
|
267
|
+
'error' => 'File not found'
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
$fileName = basename($filePath);
|
|
272
|
+
$fileSize = filesize($fullPath);
|
|
273
|
+
|
|
274
|
+
$this->setDownloadHeader($fileName, $fullPath, $fileSize);
|
|
275
|
+
|
|
276
|
+
readfile($fullPath);
|
|
277
|
+
exit;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
public function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null): ?string
|
|
281
|
+
{
|
|
282
|
+
// For local storage, return direct file URL
|
|
283
|
+
return $this->getFileUrl($filePath);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
public function getFilePath(string $filePath)
|
|
287
|
+
{
|
|
288
|
+
return $this->dirPath . DIRECTORY_SEPARATOR . $filePath;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
public function deleteFile(string $filePath, $bucket = null)
|
|
292
|
+
{
|
|
293
|
+
$fullPath = $this->dirPath . DIRECTORY_SEPARATOR . $filePath;
|
|
294
|
+
|
|
295
|
+
if (file_exists($fullPath)) {
|
|
296
|
+
return unlink($fullPath);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private function getFileUrl(string $filePath): string
|
|
303
|
+
{
|
|
304
|
+
$uploadDir = wp_get_upload_dir();
|
|
305
|
+
return $uploadDir['baseurl'] . '/' . $this->getDirName() . '/' . $filePath;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## S3 Storage Implementation
|
|
311
|
+
|
|
312
|
+
### S3Driver Class
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
class S3Driver extends BaseDriver
|
|
316
|
+
{
|
|
317
|
+
private string $accessKey;
|
|
318
|
+
private string $secretKey;
|
|
319
|
+
private string $bucket;
|
|
320
|
+
private string $region;
|
|
321
|
+
|
|
322
|
+
public function __construct(string $dirPath = null, string $dirName = null)
|
|
323
|
+
{
|
|
324
|
+
parent::__construct($dirPath, $dirName);
|
|
325
|
+
|
|
326
|
+
$getSettings = (new S3Settings())->get();
|
|
327
|
+
|
|
328
|
+
$this->secretKey = Arr::get($getSettings, 'secret_key', '');
|
|
329
|
+
$this->accessKey = Arr::get($getSettings, 'access_key', '');
|
|
330
|
+
$this->bucket = Arr::get($getSettings, 'bucket', '');
|
|
331
|
+
$this->region = Arr::get($getSettings, 'region', '');
|
|
332
|
+
$this->storageDriver = new S3StorageDriver();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
public function uploadFile($localFilePath, $uploadToFilePath, $file, $params = [])
|
|
336
|
+
{
|
|
337
|
+
$fileSize = $file->toArray()['size_in_bytes'];
|
|
338
|
+
|
|
339
|
+
try {
|
|
340
|
+
$s3Client = new S3Client([
|
|
341
|
+
'version' => 'latest',
|
|
342
|
+
'region' => $this->region,
|
|
343
|
+
'credentials' => [
|
|
344
|
+
'key' => $this->accessKey,
|
|
345
|
+
'secret' => $this->secretKey,
|
|
346
|
+
],
|
|
347
|
+
]);
|
|
348
|
+
|
|
349
|
+
$result = $s3Client->putObject([
|
|
350
|
+
'Bucket' => $this->bucket,
|
|
351
|
+
'Key' => $uploadToFilePath,
|
|
352
|
+
'SourceFile' => $localFilePath,
|
|
353
|
+
'ContentType' => $file->getMimeType(),
|
|
354
|
+
'ACL' => 'private', // Private by default for security
|
|
355
|
+
]);
|
|
356
|
+
|
|
357
|
+
return [
|
|
358
|
+
'success' => true,
|
|
359
|
+
'file_path' => $uploadToFilePath,
|
|
360
|
+
'file_url' => $result['ObjectURL']
|
|
361
|
+
];
|
|
362
|
+
|
|
363
|
+
} catch (Exception $e) {
|
|
364
|
+
return [
|
|
365
|
+
'success' => false,
|
|
366
|
+
'error' => $e->getMessage()
|
|
367
|
+
];
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
public function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null): ?string
|
|
372
|
+
{
|
|
373
|
+
try {
|
|
374
|
+
$s3Client = new S3Client([
|
|
375
|
+
'version' => 'latest',
|
|
376
|
+
'region' => $this->region,
|
|
377
|
+
'credentials' => [
|
|
378
|
+
'key' => $this->accessKey,
|
|
379
|
+
'secret' => $this->secretKey,
|
|
380
|
+
],
|
|
381
|
+
]);
|
|
382
|
+
|
|
383
|
+
$bucket = $bucket ?? $this->bucket;
|
|
384
|
+
$expiration = '+1 hour'; // Default expiration
|
|
385
|
+
|
|
386
|
+
// Custom expiration for product downloads
|
|
387
|
+
if ($productDownload) {
|
|
388
|
+
$expiration = '+24 hours'; // Longer expiration for product downloads
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
$cmd = $s3Client->getCommand('GetObject', [
|
|
392
|
+
'Bucket' => $bucket,
|
|
393
|
+
'Key' => $filePath,
|
|
394
|
+
]);
|
|
395
|
+
|
|
396
|
+
$request = $s3Client->createPresignedRequest($cmd, $expiration);
|
|
397
|
+
|
|
398
|
+
return (string) $request->getUri();
|
|
399
|
+
|
|
400
|
+
} catch (Exception $e) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
public function deleteFile(string $filePath, $bucket = null)
|
|
406
|
+
{
|
|
407
|
+
try {
|
|
408
|
+
$s3Client = new S3Client([
|
|
409
|
+
'version' => 'latest',
|
|
410
|
+
'region' => $this->region,
|
|
411
|
+
'credentials' => [
|
|
412
|
+
'key' => $this->accessKey,
|
|
413
|
+
'secret' => $this->secretKey,
|
|
414
|
+
],
|
|
415
|
+
]);
|
|
416
|
+
|
|
417
|
+
$bucket = $bucket ?? $this->bucket;
|
|
418
|
+
|
|
419
|
+
$result = $s3Client->deleteObject([
|
|
420
|
+
'Bucket' => $bucket,
|
|
421
|
+
'Key' => $filePath,
|
|
422
|
+
]);
|
|
423
|
+
|
|
424
|
+
return true;
|
|
425
|
+
|
|
426
|
+
} catch (Exception $e) {
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
public function buckets()
|
|
432
|
+
{
|
|
433
|
+
return S3BucketList::get(
|
|
434
|
+
$this->secretKey,
|
|
435
|
+
$this->accessKey,
|
|
436
|
+
$this->region
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
## Storage Settings
|
|
443
|
+
|
|
444
|
+
### BaseStorageSettings Class
|
|
445
|
+
|
|
446
|
+
```
|
|
447
|
+
abstract class BaseStorageSettings
|
|
448
|
+
{
|
|
449
|
+
protected $settings;
|
|
450
|
+
protected $driverHandler = 'fluent_cart_storage_settings_';
|
|
451
|
+
|
|
452
|
+
public function __construct($slug)
|
|
453
|
+
{
|
|
454
|
+
$settings = fluent_cart_get_option($this->driverHandler.$slug, []);
|
|
455
|
+
$this->settings = wp_parse_args($settings, $this->getDefaultSettings());
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
abstract protected function getDefaultSettings();
|
|
459
|
+
abstract public function isActive();
|
|
460
|
+
|
|
461
|
+
public function get()
|
|
462
|
+
{
|
|
463
|
+
return $this->settings;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Local Storage Settings
|
|
469
|
+
|
|
470
|
+
```
|
|
471
|
+
class LocalSettings extends BaseStorageSettings
|
|
472
|
+
{
|
|
473
|
+
protected function getDefaultSettings()
|
|
474
|
+
{
|
|
475
|
+
return [
|
|
476
|
+
'is_active' => 'no'
|
|
477
|
+
];
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
public function isActive()
|
|
481
|
+
{
|
|
482
|
+
return $this->settings['is_active'] === 'yes';
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### S3 Storage Settings
|
|
488
|
+
|
|
489
|
+
```
|
|
490
|
+
class S3Settings extends BaseStorageSettings
|
|
491
|
+
{
|
|
492
|
+
protected function getDefaultSettings()
|
|
493
|
+
{
|
|
494
|
+
return [
|
|
495
|
+
'is_active' => 'no',
|
|
496
|
+
'access_key' => '',
|
|
497
|
+
'secret_key' => '',
|
|
498
|
+
'bucket' => '',
|
|
499
|
+
'region' => 'us-east-1',
|
|
500
|
+
'buckets' => []
|
|
501
|
+
];
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
public function isActive()
|
|
505
|
+
{
|
|
506
|
+
$isActive = $this->settings['is_active'] === 'yes';
|
|
507
|
+
$hasSelectedBuckets = !empty($this->settings['buckets']) &&
|
|
508
|
+
is_array($this->settings['buckets']) &&
|
|
509
|
+
count($this->settings['buckets']) > 0;
|
|
510
|
+
|
|
511
|
+
return $isActive && $hasSelectedBuckets;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
## Creating Custom Storage Drivers
|
|
517
|
+
|
|
518
|
+
### 1. Create Storage Driver Class
|
|
519
|
+
|
|
520
|
+
```
|
|
521
|
+
<?php
|
|
522
|
+
namespace FluentCart\App\Modules\StorageDrivers\CustomDriver;
|
|
523
|
+
|
|
524
|
+
use FluentCart\App\Modules\StorageDrivers\BaseStorageDriver;
|
|
525
|
+
use FluentCart\App\Vite;
|
|
526
|
+
|
|
527
|
+
class CustomDriver extends BaseStorageDriver
|
|
528
|
+
{
|
|
529
|
+
public function __construct()
|
|
530
|
+
{
|
|
531
|
+
parent::__construct(
|
|
532
|
+
__('Custom Storage', 'fluent-cart'),
|
|
533
|
+
'custom_driver',
|
|
534
|
+
'#your-brand-color'
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
public function getLogo(): string
|
|
539
|
+
{
|
|
540
|
+
return Vite::getAssetUrl("images/storage-drivers/custom-logo.svg");
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
public function getDescription(): string
|
|
544
|
+
{
|
|
545
|
+
return esc_html__('Custom storage driver for your specific needs', 'fluent-cart');
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
public function isEnabled(): bool
|
|
549
|
+
{
|
|
550
|
+
return (new CustomDriverSettings())->isActive();
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
public function getSettings()
|
|
554
|
+
{
|
|
555
|
+
return (new CustomDriverSettings())->get();
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
public function fields(): array
|
|
559
|
+
{
|
|
560
|
+
return [
|
|
561
|
+
'view' => [
|
|
562
|
+
'title' => __('Custom Driver Settings', 'fluent-cart'),
|
|
563
|
+
'type' => 'section',
|
|
564
|
+
'disable_nesting' => true,
|
|
565
|
+
'columns' => [
|
|
566
|
+
'default' => 1,
|
|
567
|
+
'md' => 1,
|
|
568
|
+
'lg' => 1
|
|
569
|
+
],
|
|
570
|
+
'schema' => [
|
|
571
|
+
'is_active' => [
|
|
572
|
+
'value' => '',
|
|
573
|
+
'label' => __('Enable custom driver', 'fluent-cart'),
|
|
574
|
+
'type' => 'checkbox'
|
|
575
|
+
],
|
|
576
|
+
'api_key' => [
|
|
577
|
+
'value' => '',
|
|
578
|
+
'label' => __('API Key', 'fluent-cart'),
|
|
579
|
+
'type' => 'text',
|
|
580
|
+
'required' => true
|
|
581
|
+
],
|
|
582
|
+
'endpoint' => [
|
|
583
|
+
'value' => '',
|
|
584
|
+
'label' => __('Endpoint URL', 'fluent-cart'),
|
|
585
|
+
'type' => 'text',
|
|
586
|
+
'required' => true
|
|
587
|
+
]
|
|
588
|
+
]
|
|
589
|
+
]
|
|
590
|
+
];
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
public function getDriverClass(): string
|
|
594
|
+
{
|
|
595
|
+
return CustomDriverImplementation::class;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
public function hiddenSettingKeys(): array
|
|
599
|
+
{
|
|
600
|
+
return ['api_key', 'secret_key'];
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
public function verifyConnectInfo(array $data, $args = [])
|
|
604
|
+
{
|
|
605
|
+
// Implement connection verification logic
|
|
606
|
+
$apiKey = $data['api_key'] ?? '';
|
|
607
|
+
$endpoint = $data['endpoint'] ?? '';
|
|
608
|
+
|
|
609
|
+
if (empty($apiKey) || empty($endpoint)) {
|
|
610
|
+
return new \WP_Error('missing_credentials', 'API Key and Endpoint are required');
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// Test connection
|
|
614
|
+
$response = wp_remote_get($endpoint . '/test', [
|
|
615
|
+
'headers' => [
|
|
616
|
+
'Authorization' => 'Bearer ' . $apiKey
|
|
617
|
+
],
|
|
618
|
+
'timeout' => 10
|
|
619
|
+
]);
|
|
620
|
+
|
|
621
|
+
if (is_wp_error($response)) {
|
|
622
|
+
return new \WP_Error('connection_failed', 'Failed to connect to custom storage service');
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
return true;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
### 2. Create Driver Implementation
|
|
631
|
+
|
|
632
|
+
```
|
|
633
|
+
<?php
|
|
634
|
+
namespace FluentCart\App\Services\FileSystem\Drivers\CustomDriver;
|
|
635
|
+
|
|
636
|
+
use FluentCart\App\Services\FileSystem\Drivers\BaseDriver;
|
|
637
|
+
use FluentCart\App\Modules\StorageDrivers\CustomDriver\CustomDriver as CustomStorageDriver;
|
|
638
|
+
|
|
639
|
+
class CustomDriverImplementation extends BaseDriver
|
|
640
|
+
{
|
|
641
|
+
private string $apiKey;
|
|
642
|
+
private string $endpoint;
|
|
643
|
+
|
|
644
|
+
public function __construct(string $dirPath = null, string $dirName = null)
|
|
645
|
+
{
|
|
646
|
+
parent::__construct($dirPath, $dirName);
|
|
647
|
+
|
|
648
|
+
$settings = (new CustomDriverSettings())->get();
|
|
649
|
+
$this->apiKey = $settings['api_key'] ?? '';
|
|
650
|
+
$this->endpoint = $settings['endpoint'] ?? '';
|
|
651
|
+
$this->storageDriver = new CustomStorageDriver();
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
public function uploadFile($localFilePath, $uploadToFilePath, $file, $params = [])
|
|
655
|
+
{
|
|
656
|
+
try {
|
|
657
|
+
$response = wp_remote_post($this->endpoint . '/upload', [
|
|
658
|
+
'headers' => [
|
|
659
|
+
'Authorization' => 'Bearer ' . $this->apiKey,
|
|
660
|
+
'Content-Type' => 'multipart/form-data'
|
|
661
|
+
],
|
|
662
|
+
'body' => [
|
|
663
|
+
'file' => new \CURLFile($localFilePath),
|
|
664
|
+
'path' => $uploadToFilePath,
|
|
665
|
+
'metadata' => json_encode([
|
|
666
|
+
'size' => filesize($localFilePath),
|
|
667
|
+
'type' => mime_content_type($localFilePath)
|
|
668
|
+
])
|
|
669
|
+
],
|
|
670
|
+
'timeout' => 60
|
|
671
|
+
]);
|
|
672
|
+
|
|
673
|
+
if (is_wp_error($response)) {
|
|
674
|
+
return [
|
|
675
|
+
'success' => false,
|
|
676
|
+
'error' => $response->get_error_message()
|
|
677
|
+
];
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
$body = wp_remote_retrieve_body($response);
|
|
681
|
+
$data = json_decode($body, true);
|
|
682
|
+
|
|
683
|
+
if ($data['success']) {
|
|
684
|
+
return [
|
|
685
|
+
'success' => true,
|
|
686
|
+
'file_path' => $uploadToFilePath,
|
|
687
|
+
'file_url' => $data['file_url']
|
|
688
|
+
];
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
return [
|
|
692
|
+
'success' => false,
|
|
693
|
+
'error' => $data['error'] ?? 'Upload failed'
|
|
694
|
+
];
|
|
695
|
+
|
|
696
|
+
} catch (Exception $e) {
|
|
697
|
+
return [
|
|
698
|
+
'success' => false,
|
|
699
|
+
'error' => $e->getMessage()
|
|
700
|
+
];
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
public function getSignedDownloadUrl(string $filePath, $bucket = null, $productDownload = null): ?string
|
|
705
|
+
{
|
|
706
|
+
try {
|
|
707
|
+
$response = wp_remote_post($this->endpoint . '/generate-url', [
|
|
708
|
+
'headers' => [
|
|
709
|
+
'Authorization' => 'Bearer ' . $this->apiKey,
|
|
710
|
+
'Content-Type' => 'application/json'
|
|
711
|
+
],
|
|
712
|
+
'body' => json_encode([
|
|
713
|
+
'file_path' => $filePath,
|
|
714
|
+
'expires_in' => $productDownload ? 86400 : 3600 // 24h for products, 1h for others
|
|
715
|
+
]),
|
|
716
|
+
'timeout' => 30
|
|
717
|
+
]);
|
|
718
|
+
|
|
719
|
+
if (is_wp_error($response)) {
|
|
720
|
+
return null;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
$body = wp_remote_retrieve_body($response);
|
|
724
|
+
$data = json_decode($body, true);
|
|
725
|
+
|
|
726
|
+
return $data['download_url'] ?? null;
|
|
727
|
+
|
|
728
|
+
} catch (Exception $e) {
|
|
729
|
+
return null;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
public function deleteFile(string $filePath, $bucket = null)
|
|
734
|
+
{
|
|
735
|
+
try {
|
|
736
|
+
$response = wp_remote_request($this->endpoint . '/delete', [
|
|
737
|
+
'method' => 'DELETE',
|
|
738
|
+
'headers' => [
|
|
739
|
+
'Authorization' => 'Bearer ' . $this->apiKey,
|
|
740
|
+
'Content-Type' => 'application/json'
|
|
741
|
+
],
|
|
742
|
+
'body' => json_encode([
|
|
743
|
+
'file_path' => $filePath
|
|
744
|
+
]),
|
|
745
|
+
'timeout' => 30
|
|
746
|
+
]);
|
|
747
|
+
|
|
748
|
+
if (is_wp_error($response)) {
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
$body = wp_remote_retrieve_body($response);
|
|
753
|
+
$data = json_decode($body, true);
|
|
754
|
+
|
|
755
|
+
return $data['success'] ?? false;
|
|
756
|
+
|
|
757
|
+
} catch (Exception $e) {
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
public function listFiles(array $params = [])
|
|
763
|
+
{
|
|
764
|
+
try {
|
|
765
|
+
$response = wp_remote_get($this->endpoint . '/files', [
|
|
766
|
+
'headers' => [
|
|
767
|
+
'Authorization' => 'Bearer ' . $this->apiKey
|
|
768
|
+
],
|
|
769
|
+
'body' => $params,
|
|
770
|
+
'timeout' => 30
|
|
771
|
+
]);
|
|
772
|
+
|
|
773
|
+
if (is_wp_error($response)) {
|
|
774
|
+
return [];
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
$body = wp_remote_retrieve_body($response);
|
|
778
|
+
$data = json_decode($body, true);
|
|
779
|
+
|
|
780
|
+
return $data['files'] ?? [];
|
|
781
|
+
|
|
782
|
+
} catch (Exception $e) {
|
|
783
|
+
return [];
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
public function downloadFile(string $filePath)
|
|
788
|
+
{
|
|
789
|
+
$downloadUrl = $this->getSignedDownloadUrl($filePath);
|
|
790
|
+
|
|
791
|
+
if (!$downloadUrl) {
|
|
792
|
+
return [
|
|
793
|
+
'success' => false,
|
|
794
|
+
'error' => 'Failed to generate download URL'
|
|
795
|
+
];
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// Redirect to download URL
|
|
799
|
+
wp_redirect($downloadUrl);
|
|
800
|
+
exit;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
public function getFilePath(string $filePath)
|
|
804
|
+
{
|
|
805
|
+
return $this->endpoint . '/files/' . $filePath;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
### 3. Create Settings Class
|
|
811
|
+
|
|
812
|
+
```
|
|
813
|
+
<?php
|
|
814
|
+
namespace FluentCart\App\Modules\StorageDrivers\CustomDriver;
|
|
815
|
+
|
|
816
|
+
use FluentCart\App\Modules\StorageDrivers\BaseStorageSettings;
|
|
817
|
+
|
|
818
|
+
class CustomDriverSettings extends BaseStorageSettings
|
|
819
|
+
{
|
|
820
|
+
protected function getDefaultSettings()
|
|
821
|
+
{
|
|
822
|
+
return [
|
|
823
|
+
'is_active' => 'no',
|
|
824
|
+
'api_key' => '',
|
|
825
|
+
'endpoint' => ''
|
|
826
|
+
];
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
public function isActive()
|
|
830
|
+
{
|
|
831
|
+
return $this->settings['is_active'] === 'yes';
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
```
|
|
835
|
+
|
|
836
|
+
### 4. Register Custom Driver
|
|
837
|
+
|
|
838
|
+
```
|
|
839
|
+
// In your plugin's initialization
|
|
840
|
+
add_action('fluentcart_loaded', function($app) {
|
|
841
|
+
// Register custom storage driver
|
|
842
|
+
$customDriver = new \FluentCart\App\Modules\StorageDrivers\CustomDriver\CustomDriver();
|
|
843
|
+
$customDriver->init();
|
|
844
|
+
});
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
## File Operations
|
|
848
|
+
|
|
849
|
+
### Uploading Files
|
|
850
|
+
|
|
851
|
+
```
|
|
852
|
+
use FluentCart\App\Services\FileSystem\FileManager;
|
|
853
|
+
|
|
854
|
+
// Initialize file manager with specific driver
|
|
855
|
+
$fileManager = new FileManager('s3', 'products', 'digital-files');
|
|
856
|
+
|
|
857
|
+
// Upload a file
|
|
858
|
+
$result = $fileManager->uploadFile(
|
|
859
|
+
$localFilePath, // Local file path
|
|
860
|
+
'product-123/file.pdf', // Remote file path
|
|
861
|
+
$uploadedFile, // File object
|
|
862
|
+
['metadata' => 'value'] // Additional parameters
|
|
863
|
+
);
|
|
864
|
+
|
|
865
|
+
if ($result['success']) {
|
|
866
|
+
echo "File uploaded successfully: " . $result['file_url'];
|
|
867
|
+
} else {
|
|
868
|
+
echo "Upload failed: " . $result['error'];
|
|
869
|
+
}
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
### Downloading Files
|
|
873
|
+
|
|
874
|
+
```
|
|
875
|
+
// Generate signed download URL
|
|
876
|
+
$downloadUrl = $fileManager->getSignedDownloadUrl(
|
|
877
|
+
'product-123/file.pdf',
|
|
878
|
+
'my-bucket',
|
|
879
|
+
$productDownload // Optional: product download object
|
|
880
|
+
);
|
|
881
|
+
|
|
882
|
+
if ($downloadUrl) {
|
|
883
|
+
// Redirect user to download URL
|
|
884
|
+
wp_redirect($downloadUrl);
|
|
885
|
+
exit;
|
|
886
|
+
}
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
### Listing Files
|
|
890
|
+
|
|
891
|
+
```
|
|
892
|
+
// List files with search
|
|
893
|
+
$files = $fileManager->listFiles([
|
|
894
|
+
'search' => 'product-123',
|
|
895
|
+
'limit' => 50,
|
|
896
|
+
'offset' => 0
|
|
897
|
+
]);
|
|
898
|
+
|
|
899
|
+
foreach ($files as $file) {
|
|
900
|
+
echo "File: " . $file['name'] . " (" . $file['size'] . " bytes)\n";
|
|
901
|
+
}
|
|
902
|
+
```
|
|
903
|
+
|
|
904
|
+
### Deleting Files
|
|
905
|
+
|
|
906
|
+
```
|
|
907
|
+
// Delete a file
|
|
908
|
+
$success = $fileManager->deleteFile('product-123/file.pdf', 'my-bucket');
|
|
909
|
+
|
|
910
|
+
if ($success) {
|
|
911
|
+
echo "File deleted successfully";
|
|
912
|
+
} else {
|
|
913
|
+
echo "Failed to delete file";
|
|
914
|
+
}
|
|
915
|
+
```
|
|
916
|
+
|
|
917
|
+
## Hooks and Filters
|
|
918
|
+
|
|
919
|
+
### Storage Driver Hooks
|
|
920
|
+
|
|
921
|
+
```
|
|
922
|
+
// Modify file upload parameters
|
|
923
|
+
add_filter('fluent_cart/storage/upload_params', function($params, $file, $driver) {
|
|
924
|
+
// Add custom metadata
|
|
925
|
+
$params['custom_metadata'] = [
|
|
926
|
+
'uploaded_by' => get_current_user_id(),
|
|
927
|
+
'upload_time' => current_time('mysql')
|
|
928
|
+
];
|
|
929
|
+
|
|
930
|
+
return $params;
|
|
931
|
+
}, 10, 3);
|
|
932
|
+
|
|
933
|
+
// Modify download URL generation
|
|
934
|
+
add_filter('fluent_cart/storage/download_url', function($url, $filePath, $driver) {
|
|
935
|
+
// Add custom tracking parameters
|
|
936
|
+
$url .= '&tracking_id=' . wp_generate_uuid4();
|
|
937
|
+
|
|
938
|
+
return $url;
|
|
939
|
+
}, 10, 3);
|
|
940
|
+
|
|
941
|
+
// Custom file validation
|
|
942
|
+
add_filter('fluent_cart/storage/validate_file', function($isValid, $file, $driver) {
|
|
943
|
+
// Custom validation logic
|
|
944
|
+
if ($file->getSize() > 100 * 1024 * 1024) { // 100MB limit
|
|
945
|
+
return new \WP_Error('file_too_large', 'File size exceeds 100MB limit');
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
return $isValid;
|
|
949
|
+
}, 10, 3);
|
|
950
|
+
```
|
|
951
|
+
|
|
952
|
+
### Storage Driver Actions
|
|
953
|
+
|
|
954
|
+
```
|
|
955
|
+
// After file upload
|
|
956
|
+
add_action('fluent_cart/storage/file_uploaded', function($filePath, $driver, $result) {
|
|
957
|
+
// Log upload activity
|
|
958
|
+
error_log("File uploaded: {$filePath} using {$driver}");
|
|
959
|
+
|
|
960
|
+
// Send notification
|
|
961
|
+
wp_mail(
|
|
962
|
+
get_option('admin_email'),
|
|
963
|
+
'File Uploaded',
|
|
964
|
+
"A new file has been uploaded: {$filePath}"
|
|
965
|
+
);
|
|
966
|
+
}, 10, 3);
|
|
967
|
+
|
|
968
|
+
// Before file deletion
|
|
969
|
+
add_action('fluent_cart/storage/before_file_delete', function($filePath, $driver) {
|
|
970
|
+
// Create backup before deletion
|
|
971
|
+
$backupPath = 'backups/' . basename($filePath);
|
|
972
|
+
// Backup logic here
|
|
973
|
+
}, 10, 2);
|
|
974
|
+
|
|
975
|
+
// After file deletion
|
|
976
|
+
add_action('fluent_cart/storage/file_deleted', function($filePath, $driver) {
|
|
977
|
+
// Log deletion
|
|
978
|
+
error_log("File deleted: {$filePath} from {$driver}");
|
|
979
|
+
}, 10, 2);
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
---
|
|
983
|
+
|
|
984
|
+
**Next Steps:**
|
|
985
|
+
|
|
986
|
+
- [Modules Overview](./index.md) - Back to modules overview
|