brainerce 1.6.0 → 1.9.0
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/AI_BUILDER_PROMPT.md +51 -2
- package/package.json +1 -1
package/AI_BUILDER_PROMPT.md
CHANGED
|
@@ -559,6 +559,54 @@ const suggestions = await client.getSearchSuggestions('blue', 5);
|
|
|
559
559
|
|
|
560
560
|
---
|
|
561
561
|
|
|
562
|
+
## Product Recommendations (Cross-Sells, Upsells, Related)
|
|
563
|
+
|
|
564
|
+
Stores can configure product relations. Use these to boost sales with smart product suggestions:
|
|
565
|
+
|
|
566
|
+
| Type | Where to Show | Purpose |
|
|
567
|
+
|------|--------------|---------|
|
|
568
|
+
| **Cross-sells** | Cart page | Complementary products ("You might also need") |
|
|
569
|
+
| **Upsells** | Product page | Premium alternatives ("Upgrade your choice") |
|
|
570
|
+
| **Related** | Bottom of product page | Similar products |
|
|
571
|
+
|
|
572
|
+
```typescript
|
|
573
|
+
import type { ProductRecommendationsResponse, CartRecommendationsResponse } from 'brainerce';
|
|
574
|
+
|
|
575
|
+
// Product page — recommendations come EMBEDDED in the product response (no extra API call needed)
|
|
576
|
+
const product = await client.getProductBySlug('some-slug');
|
|
577
|
+
const recs = (product as any).recommendations as ProductRecommendationsResponse | undefined;
|
|
578
|
+
// recs?.upsells — premium alternatives (show on product page)
|
|
579
|
+
// recs?.related — similar products (show at bottom of product page)
|
|
580
|
+
// recs?.crossSells — complementary products (typically used on cart page)
|
|
581
|
+
|
|
582
|
+
// Each recommendation has: id, name, slug, basePrice, salePrice, images[], type, inventory
|
|
583
|
+
|
|
584
|
+
// Cart page — cross-sell suggestions for cart items (separate call, since cart has no embedded recs)
|
|
585
|
+
const cart = await client.smartGetCart();
|
|
586
|
+
const cartRecs: CartRecommendationsResponse = await client.getCartRecommendations(cart.id, 4);
|
|
587
|
+
// cartRecs.recommendations — deduplicated cross-sells (excludes items already in cart)
|
|
588
|
+
|
|
589
|
+
// Render recommendation cards on product page
|
|
590
|
+
{recs?.upsells && recs.upsells.length > 0 && (
|
|
591
|
+
<section>
|
|
592
|
+
<h2>Upgrade Your Choice</h2>
|
|
593
|
+
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
|
|
594
|
+
{recs.upsells.map(item => (
|
|
595
|
+
<a key={item.id} href={`/products/${item.slug}`}>
|
|
596
|
+
<img src={item.images?.[0]?.url} alt={item.name} />
|
|
597
|
+
<p>{item.name}</p>
|
|
598
|
+
<p>{formatPrice(item.salePrice || item.basePrice)}</p>
|
|
599
|
+
</a>
|
|
600
|
+
))}
|
|
601
|
+
</div>
|
|
602
|
+
</section>
|
|
603
|
+
)}
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
> **Note:** Recommendations return empty arrays when no relations are configured — the UI just renders nothing. Always build the sections. The `getProductRecommendations()` SDK method still works as a fallback for older storefronts.
|
|
607
|
+
|
|
608
|
+
---
|
|
609
|
+
|
|
562
610
|
## Product Custom Fields (Metafields)
|
|
563
611
|
|
|
564
612
|
Products may have custom fields defined by the store owner (e.g., "Material", "Care Instructions", "Warranty").
|
|
@@ -727,8 +775,8 @@ if (params.get('oauth_success') === 'true') {
|
|
|
727
775
|
|
|
728
776
|
- [ ] **Home** (`/`) - Featured products grid
|
|
729
777
|
- [ ] **Products** (`/products`) - Product list with infinite scroll
|
|
730
|
-
- [ ] **Product Detail** (`/products/[slug]`) - Use `getProductBySlug(slug)`
|
|
731
|
-
- [ ] **Cart** (`/cart`) - Show items, quantities, totals, **coupon code input**, discount display
|
|
778
|
+
- [ ] **Product Detail** (`/products/[slug]`) - Use `getProductBySlug(slug)`. Show **upsells** + **related products** from `product.recommendations` (embedded in response)
|
|
779
|
+
- [ ] **Cart** (`/cart`) - Show items, quantities, totals, **coupon code input**, discount display, **cross-sell recommendations** via `getCartRecommendations()`
|
|
732
780
|
- [ ] **Checkout** (`/checkout`) - Address → Shipping → Payment. **Show discount in order summary!**
|
|
733
781
|
- [ ] **Success** (`/checkout/success`) - **Must call `completeGuestCheckout()`!**
|
|
734
782
|
- [ ] **Login** (`/login`) - Email/password + social buttons, handle `requiresVerification`
|
|
@@ -751,6 +799,7 @@ Some features may not be configured yet, but the store owner can enable them at
|
|
|
751
799
|
- **Product Discount Badges** → `getProductDiscountBadge(id)` returns `null` — renders nothing.
|
|
752
800
|
- **Cart Nudges** → `cart.nudges` is `[]` — renders nothing.
|
|
753
801
|
- **Coupon Input** → Always show in cart. Works even with no coupons configured.
|
|
802
|
+
- **Product Recommendations** → Upsells + related on product page (from `product.recommendations`), cross-sells on cart page (`getCartRecommendations()`). Returns empty arrays when none configured.
|
|
754
803
|
|
|
755
804
|
---
|
|
756
805
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Official SDK for building e-commerce storefronts with Brainerce Platform. Perfect for vibe-coded sites, AI-built stores (Cursor, Lovable, v0), and custom storefronts.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|