I was creating a cart transform extension that would add an additional cost to a product if a person selects they want personalization. The personalization input fields come through as custom line item properties, and that works great. The big issue, and I’m simply amazed that this is an issue, is that there is no way to access those properties through Shopify’s Function GQL API to target that product to adjust the price. That’s a huge pain. Ok, then. Moving on, I figured I would create a separate “upcharge” product to try to merge or expand that with the personalized product. When that happens, all the custom properties disappear. Again, no idea why that is a thing. It’s incredibly frustrating, to say the least.
So, I decided to go and see what Shopify’s AI assistant would tell me. It is claiming that you can nest a product under a parent line item using the following code:
fetch('/cart/add.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
items: [
{
id: ADDON_PRODUCT_VARIANT_ID,
quantity: 1,
parent_id: parentLine.id // Use the cart line's id, not the variant id
}
]
})
The documentation for this that the AI agent keeps giving me goes to a 404 page. I do not see “parent_id” referenced anywhere in the AJAX API documentation, but the AI agent keeps claiming, “As of July 2024, nested cart lines are still a supported feature in Shopify”. I’ve tried it, and it just doesn’t work. The “child product” is added to the cart, but there is no nesting. Even if I were to remove the child product, the parent is still in the cart.
So, I am led to believe the AI assistant is giving me misinformation. Can anyone confirm if this is still a feature? If not, how have people handled this situation, where we need to keep the custom properties AND adjust the price of the product?
Thanks in advance for any and all help.