Im using shrine pro elite ecom theme and whenever there is more than one item in the cart for ex. my main product and a free gift i cannot remove the products from the cart and am given an error code “no valid id or line paramters” i have tried mostly everything from deleting apps, clearing cache, it works on refresh theme just fine however I am not using that theme for my site. Im not the best with code but i assume my problem lies there. Any help?
Hello @Swiftyy
Thank you for submitting your query to the Shopify community. I’d be happy to assist you. Could you please provide the store URL and password (if it’s password-protected) so I can review and get back to you with an update?
Hey @Swiftyy ,
The error “no valid id or line parameters” typically occurs when the cart removal buttons aren’t properly configured to pass the correct item identifiers to Shopify’s cart API. Try this:
- Add the custom JavaScript code from the artifact above to your theme:
- Go to your Shopify admin → Online Store → Themes
- Click “Actions” → “Edit code”
- Look for your theme’s main JavaScript file (usually in the Assets folder)
- Add the code at the end of the file, or create a new custom JavaScript file
// Fix for "no valid id or line paramters" error in Shrine Pro Elite Ecom theme
// Add this code to your theme.js file or in a custom JavaScript file
document.addEventListener('DOMContentLoaded', function() {
// Target all cart item remove buttons
const removeButtons = document.querySelectorAll('.cart__remove-btn, .cart-item__remove, [data-cart-remove]');
if (removeButtons.length > 0) {
removeButtons.forEach(button => {
button.addEventListener('click', function(e) {
e.preventDefault();
// Get the line item ID from various possible attributes
let lineId = this.getAttribute('data-line-id') ||
this.getAttribute('data-line') ||
this.getAttribute('data-cart-item-key') ||
this.closest('[data-line-item]')?.getAttribute('data-line-item');
// If we still don't have a line ID, try to get it from the URL
if (!lineId && this.href) {
const url = new URL(this.href);
lineId = url.searchParams.get('id') || url.searchParams.get('line');
}
// If we have a valid line ID, remove the item
if (lineId) {
removeCartItem(lineId);
} else {
console.error('Could not find line ID for cart item removal');
}
});
});
}
// Function to remove item from cart using Fetch API
function removeCartItem(lineId) {
fetch('/cart/change.js', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
id: lineId,
quantity: 0
})
})
.then(response => response.json())
.then(cart => {
// Refresh the cart display
if (typeof refreshCart === 'function') {
refreshCart(cart);
} else {
// If no refreshCart function exists, reload the page
window.location.reload();
}
})
.catch(error => {
console.error('Error removing item from cart:', error);
// Fallback - redirect to cart page
window.location.href = '/cart';
});
}
// Optional: Function to refresh cart if your theme supports it
function refreshCart(cart) {
// Update cart count
const cartCountElements = document.querySelectorAll('.cart-count, .cart-count-bubble, [data-cart-count]');
cartCountElements.forEach(el => {
el.textContent = cart.item_count;
if (cart.item_count === 0) {
el.classList.add('hide');
} else {
el.classList.remove('hide');
}
});
// If using drawer cart, open it to show updated cart
const cartDrawerElement = document.querySelector('#CartDrawer, .cart-drawer, [data-drawer-cart]');
if (cartDrawerElement && typeof openCartDrawer === 'function') {
openCartDrawer();
}
// If on cart page, reload to show updated cart
if (window.location.pathname.includes('/cart')) {
window.location.reload();
}
}
});
- If creating a new file:
-
In the Assets folder, click “Add a new asset”
-
Choose “Create a blank file”
-
Name it something like “cart-fix.js”
-
Paste the code and save
-
Then make sure it’s included in your theme.liquid or other layout file with:
{{ ‘cart-fix.js’ | asset_url | script_tag }}
-
This solution addresses multiple potential causes of your issue:
- It fixes how line IDs are detected from various attribute formats
- It creates a more robust removal process using the Fetch API
- It handles failed removals gracefully with fallbacks
- It works with both traditional cart pages and drawer carts
This should work! In case it doesn’t feel free to send us your collaborator code at the email ID below and we’ll investigate and try to fix it ASAP.
Best,
Shubham
Untechnickle
Hello,
When you refer to "
-
-
Then make sure it’s included in your theme.liquid or other layout file with:
{{ ‘cart-fix.js’ | asset_url | script_tag }}
-
Do you mean to paste the same code within the theme.liquid section? This is very confusing
Just add this line
{{ ‘cart-fix.js’ | asset_url | script_tag }}
to your theme.liquid.
Unfortunately it seems to not have worked, does it matter where i paste the line? I pasted the large code into a new asset folder with the title you suggested as well as added the line to my theme.liquid {{ ‘cart-fix.js’ | asset_url | script_tag }}
Hello, maybe you can solve my problem
here is the url: https://velmyst.com/
That was it, you did correct. There might be some other script or piece of code interfering, would you mind sharing your collaborator code on the email ID below? We’ll fix it for you.
Cheers!
Shubham
Thank you, i sent the email
Hello TheUntechnickle, I am experiencing the same issue and am unable to resolve it. Would you be able to assist me by sending me an email so that I can send you the collaborator code?
Hey @DaviSimioni,
Of course, we’d love to help! Could you send us your collaborator code via DM or email? We’ll send over a store access request, and once it’s approved, we’ll look into the issue and get it fixed.
Thanks,
Shubham | untechnickle
Good evening, Shubham.
I spoke with you on the Shopify forum about the error removing variants or units from the cart drawer. Here is my Shopify code: 9965.
https://community.shopify.com/t/cant-remove-items-from-cart-when-there-is-more-than-one-item/404150/11
Thanks,
Davi Simioni.
Hey @DaviSimioni,
We’d also need your shopify URL! It’d be great if you can DM those details.
Thanks,
Shubham
This is typically because the cart form is not submitting the correct line or id parameters for each product. In Shrine Pro Elite, the cart JavaScript is likely to only assume one item or treat freebies differently. Open your cart template (cart.liquid or cart.js) and make sure the line value for each item corresponds to Shopify’s line item indexing. Also, make sure your free gift isn’t attached to the remove option in any way. Partial, temporary fixes via theme refresh seem the issue is with JS / liquid, key is to debug the cart.js removeItem function..