fluentcart-developer 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (612) 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/server.d.ts.map +1 -1
  6. package/dist/server.js +37 -1
  7. package/dist/server.js.map +1 -1
  8. package/dist/skills/fluentcart-developer/SKILL.md +108 -108
  9. package/dist/skills/fluentcart-developer/examples/README.md +30 -30
  10. package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/fluent-cart/checkout.php +32 -32
  11. package/dist/skills/fluentcart-developer/examples/fluentcart-starter-child-theme/functions.php +40 -40
  12. package/dist/skills/fluentcart-developer/examples/sample-custom-addon/fluentcart-custom-addon.php +113 -113
  13. package/dist/skills/fluentcart-developer/examples/sample-custom-payment-gateway/fluentcart-custom-gateway-example.php +148 -148
  14. package/dist/skills/fluentcart-developer/examples/sample-fee-surcharge-plugin/fluentcart-fee-surcharge.php +38 -38
  15. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/README.md +22 -22
  16. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/sample-plugin-with-licensing-sdk.php +79 -79
  17. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/FluentLicensing.php +303 -303
  18. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/LicenseSettings.php +566 -566
  19. package/dist/skills/fluentcart-developer/examples/sample-plugin-with-licensing-sdk/updater/PluginUpdater.php +304 -304
  20. package/dist/skills/fluentcart-developer/examples/sample-shipping-carrier/fluentcart-custom-shipping-carrier.php +61 -61
  21. package/dist/skills/fluentcart-developer/references/api/authentication.md +452 -452
  22. package/dist/skills/fluentcart-developer/references/api/coupons.md +786 -786
  23. package/dist/skills/fluentcart-developer/references/api/customers.md +889 -889
  24. package/dist/skills/fluentcart-developer/references/api/files.md +609 -609
  25. package/dist/skills/fluentcart-developer/references/api/index.md +432 -432
  26. package/dist/skills/fluentcart-developer/references/api/licensing.md +633 -633
  27. package/dist/skills/fluentcart-developer/references/api/order-bump.md +384 -384
  28. package/dist/skills/fluentcart-developer/references/api/orders.md +814 -814
  29. package/dist/skills/fluentcart-developer/references/api/products.md +866 -866
  30. package/dist/skills/fluentcart-developer/references/api/roles-permissions.md +536 -536
  31. package/dist/skills/fluentcart-developer/references/api/subscriptions.md +827 -827
  32. package/dist/skills/fluentcart-developer/references/database/index.md +44 -44
  33. package/dist/skills/fluentcart-developer/references/database/models/activity.md +178 -178
  34. package/dist/skills/fluentcart-developer/references/database/models/applied-coupon.md +291 -291
  35. package/dist/skills/fluentcart-developer/references/database/models/attribute-group.md +239 -239
  36. package/dist/skills/fluentcart-developer/references/database/models/attribute-relation.md +181 -181
  37. package/dist/skills/fluentcart-developer/references/database/models/attribute-term.md +219 -219
  38. package/dist/skills/fluentcart-developer/references/database/models/cart.md +645 -645
  39. package/dist/skills/fluentcart-developer/references/database/models/coupon.md +427 -427
  40. package/dist/skills/fluentcart-developer/references/database/models/customer-addresses.md +348 -348
  41. package/dist/skills/fluentcart-developer/references/database/models/customer-meta.md +156 -156
  42. package/dist/skills/fluentcart-developer/references/database/models/customer.md +584 -584
  43. package/dist/skills/fluentcart-developer/references/database/models/dynamic-model.md +163 -163
  44. package/dist/skills/fluentcart-developer/references/database/models/label-relationship.md +155 -155
  45. package/dist/skills/fluentcart-developer/references/database/models/label.md +153 -153
  46. package/dist/skills/fluentcart-developer/references/database/models/license-activation.md +182 -182
  47. package/dist/skills/fluentcart-developer/references/database/models/license-meta.md +163 -163
  48. package/dist/skills/fluentcart-developer/references/database/models/license-site.md +208 -208
  49. package/dist/skills/fluentcart-developer/references/database/models/license.md +640 -640
  50. package/dist/skills/fluentcart-developer/references/database/models/meta.md +233 -233
  51. package/dist/skills/fluentcart-developer/references/database/models/order-address.md +391 -391
  52. package/dist/skills/fluentcart-developer/references/database/models/order-download-permission.md +144 -144
  53. package/dist/skills/fluentcart-developer/references/database/models/order-item.md +383 -383
  54. package/dist/skills/fluentcart-developer/references/database/models/order-meta.md +303 -303
  55. package/dist/skills/fluentcart-developer/references/database/models/order-operation.md +158 -158
  56. package/dist/skills/fluentcart-developer/references/database/models/order-promotion-stat.md +175 -175
  57. package/dist/skills/fluentcart-developer/references/database/models/order-promotion.md +250 -250
  58. package/dist/skills/fluentcart-developer/references/database/models/order-tax-rate.md +172 -172
  59. package/dist/skills/fluentcart-developer/references/database/models/order-transaction.md +440 -440
  60. package/dist/skills/fluentcart-developer/references/database/models/order.md +727 -727
  61. package/dist/skills/fluentcart-developer/references/database/models/product-detail.md +397 -397
  62. package/dist/skills/fluentcart-developer/references/database/models/product-download.md +258 -258
  63. package/dist/skills/fluentcart-developer/references/database/models/product-meta.md +153 -153
  64. package/dist/skills/fluentcart-developer/references/database/models/product-variation.md +556 -556
  65. package/dist/skills/fluentcart-developer/references/database/models/product.md +580 -580
  66. package/dist/skills/fluentcart-developer/references/database/models/relationships.md +427 -427
  67. package/dist/skills/fluentcart-developer/references/database/models/scheduled-action.md +175 -175
  68. package/dist/skills/fluentcart-developer/references/database/models/shipping-class.md +148 -148
  69. package/dist/skills/fluentcart-developer/references/database/models/shipping-method.md +280 -280
  70. package/dist/skills/fluentcart-developer/references/database/models/shipping-zone.md +205 -205
  71. package/dist/skills/fluentcart-developer/references/database/models/subscription-meta.md +173 -173
  72. package/dist/skills/fluentcart-developer/references/database/models/subscription.md +528 -528
  73. package/dist/skills/fluentcart-developer/references/database/models/tax-class.md +195 -195
  74. package/dist/skills/fluentcart-developer/references/database/models/tax-rate.md +225 -225
  75. package/dist/skills/fluentcart-developer/references/database/models/user-meta.md +166 -166
  76. package/dist/skills/fluentcart-developer/references/database/models/user.md +220 -220
  77. package/dist/skills/fluentcart-developer/references/database/models.md +404 -404
  78. package/dist/skills/fluentcart-developer/references/database/query-builder.md +860 -860
  79. package/dist/skills/fluentcart-developer/references/database/readme.md +276 -276
  80. package/dist/skills/fluentcart-developer/references/database/schema.md +1002 -1002
  81. package/dist/skills/fluentcart-developer/references/engineering/adding-custom-pages-to-the-customer-dashboard.md +395 -395
  82. package/dist/skills/fluentcart-developer/references/engineering/index.md +4 -4
  83. package/dist/skills/fluentcart-developer/references/engineering.md +4 -4
  84. package/dist/skills/fluentcart-developer/references/getting-started.md +249 -249
  85. package/dist/skills/fluentcart-developer/references/guides/frontend.md +519 -519
  86. package/dist/skills/fluentcart-developer/references/guides/index.md +107 -107
  87. package/dist/skills/fluentcart-developer/references/guides/integrations.md +600 -600
  88. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/index.md +237 -237
  89. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/labels-and-tracking.md +481 -481
  90. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/live-rates.md +269 -269
  91. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/reference.md +223 -223
  92. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier/settings.md +370 -370
  93. package/dist/skills/fluentcart-developer/references/guides/shipping-carrier.md +237 -237
  94. package/dist/skills/fluentcart-developer/references/guides/subscriptions.md +217 -217
  95. package/dist/skills/fluentcart-developer/references/hooks/actions/admin-and-templates.md +1079 -1079
  96. package/dist/skills/fluentcart-developer/references/hooks/actions/cart-and-checkout.md +1795 -1795
  97. package/dist/skills/fluentcart-developer/references/hooks/actions/customers-and-users.md +327 -327
  98. package/dist/skills/fluentcart-developer/references/hooks/actions/licenses.md +829 -829
  99. package/dist/skills/fluentcart-developer/references/hooks/actions/modules.md +81 -81
  100. package/dist/skills/fluentcart-developer/references/hooks/actions/orders.md +757 -757
  101. package/dist/skills/fluentcart-developer/references/hooks/actions/payments-and-integrations.md +1163 -1163
  102. package/dist/skills/fluentcart-developer/references/hooks/actions/pro-modules.md +219 -219
  103. package/dist/skills/fluentcart-developer/references/hooks/actions/products-and-coupons.md +1019 -1019
  104. package/dist/skills/fluentcart-developer/references/hooks/actions/subscriptions.md +1290 -1290
  105. package/dist/skills/fluentcart-developer/references/hooks/actions.md +16 -16
  106. package/dist/skills/fluentcart-developer/references/hooks/deprecated.md +60 -60
  107. package/dist/skills/fluentcart-developer/references/hooks/filters/cart-and-checkout.md +2032 -2032
  108. package/dist/skills/fluentcart-developer/references/hooks/filters/customers-and-subscriptions.md +1746 -1746
  109. package/dist/skills/fluentcart-developer/references/hooks/filters/integrations-and-advanced.md +2439 -2439
  110. package/dist/skills/fluentcart-developer/references/hooks/filters/modules.md +464 -464
  111. package/dist/skills/fluentcart-developer/references/hooks/filters/orders-and-payments.md +2658 -2658
  112. package/dist/skills/fluentcart-developer/references/hooks/filters/pro-modules.md +502 -502
  113. package/dist/skills/fluentcart-developer/references/hooks/filters/products-and-pricing.md +1785 -1785
  114. package/dist/skills/fluentcart-developer/references/hooks/filters/settings-and-configuration.md +2966 -2966
  115. package/dist/skills/fluentcart-developer/references/hooks/filters.md +14 -14
  116. package/dist/skills/fluentcart-developer/references/hooks/index.md +35 -35
  117. package/dist/skills/fluentcart-developer/references/index.md +625 -625
  118. package/dist/skills/fluentcart-developer/references/modules/fee-system.md +427 -427
  119. package/dist/skills/fluentcart-developer/references/modules/ghost-product-selling.md +440 -440
  120. package/dist/skills/fluentcart-developer/references/modules/index.md +484 -484
  121. package/dist/skills/fluentcart-developer/references/modules/licensing.md +342 -342
  122. package/dist/skills/fluentcart-developer/references/modules/order-bump.md +433 -433
  123. package/dist/skills/fluentcart-developer/references/modules/payment-methods.md +129 -129
  124. package/dist/skills/fluentcart-developer/references/modules/refunds.md +170 -170
  125. package/dist/skills/fluentcart-developer/references/modules/shipping.md +846 -846
  126. package/dist/skills/fluentcart-developer/references/modules/storage.md +986 -986
  127. package/dist/skills/fluentcart-developer/references/modules/subscription-vendor-ids.md +186 -186
  128. package/dist/skills/fluentcart-developer/references/modules/subscriptions.md +678 -678
  129. package/dist/skills/fluentcart-developer/references/payment-methods-integration/index.md +164 -164
  130. package/dist/skills/fluentcart-developer/references/payment-methods-integration/paddle-example.md +1648 -1648
  131. package/dist/skills/fluentcart-developer/references/payment-methods-integration/payment/setting/fields.md +353 -353
  132. package/dist/skills/fluentcart-developer/references/payment-methods-integration/quick-implementation.md +1079 -1079
  133. package/dist/skills/fluentcart-developer/references/payment-methods-integration.md +164 -164
  134. package/dist/skills/fluentcart-developer/references/restapi/checkout.md +573 -573
  135. package/dist/skills/fluentcart-developer/references/restapi/coupons.md +958 -958
  136. package/dist/skills/fluentcart-developer/references/restapi/customer-profile.md +1423 -1423
  137. package/dist/skills/fluentcart-developer/references/restapi/customers.md +1103 -1103
  138. package/dist/skills/fluentcart-developer/references/restapi/dashboard.md +1083 -1083
  139. package/dist/skills/fluentcart-developer/references/restapi/data-export.md +132 -132
  140. package/dist/skills/fluentcart-developer/references/restapi/email-notifications.md +846 -846
  141. package/dist/skills/fluentcart-developer/references/restapi/files.md +313 -313
  142. package/dist/skills/fluentcart-developer/references/restapi/index.md +127 -127
  143. package/dist/skills/fluentcart-developer/references/restapi/integrations.md +1000 -1000
  144. package/dist/skills/fluentcart-developer/references/restapi/inventory.md +192 -192
  145. package/dist/skills/fluentcart-developer/references/restapi/labels-and-attributes.md +797 -797
  146. package/dist/skills/fluentcart-developer/references/restapi/licensing.md +1733 -1733
  147. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-available-shipping-methods.md +30 -30
  148. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-checkout-summary.md +28 -28
  149. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-country-info.md +29 -29
  150. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-order-info.md +28 -28
  151. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/get-shipping-methods-list-view.md +30 -30
  152. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/login.md +66 -66
  153. package/dist/skills/fluentcart-developer/references/restapi/operations/checkout/place-order.md +179 -179
  154. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/apply-coupon.md +83 -83
  155. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/cancel-coupon.md +87 -87
  156. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/check-product-eligibility.md +59 -59
  157. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/create-coupon.md +230 -230
  158. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/delete-coupon.md +29 -29
  159. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/get-coupon-settings.md +20 -20
  160. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/get-coupon.md +27 -27
  161. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/list-coupon-codes.md +20 -20
  162. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/list-coupons.md +37 -37
  163. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/re-apply-coupons.md +75 -75
  164. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/store-coupon-settings.md +40 -40
  165. package/dist/skills/fluentcart-developer/references/restapi/operations/coupons/update-coupon.md +133 -133
  166. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/create-address-checkout.md +138 -138
  167. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/create-profile-address.md +119 -119
  168. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/dashboard-overview.md +22 -22
  169. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/delete-profile-address.md +46 -46
  170. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-order-details.md +30 -30
  171. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-portal-sections.md +29 -29
  172. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-profile-details.md +22 -22
  173. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-transaction-billing-address.md +30 -30
  174. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/get-upgrade-paths.md +31 -31
  175. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/list-downloads.md +29 -29
  176. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/list-orders.md +28 -28
  177. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/make-profile-address-primary.md +55 -55
  178. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/pause-subscription.md +29 -29
  179. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/resume-subscription.md +29 -29
  180. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/save-transaction-billing-address.md +92 -92
  181. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/select-address-for-checkout.md +32 -32
  182. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/update-profile-address.md +115 -115
  183. package/dist/skills/fluentcart-developer/references/restapi/operations/customer-profile/update-profile-details.md +69 -69
  184. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/attach-user.md +50 -50
  185. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/bulk-actions.md +65 -65
  186. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/create-address.md +135 -135
  187. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/create-customer.md +108 -108
  188. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/delete-address.md +62 -62
  189. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/detach-user.md +28 -28
  190. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/find-customer-order.md +27 -27
  191. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-attachable-users.md +20 -20
  192. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-addresses.md +28 -28
  193. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-orders.md +37 -37
  194. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer-stats.md +27 -27
  195. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/get-customer.md +32 -32
  196. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/list-customers.md +37 -37
  197. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/recalculate-ltv.md +28 -28
  198. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/set-primary-address.md +72 -72
  199. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-additional-info.md +55 -55
  200. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-address.md +144 -144
  201. package/dist/skills/fluentcart-developer/references/restapi/operations/customers/update-customer.md +123 -123
  202. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/attach-note-to-order.md +49 -49
  203. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/create-all-pages.md +21 -21
  204. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/create-single-page.md +55 -55
  205. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/delete-activity.md +28 -28
  206. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-country-info.md +29 -29
  207. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-dashboard-stats.md +22 -22
  208. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-filter-options.md +31 -31
  209. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-onboarding-data.md +20 -20
  210. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-onboarding-settings.md +20 -20
  211. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-print-templates.md +20 -20
  212. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-search-options.md +27 -27
  213. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/get-widgets.md +28 -28
  214. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/initialize-app.md +20 -20
  215. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-activities.md +33 -33
  216. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-attachments.md +21 -21
  217. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/list-countries.md +20 -20
  218. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/mark-activity-read.md +53 -53
  219. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/run-data-backfills.md +21 -21
  220. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-onboarding-settings.md +54 -54
  221. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-onboarding-tax-settings.md +73 -73
  222. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/save-print-templates.md +64 -64
  223. package/dist/skills/fluentcart-developer/references/restapi/operations/dashboard/upload-attachment.md +42 -42
  224. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-customers-batch.md +129 -129
  225. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-licenses-batch.md +133 -133
  226. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-orders-batch.md +129 -129
  227. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/export-subscriptions-batch.md +129 -129
  228. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-customers-export-schema.md +21 -21
  229. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-licenses-export-schema.md +26 -26
  230. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-orders-export-schema.md +21 -21
  231. package/dist/skills/fluentcart-developer/references/restapi/operations/data-export/get-subscriptions-export-schema.md +21 -21
  232. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/enable-notification.md +57 -57
  233. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-digest-settings.md +22 -22
  234. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-notification.md +30 -30
  235. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-reminders.md +22 -22
  236. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-settings.md +22 -22
  237. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/get-shortcodes.md +22 -22
  238. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/list-notifications.md +20 -20
  239. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/preview-default-template.md +66 -66
  240. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/preview-notification.md +50 -50
  241. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-digest-settings.md +101 -101
  242. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-reminders.md +162 -162
  243. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/save-settings.md +99 -99
  244. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/send-digest-test.md +47 -47
  245. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/send-manual-reminder.md +51 -51
  246. package/dist/skills/fluentcart-developer/references/restapi/operations/email-notification/update-notification.md +93 -93
  247. package/dist/skills/fluentcart-developer/references/restapi/operations/files/delete-file.md +31 -31
  248. package/dist/skills/fluentcart-developer/references/restapi/operations/files/get-bucket-list.md +28 -28
  249. package/dist/skills/fluentcart-developer/references/restapi/operations/files/list-files.md +30 -30
  250. package/dist/skills/fluentcart-developer/references/restapi/operations/files/upload-editor-file.md +32 -32
  251. package/dist/skills/fluentcart-developer/references/restapi/operations/files/upload-file.md +34 -34
  252. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/chained-data-request.md +46 -46
  253. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/change-feed-status.md +51 -51
  254. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/delete-feed.md +27 -27
  255. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-dynamic-options.md +29 -29
  256. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-feed-lists.md +27 -27
  257. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-feed-settings.md +27 -27
  258. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-global-feeds.md +20 -20
  259. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/get-global-settings.md +26 -26
  260. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/install-addon-plugin.md +49 -49
  261. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/list-addons.md +20 -20
  262. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/save-feed-settings.md +52 -52
  263. package/dist/skills/fluentcart-developer/references/restapi/operations/integration/set-global-settings.md +50 -50
  264. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/bulk-update-stock.md +94 -94
  265. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/export-inventory.md +81 -81
  266. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/get-adjustment-history.md +26 -26
  267. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/get-inventory-stats.md +21 -21
  268. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/list-inventory.md +33 -33
  269. package/dist/skills/fluentcart-developer/references/restapi/operations/inventory/update-stock.md +75 -75
  270. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-attribute-group.md +31 -31
  271. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-label.md +31 -31
  272. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/create-terms.md +90 -90
  273. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/delete-attribute-group.md +28 -28
  274. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/delete-attribute-term.md +29 -29
  275. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/get-attribute-group.md +28 -28
  276. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/get-attribute-library.md +20 -20
  277. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-attribute-groups.md +32 -32
  278. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-attribute-terms.md +33 -33
  279. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/list-labels.md +20 -20
  280. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/reorder-groups.md +51 -51
  281. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/reorder-terms.md +56 -56
  282. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-attribute-group.md +37 -37
  283. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-attribute-term.md +39 -39
  284. package/dist/skills/fluentcart-developer/references/restapi/operations/labels-attributes/update-label-selections.md +32 -32
  285. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/activate-plugin-license.md +41 -41
  286. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/activate-site-admin.md +60 -60
  287. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-plugin-license.md +18 -18
  288. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-site-admin.md +67 -67
  289. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/deactivate-site-customer.md +47 -47
  290. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/delete-license.md +24 -24
  291. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/extend-license-validity.md +47 -47
  292. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-customer-license-details.md +25 -25
  293. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-customer-licenses-admin.md +26 -26
  294. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-activations.md +25 -25
  295. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-details.md +25 -25
  296. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-license-site.md +30 -30
  297. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-plugin-license-status.md +18 -18
  298. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/get-product-license-settings.md +24 -24
  299. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-customer-licenses.md +25 -25
  300. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-license-sites.md +33 -33
  301. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/list-licenses.md +38 -38
  302. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-activate-license.md +54 -54
  303. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-check-license.md +26 -26
  304. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-deactivate-license.md +46 -46
  305. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-download-license-package.md +23 -23
  306. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/public-get-license-version.md +26 -26
  307. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/regenerate-license-key.md +24 -24
  308. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/save-product-license-settings.md +193 -193
  309. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/update-license-activation-limit.md +53 -53
  310. package/dist/skills/fluentcart-developer/references/restapi/operations/licensing/update-license-status.md +52 -52
  311. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/create-order-bump.md +47 -47
  312. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/delete-order-bump.md +25 -25
  313. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/get-order-bump.md +25 -25
  314. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/list-order-bumps.md +29 -29
  315. package/dist/skills/fluentcart-developer/references/restapi/operations/order-bumps/update-order-bump.md +141 -141
  316. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/accept-dispute.md +47 -47
  317. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/bulk-actions.md +72 -72
  318. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/calculate-shipping.md +67 -67
  319. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/calculate-tax.md +98 -98
  320. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/change-customer.md +50 -50
  321. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/charge-now.md +29 -29
  322. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-and-change-customer.md +92 -92
  323. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-custom-order-item.md +68 -68
  324. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-order.md +351 -351
  325. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/create-renewal-now.md +29 -29
  326. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/delete-order.md +28 -28
  327. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/generate-missing-licenses.md +29 -29
  328. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-order-transactions.md +27 -27
  329. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-order.md +27 -27
  330. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-renewal.md +28 -28
  331. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-shipping-methods.md +28 -28
  332. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/get-single-transaction.md +28 -28
  333. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-order-currencies.md +22 -22
  334. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-orders.md +42 -42
  335. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/list-renewals.md +28 -28
  336. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/mark-as-paid.md +61 -61
  337. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/price-order.md +135 -135
  338. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/refund-order.md +72 -72
  339. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/resend-renewal-invoice.md +29 -29
  340. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/skip-renewal.md +48 -48
  341. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/sync-order-statuses.md +28 -28
  342. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/sync-pending-transaction.md +29 -29
  343. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order-address-id.md +60 -60
  344. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order-address.md +98 -98
  345. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-order.md +172 -172
  346. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-statuses.md +77 -77
  347. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-subscription-details.md +84 -84
  348. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/update-transaction-status.md +51 -51
  349. package/dist/skills/fluentcart-developer/references/restapi/operations/orders/void-renewal.md +30 -30
  350. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/create-pdf-template.md +42 -42
  351. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/delete-pdf-template.md +26 -26
  352. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/download-pdf-preview.md +44 -44
  353. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-factory-default-templates.md +19 -19
  354. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-pdf-status.md +21 -21
  355. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-pdf-template.md +26 -26
  356. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-saved-templates.md +21 -21
  357. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/get-seller-details.md +19 -19
  358. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/list-pdf-templates.md +19 -19
  359. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/save-pdf-template.md +53 -53
  360. package/dist/skills/fluentcart-developer/references/restapi/operations/pdf-templates/save-seller-details.md +97 -97
  361. package/dist/skills/fluentcart-developer/references/restapi/operations/products/add-product-terms.md +64 -64
  362. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-edit-fetch.md +30 -30
  363. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-insert-products.md +62 -62
  364. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-update-products.md +59 -59
  365. package/dist/skills/fluentcart-developer/references/restapi/operations/products/bulk-update-variants.md +83 -83
  366. package/dist/skills/fluentcart-developer/references/restapi/operations/products/change-integration-status.md +64 -64
  367. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-dummy-products.md +45 -45
  368. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-product.md +81 -81
  369. package/dist/skills/fluentcart-developer/references/restapi/operations/products/create-variation.md +181 -181
  370. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-downloadable-file.md +27 -27
  371. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-product-integration.md +30 -30
  372. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-product.md +27 -27
  373. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-taxonomy-term.md +55 -55
  374. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-upgrade-path.md +27 -27
  375. package/dist/skills/fluentcart-developer/references/restapi/operations/products/delete-variation.md +27 -27
  376. package/dist/skills/fluentcart-developer/references/restapi/operations/products/do-bulk-action.md +56 -56
  377. package/dist/skills/fluentcart-developer/references/restapi/operations/products/duplicate-product.md +56 -56
  378. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-products-by-ids.md +26 -26
  379. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-taxonomy-terms.md +20 -20
  380. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-terms-by-parent.md +60 -60
  381. package/dist/skills/fluentcart-developer/references/restapi/operations/products/fetch-variations-by-ids.md +26 -26
  382. package/dist/skills/fluentcart-developer/references/restapi/operations/products/find-subscription-variants.md +26 -26
  383. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-bundle-info.md +27 -27
  384. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-downloadable-url.md +27 -27
  385. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-max-excerpt-word-count.md +20 -20
  386. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-pricing-widgets.md +27 -27
  387. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-integration-feeds.md +29 -29
  388. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-integration-settings.md +31 -31
  389. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product-pricing.md +28 -28
  390. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-product.md +28 -28
  391. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-related-products.md +31 -31
  392. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-upgrade-settings.md +27 -27
  393. package/dist/skills/fluentcart-developer/references/restapi/operations/products/get-variation-upgrade-paths.md +28 -28
  394. package/dist/skills/fluentcart-developer/references/restapi/operations/products/group-bulk-update-variants.md +103 -103
  395. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-all-variants.md +26 -26
  396. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-product-variations.md +26 -26
  397. package/dist/skills/fluentcart-developer/references/restapi/operations/products/list-products.md +34 -34
  398. package/dist/skills/fluentcart-developer/references/restapi/operations/products/remove-shipping-class.md +27 -27
  399. package/dist/skills/fluentcart-developer/references/restapi/operations/products/remove-tax-class.md +27 -27
  400. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-bundle-info.md +56 -56
  401. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-product-integration.md +62 -62
  402. package/dist/skills/fluentcart-developer/references/restapi/operations/products/save-upgrade-path.md +78 -78
  403. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-product-variant-options.md +29 -29
  404. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-products-by-name.md +28 -28
  405. package/dist/skills/fluentcart-developer/references/restapi/operations/products/search-variants-by-name.md +28 -28
  406. package/dist/skills/fluentcart-developer/references/restapi/operations/products/set-variation-media.md +74 -74
  407. package/dist/skills/fluentcart-developer/references/restapi/operations/products/suggest-sku.md +28 -28
  408. package/dist/skills/fluentcart-developer/references/restapi/operations/products/sync-downloadable-files.md +134 -134
  409. package/dist/skills/fluentcart-developer/references/restapi/operations/products/sync-taxonomy-terms.md +61 -61
  410. package/dist/skills/fluentcart-developer/references/restapi/operations/products/toggle-product-tax-exemption.md +56 -56
  411. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-downloadable-file.md +98 -98
  412. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-inventory.md +56 -56
  413. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-long-desc-editor-mode.md +49 -49
  414. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-manage-stock.md +53 -53
  415. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-product-detail.md +58 -58
  416. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-product-pricing.md +225 -225
  417. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-shipping-class.md +49 -49
  418. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-tax-class.md +49 -49
  419. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-upgrade-path.md +78 -78
  420. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variant-option.md +79 -79
  421. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variant-tax-exemption.md +56 -56
  422. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variation-pricing-table.md +49 -49
  423. package/dist/skills/fluentcart-developer/references/restapi/operations/products/update-variation.md +105 -105
  424. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/get-product-views.md +34 -34
  425. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/list-products.md +42 -42
  426. package/dist/skills/fluentcart-developer/references/restapi/operations/public-shop/search-products.md +30 -30
  427. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/channel-rules.md +24 -24
  428. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/country-heat-map.md +22 -22
  429. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/coupon-overview.md +37 -37
  430. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/coupons.md +36 -36
  431. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-insights.md +31 -31
  432. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-overview.md +36 -36
  433. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-repeat.md +35 -35
  434. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-segment-customers.md +36 -36
  435. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-segments.md +30 -30
  436. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/customer-value.md +34 -34
  437. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/dashboard-stats.md +30 -30
  438. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/failed-orders.md +34 -34
  439. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-new-vs-returning-customer.md +34 -34
  440. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-report-by-day-and-hour.md +34 -34
  441. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-report-meta.md +29 -29
  442. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/fetch-top-sold-products.md +34 -34
  443. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/future-renewals.md +31 -31
  444. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/generate-retention-snapshots.md +24 -24
  445. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-overview.md +30 -30
  446. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-recent-activities.md +26 -26
  447. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-recent-orders.md +20 -20
  448. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/get-revenue.md +37 -37
  449. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments-at-risk.md +35 -35
  450. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments-variations.md +33 -33
  451. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/installments.md +33 -33
  452. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/item-count-distribution.md +34 -34
  453. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-chart.md +30 -30
  454. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-pie-chart.md +22 -22
  455. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/license-summary.md +22 -22
  456. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/locations.md +43 -43
  457. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-chart.md +37 -37
  458. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-completion-time.md +34 -34
  459. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-mix.md +34 -34
  460. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/order-value-distribution.md +34 -34
  461. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods-disputes.md +38 -38
  462. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods-methods.md +36 -36
  463. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/payment-methods.md +37 -37
  464. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-comparison-launch.md +33 -33
  465. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-comparison.md +40 -40
  466. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-detail.md +37 -37
  467. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/product-sales.md +37 -37
  468. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/refunds-overview.md +37 -37
  469. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/retention-snapshots-step.md +45 -45
  470. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/sales-growth-chart.md +35 -35
  471. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/save-channel-rules.md +73 -73
  472. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/source-channels.md +37 -37
  473. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/sources.md +49 -49
  474. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-cohorts.md +33 -33
  475. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-health.md +30 -30
  476. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-rebuys.md +37 -37
  477. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-retention.md +34 -34
  478. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscription-variations.md +22 -22
  479. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/subscriptions-overview.md +37 -37
  480. package/dist/skills/fluentcart-developer/references/restapi/operations/reports/weeks-between-refund.md +34 -34
  481. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/assign-role.md +48 -48
  482. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/delete-role-assignment.md +47 -47
  483. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/get-role.md +25 -25
  484. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/list-managers.md +18 -18
  485. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/list-roles.md +18 -18
  486. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/search-users.md +25 -25
  487. package/dist/skills/fluentcart-developer/references/restapi/operations/roles-permissions/update-role.md +43 -43
  488. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/create-saved-view.md +106 -106
  489. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/delete-saved-view.md +26 -26
  490. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/list-saved-views.md +25 -25
  491. package/dist/skills/fluentcart-developer/references/restapi/operations/saved-views/update-saved-view.md +83 -83
  492. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/activate-payment-addon.md +44 -44
  493. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/activate-plugin-addon.md +44 -44
  494. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/change-storage-driver-status.md +56 -56
  495. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/check-paypal-webhook.md +26 -26
  496. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/create-storage-bucket.md +63 -63
  497. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/disconnect-payment-method.md +55 -55
  498. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/exchange-paypal-seller-auth-token.md +62 -62
  499. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-active-storage-drivers.md +20 -20
  500. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-checkout-fields.md +22 -22
  501. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-email-shortcodes.md +20 -20
  502. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-mcp-config-snippets.md +26 -26
  503. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-mcp-status.md +20 -20
  504. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-module-settings.md +20 -20
  505. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-payment-method-connection-info.md +26 -26
  506. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-payment-method-settings.md +26 -26
  507. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-permissions.md +22 -22
  508. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-plugin-addons.md +20 -20
  509. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-storage-driver-settings.md +27 -27
  510. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/get-store-settings.md +26 -26
  511. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-mcp-adapter.md +21 -21
  512. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-payment-addon.md +60 -60
  513. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/install-plugin-addon.md +64 -64
  514. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-all-payment-methods.md +20 -20
  515. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-all-storage-drivers.md +20 -20
  516. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/list-storage-buckets.md +67 -67
  517. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/reorder-payment-methods.md +55 -55
  518. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/reset-storage-driver-settings.md +45 -45
  519. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-checkout-fields.md +133 -133
  520. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-confirmation-settings.md +68 -68
  521. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-module-settings.md +68 -68
  522. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-payment-method-design.md +67 -67
  523. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-payment-method-settings.md +58 -58
  524. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-permissions.md +68 -68
  525. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-storage-driver-settings.md +62 -62
  526. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/save-store-settings.md +239 -239
  527. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/setup-paypal-webhook.md +48 -48
  528. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/toggle-mcp.md +40 -40
  529. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/verify-storage-driver-connection.md +62 -62
  530. package/dist/skills/fluentcart-developer/references/restapi/operations/settings/verify-turnstile-keys.md +55 -55
  531. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-class.md +73 -73
  532. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-method.md +110 -110
  533. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/create-shipping-zone.md +56 -56
  534. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-class.md +29 -29
  535. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-method.md +29 -29
  536. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/delete-shipping-zone.md +29 -29
  537. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-class-profile.md +30 -30
  538. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-class.md +29 -29
  539. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-packages.md +22 -22
  540. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-shipping-zone.md +27 -27
  541. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-zone-countries.md +22 -22
  542. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/get-zone-states.md +28 -28
  543. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/list-shipping-classes.md +31 -31
  544. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/list-shipping-zones.md +31 -31
  545. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/save-shipping-packages.md +112 -112
  546. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-class.md +79 -79
  547. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-method.md +113 -113
  548. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-shipping-zone.md +62 -62
  549. package/dist/skills/fluentcart-developer/references/restapi/operations/shipping/update-zone-order.md +52 -52
  550. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/cancel-auto-renew.md +30 -30
  551. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/cancel-subscription.md +52 -52
  552. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/confirm-subscription-switch.md +70 -70
  553. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/fetch-subscription-remote.md +28 -28
  554. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/generate-early-payment-link.md +29 -29
  555. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-customer-subscription.md +27 -27
  556. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-or-create-plan.md +69 -69
  557. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-setup-intent-attempts.md +30 -30
  558. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/get-subscription.md +28 -28
  559. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/initiate-early-payment.md +31 -31
  560. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/list-customer-subscriptions.md +27 -27
  561. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/list-subscriptions.md +39 -39
  562. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/pause-subscription.md +28 -28
  563. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/reactivate-subscription.md +28 -28
  564. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/resume-subscription.md +28 -28
  565. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/switch-payment-method.md +70 -70
  566. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/update-payment-method.md +69 -69
  567. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/update-vendor-ids.md +56 -56
  568. package/dist/skills/fluentcart-developer/references/restapi/operations/subscriptions/verify-vendor-ids.md +56 -56
  569. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/create-tax-class.md +51 -51
  570. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/create-tax-rate.md +117 -117
  571. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-product-override.md +27 -27
  572. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-shipping-tax-override.md +27 -27
  573. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-tax-class.md +28 -28
  574. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/delete-tax-rate.md +27 -27
  575. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-country-tax-id.md +27 -27
  576. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-country-tax-rates.md +28 -28
  577. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-eu-vat-product-overrides.md +20 -20
  578. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-oss-country-rates.md +20 -20
  579. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-preconfigured-tax-rates.md +20 -20
  580. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-product-overrides.md +27 -27
  581. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/get-tax-settings.md +20 -20
  582. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-all-tax-rates.md +20 -20
  583. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-tax-classes.md +20 -20
  584. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/list-tax-records.md +37 -37
  585. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/mark-taxes-as-filed.md +58 -58
  586. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/reset-eu-vat-rates.md +21 -21
  587. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-configured-countries.md +57 -57
  588. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-country-tax-id.md +50 -50
  589. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-eu-vat-cross-border-settings.md +127 -127
  590. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-oss-country-rates.md +100 -100
  591. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-product-override.md +110 -110
  592. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-shipping-tax-override.md +52 -52
  593. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/save-tax-settings.md +166 -166
  594. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/update-country-status.md +54 -54
  595. package/dist/skills/fluentcart-developer/references/restapi/operations/tax/update-tax-rate.md +116 -116
  596. package/dist/skills/fluentcart-developer/references/restapi/order-bumps.md +433 -433
  597. package/dist/skills/fluentcart-developer/references/restapi/orders.md +1212 -1212
  598. package/dist/skills/fluentcart-developer/references/restapi/pdf-templates.md +212 -212
  599. package/dist/skills/fluentcart-developer/references/restapi/products.md +2485 -2485
  600. package/dist/skills/fluentcart-developer/references/restapi/public-shop.md +191 -191
  601. package/dist/skills/fluentcart-developer/references/restapi/reports.md +3773 -3773
  602. package/dist/skills/fluentcart-developer/references/restapi/roles.md +403 -403
  603. package/dist/skills/fluentcart-developer/references/restapi/saved-views.md +136 -136
  604. package/dist/skills/fluentcart-developer/references/restapi/settings.md +1423 -1423
  605. package/dist/skills/fluentcart-developer/references/restapi/shipping.md +905 -905
  606. package/dist/skills/fluentcart-developer/references/restapi/subscriptions.md +1169 -1169
  607. package/dist/skills/fluentcart-developer/references/restapi/tax.md +1551 -1551
  608. package/dist/skills/fluentcart-developer/references/restapi.md +127 -127
  609. package/dist/skills/fluentcart-developer/scripts/cli.js +1 -1
  610. package/dist/version.d.ts +1 -1
  611. package/dist/version.js +1 -1
  612. 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
+ ---