Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Is there a way to get the variant title from the app bridge on the pos, when I fetch the cart the variantTitle is null?
the docs don't even have the variantTitle listed. I would expect it to be set to something like "Small / White" like the similar field in the storefront api.
function load_cart_info()
{
return new Promise(function(accept,reject,) {
let Cart = AppBridge.actions.Cart;
let cart = Cart.create(App);
var unsubscriber = cart.subscribe(Cart.Action.UPDATE, function (payload)
{
unsubscriber();
ret = {};
console.log(payload);
ret.items= payload.data.lineItems.map(function(elem) {
return {
"price":elem.price*100,
"name":buildLineItemName(elem),
"product_id":elem.productId,
"variant_id":elem.variantId,
"qty":elem.quantity
};
});
ret.price = payload.data.subtotal*100;
console.log("cart info");
console.log(ret);
accept(ret);
});
cart.dispatch(Cart.Action.FETCH);
});
}
function buildLineItemName(item)
{
let name = item.title;
if ("variantTitle" in item && item.variantTitle !== null && item.variantTitle != "Default Title") {
name += " - " + item.variantTitle;
}
return name;
}