INNER CODE UNIT · JavaScript
getUserAgent
Cezerin2/Server · src/ajaxRouter.js:53
const getUserAgent = req => req.get('user-agent');
const fillCartItemWithProductData = (products, cartItem) => {
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;