@nextblock-cms/ecom 0.20.3 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/_virtual/_rolldown/runtime.cjs +1 -0
- package/index.cjs +1 -0
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs +1 -0
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs +1 -0
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs +1 -0
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs +1 -0
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs +1 -0
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs +1 -0
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs +1 -0
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs +1 -0
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs +1 -0
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs +1 -0
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs +1 -0
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs +1 -0
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs +1 -0
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs +1 -0
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs +1 -0
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs +29 -0
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs +1 -0
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs +1 -0
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs +1 -0
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs +1 -0
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs +1 -0
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs +1 -0
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs +1 -0
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs +1 -0
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs +1 -0
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs +1 -0
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs +1 -0
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs +1 -0
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs +1 -0
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs +1 -0
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs +1 -0
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs +1 -0
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs +1 -0
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs +1 -0
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs +1 -0
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs +1 -0
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs +1 -0
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs +1 -0
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs +1 -0
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs +1 -0
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs +1 -0
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs +1 -0
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs +1 -0
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs +33 -0
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs +1 -0
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs +1 -0
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs +61 -0
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs +1 -0
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs +1 -0
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
- package/lib/pages/cms/coupons/CouponsPage.cjs +5 -0
- package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs +1 -0
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
- package/lib/pages/cms/coupons/EditCouponPage.cjs +1 -0
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
- package/lib/pages/cms/coupons/ProductScopePicker.cjs +1 -0
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
- package/lib/pages/cms/coupons/actions.cjs +1 -0
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs +1 -0
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs +1 -0
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs +1 -0
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
- package/lib/pages/cms/orders/OrderPrintButton.cjs +1 -0
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs +1 -0
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
- package/lib/pages/cms/orders/OrdersPage.cjs +1 -0
- package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
- package/lib/pages/cms/orders/actions.cjs +7 -0
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs +1 -0
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs +1 -0
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs +1 -0
- package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
- package/lib/pages/cms/payments/PaymentsPage.cjs +1 -0
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
- package/lib/pages/cms/payments/actions.cjs +1 -0
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs +1 -0
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs +1 -0
- package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +63 -66
- package/lib/pages/cms/products/[id]/edit/EditProductPage.cjs +1 -0
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
- package/lib/pages/cms/products/[id]/edit/EditProductPage.es.js +139 -0
- package/lib/pages/cms/products/actions.cjs +44 -0
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs +1 -0
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs +1 -0
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs +1 -0
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs +1 -0
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs +1 -0
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs +1 -0
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
- package/lib/pages/cms/products/components/DeleteProductButton.cjs +1 -0
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs +1 -0
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs +1 -0
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs +1 -0
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs +1 -0
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs +1 -0
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs +1 -0
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs +1 -0
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs +5 -0
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.cjs +1 -0
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
- package/lib/pages/cms/products/index.cjs +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs +1 -0
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs +2 -0
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
- package/lib/pages/cms/products/inventory/actions.cjs +3 -0
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs +1 -0
- package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
- package/lib/pages/cms/products/product-price-sync.cjs +1 -0
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs +1 -0
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs +5 -0
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs +1 -0
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
- package/lib/pages/cms/shipping/components/ZoneForm.cjs +1 -0
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs +1 -0
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs +1 -0
- package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
- package/lib/pages/cms/taxes/actions.cjs +1 -0
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs +1 -0
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
- package/lib/pages/cms/taxes/index.cjs +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs +1 -0
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs +238 -0
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs +1 -0
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs +1 -0
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs +1 -0
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs +1 -0
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs +1 -0
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs +1 -0
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs +1 -0
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs +1 -0
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs +1 -0
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs +15 -0
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs +7 -0
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs +1 -0
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs +1 -0
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs +1 -0
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs +1 -0
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs +1 -0
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs +1 -0
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs +1 -0
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs +1 -0
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs +1 -0
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs +1 -0
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs +1 -0
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs +1 -0
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs +1 -0
- package/lib/zod-config.es.js +5 -6
- package/package.json +22 -21
- package/server.cjs +1 -0
- package/server.es.js +56 -211
- package/index.cjs.js +0 -1
- package/lib/CurrencyProvider.cjs.js +0 -1
- package/lib/PaymentReadinessProvider.cjs.js +0 -1
- package/lib/cart-store.cjs.js +0 -1
- package/lib/components/AccountNavigationMenu.cjs.js +0 -1
- package/lib/components/AddToCartButton.cjs.js +0 -1
- package/lib/components/Cart.cjs.js +0 -1
- package/lib/components/CartDrawer.cjs.js +0 -1
- package/lib/components/CartIcon.cjs.js +0 -1
- package/lib/components/Checkout.cjs.js +0 -1
- package/lib/components/CouponForm.cjs.js +0 -1
- package/lib/components/CurrencySwitcher.cjs.js +0 -1
- package/lib/components/CustomerProfileForm.cjs.js +0 -1
- package/lib/components/FeaturedProduct.cjs.js +0 -1
- package/lib/components/FreemiusLicensePanel.cjs.js +0 -1
- package/lib/components/InvoiceDocument.cjs.js +0 -1
- package/lib/components/InvoiceViewerShell.cjs.js +0 -29
- package/lib/components/ProductCard.cjs.js +0 -1
- package/lib/components/ProductDetailsLayout.cjs.js +0 -1
- package/lib/components/ProductGallery.cjs.js +0 -1
- package/lib/components/ProductGrid.cjs.js +0 -1
- package/lib/components/ShippingEstimator.cjs.js +0 -1
- package/lib/components/ShortDescription.cjs.js +0 -1
- package/lib/components/SimpleTiptapRenderer.cjs.js +0 -1
- package/lib/components/SubscriptionSelector.cjs.js +0 -1
- package/lib/countries.cjs.js +0 -1
- package/lib/coupon-server.cjs.js +0 -1
- package/lib/coupons.cjs.js +0 -1
- package/lib/currency-constants.cjs.js +0 -1
- package/lib/currency-rest-client.cjs.js +0 -1
- package/lib/currency-store.cjs.js +0 -1
- package/lib/currency-sync.cjs.js +0 -1
- package/lib/currency.cjs.js +0 -1
- package/lib/customer-addresses.cjs.js +0 -1
- package/lib/customer-orders.cjs.js +0 -1
- package/lib/customer.cjs.js +0 -1
- package/lib/export-helpers.cjs.js +0 -1
- package/lib/factory.cjs.js +0 -1
- package/lib/freemius-coupons.cjs.js +0 -1
- package/lib/freemius-license-claim.cjs.js +0 -1
- package/lib/freemius-license.cjs.js +0 -1
- package/lib/freemius-order-sync.cjs.js +0 -1
- package/lib/freemius-trial-provision.cjs.js +0 -1
- package/lib/inventory-settings.cjs.js +0 -1
- package/lib/invoice-server.cjs.js +0 -33
- package/lib/invoice-ui.cjs.js +0 -1
- package/lib/invoice.cjs.js +0 -1
- package/lib/order-inventory.cjs.js +0 -61
- package/lib/order-tax-details.cjs.js +0 -1
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +0 -1
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +0 -5
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +0 -1
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +0 -1
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +0 -1
- package/lib/pages/cms/coupons/actions.cjs.js +0 -1
- package/lib/pages/cms/coupons/product-options.cjs.js +0 -1
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +0 -1
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +0 -1
- package/lib/pages/cms/orders/OrdersPage.cjs.js +0 -1
- package/lib/pages/cms/orders/actions.cjs.js +0 -7
- package/lib/pages/cms/orders/export-actions.cjs.js +0 -1
- package/lib/pages/cms/orders/server-actions.cjs.js +0 -1
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +0 -1
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +0 -1
- package/lib/pages/cms/payments/actions.cjs.js +0 -1
- package/lib/pages/cms/payments/queries.cjs.js +0 -1
- package/lib/pages/cms/products/ProductsPage.cjs.js +0 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +0 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +0 -156
- package/lib/pages/cms/products/actions.cjs.js +0 -44
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +0 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +0 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +0 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +0 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +0 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +0 -1
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +0 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductForm.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +0 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +0 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +0 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +0 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +0 -5
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +0 -1
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +0 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +0 -2
- package/lib/pages/cms/products/inventory/actions.cjs.js +0 -3
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +0 -1
- package/lib/pages/cms/products/product-price-sync.cjs.js +0 -1
- package/lib/pages/cms/products/server-actions.cjs.js +0 -1
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +0 -5
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +0 -1
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +0 -1
- package/lib/pages/cms/shipping/server-actions.cjs.js +0 -1
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +0 -1
- package/lib/pages/cms/taxes/actions.cjs.js +0 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +0 -1
- package/lib/payment-config.cjs.js +0 -1
- package/lib/product-actions.cjs.js +0 -238
- package/lib/product-context.cjs.js +0 -1
- package/lib/product-schema.cjs.js +0 -1
- package/lib/providers/freemius.cjs.js +0 -5
- package/lib/providers/stripe.cjs.js +0 -1
- package/lib/server-actions/coupon-actions.cjs.js +0 -1
- package/lib/server-actions/customer-actions.cjs.js +0 -1
- package/lib/server-actions/product-actions.cjs.js +0 -1
- package/lib/server-actions/shipping-actions.cjs.js +0 -1
- package/lib/server-actions/tax-actions.cjs.js +0 -1
- package/lib/shared-inventory.cjs.js +0 -15
- package/lib/shipping/resolver.cjs.js +0 -7
- package/lib/shipping-rate-currency.cjs.js +0 -1
- package/lib/states.cjs.js +0 -1
- package/lib/stripe/checkout.cjs.js +0 -1
- package/lib/stripe/client.cjs.js +0 -1
- package/lib/stripe/order-sync.cjs.js +0 -1
- package/lib/stripe/webhooks.cjs.js +0 -1
- package/lib/tax-calculation.cjs.js +0 -1
- package/lib/trials.cjs.js +0 -1
- package/lib/types.cjs.js +0 -1
- package/lib/use-cart.cjs.js +0 -1
- package/lib/use-price-formatter.cjs.js +0 -1
- package/lib/variation-utils.cjs.js +0 -1
- package/lib/zod-config.cjs.js +0 -1
- package/server.cjs.js +0 -1
|
@@ -1,128 +1,116 @@
|
|
|
1
|
+
import { ECOMMERCE_INVENTORY_SETTINGS_KEY as e, normalizeEcommerceInventorySettings as t } from "./inventory-settings.es.js";
|
|
1
2
|
import "server-only";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
|
|
3
|
+
import n from "postgres";
|
|
4
|
+
//#region src/lib/order-inventory.ts
|
|
5
|
+
function r() {
|
|
6
|
+
return process.env.POSTGRES_URL || process.env.DATABASE_URL || null;
|
|
6
7
|
}
|
|
7
|
-
async function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
await a.begin(async (e) => {
|
|
18
|
-
const t = e, s = (await t`
|
|
8
|
+
async function i(i) {
|
|
9
|
+
let a = r();
|
|
10
|
+
if (!a) throw Error("Missing POSTGRES_URL or DATABASE_URL for inventory fallback");
|
|
11
|
+
let o = n(a, {
|
|
12
|
+
ssl: "require",
|
|
13
|
+
onnotice: () => {}
|
|
14
|
+
});
|
|
15
|
+
try {
|
|
16
|
+
await o.begin(async (n) => {
|
|
17
|
+
let r = n, a = (await r`
|
|
19
18
|
SELECT inventory_deducted_at
|
|
20
19
|
FROM public.orders
|
|
21
|
-
WHERE id = ${
|
|
20
|
+
WHERE id = ${i}
|
|
22
21
|
FOR UPDATE
|
|
23
22
|
`)[0];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const c = await t`
|
|
23
|
+
if (!a || a.inventory_deducted_at) return;
|
|
24
|
+
let o = await r`
|
|
27
25
|
SELECT value
|
|
28
26
|
FROM public.site_settings
|
|
29
|
-
WHERE key = ${
|
|
27
|
+
WHERE key = ${e}
|
|
30
28
|
LIMIT 1
|
|
31
29
|
`;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
).trackQuantities) {
|
|
35
|
-
await t`
|
|
30
|
+
if (!t(o[0]?.value).trackQuantities) {
|
|
31
|
+
await r`
|
|
36
32
|
UPDATE public.orders
|
|
37
33
|
SET inventory_deducted_at = now()
|
|
38
|
-
WHERE id = ${
|
|
34
|
+
WHERE id = ${i}
|
|
39
35
|
`;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
let s = await r`
|
|
43
39
|
SELECT
|
|
44
40
|
product_id,
|
|
45
41
|
variant_id,
|
|
46
42
|
SUM(quantity)::integer AS quantity
|
|
47
43
|
FROM public.order_items
|
|
48
|
-
WHERE order_id = ${
|
|
44
|
+
WHERE order_id = ${i}
|
|
49
45
|
GROUP BY product_id, variant_id
|
|
50
46
|
`;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
for (let e of s) {
|
|
48
|
+
if (e.variant_id) {
|
|
49
|
+
let t = (await r`
|
|
54
50
|
SELECT
|
|
55
51
|
sku,
|
|
56
52
|
stock_quantity
|
|
57
53
|
FROM public.product_variants
|
|
58
|
-
WHERE id = ${
|
|
54
|
+
WHERE id = ${e.variant_id}
|
|
59
55
|
LIMIT 1
|
|
60
56
|
`)[0];
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
await t`
|
|
57
|
+
if (!t?.sku) continue;
|
|
58
|
+
await r`
|
|
64
59
|
INSERT INTO public.inventory_items (sku, quantity)
|
|
65
|
-
VALUES (${
|
|
60
|
+
VALUES (${t.sku}, ${Math.max(0, t.stock_quantity ?? 0)})
|
|
66
61
|
ON CONFLICT (sku) DO NOTHING
|
|
67
|
-
`, await
|
|
62
|
+
`, await r`
|
|
68
63
|
UPDATE public.inventory_items
|
|
69
64
|
SET
|
|
70
|
-
quantity = GREATEST(COALESCE(quantity, 0) - ${
|
|
65
|
+
quantity = GREATEST(COALESCE(quantity, 0) - ${e.quantity}, 0),
|
|
71
66
|
updated_at = now()
|
|
72
|
-
WHERE sku = ${
|
|
67
|
+
WHERE sku = ${t.sku}
|
|
73
68
|
`;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (e.product_id) {
|
|
72
|
+
let t = (await r`
|
|
78
73
|
SELECT
|
|
79
74
|
sku,
|
|
80
75
|
stock
|
|
81
76
|
FROM public.products
|
|
82
|
-
WHERE id = ${
|
|
77
|
+
WHERE id = ${e.product_id}
|
|
83
78
|
LIMIT 1
|
|
84
79
|
`)[0];
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
await t`
|
|
80
|
+
if (!t?.sku) continue;
|
|
81
|
+
await r`
|
|
88
82
|
INSERT INTO public.inventory_items (sku, quantity)
|
|
89
|
-
VALUES (${
|
|
83
|
+
VALUES (${t.sku}, ${Math.max(0, t.stock ?? 0)})
|
|
90
84
|
ON CONFLICT (sku) DO NOTHING
|
|
91
|
-
`, await
|
|
85
|
+
`, await r`
|
|
92
86
|
UPDATE public.inventory_items
|
|
93
87
|
SET
|
|
94
|
-
quantity = GREATEST(COALESCE(quantity, 0) - ${
|
|
88
|
+
quantity = GREATEST(COALESCE(quantity, 0) - ${e.quantity}, 0),
|
|
95
89
|
updated_at = now()
|
|
96
|
-
WHERE sku = ${
|
|
90
|
+
WHERE sku = ${t.sku}
|
|
97
91
|
`;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
await r`
|
|
101
95
|
UPDATE public.orders
|
|
102
96
|
SET inventory_deducted_at = now()
|
|
103
|
-
WHERE id = ${
|
|
97
|
+
WHERE id = ${i}
|
|
104
98
|
`;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
});
|
|
100
|
+
} finally {
|
|
101
|
+
await o.end();
|
|
102
|
+
}
|
|
109
103
|
}
|
|
110
|
-
async function
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const t = e instanceof Error ? e.message : String(e);
|
|
121
|
-
throw new Error(
|
|
122
|
-
`Failed to reconcile inventory for order ${n}. RPC error: ${a.message}. Fallback error: ${t}`
|
|
123
|
-
);
|
|
124
|
-
}
|
|
104
|
+
async function a(e, t) {
|
|
105
|
+
let { error: n } = await e.rpc("apply_order_inventory_deduction", { p_order_id: t });
|
|
106
|
+
if (!n) return { method: "rpc" };
|
|
107
|
+
console.error(`[Inventory] RPC deduction failed for order ${t}:`, n);
|
|
108
|
+
try {
|
|
109
|
+
return await i(t), { method: "sql-fallback" };
|
|
110
|
+
} catch (e) {
|
|
111
|
+
let r = e instanceof Error ? e.message : String(e);
|
|
112
|
+
throw Error(`Failed to reconcile inventory for order ${t}. RPC error: ${n.message}. Fallback error: ${r}`);
|
|
113
|
+
}
|
|
125
114
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
};
|
|
115
|
+
//#endregion
|
|
116
|
+
export { a as applyOrderInventoryDeduction };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={gst:`GST`,qst:`QST`,hst:`HST`,pst:`PST`,vat:`VAT`,sales_tax:`Sales Tax`,amusement_tax:`Amusement Tax`,retail_delivery_fee:`Retail Delivery Fee`};function t(){return new Date().toISOString()}function n(t){let n=t.tax_type?.trim().toLowerCase();return n&&e[n]?e[n]:t.display_name||`Tax`}function r(e){return typeof e.effective_percentage==`number`?e.effective_percentage:typeof e.percentage==`number`?e.percentage:null}function i(e){return e.jurisdiction?e.jurisdiction:[e.state,e.country].filter(Boolean).join(`, `)||null}function a(e){return JSON.stringify({source:e.source,rate_id:e.rate.id??null,display_name:n(e.rate),percentage:r(e.rate),jurisdiction:i(e.rate),jurisdiction_level:e.rate.jurisdiction_level??null,country:e.rate.country??null,state:e.rate.state??null,tax_type:e.rate.tax_type??null,inclusive:e.rate.inclusive??null})}function o(e){let t=new Map;for(let n of e){let e=a(n),r=t.get(e);if(!r){t.set(e,{...n,scope:`aggregate`,line_item_id:null});continue}r.amount+=n.amount,r.taxable_amount=typeof r.taxable_amount==`number`||typeof n.taxable_amount==`number`?(typeof r.taxable_amount==`number`?r.taxable_amount:0)+(typeof n.taxable_amount==`number`?n.taxable_amount:0):null,r.description!==n.description&&(r.description=null),r.taxability_reason!==n.taxability_reason&&(r.taxability_reason=null)}return[...t.values()].sort((e,t)=>{let i=n(e.rate).localeCompare(n(t.rate));return i===0?(r(e.rate)??0)-(r(t.rate)??0):i})}function s(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e;return typeof n.currency==`string`?{source:n.source===`manual`||n.source===`stripe_checkout`||n.source===`none`?n.source:`none`,mode:n.mode===`automatic`?`automatic`:`manual`,currency:n.currency,subtotal:typeof n.subtotal==`number`?n.subtotal:0,shipping_total:typeof n.shipping_total==`number`?n.shipping_total:0,tax_total:typeof n.tax_total==`number`?n.tax_total:0,total:typeof n.total==`number`?n.total:0,is_finalized:!!n.is_finalized,lines:Array.isArray(n.lines)?o(n.lines):[],updated_at:typeof n.updated_at==`string`?n.updated_at:t()}:null}function c(e){let n=e.currency||`usd`,r=e.calculation.mode===`manual`&&!e.calculation.isPendingExternalCalculation;return{source:e.calculation.enabled&&e.calculation.mode===`manual`?`manual`:e.calculation.mode===`automatic`?`stripe_checkout`:`none`,mode:e.calculation.mode,currency:n,subtotal:e.subtotal,shipping_total:e.shippingTotal,tax_total:e.calculation.amount,total:e.total,is_finalized:r,lines:e.calculation.enabled&&e.calculation.mode===`manual`?e.calculation.lines.map(t=>({scope:`aggregate`,source:`manual`,amount:t.amount,taxable_amount:e.calculation.taxableSubtotal,description:t.name,rate:{id:t.id??null,display_name:t.name,percentage:t.rate,country:t.country_code,state:t.state_code??null}})):[],updated_at:t()}}function l(e){return{id:e.id,display_name:e.display_name,percentage:e.percentage,effective_percentage:e.effective_percentage,jurisdiction:e.jurisdiction,jurisdiction_level:e.jurisdiction_level,country:e.country,state:e.state,tax_type:e.tax_type,inclusive:e.inclusive,description:e.description}}function u(e){let n=e.currency||e.session.currency||`usd`,r=typeof e.session.amount_total==`number`?e.session.amount_total:0,i=e.session.total_details?.amount_tax??0,a=[];for(let t of e.lineItems)for(let e of t.taxes||[])a.push({scope:`line_item`,source:`stripe_checkout`,amount:e.amount,taxable_amount:e.taxable_amount,description:t.description||void 0,line_item_id:t.id,taxability_reason:e.taxability_reason,rate:l(e.rate)});if(a.length===0)for(let t of e.session.total_details?.breakdown?.taxes||[])a.push({scope:`aggregate`,source:`stripe_checkout`,amount:t.amount,taxable_amount:t.taxable_amount,description:t.rate.display_name,taxability_reason:t.taxability_reason,rate:l(t.rate)});let s=o(a);return{source:i>0||s.length>0?`stripe_checkout`:`none`,mode:e.fallbackMode===`manual`?`manual`:`automatic`,currency:n,subtotal:e.subtotal,shipping_total:e.shippingTotal,tax_total:i,total:r,is_finalized:!0,lines:s,updated_at:t()}}exports.aggregateOrderTaxLines=o,exports.buildOrderTaxDetailsFromCalculation=c,exports.buildOrderTaxDetailsFromStripeSession=u,exports.getOrderTaxRateJurisdiction=i,exports.getOrderTaxRateLabel=n,exports.getOrderTaxRatePercentage=r,exports.normalizeOrderTaxDetails=s;
|
|
@@ -1,164 +1,153 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
//#region src/lib/order-tax-details.ts
|
|
2
|
+
var e = {
|
|
3
|
+
gst: "GST",
|
|
4
|
+
qst: "QST",
|
|
5
|
+
hst: "HST",
|
|
6
|
+
pst: "PST",
|
|
7
|
+
vat: "VAT",
|
|
8
|
+
sales_tax: "Sales Tax",
|
|
9
|
+
amusement_tax: "Amusement Tax",
|
|
10
|
+
retail_delivery_fee: "Retail Delivery Fee"
|
|
10
11
|
};
|
|
11
|
-
function
|
|
12
|
-
|
|
12
|
+
function t() {
|
|
13
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
function n(t) {
|
|
16
|
+
let n = t.tax_type?.trim().toLowerCase();
|
|
17
|
+
return n && e[n] ? e[n] : t.display_name || "Tax";
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
19
|
+
function r(e) {
|
|
20
|
+
return typeof e.effective_percentage == "number" ? e.effective_percentage : typeof e.percentage == "number" ? e.percentage : null;
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
22
|
+
function i(e) {
|
|
23
|
+
return e.jurisdiction ? e.jurisdiction : [e.state, e.country].filter(Boolean).join(", ") || null;
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
function a(e) {
|
|
26
|
+
return JSON.stringify({
|
|
27
|
+
source: e.source,
|
|
28
|
+
rate_id: e.rate.id ?? null,
|
|
29
|
+
display_name: n(e.rate),
|
|
30
|
+
percentage: r(e.rate),
|
|
31
|
+
jurisdiction: i(e.rate),
|
|
32
|
+
jurisdiction_level: e.rate.jurisdiction_level ?? null,
|
|
33
|
+
country: e.rate.country ?? null,
|
|
34
|
+
state: e.rate.state ?? null,
|
|
35
|
+
tax_type: e.rate.tax_type ?? null,
|
|
36
|
+
inclusive: e.rate.inclusive ?? null
|
|
37
|
+
});
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
function o(e) {
|
|
40
|
+
let t = /* @__PURE__ */ new Map();
|
|
41
|
+
for (let n of e) {
|
|
42
|
+
let e = a(n), r = t.get(e);
|
|
43
|
+
if (!r) {
|
|
44
|
+
t.set(e, {
|
|
45
|
+
...n,
|
|
46
|
+
scope: "aggregate",
|
|
47
|
+
line_item_id: null
|
|
48
|
+
});
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
r.amount += n.amount, r.taxable_amount = typeof r.taxable_amount == "number" || typeof n.taxable_amount == "number" ? (typeof r.taxable_amount == "number" ? r.taxable_amount : 0) + (typeof n.taxable_amount == "number" ? n.taxable_amount : 0) : null, r.description !== n.description && (r.description = null), r.taxability_reason !== n.taxability_reason && (r.taxability_reason = null);
|
|
52
|
+
}
|
|
53
|
+
return [...t.values()].sort((e, t) => {
|
|
54
|
+
let i = n(e.rate).localeCompare(n(t.rate));
|
|
55
|
+
return i === 0 ? (r(e.rate) ?? 0) - (r(t.rate) ?? 0) : i;
|
|
56
|
+
});
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
58
|
+
function s(e) {
|
|
59
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return null;
|
|
60
|
+
let n = e;
|
|
61
|
+
return typeof n.currency == "string" ? {
|
|
62
|
+
source: n.source === "manual" || n.source === "stripe_checkout" || n.source === "none" ? n.source : "none",
|
|
63
|
+
mode: n.mode === "automatic" ? "automatic" : "manual",
|
|
64
|
+
currency: n.currency,
|
|
65
|
+
subtotal: typeof n.subtotal == "number" ? n.subtotal : 0,
|
|
66
|
+
shipping_total: typeof n.shipping_total == "number" ? n.shipping_total : 0,
|
|
67
|
+
tax_total: typeof n.tax_total == "number" ? n.tax_total : 0,
|
|
68
|
+
total: typeof n.total == "number" ? n.total : 0,
|
|
69
|
+
is_finalized: !!n.is_finalized,
|
|
70
|
+
lines: Array.isArray(n.lines) ? o(n.lines) : [],
|
|
71
|
+
updated_at: typeof n.updated_at == "string" ? n.updated_at : t()
|
|
72
|
+
} : null;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
74
|
+
function c(e) {
|
|
75
|
+
let n = e.currency || "usd", r = e.calculation.mode === "manual" && !e.calculation.isPendingExternalCalculation;
|
|
76
|
+
return {
|
|
77
|
+
source: e.calculation.enabled && e.calculation.mode === "manual" ? "manual" : e.calculation.mode === "automatic" ? "stripe_checkout" : "none",
|
|
78
|
+
mode: e.calculation.mode,
|
|
79
|
+
currency: n,
|
|
80
|
+
subtotal: e.subtotal,
|
|
81
|
+
shipping_total: e.shippingTotal,
|
|
82
|
+
tax_total: e.calculation.amount,
|
|
83
|
+
total: e.total,
|
|
84
|
+
is_finalized: r,
|
|
85
|
+
lines: e.calculation.enabled && e.calculation.mode === "manual" ? e.calculation.lines.map((t) => ({
|
|
86
|
+
scope: "aggregate",
|
|
87
|
+
source: "manual",
|
|
88
|
+
amount: t.amount,
|
|
89
|
+
taxable_amount: e.calculation.taxableSubtotal,
|
|
90
|
+
description: t.name,
|
|
91
|
+
rate: {
|
|
92
|
+
id: t.id ?? null,
|
|
93
|
+
display_name: t.name,
|
|
94
|
+
percentage: t.rate,
|
|
95
|
+
country: t.country_code,
|
|
96
|
+
state: t.state_code ?? null
|
|
97
|
+
}
|
|
98
|
+
})) : [],
|
|
99
|
+
updated_at: t()
|
|
100
|
+
};
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
102
|
+
function l(e) {
|
|
103
|
+
return {
|
|
104
|
+
id: e.id,
|
|
105
|
+
display_name: e.display_name,
|
|
106
|
+
percentage: e.percentage,
|
|
107
|
+
effective_percentage: e.effective_percentage,
|
|
108
|
+
jurisdiction: e.jurisdiction,
|
|
109
|
+
jurisdiction_level: e.jurisdiction_level,
|
|
110
|
+
country: e.country,
|
|
111
|
+
state: e.state,
|
|
112
|
+
tax_type: e.tax_type,
|
|
113
|
+
inclusive: e.inclusive,
|
|
114
|
+
description: e.description
|
|
115
|
+
};
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
is_finalized: !0,
|
|
152
|
-
lines: u,
|
|
153
|
-
updated_at: c()
|
|
154
|
-
};
|
|
117
|
+
function u(e) {
|
|
118
|
+
let n = e.currency || e.session.currency || "usd", r = typeof e.session.amount_total == "number" ? e.session.amount_total : 0, i = e.session.total_details?.amount_tax ?? 0, a = [];
|
|
119
|
+
for (let t of e.lineItems) for (let e of t.taxes || []) a.push({
|
|
120
|
+
scope: "line_item",
|
|
121
|
+
source: "stripe_checkout",
|
|
122
|
+
amount: e.amount,
|
|
123
|
+
taxable_amount: e.taxable_amount,
|
|
124
|
+
description: t.description || void 0,
|
|
125
|
+
line_item_id: t.id,
|
|
126
|
+
taxability_reason: e.taxability_reason,
|
|
127
|
+
rate: l(e.rate)
|
|
128
|
+
});
|
|
129
|
+
if (a.length === 0) for (let t of e.session.total_details?.breakdown?.taxes || []) a.push({
|
|
130
|
+
scope: "aggregate",
|
|
131
|
+
source: "stripe_checkout",
|
|
132
|
+
amount: t.amount,
|
|
133
|
+
taxable_amount: t.taxable_amount,
|
|
134
|
+
description: t.rate.display_name,
|
|
135
|
+
taxability_reason: t.taxability_reason,
|
|
136
|
+
rate: l(t.rate)
|
|
137
|
+
});
|
|
138
|
+
let s = o(a);
|
|
139
|
+
return {
|
|
140
|
+
source: i > 0 || s.length > 0 ? "stripe_checkout" : "none",
|
|
141
|
+
mode: e.fallbackMode === "manual" ? "manual" : "automatic",
|
|
142
|
+
currency: n,
|
|
143
|
+
subtotal: e.subtotal,
|
|
144
|
+
shipping_total: e.shippingTotal,
|
|
145
|
+
tax_total: i,
|
|
146
|
+
total: r,
|
|
147
|
+
is_finalized: !0,
|
|
148
|
+
lines: s,
|
|
149
|
+
updated_at: t()
|
|
150
|
+
};
|
|
155
151
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
x as buildOrderTaxDetailsFromCalculation,
|
|
159
|
-
b as buildOrderTaxDetailsFromStripeSession,
|
|
160
|
-
f as getOrderTaxRateJurisdiction,
|
|
161
|
-
l as getOrderTaxRateLabel,
|
|
162
|
-
s as getOrderTaxRatePercentage,
|
|
163
|
-
y as normalizeOrderTaxDetails
|
|
164
|
-
};
|
|
152
|
+
//#endregion
|
|
153
|
+
export { o as aggregateOrderTaxLines, c as buildOrderTaxDetailsFromCalculation, u as buildOrderTaxDetailsFromStripeSession, i as getOrderTaxRateJurisdiction, n as getOrderTaxRateLabel, r as getOrderTaxRatePercentage, s as normalizeOrderTaxDetails };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./ProductScopePicker.cjs");let t=require("@nextblock-cms/utils"),n=require("react/jsx-runtime"),r=require("@nextblock-cms/ui");function i(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,16)}function a(e,n){let r=(0,t.getCurrencyMinorUnitFactor)(n)===1?0:2;return e.toFixed(r)}function o(e,n){return e?.discount_amount?e.discount_type===`fixed`?a((0,t.minorUnitAmountToMajor)(e.discount_amount,n),n):e.discount_amount:10}function s({action:t,products:a,coupon:s,selectedProductIds:c=[],submitLabel:l,currencyCode:u=`USD`}){return(0,n.jsxs)(`form`,{action:t,children:[(0,n.jsx)(`input`,{type:`hidden`,name:`currency_code`,value:u}),(0,n.jsxs)(r.Card,{children:[(0,n.jsx)(r.CardHeader,{children:(0,n.jsx)(r.CardTitle,{children:s?.id?`Edit Coupon`:`Create Coupon`})}),(0,n.jsxs)(r.CardContent,{className:`space-y-6`,children:[(0,n.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`coupon-code`,children:`Code`}),(0,n.jsx)(r.Input,{id:`coupon-code`,name:`code`,defaultValue:s?.code||``,className:`uppercase`,required:!0})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`coupon-name`,children:`Name`}),(0,n.jsx)(r.Input,{id:`coupon-name`,name:`name`,defaultValue:s?.name||``,required:!0})]})]}),(0,n.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`provider-scope`,children:`Provider scope`}),(0,n.jsxs)(`select`,{id:`provider-scope`,name:`provider_scope`,defaultValue:s?.provider_scope||`all`,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,children:[(0,n.jsx)(`option`,{value:`all`,children:`Stripe + Freemius`}),(0,n.jsx)(`option`,{value:`stripe`,children:`Stripe only`}),(0,n.jsx)(`option`,{value:`freemius`,children:`Freemius only`})]})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`discount-type`,children:`Discount type`}),(0,n.jsxs)(`select`,{id:`discount-type`,name:`discount_type`,defaultValue:s?.discount_type||`percent`,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,children:[(0,n.jsx)(`option`,{value:`percent`,children:`Percent`}),(0,n.jsx)(`option`,{value:`fixed`,children:`Fixed amount`})]})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`discount-amount`,children:`Amount`}),(0,n.jsx)(r.Input,{id:`discount-amount`,name:`discount_amount`,type:`number`,min:`0.01`,step:`0.01`,defaultValue:o(s,u),required:!0}),(0,n.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Percent coupons use 1-100. Fixed coupons use regular amounts, for example $10.00.`})]})]}),(0,n.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`starts-at`,children:`Starts at`}),(0,n.jsx)(r.Input,{id:`starts-at`,name:`starts_at`,type:`datetime-local`,defaultValue:i(s?.starts_at)})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`ends-at`,children:`Ends at`}),(0,n.jsx)(r.Input,{id:`ends-at`,name:`ends_at`,type:`datetime-local`,defaultValue:i(s?.ends_at)})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`redemption-limit`,children:`Redemption limit`}),(0,n.jsx)(r.Input,{id:`redemption-limit`,name:`redemption_limit`,type:`number`,min:`1`,defaultValue:s?.redemption_limit||``})]})]}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(r.Label,{htmlFor:`internal-note`,children:`Internal note`}),(0,n.jsx)(r.Textarea,{id:`internal-note`,name:`internal_note`,defaultValue:s?.internal_note||``,rows:3})]}),(0,n.jsxs)(`div`,{className:`rounded-lg border bg-muted/20 p-4`,children:[(0,n.jsx)(`input`,{type:`hidden`,name:`is_active`,value:`false`}),(0,n.jsxs)(`label`,{htmlFor:`coupon-active`,className:`flex cursor-pointer items-start gap-3`,children:[(0,n.jsx)(`input`,{id:`coupon-active`,name:`is_active`,type:`checkbox`,value:`true`,defaultChecked:s?.is_active??!0,className:`mt-0.5 h-4 w-4 rounded border-slate-300 text-primary focus:ring-primary`}),(0,n.jsxs)(`span`,{children:[(0,n.jsx)(`span`,{className:`block text-sm font-medium`,children:`Active`}),(0,n.jsx)(`span`,{className:`block text-sm text-muted-foreground`,children:`Active coupons can be applied by shoppers during cart and checkout.`})]})]})]}),(0,n.jsxs)(`div`,{className:`space-y-3`,children:[(0,n.jsxs)(`div`,{children:[(0,n.jsx)(`h3`,{className:`font-semibold`,children:`Product scope`}),(0,n.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Leave every product unchecked to apply this coupon to all products in the selected provider scope.`})]}),(0,n.jsx)(e.ProductScopePicker,{products:a,selectedProductIds:c})]}),(0,n.jsx)(`div`,{className:`flex justify-end`,children:(0,n.jsx)(r.Button,{type:`submit`,children:l})})]})]})]})}exports.CouponEditorForm=s;
|