INNER CODE UNIT · JavaScript
product
Cezerin2/Server · src/ajaxRouter.js:56
const product = products.find(p => p.id === cartItem.product_id);
if (product) {
cartItem.image_url =
product.images && product.images.length > 0
? product.images[0].url
: null;
cartItem.path = product.path;
cartItem.stock_backorder = product.stock_backorder;
cartItem.stock_preorder = product.stock_preorder;
if (cartItem.variant_id && cartItem.variant_id.length > 0) {
const variant = OrderItemsService.getVariantFromProduct(
product,
cartItem.variant_id
);
cartItem.stock_quantity = variant ? variant.stock_quantity : 0;
} else {
cartItem.stock_quantity = product.stock_quantity;
}