buy-button-js icon indicating copy to clipboard operation
buy-button-js copied to clipboard

Adding line items with custom attributes / line item properties

Open napter opened this issue 5 years ago • 37 comments

The JS buy SDK has a way to add custom attributes. I cannot find an equivalent way to add those to line items in the cart when using the JS buy button. I have tried to add them items to the cart manually following the instructions linked above - but cannot find any documentation on how to get the checkout ID. "client.checkout.id" is unassigned.

`

	ui.createComponent('product', {
		id: 2461692624960,
		node: document.getElementById('shopifynode'),
		options: {
			product: {
			buttonDestination: 'cart',
			},
			cart: {
				startOpen: true,
				'events': {
				}
			}
		}
	}).then((c) => {

    const lineItem = {variantId: 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yMjkyOTcwMjU4NDM4NA==', quantity: 1};
    client.checkout.addLineItems(client.checkout.id, [lineItem]).then((updatedCheckout) => {
      //checkoutWindow.location = updatedCheckout.webUrl;
	  console.log(checkout.lineItems);
    });
	}

`

napter avatar Jan 18 '19 23:01 napter