Shopping (Flutter)
Shopping configurations
Customize shopping click behaviors
Product Hydration
FireworkSDK.getInstance().shopping.onUpdateProductDetails =
(UpdateProductDetailsEvent? event) async {
if (event == null) {
return null;
}
List<Product> products = [];
for (var productId in event.productIds) {
// Get the latest product info from the server, such as the host app server.
final remoteProduct = await fetchProductFromServer(productId)
final product = Product(
productId: productId,
name: remoteProduct.name, // Update the product name
description: remoteProduct.description, // Update the product description
units: remoteProduct.variants!.map((remoteProductVariant) {
return ProductUnit(
unitId: remoteProductVariant.id,
url: remoteProductVariant.url, // Update product variant url
imageUrl: remoteProductVariant.imageUrl, // Update product variant image url
isAvailable: remoteProductVariant.isAvailable, // Update product variant availability
price: ProductPrice(
amount: remoteProductVariant.amount,
currencyCode: remoteProductVariant.currencyCode,
), // Update product variant price
);
}).toList(),
);
products.add(product);
}
// The above example retrieves products one by one.
// But if the server API allows bulk retrieval of product information,
// you can also obtain remote product information in bulk.
// Such as: final remoteProducts = await fetchProductsFromServer(event.productIds)
return products;
};Reference
Last updated
Was this helpful?