Вы можете добавить поля ввода с именем properties[some-prop-name]
в форму вашего продукта, которые будут включать обязательные данные связывания
Например, добавление следующего ввода в форму продукта будетдобавьте свойство элемента строки в ваш продукт по мере его добавления:
<input type="checkbox" name="properties[_add_to_box]" value="{{ box_identifier }}" />
Если вы хотите динамически обновлять свойства элемента строки, чтобы добавлять / переупорядочивать элементы в полях после васэто можно сделать с помощью запросов AJAX, нацеленных на конечную точку /cart/change.js
Вот пример такой команды, которую вы выполняете, когда пользователь изменяет соответствующий элемент ввода:
/* Assuming we have a variable named cart (containing the cart JSON) and the the 0-based index for the item we want to update */
var line = index + 1; //Shopify uses 1-based indexing for line-items
var qty = cart.items[index].quantity;
jQuery.ajax({
url:'/cart/change.js',
type:'post',
dataType:'json',
data:{
line: line, /* Line to edit: REQUIRED */
quantity: qty, /* 'New' quantity - If omitted, the line will change to quantity 1! */
properties:{
/*
This properties object will replace any existing properties object on the line-item, so be sure to include everything, not just what you're changing!
Properties with keys that are prepended with an underscore (_) are hidden in Shopify's checkout page.
*/
_box_id: 'box01',
'Congratulatory Message':'Hooray! You did it!'
}
},
success:function(cart){
console.log('Success!', cart)
},
error:function(err){
alert('Something went wrong!', err)
}
})
Надеюсь, это поможет вам включить вашу функцию!