You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fixed cookbook steps, only try to read actual text files
* Trying triple tildes for code blocks
* Regenerating all cookbook recipes
* Fixing shopify.dev rendering of recipes
* fix formatting of notes on shopify.dev render
* Update recipes from feedback on shopify.dev versions
* Update render command to render all recipes if none specified
* in Hydrogen in Hydrogen
* More shopify.dev format fixing
* Switch to string only steps
* Regenerate all recipes
* Fixing schema
* Pulling across new step names from shopify.dev PR
* Fixing null descriptions in recipes
* I'd accidentally overwritten descriptions rather than names
Copy file name to clipboardExpand all lines: cookbook/llms/b2b.prompt.md
+62-74Lines changed: 62 additions & 74 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,21 +47,9 @@ with buyer information (company location + customer token) to ensure accurate B2
47
47
48
48
## Notes
49
49
50
-
> [!NOTE]
51
-
> This recipe requires a Shopify Plus plan for B2B functionality
52
-
53
-
> [!NOTE]
54
-
> Your store must use new customer accounts (not classic accounts)
55
-
56
-
> [!NOTE]
57
-
> Only the product display page uses contextualized queries in this example
58
-
59
50
> [!NOTE]
60
51
> For production, all product queries should be contextualized with buyer information
61
52
62
-
> [!NOTE]
63
-
> The location selector appears automatically for customers with multiple company locations
64
-
65
53
## Requirements
66
54
67
55
- Shopify Plus plan with B2B enabled
@@ -80,13 +68,13 @@ with buyer information (company location + customer token) to ensure accurate B2
80
68
81
69
## Steps
82
70
83
-
### Step 1: README.md
84
-
71
+
### Step 1: Document B2B features, requirements, and implementation details in the project README
85
72
73
+
Update the README file with comprehensive B2B commerce documentation, explaining features like company locations, quantity rules, and volume pricing implementation
86
74
87
75
#### File: /README.md
88
76
89
-
```diff
77
+
~~~diff
90
78
@@ -18,6 +18,45 @@ Hydrogen is Shopify’s stack for headless commerce. Hydrogen is designed to dov
91
79
- TypeScript and JavaScript flavors
92
80
- Minimal setup of components and routes
@@ -133,15 +121,15 @@ with buyer information (company location + customer token) to ensure accurate B2
### Step 2: Create a React context provider to manage company location state across the app
139
127
128
+
Create a React context provider that manages the selected company location state and provides location switching functionality throughout the B2B application
### Step 4: Build a modal that lets customers choose which company location to use for pricing
244
232
233
+
Create a modal component that displays available company locations and allows B2B customers to select the appropriate location for contextualized pricing
@@ -317,15 +305,15 @@ export function B2BLocationSelector() {
317
305
</div>
318
306
);
319
307
}
320
-
```
321
-
322
-
### Step 3: app/components/Header.tsx
308
+
~~~
323
309
310
+
### Step 5: Add a location selector button to the header for switching between company locations
324
311
312
+
Add a location selector button to the site header that allows B2B customers to easily switch between their company's different locations
325
313
326
314
#### File: /app/components/Header.tsx
327
315
328
-
```diff
316
+
~~~diff
329
317
@@ -7,6 +7,9 @@ import {
330
318
} from '@shopify/hydrogen';
331
319
import type {HeaderQuery, CartApiQueryFragment} from 'storefrontapi.generated';
@@ -375,15 +363,15 @@ export function B2BLocationSelector() {
375
363
const FALLBACK_HEADER_MENU = {
376
364
id: 'gid://shopify/Menu/199655587896',
377
365
items: [
378
-
```
379
-
380
-
### Step 3: app/components/PriceBreaks.tsx
366
+
~~~
381
367
368
+
### Step 6: Display volume pricing tiers that show bulk purchase discounts
382
369
370
+
Create a component that displays volume pricing breaks, showing customers the discounted prices they'll receive for bulk purchases at different quantity thresholds
@@ -423,15 +411,15 @@ export function PriceBreaks({priceBreaks}: PriceBreaksProps) {
423
411
</>
424
412
);
425
413
}
426
-
```
427
-
428
-
### Step 4: app/components/ProductForm.tsx
414
+
~~~
429
415
416
+
### Step 7: Accept quantity parameter to support B2B minimum quantity and increment rules
430
417
418
+
Update the ProductForm component to accept and handle quantity parameters that enforce B2B minimum quantities and increment rules when adding products to cart
431
419
432
420
#### File: /app/components/ProductForm.tsx
433
421
434
-
```diff
422
+
~~~diff
435
423
@@ -8,12 +8,15 @@ import {AddToCartButton} from './AddToCartButton';
436
424
import {useAside} from './Aside';
437
425
import type {ProductFragment} from 'storefrontapi.generated';
@@ -458,15 +446,15 @@ export function PriceBreaks({priceBreaks}: PriceBreaksProps) {
458
446
selectedVariant,
459
447
},
460
448
]
461
-
```
462
-
463
-
### Step 4: app/components/QuantityRules.tsx
449
+
~~~
464
450
451
+
### Step 8: Show minimum, maximum, and increment quantity requirements for B2B products
465
452
453
+
Create a component that displays B2B quantity rules to customers, showing minimum order quantities, maximum limits, and required increments for business products
### Step 12: Handle location selection and automatically set location if customer has only one
679
666
667
+
Create a route handler that processes location selection requests and automatically sets the location if a B2B customer only has access to one company location
@@ -719,15 +707,15 @@ export async function loader({context}: Route.LoaderArgs) {
719
707
exportdefaultfunction CartRoute() {
720
708
return <B2BLocationSelector />;
721
709
}
722
-
```
723
-
724
-
### Step 7: app/routes/account_.logout.tsx
710
+
~~~
725
711
712
+
### Step 13: Clear company location and customer data from cart when logging out
726
713
714
+
Update the logout process to clear B2B-specific data including selected company location and customer context from the cart session
727
715
728
716
#### File: /app/routes/account_.logout.tsx
729
717
730
-
```diff
718
+
~~~diff
731
719
@@ -7,5 +7,10 @@ export async function loader() {
732
720
}
733
721
@@ -739,15 +727,15 @@ export default function CartRoute() {
739
727
+ });
740
728
return context.customerAccount.logout();
741
729
}
742
-
```
743
-
744
-
### Step 8: app/routes/products.$handle.tsx
730
+
~~~
745
731
732
+
### Step 14: Contextualize product queries with buyer information and display B2B pricing details
746
733
734
+
Update product queries to include buyer context (company location and customer token) and display B2B-specific pricing, quantity rules, and volume discounts on product pages
747
735
748
736
#### File: /app/routes/products.$handle.tsx
749
737
750
-
```diff
738
+
~~~diff
751
739
@@ -15,6 +15,19 @@ import {ProductPrice} from '~/components/ProductPrice';
752
740
import {ProductImage} from '~/components/ProductImage';
753
741
import {ProductForm} from '~/components/ProductForm';
@@ -889,6 +877,6 @@ export default function CartRoute() {
0 commit comments