MarketplaceService.getProductById (customer detail)
core/services/marketplace_service.dart · getProductById
Overview
Customer-side single-product fetch used by ProductDetailScreen when it can't rely on the route extra. Returns the typed Product including variants with calculated_price.
User Flow
- loadProduct(productId) calls marketplaceServiceProvider.getProductById.
- Response includes variants + calculated_price (per-region pricing).
- Product.fromJson maps the response into the typed entity used by the screen.
Cases & Edge Cases
- Product not found → throws 'Product not found' which the controller surfaces as state.error.
- calculated_price requires the `fields=*variants.calculated_price` query — already part of the service method.
Code References
- lib/src/core/services/marketplace_service.dart:78 // getProductById
- lib/src/features/shared/marketplace/models/product.dart // Product
API Calls
- GET
/store/physical-products/:productId?fields=*variants.calculated_priceno statusCustomer-side single product fetch (fallback when ProductDetailScreen has no route extra).
Response{ product: Product }Errors- ·product not found → thrown as 'Product not found', surfaced as state.error
lib/src/features/shared/product_details/views/product_details_screen.dart // loadProductauth: customer. calculated_price requires the explicit fields query.
Notes
Customer + seller views read different endpoints (/store vs /vendor) and don't share a typed contract — be cautious when refactoring.