create-brainerce-store 1.14.1 → 1.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var require_package = __commonJS({
31
31
  "package.json"(exports2, module2) {
32
32
  module2.exports = {
33
33
  name: "create-brainerce-store",
34
- version: "1.14.1",
34
+ version: "1.14.2",
35
35
  description: "Scaffold a production-ready e-commerce storefront connected to Brainerce",
36
36
  bin: {
37
37
  "create-brainerce-store": "dist/index.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-brainerce-store",
3
- "version": "1.14.1",
3
+ "version": "1.14.2",
4
4
  "description": "Scaffold a production-ready e-commerce storefront connected to Brainerce",
5
5
  "bin": {
6
6
  "create-brainerce-store": "dist/index.js"
@@ -46,6 +46,7 @@ function CheckoutContent() {
46
46
  const [destinations, setDestinations] = useState<ShippingDestinations | null>(null);
47
47
  const [pickupLocations, setPickupLocations] = useState<PickupLocation[]>([]);
48
48
  const [deliveryType, setDeliveryType] = useState<'shipping' | 'pickup'>('shipping');
49
+ const [isAllDigital, setIsAllDigital] = useState(false);
49
50
 
50
51
  // Check for returning from canceled payment
51
52
  const canceled = searchParams.get('canceled') === 'true';
@@ -73,7 +74,13 @@ function CheckoutContent() {
73
74
  setCheckout(existing);
74
75
 
75
76
  // Determine step based on checkout state
76
- if (existing.deliveryType === 'pickup' && existing.pickupLocation) {
77
+ const allDigital = existing.lineItems.every(
78
+ (i) => (i.product as unknown as { isDownloadable?: boolean }).isDownloadable
79
+ );
80
+ setIsAllDigital(allDigital);
81
+ if (allDigital) {
82
+ setStep('payment');
83
+ } else if (existing.deliveryType === 'pickup' && existing.pickupLocation) {
77
84
  setDeliveryType('pickup');
78
85
  setStep('payment');
79
86
  } else if (existing.shippingAddress && existing.shippingRateId) {
@@ -93,6 +100,16 @@ function CheckoutContent() {
93
100
  if (cart && cart.id) {
94
101
  const newCheckout = await client.createCheckout({ cartId: cart.id });
95
102
  setCheckout(newCheckout);
103
+
104
+ // If all items are downloadable, skip shipping entirely
105
+ const allDigital = newCheckout.lineItems.every(
106
+ (i) => (i.product as unknown as { isDownloadable?: boolean }).isDownloadable
107
+ );
108
+ setIsAllDigital(allDigital);
109
+ if (allDigital) {
110
+ setStep('payment');
111
+ return;
112
+ }
96
113
  } else {
97
114
  setError(t('cartIsEmpty'));
98
115
  }
@@ -265,8 +282,9 @@ function CheckoutContent() {
265
282
  );
266
283
  }
267
284
 
268
- const steps: { key: CheckoutStep; label: string }[] =
269
- pickupLocations.length > 0
285
+ const steps: { key: CheckoutStep; label: string }[] = isAllDigital
286
+ ? [{ key: 'payment', label: t('stepPayment') }]
287
+ : pickupLocations.length > 0
270
288
  ? deliveryType === 'pickup'
271
289
  ? [
272
290
  { key: 'method', label: t('stepMethod') },
@@ -461,13 +479,15 @@ function CheckoutContent() {
461
479
  <div>
462
480
  <div className="mb-4 flex items-center justify-between">
463
481
  <h2 className="text-foreground text-lg font-semibold">{t('payment')}</h2>
464
- <button
465
- type="button"
466
- onClick={() => setStep(deliveryType === 'pickup' ? 'pickup' : 'shipping')}
467
- className="text-primary text-sm hover:underline"
468
- >
469
- {deliveryType === 'pickup' ? t('changePickup') : t('changeShipping')}
470
- </button>
482
+ {!isAllDigital && (
483
+ <button
484
+ type="button"
485
+ onClick={() => setStep(deliveryType === 'pickup' ? 'pickup' : 'shipping')}
486
+ className="text-primary text-sm hover:underline"
487
+ >
488
+ {deliveryType === 'pickup' ? t('changePickup') : t('changeShipping')}
489
+ </button>
490
+ )}
471
491
  </div>
472
492
 
473
493
  <PaymentStep checkoutId={checkout.id} />
@@ -543,8 +563,8 @@ function CheckoutContent() {
543
563
  )
544
564
  )}
545
565
 
546
- {/* Coupon input — show from shipping/pickup step onwards */}
547
- {cart && (step === 'shipping' || step === 'pickup' || step === 'payment') && (
566
+ {/* Coupon input — show from shipping/pickup step onwards (or immediately if digital) */}
567
+ {cart && (isAllDigital || step === 'shipping' || step === 'pickup' || step === 'payment') && (
548
568
  <div className="border-border border-t pt-4">
549
569
  <CouponInput cart={cart} onUpdate={handleCouponUpdate} />
550
570
  </div>