@@ -89,24 +89,13 @@ export async function calculateCheckoutPricing(
8989 id : { in : productIds } ,
9090 storeId,
9191 deletedAt : null ,
92- status : 'active' ,
9392 } ,
9493 select : {
9594 id : true ,
9695 name : true ,
9796 price : true ,
98- currency : true ,
9997 sku : true ,
10098 inventoryQty : true ,
101- variants : {
102- where : { deletedAt : null } ,
103- select : {
104- id : true ,
105- price : true ,
106- sku : true ,
107- inventoryQty : true ,
108- } ,
109- } ,
11099 } ,
111100 } ) ;
112101
@@ -120,32 +109,23 @@ export async function calculateCheckoutPricing(
120109 // Calculate line items
121110 const lineItems : LineItemCalculation [ ] = [ ] ;
122111 let subtotal = 0 ;
123- const currency = products [ 0 ] ?. currency || 'USD' ;
112+ // Currency is stored at store level, not product level
113+ const currency = 'USD' ; // TODO: Get from store settings
124114
125115 for ( const item of items ) {
126116 const product = products . find ( p => p . id === item . productId ) ;
127117 if ( ! product ) {
128118 throw new NotFoundError ( 'Product' , item . productId ) ;
129119 }
130120
131- // Check currency consistency
132- if ( product . currency !== currency ) {
133- throw new ValidationError ( 'All products must use the same currency' ) ;
134- }
135-
136121 let unitPrice = product . price ;
137122 let sku = product . sku ;
138123 let inventoryQty = product . inventoryQty ;
139124
140125 // Handle variant pricing if variant selected
141126 if ( item . variantId ) {
142- const variant = product . variants . find ( v => v . id === item . variantId ) ;
143- if ( ! variant ) {
144- throw new NotFoundError ( 'Product variant' , item . variantId ) ;
145- }
146- unitPrice = variant . price ;
147- sku = variant . sku ;
148- inventoryQty = variant . inventoryQty ;
127+ // TODO: Add variant support - query ProductVariant table separately
128+ throw new ValidationError ( 'Product variants not yet supported' ) ;
149129 }
150130
151131 // Validate inventory
@@ -208,9 +188,9 @@ export async function calculateCheckoutPricing(
208188 * @returns Total discount amount
209189 */
210190async function calculateDiscounts (
211- storeId : string ,
212- subtotal : number ,
213- lineItems : LineItemCalculation [ ] ,
191+ _storeId : string ,
192+ _subtotal : number ,
193+ _lineItems : LineItemCalculation [ ] ,
214194 discountCode ?: string
215195) : Promise < number > {
216196 if ( ! discountCode ) {
@@ -231,9 +211,9 @@ async function calculateDiscounts(
231211 * @returns Tax amount
232212 */
233213async function calculateTax (
234- storeId : string ,
235- subtotalAfterDiscount : number ,
236- shippingTotal : number
214+ _storeId : string ,
215+ _subtotalAfterDiscount : number ,
216+ _shippingTotal : number
237217) : Promise < number > {
238218 // TODO: Implement tax calculation based on store settings and shipping address
239219 // For now, return 0 (will be implemented with tax service)
@@ -265,13 +245,6 @@ export async function validateInventoryAvailability(
265245 id : true ,
266246 name : true ,
267247 inventoryQty : true ,
268- variants : {
269- where : { deletedAt : null } ,
270- select : {
271- id : true ,
272- inventoryQty : true ,
273- } ,
274- } ,
275248 } ,
276249 } ) ;
277250
@@ -284,11 +257,8 @@ export async function validateInventoryAvailability(
284257 let availableQty = product . inventoryQty ;
285258
286259 if ( item . variantId ) {
287- const variant = product . variants . find ( v => v . id === item . variantId ) ;
288- if ( ! variant ) {
289- throw new NotFoundError ( 'Product variant' , item . variantId ) ;
290- }
291- availableQty = variant . inventoryQty ;
260+ // TODO: Add variant support - query ProductVariant table separately
261+ throw new ValidationError ( 'Product variants not yet supported' ) ;
292262 }
293263
294264 if ( availableQty < item . quantity ) {
0 commit comments