fluentcart-developer 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (609) hide show
  1. package/LICENSE.md +26 -26
  2. package/README.md +59 -59
  3. package/dist/cards/fluentcart/templates-native.js +1087 -1087
  4. package/dist/cards/fluentcart/tools.js +2309 -2309
  5. package/dist/skills/fluentcart-developer/SKILL.md +108 -108
  6. package/dist/skills/fluentcart-developer/examples/README.md +30 -30
  7. package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/fluent-cart/checkout.php +32 -32
  8. package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/functions.php +40 -40
  9. package/dist/skills/fluentcart-developer/examples/sample-custom-addon/fluentcart-custom-addon.php +113 -113
  10. package/dist/skills/fluentcart-developer/examples/sample-custom-payment-gateway/fluentcart-custom-gateway-example.php +148 -148
  11. package/dist/skills/fluentcart-developer/examples/sample-fee-surcharge-plugin/fluentcart-fee-surcharge.php +38 -38
  12. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/README.md +22 -22
  13. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/sample-plugin-with-licensing-sdk.php +79 -79
  14. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/FluentLicensing.php +303 -303
  15. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/LicenseSettings.php +566 -566
  16. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/PluginUpdater.php +304 -304
  17. package/dist/skills/fluentcart-developer/examples/sample-shipping-carrier/fluentcart-custom-shipping-carrier.php +61 -61
  18. package/dist/skills/fluentcart-developer/references/api/authentication.md +452 -452
  19. package/dist/skills/fluentcart-developer/references/api/coupons.md +786 -786
  20. package/dist/skills/fluentcart-developer/references/api/customers.md +889 -889
  21. package/dist/skills/fluentcart-developer/references/api/files.md +609 -609
  22. package/dist/skills/fluentcart-developer/references/api/index.md +432 -432
  23. package/dist/skills/fluentcart-developer/references/api/licensing.md +633 -633
  24. package/dist/skills/fluentcart-developer/references/api/order-bump.md +384 -384
  25. package/dist/skills/fluentcart-developer/references/api/orders.md +814 -814
  26. package/dist/skills/fluentcart-developer/references/api/products.md +866 -866
  27. package/dist/skills/fluentcart-developer/references/api/roles-permissions.md +536 -536
  28. package/dist/skills/fluentcart-developer/references/api/subscriptions.md +827 -827
  29. package/dist/skills/fluentcart-developer/references/database/index.md +44 -44
  30. package/dist/skills/fluentcart-developer/references/database/models/activity.md +178 -178
  31. package/dist/skills/fluentcart-developer/references/database/models/applied-coupon.md +291 -291
  32. package/dist/skills/fluentcart-developer/references/database/models/attribute-group.md +239 -239
  33. package/dist/skills/fluentcart-developer/references/database/models/attribute-relation.md +181 -181
  34. package/dist/skills/fluentcart-developer/references/database/models/attribute-term.md +219 -219
  35. package/dist/skills/fluentcart-developer/references/database/models/cart.md +645 -645
  36. package/dist/skills/fluentcart-developer/references/database/models/coupon.md +427 -427
  37. package/dist/skills/fluentcart-developer/references/database/models/customer-addresses.md +348 -348
  38. package/dist/skills/fluentcart-developer/references/database/models/customer-meta.md +156 -156
  39. package/dist/skills/fluentcart-developer/references/database/models/customer.md +584 -584
  40. package/dist/skills/fluentcart-developer/references/database/models/dynamic-model.md +163 -163
  41. package/dist/skills/fluentcart-developer/references/database/models/label-relationship.md +155 -155
  42. package/dist/skills/fluentcart-developer/references/database/models/label.md +153 -153
  43. package/dist/skills/fluentcart-developer/references/database/models/license-activation.md +182 -182
  44. package/dist/skills/fluentcart-developer/references/database/models/license-meta.md +163 -163
  45. package/dist/skills/fluentcart-developer/references/database/models/license-site.md +208 -208
  46. package/dist/skills/fluentcart-developer/references/database/models/license.md +640 -640
  47. package/dist/skills/fluentcart-developer/references/database/models/meta.md +233 -233
  48. package/dist/skills/fluentcart-developer/references/database/models/order-address.md +391 -391
  49. package/dist/skills/fluentcart-developer/references/database/models/order-download-permission.md +144 -144
  50. package/dist/skills/fluentcart-developer/references/database/models/order-item.md +383 -383
  51. package/dist/skills/fluentcart-developer/references/database/models/order-meta.md +303 -303
  52. package/dist/skills/fluentcart-developer/references/database/models/order-operation.md +158 -158
  53. package/dist/skills/fluentcart-developer/references/database/models/order-promotion-stat.md +175 -175
  54. package/dist/skills/fluentcart-developer/references/database/models/order-promotion.md +250 -250
  55. package/dist/skills/fluentcart-developer/references/database/models/order-tax-rate.md +172 -172
  56. package/dist/skills/fluentcart-developer/references/database/models/order-transaction.md +440 -440
  57. package/dist/skills/fluentcart-developer/references/database/models/order.md +727 -727
  58. package/dist/skills/fluentcart-developer/references/database/models/product-detail.md +397 -397
  59. package/dist/skills/fluentcart-developer/references/database/models/product-download.md +258 -258
  60. package/dist/skills/fluentcart-developer/references/database/models/product-meta.md +153 -153
  61. package/dist/skills/fluentcart-developer/references/database/models/product-variation.md +556 -556
  62. package/dist/skills/fluentcart-developer/references/database/models/product.md +580 -580
  63. package/dist/skills/fluentcart-developer/references/database/models/relationships.md +427 -427
  64. package/dist/skills/fluentcart-developer/references/database/models/scheduled-action.md +175 -175
  65. package/dist/skills/fluentcart-developer/references/database/models/shipping-class.md +148 -148
  66. package/dist/skills/fluentcart-developer/references/database/models/shipping-method.md +280 -280
  67. package/dist/skills/fluentcart-developer/references/database/models/shipping-zone.md +205 -205
  68. package/dist/skills/fluentcart-developer/references/database/models/subscription-meta.md +173 -173
  69. package/dist/skills/fluentcart-developer/references/database/models/subscription.md +528 -528
  70. package/dist/skills/fluentcart-developer/references/database/models/tax-class.md +195 -195
  71. package/dist/skills/fluentcart-developer/references/database/models/tax-rate.md +225 -225
  72. package/dist/skills/fluentcart-developer/references/database/models/user-meta.md +166 -166
  73. package/dist/skills/fluentcart-developer/references/database/models/user.md +220 -220
  74. package/dist/skills/fluentcart-developer/references/database/models.md +404 -404
  75. package/dist/skills/fluentcart-developer/references/database/query-builder.md +860 -860
  76. package/dist/skills/fluentcart-developer/references/database/readme.md +276 -276
  77. package/dist/skills/fluentcart-developer/references/database/schema.md +1002 -1002
  78. package/dist/skills/fluentcart-developer/references/engineering/adding-custom-pages-to-the-customer-dashboard.md +395 -395
  79. package/dist/skills/fluentcart-developer/references/engineering/index.md +4 -4
  80. package/dist/skills/fluentcart-developer/references/engineering.md +4 -4
  81. package/dist/skills/fluentcart-developer/references/getting-started.md +249 -249
  82. package/dist/skills/fluentcart-developer/references/guides/frontend.md +519 -519
  83. package/dist/skills/fluentcart-developer/references/guides/index.md +107 -107
  84. package/dist/skills/fluentcart-developer/references/guides/integrations.md +600 -600
  85. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/index.md +237 -237
  86. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/labels-and-tracking.md +481 -481
  87. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/live-rates.md +269 -269
  88. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/reference.md +223 -223
  89. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/settings.md +370 -370
  90. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier.md +237 -237
  91. package/dist/skills/fluentcart-developer/references/guides/subscriptions.md +217 -217
  92. package/dist/skills/fluentcart-developer/references/hooks/actions/admin-and-templates.md +1079 -1079
  93. package/dist/skills/fluentcart-developer/references/hooks/actions/cart-and-checkout.md +1795 -1795
  94. package/dist/skills/fluentcart-developer/references/hooks/actions/customers-and-users.md +327 -327
  95. package/dist/skills/fluentcart-developer/references/hooks/actions/licenses.md +829 -829
  96. package/dist/skills/fluentcart-developer/references/hooks/actions/modules.md +81 -81
  97. package/dist/skills/fluentcart-developer/references/hooks/actions/orders.md +757 -757
  98. package/dist/skills/fluentcart-developer/references/hooks/actions/payments-and-integrations.md +1163 -1163
  99. package/dist/skills/fluentcart-developer/references/hooks/actions/pro-modules.md +219 -219
  100. package/dist/skills/fluentcart-developer/references/hooks/actions/products-and-coupons.md +1019 -1019
  101. package/dist/skills/fluentcart-developer/references/hooks/actions/subscriptions.md +1290 -1290
  102. package/dist/skills/fluentcart-developer/references/hooks/actions.md +16 -16
  103. package/dist/skills/fluentcart-developer/references/hooks/deprecated.md +60 -60
  104. package/dist/skills/fluentcart-developer/references/hooks/filters/cart-and-checkout.md +2032 -2032
  105. package/dist/skills/fluentcart-developer/references/hooks/filters/customers-and-subscriptions.md +1746 -1746
  106. package/dist/skills/fluentcart-developer/references/hooks/filters/integrations-and-advanced.md +2439 -2439
  107. package/dist/skills/fluentcart-developer/references/hooks/filters/modules.md +464 -464
  108. package/dist/skills/fluentcart-developer/references/hooks/filters/orders-and-payments.md +2658 -2658
  109. package/dist/skills/fluentcart-developer/references/hooks/filters/pro-modules.md +502 -502
  110. package/dist/skills/fluentcart-developer/references/hooks/filters/products-and-pricing.md +1785 -1785
  111. package/dist/skills/fluentcart-developer/references/hooks/filters/settings-and-configuration.md +2966 -2966
  112. package/dist/skills/fluentcart-developer/references/hooks/filters.md +14 -14
  113. package/dist/skills/fluentcart-developer/references/hooks/index.md +35 -35
  114. package/dist/skills/fluentcart-developer/references/index.md +625 -625
  115. package/dist/skills/fluentcart-developer/references/modules/fee-system.md +427 -427
  116. package/dist/skills/fluentcart-developer/references/modules/ghost-product-selling.md +440 -440
  117. package/dist/skills/fluentcart-developer/references/modules/index.md +484 -484
  118. package/dist/skills/fluentcart-developer/references/modules/licensing.md +342 -342
  119. package/dist/skills/fluentcart-developer/references/modules/order-bump.md +433 -433
  120. package/dist/skills/fluentcart-developer/references/modules/payment-methods.md +129 -129
  121. package/dist/skills/fluentcart-developer/references/modules/refunds.md +170 -170
  122. package/dist/skills/fluentcart-developer/references/modules/shipping.md +846 -846
  123. package/dist/skills/fluentcart-developer/references/modules/storage.md +986 -986
  124. package/dist/skills/fluentcart-developer/references/modules/subscription-vendor-ids.md +186 -186
  125. package/dist/skills/fluentcart-developer/references/modules/subscriptions.md +678 -678
  126. package/dist/skills/fluentcart-developer/references/payment-methods-integration/index.md +164 -164
  127. package/dist/skills/fluentcart-developer/references/payment-methods-integration/paddle-example.md +1648 -1648
  128. package/dist/skills/fluentcart-developer/references/payment-methods-integration/payment/setting/fields.md +353 -353
  129. package/dist/skills/fluentcart-developer/references/payment-methods-integration/quick-implementation.md +1079 -1079
  130. package/dist/skills/fluentcart-developer/references/payment-methods-integration.md +164 -164
  131. package/dist/skills/fluentcart-developer/references/restapi/checkout.md +573 -573
  132. package/dist/skills/fluentcart-developer/references/restapi/coupons.md +958 -958
  133. package/dist/skills/fluentcart-developer/references/restapi/customer-profile.md +1423 -1423
  134. package/dist/skills/fluentcart-developer/references/restapi/customers.md +1103 -1103
  135. package/dist/skills/fluentcart-developer/references/restapi/dashboard.md +1083 -1083
  136. package/dist/skills/fluentcart-developer/references/restapi/data-export.md +132 -132
  137. package/dist/skills/fluentcart-developer/references/restapi/email-notifications.md +846 -846
  138. package/dist/skills/fluentcart-developer/references/restapi/files.md +313 -313
  139. package/dist/skills/fluentcart-developer/references/restapi/index.md +127 -127
  140. package/dist/skills/fluentcart-developer/references/restapi/integrations.md +1000 -1000
  141. package/dist/skills/fluentcart-developer/references/restapi/inventory.md +192 -192
  142. package/dist/skills/fluentcart-developer/references/restapi/labels-and-attributes.md +797 -797
  143. package/dist/skills/fluentcart-developer/references/restapi/licensing.md +1733 -1733
  144. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-available-shipping-methods.md +30 -30
  145. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-checkout-summary.md +28 -28
  146. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-country-info.md +29 -29
  147. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-order-info.md +28 -28
  148. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-shipping-methods-list-view.md +30 -30
  149. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/login.md +66 -66
  150. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/place-order.md +179 -179
  151. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/apply-coupon.md +83 -83
  152. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/cancel-coupon.md +87 -87
  153. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/check-product-eligibility.md +59 -59
  154. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/create-coupon.md +230 -230
  155. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/delete-coupon.md +29 -29
  156. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/get-coupon-settings.md +20 -20
  157. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/get-coupon.md +27 -27
  158. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/list-coupon-codes.md +20 -20
  159. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/list-coupons.md +37 -37
  160. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/re-apply-coupons.md +75 -75
  161. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/store-coupon-settings.md +40 -40
  162. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/update-coupon.md +133 -133
  163. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/create-address-checkout.md +138 -138
  164. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/create-profile-address.md +119 -119
  165. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/dashboard-overview.md +22 -22
  166. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/delete-profile-address.md +46 -46
  167. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-order-details.md +30 -30
  168. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-portal-sections.md +29 -29
  169. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-profile-details.md +22 -22
  170. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-transaction-billing-address.md +30 -30
  171. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-upgrade-paths.md +31 -31
  172. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/list-downloads.md +29 -29
  173. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/list-orders.md +28 -28
  174. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/make-profile-address-primary.md +55 -55
  175. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/pause-subscription.md +29 -29
  176. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/resume-subscription.md +29 -29
  177. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/save-transaction-billing-address.md +92 -92
  178. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/select-address-for-checkout.md +32 -32
  179. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/update-profile-address.md +115 -115
  180. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/update-profile-details.md +69 -69
  181. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/attach-user.md +50 -50
  182. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/bulk-actions.md +65 -65
  183. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/create-address.md +135 -135
  184. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/create-customer.md +108 -108
  185. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/delete-address.md +62 -62
  186. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/detach-user.md +28 -28
  187. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/find-customer-order.md +27 -27
  188. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-attachable-users.md +20 -20
  189. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-addresses.md +28 -28
  190. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-orders.md +37 -37
  191. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-stats.md +27 -27
  192. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer.md +32 -32
  193. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/list-customers.md +37 -37
  194. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/recalculate-ltv.md +28 -28
  195. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/set-primary-address.md +72 -72
  196. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-additional-info.md +55 -55
  197. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-address.md +144 -144
  198. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-customer.md +123 -123
  199. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/attach-note-to-order.md +49 -49
  200. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/create-all-pages.md +21 -21
  201. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/create-single-page.md +55 -55
  202. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/delete-activity.md +28 -28
  203. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-country-info.md +29 -29
  204. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-dashboard-stats.md +22 -22
  205. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-filter-options.md +31 -31
  206. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-onboarding-data.md +20 -20
  207. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-onboarding-settings.md +20 -20
  208. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-print-templates.md +20 -20
  209. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-search-options.md +27 -27
  210. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-widgets.md +28 -28
  211. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/initialize-app.md +20 -20
  212. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-activities.md +33 -33
  213. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-attachments.md +21 -21
  214. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-countries.md +20 -20
  215. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/mark-activity-read.md +53 -53
  216. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/run-data-backfills.md +21 -21
  217. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-onboarding-settings.md +54 -54
  218. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-onboarding-tax-settings.md +73 -73
  219. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-print-templates.md +64 -64
  220. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/upload-attachment.md +42 -42
  221. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-customers-batch.md +129 -129
  222. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-licenses-batch.md +133 -133
  223. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-orders-batch.md +129 -129
  224. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-subscriptions-batch.md +129 -129
  225. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-customers-export-schema.md +21 -21
  226. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-licenses-export-schema.md +26 -26
  227. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-orders-export-schema.md +21 -21
  228. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-subscriptions-export-schema.md +21 -21
  229. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/enable-notification.md +57 -57
  230. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-digest-settings.md +22 -22
  231. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-notification.md +30 -30
  232. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-reminders.md +22 -22
  233. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-settings.md +22 -22
  234. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-shortcodes.md +22 -22
  235. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/list-notifications.md +20 -20
  236. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/preview-default-template.md +66 -66
  237. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/preview-notification.md +50 -50
  238. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-digest-settings.md +101 -101
  239. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-reminders.md +162 -162
  240. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-settings.md +99 -99
  241. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/send-digest-test.md +47 -47
  242. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/send-manual-reminder.md +51 -51
  243. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/update-notification.md +93 -93
  244. package/dist/skills/fluentcart-developer/references/restapi/operations/files/delete-file.md +31 -31
  245. package/dist/skills/fluentcart-developer/references/restapi/operations/files/get-bucket-list.md +28 -28
  246. package/dist/skills/fluentcart-developer/references/restapi/operations/files/list-files.md +30 -30
  247. package/dist/skills/fluentcart-developer/references/restapi/operations/files/upload-editor-file.md +32 -32
  248. package/dist/skills/fluentcart-developer/references/restapi/operations/files/upload-file.md +34 -34
  249. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/chained-data-request.md +46 -46
  250. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/change-feed-status.md +51 -51
  251. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/delete-feed.md +27 -27
  252. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-dynamic-options.md +29 -29
  253. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-feed-lists.md +27 -27
  254. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-feed-settings.md +27 -27
  255. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-global-feeds.md +20 -20
  256. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-global-settings.md +26 -26
  257. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/install-addon-plugin.md +49 -49
  258. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/list-addons.md +20 -20
  259. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/save-feed-settings.md +52 -52
  260. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/set-global-settings.md +50 -50
  261. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/bulk-update-stock.md +94 -94
  262. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/export-inventory.md +81 -81
  263. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/get-adjustment-history.md +26 -26
  264. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/get-inventory-stats.md +21 -21
  265. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/list-inventory.md +33 -33
  266. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/update-stock.md +75 -75
  267. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-attribute-group.md +31 -31
  268. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-label.md +31 -31
  269. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-terms.md +90 -90
  270. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/delete-attribute-group.md +28 -28
  271. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/delete-attribute-term.md +29 -29
  272. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/get-attribute-group.md +28 -28
  273. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/get-attribute-library.md +20 -20
  274. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-attribute-groups.md +32 -32
  275. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-attribute-terms.md +33 -33
  276. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-labels.md +20 -20
  277. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/reorder-groups.md +51 -51
  278. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/reorder-terms.md +56 -56
  279. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-attribute-group.md +37 -37
  280. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-attribute-term.md +39 -39
  281. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-label-selections.md +32 -32
  282. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/activate-plugin-license.md +41 -41
  283. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/activate-site-admin.md +60 -60
  284. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-plugin-license.md +18 -18
  285. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-site-admin.md +67 -67
  286. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-site-customer.md +47 -47
  287. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/delete-license.md +24 -24
  288. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/extend-license-validity.md +47 -47
  289. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-customer-license-details.md +25 -25
  290. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-customer-licenses-admin.md +26 -26
  291. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-activations.md +25 -25
  292. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-details.md +25 -25
  293. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-site.md +30 -30
  294. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-plugin-license-status.md +18 -18
  295. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-product-license-settings.md +24 -24
  296. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-customer-licenses.md +25 -25
  297. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-license-sites.md +33 -33
  298. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-licenses.md +38 -38
  299. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-activate-license.md +54 -54
  300. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-check-license.md +26 -26
  301. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-deactivate-license.md +46 -46
  302. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-download-license-package.md +23 -23
  303. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-get-license-version.md +26 -26
  304. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/regenerate-license-key.md +24 -24
  305. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/save-product-license-settings.md +193 -193
  306. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/update-license-activation-limit.md +53 -53
  307. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/update-license-status.md +52 -52
  308. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/create-order-bump.md +47 -47
  309. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/delete-order-bump.md +25 -25
  310. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/get-order-bump.md +25 -25
  311. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/list-order-bumps.md +29 -29
  312. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/update-order-bump.md +141 -141
  313. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/accept-dispute.md +47 -47
  314. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/bulk-actions.md +72 -72
  315. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/calculate-shipping.md +67 -67
  316. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/calculate-tax.md +98 -98
  317. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/change-customer.md +50 -50
  318. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/charge-now.md +29 -29
  319. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-and-change-customer.md +92 -92
  320. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-custom-order-item.md +68 -68
  321. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-order.md +351 -351
  322. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-renewal-now.md +29 -29
  323. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/delete-order.md +28 -28
  324. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/generate-missing-licenses.md +29 -29
  325. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-order-transactions.md +27 -27
  326. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-order.md +27 -27
  327. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-renewal.md +28 -28
  328. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-shipping-methods.md +28 -28
  329. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-single-transaction.md +28 -28
  330. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-order-currencies.md +22 -22
  331. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-orders.md +42 -42
  332. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-renewals.md +28 -28
  333. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/mark-as-paid.md +61 -61
  334. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/price-order.md +135 -135
  335. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/refund-order.md +72 -72
  336. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/resend-renewal-invoice.md +29 -29
  337. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/skip-renewal.md +48 -48
  338. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/sync-order-statuses.md +28 -28
  339. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/sync-pending-transaction.md +29 -29
  340. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order-address-id.md +60 -60
  341. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order-address.md +98 -98
  342. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order.md +172 -172
  343. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-statuses.md +77 -77
  344. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-subscription-details.md +84 -84
  345. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-transaction-status.md +51 -51
  346. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/void-renewal.md +30 -30
  347. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/create-pdf-template.md +42 -42
  348. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/delete-pdf-template.md +26 -26
  349. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/download-pdf-preview.md +44 -44
  350. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-factory-default-templates.md +19 -19
  351. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-pdf-status.md +21 -21
  352. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-pdf-template.md +26 -26
  353. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-saved-templates.md +21 -21
  354. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-seller-details.md +19 -19
  355. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/list-pdf-templates.md +19 -19
  356. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/save-pdf-template.md +53 -53
  357. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/save-seller-details.md +97 -97
  358. package/dist/skills/fluentcart-developer/references/restapi/operations/products/add-product-terms.md +64 -64
  359. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-edit-fetch.md +30 -30
  360. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-insert-products.md +62 -62
  361. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-update-products.md +59 -59
  362. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-update-variants.md +83 -83
  363. package/dist/skills/fluentcart-developer/references/restapi/operations/products/change-integration-status.md +64 -64
  364. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-dummy-products.md +45 -45
  365. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-product.md +81 -81
  366. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-variation.md +181 -181
  367. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-downloadable-file.md +27 -27
  368. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-product-integration.md +30 -30
  369. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-product.md +27 -27
  370. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-taxonomy-term.md +55 -55
  371. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-upgrade-path.md +27 -27
  372. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-variation.md +27 -27
  373. package/dist/skills/fluentcart-developer/references/restapi/operations/products/do-bulk-action.md +56 -56
  374. package/dist/skills/fluentcart-developer/references/restapi/operations/products/duplicate-product.md +56 -56
  375. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-products-by-ids.md +26 -26
  376. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-taxonomy-terms.md +20 -20
  377. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-terms-by-parent.md +60 -60
  378. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-variations-by-ids.md +26 -26
  379. package/dist/skills/fluentcart-developer/references/restapi/operations/products/find-subscription-variants.md +26 -26
  380. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-bundle-info.md +27 -27
  381. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-downloadable-url.md +27 -27
  382. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-max-excerpt-word-count.md +20 -20
  383. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-pricing-widgets.md +27 -27
  384. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-integration-feeds.md +29 -29
  385. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-integration-settings.md +31 -31
  386. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-pricing.md +28 -28
  387. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product.md +28 -28
  388. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-related-products.md +31 -31
  389. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-upgrade-settings.md +27 -27
  390. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-variation-upgrade-paths.md +28 -28
  391. package/dist/skills/fluentcart-developer/references/restapi/operations/products/group-bulk-update-variants.md +103 -103
  392. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-all-variants.md +26 -26
  393. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-product-variations.md +26 -26
  394. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-products.md +34 -34
  395. package/dist/skills/fluentcart-developer/references/restapi/operations/products/remove-shipping-class.md +27 -27
  396. package/dist/skills/fluentcart-developer/references/restapi/operations/products/remove-tax-class.md +27 -27
  397. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-bundle-info.md +56 -56
  398. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-product-integration.md +62 -62
  399. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-upgrade-path.md +78 -78
  400. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-product-variant-options.md +29 -29
  401. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-products-by-name.md +28 -28
  402. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-variants-by-name.md +28 -28
  403. package/dist/skills/fluentcart-developer/references/restapi/operations/products/set-variation-media.md +74 -74
  404. package/dist/skills/fluentcart-developer/references/restapi/operations/products/suggest-sku.md +28 -28
  405. package/dist/skills/fluentcart-developer/references/restapi/operations/products/sync-downloadable-files.md +134 -134
  406. package/dist/skills/fluentcart-developer/references/restapi/operations/products/sync-taxonomy-terms.md +61 -61
  407. package/dist/skills/fluentcart-developer/references/restapi/operations/products/toggle-product-tax-exemption.md +56 -56
  408. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-downloadable-file.md +98 -98
  409. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-inventory.md +56 -56
  410. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-long-desc-editor-mode.md +49 -49
  411. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-manage-stock.md +53 -53
  412. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-product-detail.md +58 -58
  413. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-product-pricing.md +225 -225
  414. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-shipping-class.md +49 -49
  415. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-tax-class.md +49 -49
  416. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-upgrade-path.md +78 -78
  417. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variant-option.md +79 -79
  418. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variant-tax-exemption.md +56 -56
  419. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variation-pricing-table.md +49 -49
  420. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variation.md +105 -105
  421. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/get-product-views.md +34 -34
  422. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/list-products.md +42 -42
  423. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/search-products.md +30 -30
  424. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/channel-rules.md +24 -24
  425. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/country-heat-map.md +22 -22
  426. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/coupon-overview.md +37 -37
  427. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/coupons.md +36 -36
  428. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-insights.md +31 -31
  429. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-overview.md +36 -36
  430. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-repeat.md +35 -35
  431. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-segment-customers.md +36 -36
  432. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-segments.md +30 -30
  433. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-value.md +34 -34
  434. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/dashboard-stats.md +30 -30
  435. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/failed-orders.md +34 -34
  436. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-new-vs-returning-customer.md +34 -34
  437. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-report-by-day-and-hour.md +34 -34
  438. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-report-meta.md +29 -29
  439. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-top-sold-products.md +34 -34
  440. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/future-renewals.md +31 -31
  441. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/generate-retention-snapshots.md +24 -24
  442. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-overview.md +30 -30
  443. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-recent-activities.md +26 -26
  444. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-recent-orders.md +20 -20
  445. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-revenue.md +37 -37
  446. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments-at-risk.md +35 -35
  447. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments-variations.md +33 -33
  448. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments.md +33 -33
  449. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/item-count-distribution.md +34 -34
  450. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-chart.md +30 -30
  451. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-pie-chart.md +22 -22
  452. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-summary.md +22 -22
  453. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/locations.md +43 -43
  454. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-chart.md +37 -37
  455. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-completion-time.md +34 -34
  456. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-mix.md +34 -34
  457. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-value-distribution.md +34 -34
  458. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods-disputes.md +38 -38
  459. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods-methods.md +36 -36
  460. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods.md +37 -37
  461. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-comparison-launch.md +33 -33
  462. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-comparison.md +40 -40
  463. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-detail.md +37 -37
  464. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-sales.md +37 -37
  465. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/refunds-overview.md +37 -37
  466. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/retention-snapshots-step.md +45 -45
  467. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/sales-growth-chart.md +35 -35
  468. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/save-channel-rules.md +73 -73
  469. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/source-channels.md +37 -37
  470. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/sources.md +49 -49
  471. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-cohorts.md +33 -33
  472. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-health.md +30 -30
  473. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-rebuys.md +37 -37
  474. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-retention.md +34 -34
  475. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-variations.md +22 -22
  476. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscriptions-overview.md +37 -37
  477. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/weeks-between-refund.md +34 -34
  478. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/assign-role.md +48 -48
  479. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/delete-role-assignment.md +47 -47
  480. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/get-role.md +25 -25
  481. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/list-managers.md +18 -18
  482. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/list-roles.md +18 -18
  483. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/search-users.md +25 -25
  484. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/update-role.md +43 -43
  485. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/create-saved-view.md +106 -106
  486. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/delete-saved-view.md +26 -26
  487. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/list-saved-views.md +25 -25
  488. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/update-saved-view.md +83 -83
  489. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/activate-payment-addon.md +44 -44
  490. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/activate-plugin-addon.md +44 -44
  491. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/change-storage-driver-status.md +56 -56
  492. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/check-paypal-webhook.md +26 -26
  493. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/create-storage-bucket.md +63 -63
  494. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/disconnect-payment-method.md +55 -55
  495. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/exchange-paypal-seller-auth-token.md +62 -62
  496. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-active-storage-drivers.md +20 -20
  497. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-checkout-fields.md +22 -22
  498. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-email-shortcodes.md +20 -20
  499. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-mcp-config-snippets.md +26 -26
  500. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-mcp-status.md +20 -20
  501. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-module-settings.md +20 -20
  502. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-payment-method-connection-info.md +26 -26
  503. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-payment-method-settings.md +26 -26
  504. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-permissions.md +22 -22
  505. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-plugin-addons.md +20 -20
  506. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-storage-driver-settings.md +27 -27
  507. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-store-settings.md +26 -26
  508. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-mcp-adapter.md +21 -21
  509. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-payment-addon.md +60 -60
  510. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-plugin-addon.md +64 -64
  511. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-all-payment-methods.md +20 -20
  512. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-all-storage-drivers.md +20 -20
  513. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-storage-buckets.md +67 -67
  514. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/reorder-payment-methods.md +55 -55
  515. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/reset-storage-driver-settings.md +45 -45
  516. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-checkout-fields.md +133 -133
  517. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-confirmation-settings.md +68 -68
  518. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-module-settings.md +68 -68
  519. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-payment-method-design.md +67 -67
  520. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-payment-method-settings.md +58 -58
  521. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-permissions.md +68 -68
  522. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-storage-driver-settings.md +62 -62
  523. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-store-settings.md +239 -239
  524. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/setup-paypal-webhook.md +48 -48
  525. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/toggle-mcp.md +40 -40
  526. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/verify-storage-driver-connection.md +62 -62
  527. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/verify-turnstile-keys.md +55 -55
  528. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-class.md +73 -73
  529. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-method.md +110 -110
  530. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-zone.md +56 -56
  531. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-class.md +29 -29
  532. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-method.md +29 -29
  533. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-zone.md +29 -29
  534. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-class-profile.md +30 -30
  535. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-class.md +29 -29
  536. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-packages.md +22 -22
  537. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-zone.md +27 -27
  538. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-zone-countries.md +22 -22
  539. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-zone-states.md +28 -28
  540. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/list-shipping-classes.md +31 -31
  541. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/list-shipping-zones.md +31 -31
  542. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/save-shipping-packages.md +112 -112
  543. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-class.md +79 -79
  544. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-method.md +113 -113
  545. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-zone.md +62 -62
  546. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-zone-order.md +52 -52
  547. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/cancel-auto-renew.md +30 -30
  548. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/cancel-subscription.md +52 -52
  549. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/confirm-subscription-switch.md +70 -70
  550. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/fetch-subscription-remote.md +28 -28
  551. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/generate-early-payment-link.md +29 -29
  552. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-customer-subscription.md +27 -27
  553. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-or-create-plan.md +69 -69
  554. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-setup-intent-attempts.md +30 -30
  555. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-subscription.md +28 -28
  556. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/initiate-early-payment.md +31 -31
  557. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/list-customer-subscriptions.md +27 -27
  558. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/list-subscriptions.md +39 -39
  559. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/pause-subscription.md +28 -28
  560. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/reactivate-subscription.md +28 -28
  561. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/resume-subscription.md +28 -28
  562. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/switch-payment-method.md +70 -70
  563. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/update-payment-method.md +69 -69
  564. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/update-vendor-ids.md +56 -56
  565. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/verify-vendor-ids.md +56 -56
  566. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/create-tax-class.md +51 -51
  567. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/create-tax-rate.md +117 -117
  568. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-product-override.md +27 -27
  569. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-shipping-tax-override.md +27 -27
  570. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-tax-class.md +28 -28
  571. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-tax-rate.md +27 -27
  572. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-country-tax-id.md +27 -27
  573. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-country-tax-rates.md +28 -28
  574. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-eu-vat-product-overrides.md +20 -20
  575. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-oss-country-rates.md +20 -20
  576. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-preconfigured-tax-rates.md +20 -20
  577. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-product-overrides.md +27 -27
  578. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-tax-settings.md +20 -20
  579. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-all-tax-rates.md +20 -20
  580. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-tax-classes.md +20 -20
  581. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-tax-records.md +37 -37
  582. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/mark-taxes-as-filed.md +58 -58
  583. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/reset-eu-vat-rates.md +21 -21
  584. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-configured-countries.md +57 -57
  585. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-country-tax-id.md +50 -50
  586. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-eu-vat-cross-border-settings.md +127 -127
  587. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-oss-country-rates.md +100 -100
  588. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-product-override.md +110 -110
  589. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-shipping-tax-override.md +52 -52
  590. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-tax-settings.md +166 -166
  591. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/update-country-status.md +54 -54
  592. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/update-tax-rate.md +116 -116
  593. package/dist/skills/fluentcart-developer/references/restapi/order-bumps.md +433 -433
  594. package/dist/skills/fluentcart-developer/references/restapi/orders.md +1212 -1212
  595. package/dist/skills/fluentcart-developer/references/restapi/pdf-templates.md +212 -212
  596. package/dist/skills/fluentcart-developer/references/restapi/products.md +2485 -2485
  597. package/dist/skills/fluentcart-developer/references/restapi/public-shop.md +191 -191
  598. package/dist/skills/fluentcart-developer/references/restapi/reports.md +3773 -3773
  599. package/dist/skills/fluentcart-developer/references/restapi/roles.md +403 -403
  600. package/dist/skills/fluentcart-developer/references/restapi/saved-views.md +136 -136
  601. package/dist/skills/fluentcart-developer/references/restapi/settings.md +1423 -1423
  602. package/dist/skills/fluentcart-developer/references/restapi/shipping.md +905 -905
  603. package/dist/skills/fluentcart-developer/references/restapi/subscriptions.md +1169 -1169
  604. package/dist/skills/fluentcart-developer/references/restapi/tax.md +1551 -1551
  605. package/dist/skills/fluentcart-developer/references/restapi.md +127 -127
  606. package/dist/skills/fluentcart-developer/scripts/cli.js +1 -1
  607. package/dist/version.d.ts +1 -1
  608. package/dist/version.js +1 -1
  609. package/package.json +66 -65
@@ -1,860 +1,860 @@
1
- # FluentCart Query Builder
2
-
3
- ## Introduction
4
-
5
- FluentCart uses an Eloquent-based ORM system compatible with Laravel's Eloquent ORM. You can interact with database tables through Model classes or using direct query builder methods.
6
-
7
- TIP
8
-
9
- FluentCart's ORM is compatible with Laravel Framework's Eloquent ORM. If you are familiar with Laravel's Eloquent, you will feel right at home using FluentCart's database system.
10
-
11
- Every query-builder example on this page uses `App::db()`, so each needs:
12
-
13
- ```
14
- use FluentCart\App\App;
15
- ```
16
-
17
- Table names in raw SQL are not prefixed
18
-
19
- `App::db()->table('fct_orders')` resolves the WordPress table prefix for you, but raw fragments passed to `raw()`, `selectRaw()`, `whereRaw()` or `havingRaw()` are sent to MySQL untouched. A raw fragment naming a table must interpolate the prefix itself:
20
-
21
- ```
22
- global $wpdb;
23
- ->whereRaw("{$wpdb->prefix}fct_order_items.order_id = {$wpdb->prefix}fct_orders.id")
24
- ```
25
-
26
- Writing `fct_orders` in raw SQL fails with `Unknown column 'fct_orders.id'`.
27
-
28
- Timestamps
29
-
30
- Use `DateTime::gmtNow()` from `FluentCart\App\Services\DateTime\DateTime`, which returns UTC — all FluentCart timestamps are stored in GMT.
31
-
32
- ```
33
- use FluentCart\App\Services\DateTime\DateTime;
34
-
35
- DateTime::gmtNow()->format('Y-m-d H:i:s'); // now
36
- DateTime::gmtNow()->modify('-1 day')->format('Y-m-d H:i:s'); // 24 hours ago
37
- ```
38
-
39
- ### Example Using Models
40
-
41
- Here is an example using FluentCart models:
42
-
43
- ```
44
- use FluentCart\App\Models\Order;
45
-
46
- // Using the Order model
47
- $orders = Order::where('payment_status', 'paid')
48
- ->whereBetween('created_at', ['2024-01-01 00:00:00', '2024-12-30 23:59:59'])
49
- ->when($customerId, function ($query) use ($customerId) {
50
- return $query->where('customer_id', $customerId);
51
- })
52
- ->orderBy('created_at', 'ASC')
53
- ->get();
54
- ```
55
-
56
- ### Example Using Query Builder
57
-
58
- You can also use the query builder directly:
59
-
60
- ```
61
- use FluentCart\App\Models\Order;
62
-
63
- $query = Order::query()
64
- ->select(['total_amount', 'status', 'payment_method'])
65
- ->where('payment_status', 'paid')
66
- ->whereBetween('created_at', ['2024-01-01 00:00:00', '2024-12-30 23:59:59'])
67
- ->when($customerId, function ($query) use ($customerId) {
68
- return $query->where('customer_id', $customerId);
69
- })
70
- ->orderBy('created_at', 'ASC');
71
- ```
72
-
73
- ## Retrieving Results
74
-
75
- ### Retrieving All Rows From A Table
76
-
77
- You can use the model's query builder to retrieve all rows from a table. The query builder provides a fluent interface for building database queries:
78
-
79
- ```
80
- <?php
81
-
82
- use FluentCart\App\Models\Order;
83
-
84
- class OrderController extends Controller
85
- {
86
- /**
87
- * Show a list of all the application's orders.
88
- *
89
- * @return Response
90
- */
91
- public function index()
92
- {
93
- $orders = Order::all();
94
- // or using query builder
95
- $orders = Order::query()->get();
96
-
97
- return [
98
- 'orders' => $orders
99
- ];
100
- }
101
- }
102
- ```
103
-
104
- The `get` method returns a collection containing the results where each result is an instance of the Model object. You may access each column's value by accessing the column as a property of the object:
105
-
106
- ```
107
- foreach ($orders as $order) {
108
- echo $order->total_amount;
109
- }
110
- ```
111
-
112
- ### Retrieving A Single Row / Column From A Table
113
-
114
- If you just need to retrieve a single row from the database table, you may use the `first` method. This method will return a single Model object:
115
-
116
- ```
117
- use FluentCart\App\Models\Order;
118
-
119
- $order = Order::where('status', 'completed')->first();
120
-
121
- echo $order->total_amount;
122
- ```
123
-
124
- If you don't even need an entire row, you may extract a single value from a record using the `value` method. This method will return the value of the column directly:
125
-
126
- ```
127
- use FluentCart\App\Models\Order;
128
-
129
- $totalAmount = Order::where('status', 'completed')->value('total_amount');
130
- ```
131
-
132
- ### Retrieving A List Of Column Values
133
-
134
- If you would like to retrieve an array containing the values of a single column, you may use the `pluck` method. In this example, we'll retrieve an array of order IDs:
135
-
136
- ```
137
- $orderIds = App::db()->table('fct_orders')->pluck('id');
138
-
139
- foreach ($orderIds as $orderId) {
140
- echo $orderId;
141
- }
142
- ```
143
-
144
- You may also specify a custom key column for the returned Collection:
145
-
146
- ```
147
- $orderIds = App::db()->table('fct_orders')->pluck('id', 'customer_id');
148
-
149
- foreach ($orderIds as $customerId => $orderId) {
150
- echo $orderId;
151
- }
152
- ```
153
-
154
- ### Chunking Results
155
-
156
- If you need to work with thousands of database records, consider using the `chunk` method. This method retrieves a small chunk of the results at a time and feeds each chunk into a Closure for processing. This method is very useful for process thousands of records. For example, let's work with the entire `fct_orders` table in chunks of 100 records at a time:
157
-
158
- ```
159
- App::db()->table('fct_orders')->orderBy('id')->chunk(100, function ($orders) {
160
- foreach ($orders as $order) {
161
- //
162
- }
163
- });
164
- ```
165
-
166
- You may stop further chunks from being processed by returning false from the Closure:
167
-
168
- ```
169
- App::db()->table('fct_orders')->orderBy('id')->chunk(100, function ($orders) {
170
- // Process the records...
171
-
172
- return false;
173
- });
174
- ```
175
-
176
- ### Aggregates
177
-
178
- The query builder also provides a variety of aggregate methods such as `count`, `max`, `min`, `avg`, and `sum`. You may call any of these methods after constructing your query:
179
-
180
- ```
181
- $orders = App::db()->table('fct_orders')->count();
182
-
183
- $maxAmount = App::db()->table('fct_orders')->max('total_amount');
184
- ```
185
-
186
- Of course, you may combine these methods with other clauses:
187
-
188
- ```
189
- $avgAmount = App::db()->table('fct_orders')
190
- ->where('payment_status', 'paid')
191
- ->avg('total_amount');
192
- ```
193
-
194
- ### Determining If Records Exist
195
-
196
- Instead of using the `count` method to determine if any records exist that match your query's constraints, you may use the `exists`:
197
-
198
- ```
199
- return App::db()->table('fct_orders')->where('payment_status', 'paid')->exists();
200
- ```
201
-
202
- ## Selects
203
-
204
- ### Specifying A Select Clause
205
-
206
- Of course, you may not always want to select all columns from a database table. Using the `select` method, you can specify a custom `select` clause for the query:
207
-
208
- ```
209
- $orders = App::db()->table('fct_orders')->select('status', 'total_amount as order_total')->get();
210
- ```
211
-
212
- The `distinct` method allows you to force the query to return distinct results:
213
-
214
- ```
215
- $orders = App::db()->table('fct_orders')->distinct()->get();
216
- ```
217
-
218
- If you already have a query builder instance and wish to add a column to its existing select clause, you may use the `addSelect` method:
219
-
220
- ```
221
- $query = App::db()->table('fct_orders')->select('status');
222
-
223
- $orders = $query->addSelect('total_amount')->get();
224
- ```
225
-
226
- ## Raw Expressions
227
-
228
- Sometimes you may need to use a raw expression in a query. To create a raw expression, you may use the `raw` method:
229
-
230
- ```
231
- $orders = App::db()->table('fct_orders')
232
- ->select(App::db()->raw('count(*) as order_count, status'))
233
- ->where('status', '<>', 'draft')
234
- ->groupBy('status')
235
- ->get();
236
- ```
237
-
238
- ### Raw Methods
239
-
240
- Instead of using `App::db()->raw`, you may also use the following methods to insert a raw expression into various parts of your query.
241
-
242
- #### `selectRaw`
243
-
244
- The `selectRaw` method can be used in place of `select(App::db()->raw(...))`. This method accepts an optional array of bindings as its second argument:
245
-
246
- ```
247
- $orders = App::db()->table('fct_orders')
248
- ->selectRaw('total_amount * ? as price_with_tax', [1.0825])
249
- ->get();
250
- ```
251
-
252
- #### `whereRaw / orWhereRaw`
253
-
254
- The `whereRaw` and `orWhereRaw` methods can be used to inject a raw `where` clause into your query. These methods accept an optional array of bindings as their second argument:
255
-
256
- ```
257
- $orders = App::db()->table('fct_orders')
258
- ->whereRaw('total_amount > (subtotal * 1.1)')
259
- ->get();
260
- ```
261
-
262
- #### `havingRaw / orHavingRaw`
263
-
264
- The `havingRaw` and `orHavingRaw` methods may be used to set a raw string as the value of the `having` clause. These methods accept an optional array of bindings as their second argument:
265
-
266
- ```
267
- $orders = App::db()->table('fct_orders')
268
- ->select('customer_id', App::db()->raw('SUM(total_amount) as total'))
269
- ->groupBy('customer_id')
270
- ->havingRaw('SUM(total_amount) > ?', [1000])
271
- ->get();
272
- ```
273
-
274
- #### `orderByRaw`
275
-
276
- The `orderByRaw` method may be used to set a raw string as the value of the `order by` clause:
277
-
278
- ```
279
- $orders = App::db()->table('fct_orders')
280
- ->orderByRaw('FIELD(status, "pending", "processing", "completed")')
281
- ->get();
282
- ```
283
-
284
- ## Joins
285
-
286
- ### Inner Join Statement
287
-
288
- The query builder may also be used to write join statements. To perform a basic "inner join", you may use the `join` method on a query builder instance. The first argument passed to the `join` method is the name of the table you need to join to, while the remaining arguments specify the column constraints for the join. Of course, as you can see, you can join to multiple tables in a single query:
289
-
290
- ```
291
- $orders = App::db()->table('fct_orders')
292
- ->join('fct_customers', 'fct_orders.customer_id', '=', 'fct_customers.id')
293
- ->join('fct_order_items', 'fct_orders.id', '=', 'fct_order_items.order_id')
294
- ->select('fct_orders.*', 'fct_customers.email', 'fct_customers.first_name')
295
- ->get();
296
- ```
297
-
298
- ### Left Join / Right Join Statement
299
-
300
- If you would like to perform a "left join" instead of an "inner join", use the `leftJoin` method. The `leftJoin` method has the same signature as the `join` method:
301
-
302
- ```
303
- $orders = App::db()->table('fct_orders')
304
- ->leftJoin('fct_customers', 'fct_orders.customer_id', '=', 'fct_customers.id')
305
- ->get();
306
- ```
307
-
308
- Similarly, you may use the `rightJoin` method to perform a "right join":
309
-
310
- ```
311
- $orders = App::db()->table('fct_orders')
312
- ->rightJoin('fct_customers', 'fct_orders.customer_id', '=', 'fct_customers.id')
313
- ->get();
314
- ```
315
-
316
- ### Cross Join Statement
317
-
318
- To perform a "cross join" use the `crossJoin` method with the name of the table you wish to cross join to. Cross joins generate a cartesian product between the first table and the joined table:
319
-
320
- ```
321
- $products = App::db()->table('fct_product_details')
322
- ->crossJoin('fct_product_variations')
323
- ->get();
324
- ```
325
-
326
- ### Advanced Join Clauses
327
-
328
- You may also specify more advanced join clauses. To get started, pass a `Closure` as the second argument into the `join` method. The `Closure` will receive a `JoinClause` object which allows you to specify constraints on the `join` clause:
329
-
330
- ```
331
- App::db()->table('fct_orders')
332
- ->join('fct_customers', function ($join) {
333
- $join->on('fct_orders.customer_id', '=', 'fct_customers.id')
334
- ->where('fct_customers.status', '=', 'active');
335
- })
336
- ->get();
337
- ```
338
-
339
- ### Subquery Joins
340
-
341
- You may use the `joinSub`, `leftJoinSub`, and `rightJoinSub` methods to join a query to a subquery. Each of these methods receive three arguments: the subquery, its table alias, and a Closure that defines the related columns:
342
-
343
- ```
344
- $latestOrders = App::db()->table('fct_orders')
345
- ->select('customer_id', App::db()->raw('MAX(created_at) as last_order_date'))
346
- ->groupBy('customer_id');
347
-
348
- $customers = App::db()->table('fct_customers')
349
- ->joinSub($latestOrders, 'latest_orders', function ($join) {
350
- $join->on('fct_customers.id', '=', 'latest_orders.customer_id');
351
- })->get();
352
- ```
353
-
354
- ## Unions
355
-
356
- The query builder also provides a quick way to "union" two or more queries together. For example, you may create an initial query and use the `union` method to union it with a second query:
357
-
358
- ```
359
- $first = App::db()->table('fct_orders')
360
- ->whereNull('completed_at');
361
-
362
- $orders = App::db()->table('fct_orders')
363
- ->whereNull('cancelled_at')
364
- ->union($first)
365
- ->get();
366
- ```
367
-
368
- The `unionAll` method may also be used and has the same method signature as `union`. The difference between `union` and `unionAll` is that `unionAll` will not remove duplicate entries from your resultset.
369
-
370
- ## Where Clauses
371
-
372
- ### Simple Where Clauses
373
-
374
- You may use the `where` method on a query builder instance to add `where` clauses to the query. The most basic call to `where` requires three arguments. The first argument is the name of the column. The second argument is an operator, which can be any of the database's supported operators. Finally, the third argument is the value to evaluate against the column.
375
-
376
- For example, here is a query that verifies the value of a "status" column equals "completed":
377
-
378
- ```
379
- $orders = App::db()->table('fct_orders')->where('status', '=', 'completed')->get();
380
- ```
381
-
382
- For convenience, if you want to verify that a column is equal to a given value, you may pass the value directly as the second argument to the `where` method:
383
-
384
- ```
385
- $orders = App::db()->table('fct_orders')->where('status', 'completed')->get();
386
- ```
387
-
388
- Of course, you may use a variety of other operators when writing a `where` clause:
389
-
390
- ```
391
- $orders = App::db()->table('fct_orders')->where('total_amount', '>', 1000)->get();
392
-
393
- $orders = App::db()->table('fct_orders')->where('total_amount', '>=', 1000)->get();
394
-
395
- $orders = App::db()->table('fct_orders')->where('total_amount', '<', 1000)->get();
396
-
397
- $orders = App::db()->table('fct_orders')->where('total_amount', '<=', 1000)->get();
398
-
399
- $orders = App::db()->table('fct_orders')->where('status', '!=', 'draft')->get();
400
-
401
- $orders = App::db()->table('fct_orders')->where('status', '<>', 'draft')->get();
402
- ```
403
-
404
- ### Or Statements
405
-
406
- You may chain where constraints together as well as add `or` clauses to the query. The `orWhere` method accepts the same arguments as the `where` method:
407
-
408
- ```
409
- $orders = App::db()->table('fct_orders')
410
- ->where('status', 'completed')
411
- ->orWhere('payment_status', 'paid')
412
- ->get();
413
- ```
414
-
415
- ### Additional Where Clauses
416
-
417
- #### whereBetween / orWhereBetween
418
-
419
- The `whereBetween` method verifies that a column's value is between two values:
420
-
421
- ```
422
- $orders = App::db()->table('fct_orders')
423
- ->whereBetween('total_amount', [100, 500])
424
- ->get();
425
- ```
426
-
427
- The `orWhereBetween` method verifies that a column's value is outside of two values:
428
-
429
- ```
430
- $orders = App::db()->table('fct_orders')
431
- ->whereNotBetween('total_amount', [100, 500])
432
- ->get();
433
- ```
434
-
435
- #### whereIn / whereNotIn / orWhereIn / orWhereNotIn
436
-
437
- The `whereIn` method verifies that a given column's value is contained within the given array:
438
-
439
- ```
440
- $orders = App::db()->table('fct_orders')
441
- ->whereIn('status', ['pending', 'processing', 'completed'])
442
- ->get();
443
- ```
444
-
445
- The `whereNotIn` method verifies that the given column's value is not contained in the given array:
446
-
447
- ```
448
- $orders = App::db()->table('fct_orders')
449
- ->whereNotIn('status', ['canceled', 'expired'])
450
- ->get();
451
- ```
452
-
453
- #### whereNull / whereNotNull / orWhereNull / orWhereNotNull
454
-
455
- The `whereNull` method verifies that the value of the given column is `NULL`:
456
-
457
- ```
458
- $orders = App::db()->table('fct_orders')
459
- ->whereNull('completed_at')
460
- ->get();
461
- ```
462
-
463
- The `whereNotNull` method verifies that the column's value is not `NULL`:
464
-
465
- ```
466
- $orders = App::db()->table('fct_orders')
467
- ->whereNotNull('completed_at')
468
- ->get();
469
- ```
470
-
471
- #### whereDate / whereYear
472
-
473
- The `whereDate` method may be used to compare a column's value against a date:
474
-
475
- ```
476
- $orders = App::db()->table('fct_orders')
477
- ->whereDate('created_at', '2024-12-31')
478
- ->get();
479
- ```
480
-
481
- The `whereYear` method may be used to compare a column's value against a specific year:
482
-
483
- ```
484
- $orders = App::db()->table('fct_orders')
485
- ->whereYear('created_at', '2024')
486
- ->get();
487
- ```
488
-
489
- ### Parameter Grouping
490
-
491
- Sometimes you may need to create more advanced where clauses such as "where exists" or nested parameter groupings. The FluentCart query builder can handle these as well. To get started, let's look at an example of grouping constraints within parenthesis:
492
-
493
- ```
494
- App::db()->table('fct_orders')
495
- ->where('status', '=', 'completed')
496
- ->where(function ($query) {
497
- $query->where('total_amount', '>', 1000)
498
- ->orWhere('payment_method', '=', 'stripe');
499
- })
500
- ->get();
501
- ```
502
-
503
- As you can see, passing a `Closure` into the `where` method instructs the query builder to begin a constraint group. The `Closure` will receive a query builder instance which you can use to set the constraints that should be contained within the parenthesis group. The example above will produce the following SQL:
504
-
505
- ```
506
- select * from fct_orders where status = 'completed' and (total_amount > 1000 or payment_method = 'stripe')
507
- ```
508
-
509
- ### Where Exists Clauses
510
-
511
- The `whereExists` method allows you to write `where exists` SQL clauses. The `whereExists` method accepts a `Closure` argument, which will receive a query builder instance allowing you to define the query that should be placed inside the "exists" clause:
512
-
513
- ```
514
- global $wpdb;
515
-
516
- App::db()->table('fct_orders')
517
- ->whereExists(function ($query) use ($wpdb) {
518
- $query->select(App::db()->raw(1))
519
- ->from('fct_order_items')
520
- ->whereRaw("{$wpdb->prefix}fct_order_items.order_id = {$wpdb->prefix}fct_orders.id");
521
- })
522
- ->get();
523
- ```
524
-
525
- The query above will produce the following SQL:
526
-
527
- ```
528
- select * from fct_orders
529
- where exists (
530
- select 1 from fct_order_items where fct_order_items.order_id = fct_orders.id
531
- )
532
- ```
533
-
534
- ### Ordering, Grouping, Limit, & Offset
535
-
536
- #### orderBy
537
-
538
- The `orderBy` method allows you to sort the result of the query by a given column. The first argument to the `orderBy` method should be the column you wish to sort by, while the second argument controls the direction of the sort and may be either `asc` or `desc`:
539
-
540
- ```
541
- $orders = App::db()->table('fct_orders')
542
- ->orderBy('created_at', 'DESC')
543
- ->get();
544
- ```
545
-
546
- #### latest / oldest
547
-
548
- The `latest` and `oldest` methods allow you to easily order results by date. By default, result will be ordered by the `created_at` column. Or, you may pass the column name that you wish to sort by:
549
-
550
- ```
551
- $orders = App::db()->table('fct_orders')
552
- ->latest()
553
- ->get();
554
- ```
555
-
556
- #### groupBy / having
557
-
558
- The `groupBy` and `having` methods may be used to group the query results. The `having` method's signature is similar to that of the `where` method:
559
-
560
- ```
561
- $orders = App::db()->table('fct_orders')
562
- ->groupBy('customer_id')
563
- ->having('customer_id', '>', 100)
564
- ->get();
565
- ```
566
-
567
- You may pass multiple arguments to the `groupBy` method to group by multiple columns:
568
-
569
- ```
570
- $orders = App::db()->table('fct_orders')
571
- ->groupBy('customer_id', 'status')
572
- ->having('customer_id', '>', 100)
573
- ->get();
574
- ```
575
-
576
- #### skip / take
577
-
578
- To limit the number of results returned from the query, or to skip a given number of results in the query, you may use the `skip` and `take` methods:
579
-
580
- ```
581
- $orders = App::db()->table('fct_orders')
582
- ->skip(10)
583
- ->take(5)
584
- ->get();
585
- ```
586
-
587
- Alternatively, you may use the `limit` and `offset` methods:
588
-
589
- ```
590
- $orders = App::db()->table('fct_orders')
591
- ->limit(10)
592
- ->offset(5)
593
- ->get();
594
- ```
595
-
596
- ### Conditional Clauses
597
-
598
- Sometimes you may want clauses to apply to a query only when something else is true. For instance, you may only want to apply a `where` statement if a given input value is present on the incoming request. You may accomplish this using `when` method:
599
-
600
- ```
601
- $customerId = $request->get('customer_id');
602
-
603
- $orders = App::db()->table('fct_orders')
604
- ->when($customerId, function ($query, $customerId) {
605
- return $query->where('customer_id', $customerId);
606
- })
607
- ->get();
608
- ```
609
-
610
- The `when` method only executes the given `Closure` when the first parameter is `true`. If the first parameter is `false`, the Closure will not be executed.
611
-
612
- You may pass another Closure as the third parameter to the `when` method. This Closure will execute if the first parameter evaluates as `false`. To illustrate how this feature may be used, we will use it to configure the default sorting of a query:
613
-
614
- ```
615
- $sortBy = null;
616
-
617
- $orders = App::db()->table('fct_orders')
618
- ->when($sortBy, function ($query, $sortBy) {
619
- return $query->orderBy($sortBy);
620
- }, function ($query) {
621
- return $query->orderBy('created_at');
622
- })
623
- ->get();
624
- ```
625
-
626
- ## Inserts
627
-
628
- The query builder also provides an `insert` method for inserting records into the database table. The `insert` method accepts an array of column names and values:
629
-
630
- ```
631
- App::db()->table('fct_orders')->insert(
632
- ['customer_id' => 1, 'status' => 'pending', 'total_amount' => 1000]
633
- );
634
- ```
635
-
636
- You may even insert several records into the table with a single call to `insert` by passing an array of arrays. Each array represents a row to be inserted into the table:
637
-
638
- ```
639
- App::db()->table('fct_orders')->insert([
640
- ['customer_id' => 1, 'status' => 'pending', 'total_amount' => 1000],
641
- ['customer_id' => 2, 'status' => 'processing', 'total_amount' => 2000]
642
- ]);
643
- ```
644
-
645
- ### Auto-Incrementing IDs
646
-
647
- If the table has an auto-incrementing id, use the `insertGetId` method to insert a record and then retrieve the ID:
648
-
649
- ```
650
- App::db()->table('fct_orders')->insertGetId(
651
- ['customer_id' => 1, 'status' => 'pending', 'total_amount' => 1000]
652
- );
653
- ```
654
-
655
- ## Updates
656
-
657
- Of course, in addition to inserting records into the database, the query builder can also update existing records using the `update` method. The `update` method, like the `insert` method, accepts an array of column and value pairs containing the columns to be updated. You may constrain the `update` query using `where` clauses:
658
-
659
- ```
660
- App::db()->table('fct_orders')
661
- ->where('id', 1)
662
- ->update(['status' => 'completed']);
663
- ```
664
-
665
- ## Increment & Decrement
666
-
667
- The query builder also provides convenient methods for incrementing or decrementing the value of a given column. This is useful for updating stock quantities or order counts.
668
-
669
- Both of these methods accept at least one argument: the column to modify. A second argument may optionally be passed to control the amount by which the column should be incremented or decremented:
670
-
671
- ```
672
- // Decrement product stock when order is placed
673
- App::db()->table('fct_product_variations')->decrement('available', 1);
674
-
675
- // Increment the customer's purchase count
676
- App::db()->table('fct_customers')->increment('purchase_count');
677
- ```
678
-
679
- You may also specify additional columns to update during the operation:
680
-
681
- ```
682
- App::db()->table('fct_product_variations')
683
- ->decrement('available', 1, ['updated_at' => DateTime::gmtNow()->format('Y-m-d H:i:s')]);
684
- ```
685
-
686
- ## Deletes
687
-
688
- The query builder may also be used to delete records from the table via the `delete` method. You may constrain delete statements by adding where clauses before calling the `delete` method:
689
-
690
- ```
691
- App::db()->table('fct_orders')->delete();
692
-
693
- App::db()->table('fct_orders')->where('status', 'draft')->delete();
694
- ```
695
-
696
- If you wish to truncate the entire table, which will remove all rows and reset the auto-incrementing ID to zero, you may use the `truncate` method:
697
-
698
- ```
699
- App::db()->table('fct_orders')->truncate();
700
- ```
701
-
702
- ## FluentCart-Specific Query Examples
703
-
704
- ### Activity Logging Queries
705
-
706
- ```
707
- // Get all activities for a specific order
708
- $orderActivities = App::db()->table('fct_activity')
709
- ->where('module_type', 'FluentCart\App\Models\Order')
710
- ->where('module_id', 123)
711
- ->orderBy('created_at', 'desc')
712
- ->get();
713
-
714
- // Get failed activities in the last 24 hours.
715
- // The logger writes info / success / warning / error.
716
- $failedActivities = App::db()->table('fct_activity')
717
- ->where('status', 'error')
718
- ->where('created_at', '>=', DateTime::gmtNow()->modify('-1 day')->format('Y-m-d H:i:s'))
719
- ->get();
720
- ```
721
-
722
- ### Attribute System Queries
723
-
724
- ```
725
- // Get all products with specific color attribute
726
- $redProducts = App::db()->table('fct_atts_relations')
727
- ->join('fct_atts_terms', 'fct_atts_relations.term_id', '=', 'fct_atts_terms.id')
728
- ->join('fct_atts_groups', 'fct_atts_relations.group_id', '=', 'fct_atts_groups.id')
729
- ->where('fct_atts_groups.slug', 'color')
730
- ->where('fct_atts_terms.slug', 'red')
731
- ->pluck('object_id');
732
-
733
- // Get all attribute groups with their terms
734
- $attributeGroups = App::db()->table('fct_atts_groups')
735
- ->leftJoin('fct_atts_terms', 'fct_atts_groups.id', '=', 'fct_atts_terms.group_id')
736
- ->select('fct_atts_groups.*', 'fct_atts_terms.title as term_title')
737
- ->get();
738
- ```
739
-
740
- ### Label System Queries
741
-
742
- ```
743
- // Get all orders with 'featured' label
744
- $featuredOrders = App::db()->table('fct_orders')
745
- ->join('fct_label_relationships', 'fct_orders.id', '=', 'fct_label_relationships.labelable_id')
746
- ->join('fct_label', 'fct_label_relationships.label_id', '=', 'fct_label.id')
747
- ->where('fct_label_relationships.labelable_type', 'FluentCart\App\Models\Order')
748
- ->where('fct_label.value', 'featured')
749
- ->get();
750
-
751
- // Get all labels for a specific order
752
- $orderLabels = App::db()->table('fct_label_relationships')
753
- ->join('fct_label', 'fct_label_relationships.label_id', '=', 'fct_label.id')
754
- ->where('fct_label_relationships.labelable_id', 123)
755
- ->where('fct_label_relationships.labelable_type', 'FluentCart\App\Models\Order')
756
- ->pluck('fct_label.value');
757
- ```
758
-
759
- ### Scheduled Actions Queries
760
-
761
- ```
762
- // Get all pending scheduled actions that are due
763
- $dueActions = App::db()->table('fct_scheduled_actions')
764
- ->where('status', 'pending')
765
- ->where('scheduled_at', '<=', DateTime::gmtNow()->format('Y-m-d H:i:s'))
766
- ->orderBy('scheduled_at', 'asc')
767
- ->get();
768
-
769
- // Get failed actions that need retry
770
- $failedActions = App::db()->table('fct_scheduled_actions')
771
- ->where('status', 'failed')
772
- ->where('retry_count', '<', 3)
773
- ->get();
774
- ```
775
-
776
- ### Pro Licensing Queries
777
-
778
- ```
779
- // Get all active licenses for a customer
780
- $customerLicenses = App::db()->table('fct_licenses')
781
- ->where('customer_id', 123)
782
- ->where('status', 'active')
783
- ->where('expiration_date', '>', DateTime::gmtNow()->format('Y-m-d H:i:s'))
784
- ->get();
785
-
786
- // Get license activation count
787
- $activationCount = App::db()->table('fct_license_activations')
788
- ->where('license_id', 456)
789
- ->where('status', 'active')
790
- ->count();
791
-
792
- // Get all sites for a license, through fct_license_activations, which carries
793
- // both license_id and site_id.
794
- $licenseSites = App::db()->table('fct_license_sites')
795
- ->join('fct_license_activations', 'fct_license_sites.id', '=', 'fct_license_activations.site_id')
796
- ->where('fct_license_activations.license_id', 456)
797
- ->where('fct_license_activations.status', 'active')
798
- ->select(['fct_license_sites.id', 'fct_license_sites.site_url', 'fct_license_sites.server_version'])
799
- ->get();
800
- ```
801
-
802
- ### Webhook Logging Queries
803
-
804
- fct_webhook_logger is not populated
805
-
806
- The table is created by the migrator, but no code in FluentCart or FluentCart Pro reads or writes it, so it stays empty and no `status` value is ever stored. The queries below are kept for reference and will return no rows on a live store.
807
-
808
- ```
809
- // Get failed webhook deliveries
810
- $failedWebhooks = App::db()->table('fct_webhook_logger')
811
- ->where('status', 'failed')
812
- ->where('created_at', '>=', DateTime::gmtNow()->modify('-1 day')->format('Y-m-d H:i:s'))
813
- ->get();
814
-
815
- // Get webhook delivery statistics
816
- $webhookStats = App::db()->table('fct_webhook_logger')
817
- ->select('status', App::db()->raw('COUNT(*) as count'))
818
- ->where('created_at', '>=', DateTime::gmtNow()->modify('-1 week')->format('Y-m-d H:i:s'))
819
- ->groupBy('status')
820
- ->get();
821
- ```
822
-
823
- ### Complex E-commerce Queries
824
-
825
- ```
826
- // Get customer lifetime value with order count
827
- $customerStats = App::db()->table('fct_customers')
828
- ->leftJoin('fct_orders', 'fct_customers.id', '=', 'fct_orders.customer_id')
829
- ->select([
830
- 'fct_customers.id',
831
- 'fct_customers.email',
832
- 'fct_customers.first_name',
833
- 'fct_customers.last_name',
834
- App::db()->raw("COUNT({$wpdb->prefix}fct_orders.id) as order_count"),
835
- App::db()->raw("SUM({$wpdb->prefix}fct_orders.total_amount) as total_spent"),
836
- App::db()->raw("AVG({$wpdb->prefix}fct_orders.total_amount) as avg_order_value")
837
- ])
838
- ->where('fct_orders.payment_status', 'paid')
839
- ->groupBy('fct_customers.id', 'fct_customers.email', 'fct_customers.first_name', 'fct_customers.last_name')
840
- ->having('order_count', '>', 0)
841
- ->get();
842
-
843
- // Get product sales report with variations.
844
- // total_amount and line_total are BIGINT cents; divide by 100 for display.
845
- $productSales = App::db()->table('fct_order_items')
846
- ->join('fct_orders', 'fct_order_items.order_id', '=', 'fct_orders.id')
847
- ->leftJoin('fct_product_variations', 'fct_order_items.post_id', '=', 'fct_product_variations.post_id')
848
- ->select([
849
- 'fct_order_items.post_id',
850
- 'fct_product_variations.variation_title',
851
- App::db()->raw("SUM({$wpdb->prefix}fct_order_items.quantity) as total_sold"),
852
- App::db()->raw("SUM({$wpdb->prefix}fct_order_items.line_total) as total_revenue")
853
- ])
854
- ->where('fct_orders.payment_status', 'paid')
855
- ->groupBy('fct_order_items.post_id', 'fct_product_variations.variation_title')
856
- ->orderBy('total_revenue', 'desc')
857
- ->get();
858
- ```
859
-
860
- ---
1
+ # FluentCart Query Builder
2
+
3
+ ## Introduction
4
+
5
+ FluentCart uses an Eloquent-based ORM system compatible with Laravel's Eloquent ORM. You can interact with database tables through Model classes or using direct query builder methods.
6
+
7
+ TIP
8
+
9
+ FluentCart's ORM is compatible with Laravel Framework's Eloquent ORM. If you are familiar with Laravel's Eloquent, you will feel right at home using FluentCart's database system.
10
+
11
+ Every query-builder example on this page uses `App::db()`, so each needs:
12
+
13
+ ```
14
+ use FluentCart\App\App;
15
+ ```
16
+
17
+ Table names in raw SQL are not prefixed
18
+
19
+ `App::db()->table('fct_orders')` resolves the WordPress table prefix for you, but raw fragments passed to `raw()`, `selectRaw()`, `whereRaw()` or `havingRaw()` are sent to MySQL untouched. A raw fragment naming a table must interpolate the prefix itself:
20
+
21
+ ```
22
+ global $wpdb;
23
+ ->whereRaw("{$wpdb->prefix}fct_order_items.order_id = {$wpdb->prefix}fct_orders.id")
24
+ ```
25
+
26
+ Writing `fct_orders` in raw SQL fails with `Unknown column 'fct_orders.id'`.
27
+
28
+ Timestamps
29
+
30
+ Use `DateTime::gmtNow()` from `FluentCart\App\Services\DateTime\DateTime`, which returns UTC — all FluentCart timestamps are stored in GMT.
31
+
32
+ ```
33
+ use FluentCart\App\Services\DateTime\DateTime;
34
+
35
+ DateTime::gmtNow()->format('Y-m-d H:i:s'); // now
36
+ DateTime::gmtNow()->modify('-1 day')->format('Y-m-d H:i:s'); // 24 hours ago
37
+ ```
38
+
39
+ ### Example Using Models
40
+
41
+ Here is an example using FluentCart models:
42
+
43
+ ```
44
+ use FluentCart\App\Models\Order;
45
+
46
+ // Using the Order model
47
+ $orders = Order::where('payment_status', 'paid')
48
+ ->whereBetween('created_at', ['2024-01-01 00:00:00', '2024-12-30 23:59:59'])
49
+ ->when($customerId, function ($query) use ($customerId) {
50
+ return $query->where('customer_id', $customerId);
51
+ })
52
+ ->orderBy('created_at', 'ASC')
53
+ ->get();
54
+ ```
55
+
56
+ ### Example Using Query Builder
57
+
58
+ You can also use the query builder directly:
59
+
60
+ ```
61
+ use FluentCart\App\Models\Order;
62
+
63
+ $query = Order::query()
64
+ ->select(['total_amount', 'status', 'payment_method'])
65
+ ->where('payment_status', 'paid')
66
+ ->whereBetween('created_at', ['2024-01-01 00:00:00', '2024-12-30 23:59:59'])
67
+ ->when($customerId, function ($query) use ($customerId) {
68
+ return $query->where('customer_id', $customerId);
69
+ })
70
+ ->orderBy('created_at', 'ASC');
71
+ ```
72
+
73
+ ## Retrieving Results
74
+
75
+ ### Retrieving All Rows From A Table
76
+
77
+ You can use the model's query builder to retrieve all rows from a table. The query builder provides a fluent interface for building database queries:
78
+
79
+ ```
80
+ <?php
81
+
82
+ use FluentCart\App\Models\Order;
83
+
84
+ class OrderController extends Controller
85
+ {
86
+ /**
87
+ * Show a list of all the application's orders.
88
+ *
89
+ * @return Response
90
+ */
91
+ public function index()
92
+ {
93
+ $orders = Order::all();
94
+ // or using query builder
95
+ $orders = Order::query()->get();
96
+
97
+ return [
98
+ 'orders' => $orders
99
+ ];
100
+ }
101
+ }
102
+ ```
103
+
104
+ The `get` method returns a collection containing the results where each result is an instance of the Model object. You may access each column's value by accessing the column as a property of the object:
105
+
106
+ ```
107
+ foreach ($orders as $order) {
108
+ echo $order->total_amount;
109
+ }
110
+ ```
111
+
112
+ ### Retrieving A Single Row / Column From A Table
113
+
114
+ If you just need to retrieve a single row from the database table, you may use the `first` method. This method will return a single Model object:
115
+
116
+ ```
117
+ use FluentCart\App\Models\Order;
118
+
119
+ $order = Order::where('status', 'completed')->first();
120
+
121
+ echo $order->total_amount;
122
+ ```
123
+
124
+ If you don't even need an entire row, you may extract a single value from a record using the `value` method. This method will return the value of the column directly:
125
+
126
+ ```
127
+ use FluentCart\App\Models\Order;
128
+
129
+ $totalAmount = Order::where('status', 'completed')->value('total_amount');
130
+ ```
131
+
132
+ ### Retrieving A List Of Column Values
133
+
134
+ If you would like to retrieve an array containing the values of a single column, you may use the `pluck` method. In this example, we'll retrieve an array of order IDs:
135
+
136
+ ```
137
+ $orderIds = App::db()->table('fct_orders')->pluck('id');
138
+
139
+ foreach ($orderIds as $orderId) {
140
+ echo $orderId;
141
+ }
142
+ ```
143
+
144
+ You may also specify a custom key column for the returned Collection:
145
+
146
+ ```
147
+ $orderIds = App::db()->table('fct_orders')->pluck('id', 'customer_id');
148
+
149
+ foreach ($orderIds as $customerId => $orderId) {
150
+ echo $orderId;
151
+ }
152
+ ```
153
+
154
+ ### Chunking Results
155
+
156
+ If you need to work with thousands of database records, consider using the `chunk` method. This method retrieves a small chunk of the results at a time and feeds each chunk into a Closure for processing. This method is very useful for process thousands of records. For example, let's work with the entire `fct_orders` table in chunks of 100 records at a time:
157
+
158
+ ```
159
+ App::db()->table('fct_orders')->orderBy('id')->chunk(100, function ($orders) {
160
+ foreach ($orders as $order) {
161
+ //
162
+ }
163
+ });
164
+ ```
165
+
166
+ You may stop further chunks from being processed by returning false from the Closure:
167
+
168
+ ```
169
+ App::db()->table('fct_orders')->orderBy('id')->chunk(100, function ($orders) {
170
+ // Process the records...
171
+
172
+ return false;
173
+ });
174
+ ```
175
+
176
+ ### Aggregates
177
+
178
+ The query builder also provides a variety of aggregate methods such as `count`, `max`, `min`, `avg`, and `sum`. You may call any of these methods after constructing your query:
179
+
180
+ ```
181
+ $orders = App::db()->table('fct_orders')->count();
182
+
183
+ $maxAmount = App::db()->table('fct_orders')->max('total_amount');
184
+ ```
185
+
186
+ Of course, you may combine these methods with other clauses:
187
+
188
+ ```
189
+ $avgAmount = App::db()->table('fct_orders')
190
+ ->where('payment_status', 'paid')
191
+ ->avg('total_amount');
192
+ ```
193
+
194
+ ### Determining If Records Exist
195
+
196
+ Instead of using the `count` method to determine if any records exist that match your query's constraints, you may use the `exists`:
197
+
198
+ ```
199
+ return App::db()->table('fct_orders')->where('payment_status', 'paid')->exists();
200
+ ```
201
+
202
+ ## Selects
203
+
204
+ ### Specifying A Select Clause
205
+
206
+ Of course, you may not always want to select all columns from a database table. Using the `select` method, you can specify a custom `select` clause for the query:
207
+
208
+ ```
209
+ $orders = App::db()->table('fct_orders')->select('status', 'total_amount as order_total')->get();
210
+ ```
211
+
212
+ The `distinct` method allows you to force the query to return distinct results:
213
+
214
+ ```
215
+ $orders = App::db()->table('fct_orders')->distinct()->get();
216
+ ```
217
+
218
+ If you already have a query builder instance and wish to add a column to its existing select clause, you may use the `addSelect` method:
219
+
220
+ ```
221
+ $query = App::db()->table('fct_orders')->select('status');
222
+
223
+ $orders = $query->addSelect('total_amount')->get();
224
+ ```
225
+
226
+ ## Raw Expressions
227
+
228
+ Sometimes you may need to use a raw expression in a query. To create a raw expression, you may use the `raw` method:
229
+
230
+ ```
231
+ $orders = App::db()->table('fct_orders')
232
+ ->select(App::db()->raw('count(*) as order_count, status'))
233
+ ->where('status', '<>', 'draft')
234
+ ->groupBy('status')
235
+ ->get();
236
+ ```
237
+
238
+ ### Raw Methods
239
+
240
+ Instead of using `App::db()->raw`, you may also use the following methods to insert a raw expression into various parts of your query.
241
+
242
+ #### `selectRaw`
243
+
244
+ The `selectRaw` method can be used in place of `select(App::db()->raw(...))`. This method accepts an optional array of bindings as its second argument:
245
+
246
+ ```
247
+ $orders = App::db()->table('fct_orders')
248
+ ->selectRaw('total_amount * ? as price_with_tax', [1.0825])
249
+ ->get();
250
+ ```
251
+
252
+ #### `whereRaw / orWhereRaw`
253
+
254
+ The `whereRaw` and `orWhereRaw` methods can be used to inject a raw `where` clause into your query. These methods accept an optional array of bindings as their second argument:
255
+
256
+ ```
257
+ $orders = App::db()->table('fct_orders')
258
+ ->whereRaw('total_amount > (subtotal * 1.1)')
259
+ ->get();
260
+ ```
261
+
262
+ #### `havingRaw / orHavingRaw`
263
+
264
+ The `havingRaw` and `orHavingRaw` methods may be used to set a raw string as the value of the `having` clause. These methods accept an optional array of bindings as their second argument:
265
+
266
+ ```
267
+ $orders = App::db()->table('fct_orders')
268
+ ->select('customer_id', App::db()->raw('SUM(total_amount) as total'))
269
+ ->groupBy('customer_id')
270
+ ->havingRaw('SUM(total_amount) > ?', [1000])
271
+ ->get();
272
+ ```
273
+
274
+ #### `orderByRaw`
275
+
276
+ The `orderByRaw` method may be used to set a raw string as the value of the `order by` clause:
277
+
278
+ ```
279
+ $orders = App::db()->table('fct_orders')
280
+ ->orderByRaw('FIELD(status, "pending", "processing", "completed")')
281
+ ->get();
282
+ ```
283
+
284
+ ## Joins
285
+
286
+ ### Inner Join Statement
287
+
288
+ The query builder may also be used to write join statements. To perform a basic "inner join", you may use the `join` method on a query builder instance. The first argument passed to the `join` method is the name of the table you need to join to, while the remaining arguments specify the column constraints for the join. Of course, as you can see, you can join to multiple tables in a single query:
289
+
290
+ ```
291
+ $orders = App::db()->table('fct_orders')
292
+ ->join('fct_customers', 'fct_orders.customer_id', '=', 'fct_customers.id')
293
+ ->join('fct_order_items', 'fct_orders.id', '=', 'fct_order_items.order_id')
294
+ ->select('fct_orders.*', 'fct_customers.email', 'fct_customers.first_name')
295
+ ->get();
296
+ ```
297
+
298
+ ### Left Join / Right Join Statement
299
+
300
+ If you would like to perform a "left join" instead of an "inner join", use the `leftJoin` method. The `leftJoin` method has the same signature as the `join` method:
301
+
302
+ ```
303
+ $orders = App::db()->table('fct_orders')
304
+ ->leftJoin('fct_customers', 'fct_orders.customer_id', '=', 'fct_customers.id')
305
+ ->get();
306
+ ```
307
+
308
+ Similarly, you may use the `rightJoin` method to perform a "right join":
309
+
310
+ ```
311
+ $orders = App::db()->table('fct_orders')
312
+ ->rightJoin('fct_customers', 'fct_orders.customer_id', '=', 'fct_customers.id')
313
+ ->get();
314
+ ```
315
+
316
+ ### Cross Join Statement
317
+
318
+ To perform a "cross join" use the `crossJoin` method with the name of the table you wish to cross join to. Cross joins generate a cartesian product between the first table and the joined table:
319
+
320
+ ```
321
+ $products = App::db()->table('fct_product_details')
322
+ ->crossJoin('fct_product_variations')
323
+ ->get();
324
+ ```
325
+
326
+ ### Advanced Join Clauses
327
+
328
+ You may also specify more advanced join clauses. To get started, pass a `Closure` as the second argument into the `join` method. The `Closure` will receive a `JoinClause` object which allows you to specify constraints on the `join` clause:
329
+
330
+ ```
331
+ App::db()->table('fct_orders')
332
+ ->join('fct_customers', function ($join) {
333
+ $join->on('fct_orders.customer_id', '=', 'fct_customers.id')
334
+ ->where('fct_customers.status', '=', 'active');
335
+ })
336
+ ->get();
337
+ ```
338
+
339
+ ### Subquery Joins
340
+
341
+ You may use the `joinSub`, `leftJoinSub`, and `rightJoinSub` methods to join a query to a subquery. Each of these methods receive three arguments: the subquery, its table alias, and a Closure that defines the related columns:
342
+
343
+ ```
344
+ $latestOrders = App::db()->table('fct_orders')
345
+ ->select('customer_id', App::db()->raw('MAX(created_at) as last_order_date'))
346
+ ->groupBy('customer_id');
347
+
348
+ $customers = App::db()->table('fct_customers')
349
+ ->joinSub($latestOrders, 'latest_orders', function ($join) {
350
+ $join->on('fct_customers.id', '=', 'latest_orders.customer_id');
351
+ })->get();
352
+ ```
353
+
354
+ ## Unions
355
+
356
+ The query builder also provides a quick way to "union" two or more queries together. For example, you may create an initial query and use the `union` method to union it with a second query:
357
+
358
+ ```
359
+ $first = App::db()->table('fct_orders')
360
+ ->whereNull('completed_at');
361
+
362
+ $orders = App::db()->table('fct_orders')
363
+ ->whereNull('cancelled_at')
364
+ ->union($first)
365
+ ->get();
366
+ ```
367
+
368
+ The `unionAll` method may also be used and has the same method signature as `union`. The difference between `union` and `unionAll` is that `unionAll` will not remove duplicate entries from your resultset.
369
+
370
+ ## Where Clauses
371
+
372
+ ### Simple Where Clauses
373
+
374
+ You may use the `where` method on a query builder instance to add `where` clauses to the query. The most basic call to `where` requires three arguments. The first argument is the name of the column. The second argument is an operator, which can be any of the database's supported operators. Finally, the third argument is the value to evaluate against the column.
375
+
376
+ For example, here is a query that verifies the value of a "status" column equals "completed":
377
+
378
+ ```
379
+ $orders = App::db()->table('fct_orders')->where('status', '=', 'completed')->get();
380
+ ```
381
+
382
+ For convenience, if you want to verify that a column is equal to a given value, you may pass the value directly as the second argument to the `where` method:
383
+
384
+ ```
385
+ $orders = App::db()->table('fct_orders')->where('status', 'completed')->get();
386
+ ```
387
+
388
+ Of course, you may use a variety of other operators when writing a `where` clause:
389
+
390
+ ```
391
+ $orders = App::db()->table('fct_orders')->where('total_amount', '>', 1000)->get();
392
+
393
+ $orders = App::db()->table('fct_orders')->where('total_amount', '>=', 1000)->get();
394
+
395
+ $orders = App::db()->table('fct_orders')->where('total_amount', '<', 1000)->get();
396
+
397
+ $orders = App::db()->table('fct_orders')->where('total_amount', '<=', 1000)->get();
398
+
399
+ $orders = App::db()->table('fct_orders')->where('status', '!=', 'draft')->get();
400
+
401
+ $orders = App::db()->table('fct_orders')->where('status', '<>', 'draft')->get();
402
+ ```
403
+
404
+ ### Or Statements
405
+
406
+ You may chain where constraints together as well as add `or` clauses to the query. The `orWhere` method accepts the same arguments as the `where` method:
407
+
408
+ ```
409
+ $orders = App::db()->table('fct_orders')
410
+ ->where('status', 'completed')
411
+ ->orWhere('payment_status', 'paid')
412
+ ->get();
413
+ ```
414
+
415
+ ### Additional Where Clauses
416
+
417
+ #### whereBetween / orWhereBetween
418
+
419
+ The `whereBetween` method verifies that a column's value is between two values:
420
+
421
+ ```
422
+ $orders = App::db()->table('fct_orders')
423
+ ->whereBetween('total_amount', [100, 500])
424
+ ->get();
425
+ ```
426
+
427
+ The `orWhereBetween` method verifies that a column's value is outside of two values:
428
+
429
+ ```
430
+ $orders = App::db()->table('fct_orders')
431
+ ->whereNotBetween('total_amount', [100, 500])
432
+ ->get();
433
+ ```
434
+
435
+ #### whereIn / whereNotIn / orWhereIn / orWhereNotIn
436
+
437
+ The `whereIn` method verifies that a given column's value is contained within the given array:
438
+
439
+ ```
440
+ $orders = App::db()->table('fct_orders')
441
+ ->whereIn('status', ['pending', 'processing', 'completed'])
442
+ ->get();
443
+ ```
444
+
445
+ The `whereNotIn` method verifies that the given column's value is not contained in the given array:
446
+
447
+ ```
448
+ $orders = App::db()->table('fct_orders')
449
+ ->whereNotIn('status', ['canceled', 'expired'])
450
+ ->get();
451
+ ```
452
+
453
+ #### whereNull / whereNotNull / orWhereNull / orWhereNotNull
454
+
455
+ The `whereNull` method verifies that the value of the given column is `NULL`:
456
+
457
+ ```
458
+ $orders = App::db()->table('fct_orders')
459
+ ->whereNull('completed_at')
460
+ ->get();
461
+ ```
462
+
463
+ The `whereNotNull` method verifies that the column's value is not `NULL`:
464
+
465
+ ```
466
+ $orders = App::db()->table('fct_orders')
467
+ ->whereNotNull('completed_at')
468
+ ->get();
469
+ ```
470
+
471
+ #### whereDate / whereYear
472
+
473
+ The `whereDate` method may be used to compare a column's value against a date:
474
+
475
+ ```
476
+ $orders = App::db()->table('fct_orders')
477
+ ->whereDate('created_at', '2024-12-31')
478
+ ->get();
479
+ ```
480
+
481
+ The `whereYear` method may be used to compare a column's value against a specific year:
482
+
483
+ ```
484
+ $orders = App::db()->table('fct_orders')
485
+ ->whereYear('created_at', '2024')
486
+ ->get();
487
+ ```
488
+
489
+ ### Parameter Grouping
490
+
491
+ Sometimes you may need to create more advanced where clauses such as "where exists" or nested parameter groupings. The FluentCart query builder can handle these as well. To get started, let's look at an example of grouping constraints within parenthesis:
492
+
493
+ ```
494
+ App::db()->table('fct_orders')
495
+ ->where('status', '=', 'completed')
496
+ ->where(function ($query) {
497
+ $query->where('total_amount', '>', 1000)
498
+ ->orWhere('payment_method', '=', 'stripe');
499
+ })
500
+ ->get();
501
+ ```
502
+
503
+ As you can see, passing a `Closure` into the `where` method instructs the query builder to begin a constraint group. The `Closure` will receive a query builder instance which you can use to set the constraints that should be contained within the parenthesis group. The example above will produce the following SQL:
504
+
505
+ ```
506
+ select * from fct_orders where status = 'completed' and (total_amount > 1000 or payment_method = 'stripe')
507
+ ```
508
+
509
+ ### Where Exists Clauses
510
+
511
+ The `whereExists` method allows you to write `where exists` SQL clauses. The `whereExists` method accepts a `Closure` argument, which will receive a query builder instance allowing you to define the query that should be placed inside the "exists" clause:
512
+
513
+ ```
514
+ global $wpdb;
515
+
516
+ App::db()->table('fct_orders')
517
+ ->whereExists(function ($query) use ($wpdb) {
518
+ $query->select(App::db()->raw(1))
519
+ ->from('fct_order_items')
520
+ ->whereRaw("{$wpdb->prefix}fct_order_items.order_id = {$wpdb->prefix}fct_orders.id");
521
+ })
522
+ ->get();
523
+ ```
524
+
525
+ The query above will produce the following SQL:
526
+
527
+ ```
528
+ select * from fct_orders
529
+ where exists (
530
+ select 1 from fct_order_items where fct_order_items.order_id = fct_orders.id
531
+ )
532
+ ```
533
+
534
+ ### Ordering, Grouping, Limit, & Offset
535
+
536
+ #### orderBy
537
+
538
+ The `orderBy` method allows you to sort the result of the query by a given column. The first argument to the `orderBy` method should be the column you wish to sort by, while the second argument controls the direction of the sort and may be either `asc` or `desc`:
539
+
540
+ ```
541
+ $orders = App::db()->table('fct_orders')
542
+ ->orderBy('created_at', 'DESC')
543
+ ->get();
544
+ ```
545
+
546
+ #### latest / oldest
547
+
548
+ The `latest` and `oldest` methods allow you to easily order results by date. By default, result will be ordered by the `created_at` column. Or, you may pass the column name that you wish to sort by:
549
+
550
+ ```
551
+ $orders = App::db()->table('fct_orders')
552
+ ->latest()
553
+ ->get();
554
+ ```
555
+
556
+ #### groupBy / having
557
+
558
+ The `groupBy` and `having` methods may be used to group the query results. The `having` method's signature is similar to that of the `where` method:
559
+
560
+ ```
561
+ $orders = App::db()->table('fct_orders')
562
+ ->groupBy('customer_id')
563
+ ->having('customer_id', '>', 100)
564
+ ->get();
565
+ ```
566
+
567
+ You may pass multiple arguments to the `groupBy` method to group by multiple columns:
568
+
569
+ ```
570
+ $orders = App::db()->table('fct_orders')
571
+ ->groupBy('customer_id', 'status')
572
+ ->having('customer_id', '>', 100)
573
+ ->get();
574
+ ```
575
+
576
+ #### skip / take
577
+
578
+ To limit the number of results returned from the query, or to skip a given number of results in the query, you may use the `skip` and `take` methods:
579
+
580
+ ```
581
+ $orders = App::db()->table('fct_orders')
582
+ ->skip(10)
583
+ ->take(5)
584
+ ->get();
585
+ ```
586
+
587
+ Alternatively, you may use the `limit` and `offset` methods:
588
+
589
+ ```
590
+ $orders = App::db()->table('fct_orders')
591
+ ->limit(10)
592
+ ->offset(5)
593
+ ->get();
594
+ ```
595
+
596
+ ### Conditional Clauses
597
+
598
+ Sometimes you may want clauses to apply to a query only when something else is true. For instance, you may only want to apply a `where` statement if a given input value is present on the incoming request. You may accomplish this using `when` method:
599
+
600
+ ```
601
+ $customerId = $request->get('customer_id');
602
+
603
+ $orders = App::db()->table('fct_orders')
604
+ ->when($customerId, function ($query, $customerId) {
605
+ return $query->where('customer_id', $customerId);
606
+ })
607
+ ->get();
608
+ ```
609
+
610
+ The `when` method only executes the given `Closure` when the first parameter is `true`. If the first parameter is `false`, the Closure will not be executed.
611
+
612
+ You may pass another Closure as the third parameter to the `when` method. This Closure will execute if the first parameter evaluates as `false`. To illustrate how this feature may be used, we will use it to configure the default sorting of a query:
613
+
614
+ ```
615
+ $sortBy = null;
616
+
617
+ $orders = App::db()->table('fct_orders')
618
+ ->when($sortBy, function ($query, $sortBy) {
619
+ return $query->orderBy($sortBy);
620
+ }, function ($query) {
621
+ return $query->orderBy('created_at');
622
+ })
623
+ ->get();
624
+ ```
625
+
626
+ ## Inserts
627
+
628
+ The query builder also provides an `insert` method for inserting records into the database table. The `insert` method accepts an array of column names and values:
629
+
630
+ ```
631
+ App::db()->table('fct_orders')->insert(
632
+ ['customer_id' => 1, 'status' => 'pending', 'total_amount' => 1000]
633
+ );
634
+ ```
635
+
636
+ You may even insert several records into the table with a single call to `insert` by passing an array of arrays. Each array represents a row to be inserted into the table:
637
+
638
+ ```
639
+ App::db()->table('fct_orders')->insert([
640
+ ['customer_id' => 1, 'status' => 'pending', 'total_amount' => 1000],
641
+ ['customer_id' => 2, 'status' => 'processing', 'total_amount' => 2000]
642
+ ]);
643
+ ```
644
+
645
+ ### Auto-Incrementing IDs
646
+
647
+ If the table has an auto-incrementing id, use the `insertGetId` method to insert a record and then retrieve the ID:
648
+
649
+ ```
650
+ App::db()->table('fct_orders')->insertGetId(
651
+ ['customer_id' => 1, 'status' => 'pending', 'total_amount' => 1000]
652
+ );
653
+ ```
654
+
655
+ ## Updates
656
+
657
+ Of course, in addition to inserting records into the database, the query builder can also update existing records using the `update` method. The `update` method, like the `insert` method, accepts an array of column and value pairs containing the columns to be updated. You may constrain the `update` query using `where` clauses:
658
+
659
+ ```
660
+ App::db()->table('fct_orders')
661
+ ->where('id', 1)
662
+ ->update(['status' => 'completed']);
663
+ ```
664
+
665
+ ## Increment & Decrement
666
+
667
+ The query builder also provides convenient methods for incrementing or decrementing the value of a given column. This is useful for updating stock quantities or order counts.
668
+
669
+ Both of these methods accept at least one argument: the column to modify. A second argument may optionally be passed to control the amount by which the column should be incremented or decremented:
670
+
671
+ ```
672
+ // Decrement product stock when order is placed
673
+ App::db()->table('fct_product_variations')->decrement('available', 1);
674
+
675
+ // Increment the customer's purchase count
676
+ App::db()->table('fct_customers')->increment('purchase_count');
677
+ ```
678
+
679
+ You may also specify additional columns to update during the operation:
680
+
681
+ ```
682
+ App::db()->table('fct_product_variations')
683
+ ->decrement('available', 1, ['updated_at' => DateTime::gmtNow()->format('Y-m-d H:i:s')]);
684
+ ```
685
+
686
+ ## Deletes
687
+
688
+ The query builder may also be used to delete records from the table via the `delete` method. You may constrain delete statements by adding where clauses before calling the `delete` method:
689
+
690
+ ```
691
+ App::db()->table('fct_orders')->delete();
692
+
693
+ App::db()->table('fct_orders')->where('status', 'draft')->delete();
694
+ ```
695
+
696
+ If you wish to truncate the entire table, which will remove all rows and reset the auto-incrementing ID to zero, you may use the `truncate` method:
697
+
698
+ ```
699
+ App::db()->table('fct_orders')->truncate();
700
+ ```
701
+
702
+ ## FluentCart-Specific Query Examples
703
+
704
+ ### Activity Logging Queries
705
+
706
+ ```
707
+ // Get all activities for a specific order
708
+ $orderActivities = App::db()->table('fct_activity')
709
+ ->where('module_type', 'FluentCart\App\Models\Order')
710
+ ->where('module_id', 123)
711
+ ->orderBy('created_at', 'desc')
712
+ ->get();
713
+
714
+ // Get failed activities in the last 24 hours.
715
+ // The logger writes info / success / warning / error.
716
+ $failedActivities = App::db()->table('fct_activity')
717
+ ->where('status', 'error')
718
+ ->where('created_at', '>=', DateTime::gmtNow()->modify('-1 day')->format('Y-m-d H:i:s'))
719
+ ->get();
720
+ ```
721
+
722
+ ### Attribute System Queries
723
+
724
+ ```
725
+ // Get all products with specific color attribute
726
+ $redProducts = App::db()->table('fct_atts_relations')
727
+ ->join('fct_atts_terms', 'fct_atts_relations.term_id', '=', 'fct_atts_terms.id')
728
+ ->join('fct_atts_groups', 'fct_atts_relations.group_id', '=', 'fct_atts_groups.id')
729
+ ->where('fct_atts_groups.slug', 'color')
730
+ ->where('fct_atts_terms.slug', 'red')
731
+ ->pluck('object_id');
732
+
733
+ // Get all attribute groups with their terms
734
+ $attributeGroups = App::db()->table('fct_atts_groups')
735
+ ->leftJoin('fct_atts_terms', 'fct_atts_groups.id', '=', 'fct_atts_terms.group_id')
736
+ ->select('fct_atts_groups.*', 'fct_atts_terms.title as term_title')
737
+ ->get();
738
+ ```
739
+
740
+ ### Label System Queries
741
+
742
+ ```
743
+ // Get all orders with 'featured' label
744
+ $featuredOrders = App::db()->table('fct_orders')
745
+ ->join('fct_label_relationships', 'fct_orders.id', '=', 'fct_label_relationships.labelable_id')
746
+ ->join('fct_label', 'fct_label_relationships.label_id', '=', 'fct_label.id')
747
+ ->where('fct_label_relationships.labelable_type', 'FluentCart\App\Models\Order')
748
+ ->where('fct_label.value', 'featured')
749
+ ->get();
750
+
751
+ // Get all labels for a specific order
752
+ $orderLabels = App::db()->table('fct_label_relationships')
753
+ ->join('fct_label', 'fct_label_relationships.label_id', '=', 'fct_label.id')
754
+ ->where('fct_label_relationships.labelable_id', 123)
755
+ ->where('fct_label_relationships.labelable_type', 'FluentCart\App\Models\Order')
756
+ ->pluck('fct_label.value');
757
+ ```
758
+
759
+ ### Scheduled Actions Queries
760
+
761
+ ```
762
+ // Get all pending scheduled actions that are due
763
+ $dueActions = App::db()->table('fct_scheduled_actions')
764
+ ->where('status', 'pending')
765
+ ->where('scheduled_at', '<=', DateTime::gmtNow()->format('Y-m-d H:i:s'))
766
+ ->orderBy('scheduled_at', 'asc')
767
+ ->get();
768
+
769
+ // Get failed actions that need retry
770
+ $failedActions = App::db()->table('fct_scheduled_actions')
771
+ ->where('status', 'failed')
772
+ ->where('retry_count', '<', 3)
773
+ ->get();
774
+ ```
775
+
776
+ ### Pro Licensing Queries
777
+
778
+ ```
779
+ // Get all active licenses for a customer
780
+ $customerLicenses = App::db()->table('fct_licenses')
781
+ ->where('customer_id', 123)
782
+ ->where('status', 'active')
783
+ ->where('expiration_date', '>', DateTime::gmtNow()->format('Y-m-d H:i:s'))
784
+ ->get();
785
+
786
+ // Get license activation count
787
+ $activationCount = App::db()->table('fct_license_activations')
788
+ ->where('license_id', 456)
789
+ ->where('status', 'active')
790
+ ->count();
791
+
792
+ // Get all sites for a license, through fct_license_activations, which carries
793
+ // both license_id and site_id.
794
+ $licenseSites = App::db()->table('fct_license_sites')
795
+ ->join('fct_license_activations', 'fct_license_sites.id', '=', 'fct_license_activations.site_id')
796
+ ->where('fct_license_activations.license_id', 456)
797
+ ->where('fct_license_activations.status', 'active')
798
+ ->select(['fct_license_sites.id', 'fct_license_sites.site_url', 'fct_license_sites.server_version'])
799
+ ->get();
800
+ ```
801
+
802
+ ### Webhook Logging Queries
803
+
804
+ fct_webhook_logger is not populated
805
+
806
+ The table is created by the migrator, but no code in FluentCart or FluentCart Pro reads or writes it, so it stays empty and no `status` value is ever stored. The queries below are kept for reference and will return no rows on a live store.
807
+
808
+ ```
809
+ // Get failed webhook deliveries
810
+ $failedWebhooks = App::db()->table('fct_webhook_logger')
811
+ ->where('status', 'failed')
812
+ ->where('created_at', '>=', DateTime::gmtNow()->modify('-1 day')->format('Y-m-d H:i:s'))
813
+ ->get();
814
+
815
+ // Get webhook delivery statistics
816
+ $webhookStats = App::db()->table('fct_webhook_logger')
817
+ ->select('status', App::db()->raw('COUNT(*) as count'))
818
+ ->where('created_at', '>=', DateTime::gmtNow()->modify('-1 week')->format('Y-m-d H:i:s'))
819
+ ->groupBy('status')
820
+ ->get();
821
+ ```
822
+
823
+ ### Complex E-commerce Queries
824
+
825
+ ```
826
+ // Get customer lifetime value with order count
827
+ $customerStats = App::db()->table('fct_customers')
828
+ ->leftJoin('fct_orders', 'fct_customers.id', '=', 'fct_orders.customer_id')
829
+ ->select([
830
+ 'fct_customers.id',
831
+ 'fct_customers.email',
832
+ 'fct_customers.first_name',
833
+ 'fct_customers.last_name',
834
+ App::db()->raw("COUNT({$wpdb->prefix}fct_orders.id) as order_count"),
835
+ App::db()->raw("SUM({$wpdb->prefix}fct_orders.total_amount) as total_spent"),
836
+ App::db()->raw("AVG({$wpdb->prefix}fct_orders.total_amount) as avg_order_value")
837
+ ])
838
+ ->where('fct_orders.payment_status', 'paid')
839
+ ->groupBy('fct_customers.id', 'fct_customers.email', 'fct_customers.first_name', 'fct_customers.last_name')
840
+ ->having('order_count', '>', 0)
841
+ ->get();
842
+
843
+ // Get product sales report with variations.
844
+ // total_amount and line_total are BIGINT cents; divide by 100 for display.
845
+ $productSales = App::db()->table('fct_order_items')
846
+ ->join('fct_orders', 'fct_order_items.order_id', '=', 'fct_orders.id')
847
+ ->leftJoin('fct_product_variations', 'fct_order_items.post_id', '=', 'fct_product_variations.post_id')
848
+ ->select([
849
+ 'fct_order_items.post_id',
850
+ 'fct_product_variations.variation_title',
851
+ App::db()->raw("SUM({$wpdb->prefix}fct_order_items.quantity) as total_sold"),
852
+ App::db()->raw("SUM({$wpdb->prefix}fct_order_items.line_total) as total_revenue")
853
+ ])
854
+ ->where('fct_orders.payment_status', 'paid')
855
+ ->groupBy('fct_order_items.post_id', 'fct_product_variations.variation_title')
856
+ ->orderBy('total_revenue', 'desc')
857
+ ->get();
858
+ ```
859
+
860
+ ---