What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

App Bridge get variantTitle

App Bridge get variantTitle

Sam_Larkin
Shopify Partner
6 0 2

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;
}

 

 

 

 

 

s1.pngs3.pngs2.png

 

 

Replies 0 (0)