brainerce 1.6.0 → 1.7.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 +50 -2
- package/package.json +1 -1
package/AI_BUILDER_PROMPT.md
CHANGED
|
@@ -559,6 +559,53 @@ 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 — get upsells + related products
|
|
576
|
+
const recs: ProductRecommendationsResponse = await client.getProductRecommendations(product.id);
|
|
577
|
+
// recs.upsells — premium alternatives (show on product page)
|
|
578
|
+
// recs.related — similar products (show at bottom of product page)
|
|
579
|
+
// recs.crossSells — complementary products (typically used on cart page)
|
|
580
|
+
|
|
581
|
+
// Each recommendation has: id, name, slug, basePrice, salePrice, images, type, inventory
|
|
582
|
+
|
|
583
|
+
// Cart page — cross-sell suggestions for cart items
|
|
584
|
+
const cart = await client.smartGetCart();
|
|
585
|
+
const cartRecs: CartRecommendationsResponse = await client.getCartRecommendations(cart.id, 4);
|
|
586
|
+
// cartRecs.recommendations — deduplicated cross-sells (excludes items already in cart)
|
|
587
|
+
|
|
588
|
+
// Render recommendation cards
|
|
589
|
+
{recs.upsells.length > 0 && (
|
|
590
|
+
<section>
|
|
591
|
+
<h2>Upgrade Your Choice</h2>
|
|
592
|
+
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
|
|
593
|
+
{recs.upsells.map(item => (
|
|
594
|
+
<a key={item.id} href={`/products/${item.slug}`}>
|
|
595
|
+
<img src={item.images?.[0]?.url} alt={item.name} />
|
|
596
|
+
<p>{item.name}</p>
|
|
597
|
+
<p>{formatPrice(item.salePrice || item.basePrice)}</p>
|
|
598
|
+
</a>
|
|
599
|
+
))}
|
|
600
|
+
</div>
|
|
601
|
+
</section>
|
|
602
|
+
)}
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
> **Note:** These methods return empty arrays when no relations are configured — the UI just renders nothing. Always build the sections.
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
562
609
|
## Product Custom Fields (Metafields)
|
|
563
610
|
|
|
564
611
|
Products may have custom fields defined by the store owner (e.g., "Material", "Care Instructions", "Warranty").
|
|
@@ -727,8 +774,8 @@ if (params.get('oauth_success') === 'true') {
|
|
|
727
774
|
|
|
728
775
|
- [ ] **Home** (`/`) - Featured products grid
|
|
729
776
|
- [ ] **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
|
|
777
|
+
- [ ] **Product Detail** (`/products/[slug]`) - Use `getProductBySlug(slug)`. Show **upsells** + **related products** via `getProductRecommendations()`
|
|
778
|
+
- [ ] **Cart** (`/cart`) - Show items, quantities, totals, **coupon code input**, discount display, **cross-sell recommendations** via `getCartRecommendations()`
|
|
732
779
|
- [ ] **Checkout** (`/checkout`) - Address → Shipping → Payment. **Show discount in order summary!**
|
|
733
780
|
- [ ] **Success** (`/checkout/success`) - **Must call `completeGuestCheckout()`!**
|
|
734
781
|
- [ ] **Login** (`/login`) - Email/password + social buttons, handle `requiresVerification`
|
|
@@ -751,6 +798,7 @@ Some features may not be configured yet, but the store owner can enable them at
|
|
|
751
798
|
- **Product Discount Badges** → `getProductDiscountBadge(id)` returns `null` — renders nothing.
|
|
752
799
|
- **Cart Nudges** → `cart.nudges` is `[]` — renders nothing.
|
|
753
800
|
- **Coupon Input** → Always show in cart. Works even with no coupons configured.
|
|
801
|
+
- **Product Recommendations** → Upsells + related on product page, cross-sells on cart page. `getProductRecommendations()` / `getCartRecommendations()` return empty arrays when none configured.
|
|
754
802
|
|
|
755
803
|
---
|
|
756
804
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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",
|