Skip to main content
All CollectionsDeveloper Docs & Advanced Options
Add Custom Line Item Properties on Gifted Products
Add Custom Line Item Properties on Gifted Products

Sometimes it's important to include line item properties on the recipient's redemption checkout. Learn how to add this with a JS call.

Updated over a week ago

By default, line item properties that were not added by Givy are removed from the initial checkout, and don't appear on the recipient's final checkout.

This can be a problem if other apps need to see specific line items on the final order. Luckily, we have a solution!

Using the sample code below, you can add any line item properties to the _givy_properties property.

Hidden properties should begin with a "_", while visible ones should not

Sample Code

Here is some JavaScript that can be added to a page on your store which adds line item properties which will then appear on the final checkout.

Be sure to replace the values for id with the variant ID, and _givy_selling_plan_data with valid subscription data if required.

For more information on creating a custom gifting flow, check out this article

<script>
function giftSubscriptionWithProperties() {
const payload = {
items: [{
id: 42030736408716,
properties: {
_givy_recipient_name: 'Kelly',
_givy_gifter_name: 'Joe',
_givy_send_method: 'UNIQUE_LINK_SEND_METHOD',
_givy_message: 'Happy Birthday!',
_givy_selling_plan_data: [42141231234,3,'120.00'].toString(),
_givy_properties: JSON.stringify({
prop_one: 'prop one value',
prop_two: 'prop two value',
_hidden_prop: 'not visible'
})
}
}]
};

fetch(window.Shopify.routes.root + 'cart/add.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload) })

.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
}
</script>

<button onClick="giftSubscriptionWithProperties()">Gift Subscription with props</button>

Redemption Order Properties

Now, when a recipient goes to redeem their gift, the checkout will include any visible line item properties, and the order on Shopify will show all properties including the hidden ones.

Did this answer your question?