Prestige Theme error code "no valid id or line paramters"

Prestige Theme error code "no valid id or line paramters"

OmegaCoffee
Excursionist
38 0 4

When trying to remove items from the cart on my site it gives an error code "no valid id or line parameters". If you refresh the page and try again it works fine. It doesn't always do it either which is super confusing. 

Replies 6 (6)

Swiftyy
Tourist
7 0 1

I have this same issue except i am on a different theme, shrine pro elite ecom. Ive noticed at least in my case this occurs when there is more than one item in the cart whether its 3 of my main product or my main product plus a free gift. Devs had responded to me with some code however it did not work for me but maybe it will work for your theme 

 

Swiftyy
Tourist
7 0 1

Here is what i was provided:

  1. 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();
    }
  }
});
Copy
  • 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

 

tim
Shopify Partner
4289 490 1577

Interesting.

 

You have an app (Pickeasy) which adds line item property "_instoreAppId": "FT=NA" to the items added to cart. This happens on the cart page.

When line item properties change, the unique ID of the item in cart changes.

Because cart page was rendered before this line item property was added, the links on your cart page become invalid and this is why your "-", "+" and "Remove" buttons no longer work until you refresh the page.

 

You should talk to the App developers about this.

 

Basically, when one wants to manipulate item in cart Shopify API allows you to use one of the following IDs:

1) line number

2) variant id

3) line item id (same as variant id, but has extra number derived from line item properties)

Methods 1 and 2 are not affected by changes in line item properties, but method 3 is.

 

Different themes may use different methods. Most of them, though (including yours) use method 3, which seems to be incompatible with the Pickeasy app.

Some App reviews mention this problem.

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
OmegaCoffee
Excursionist
38 0 4

This appears to be correct. Reaching out to pickeasy now 

tim
Shopify Partner
4289 490 1577

Let us know what they say/do

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
OmegaCoffee
Excursionist
38 0 4

They got in our system and poked around. Then sent this which did in fact fix it.

 

Hi,

 

Thank you for your patience.

 

We are pleased to inform you that our technical team has successfully implemented the updatePropertyOnCheckout feature. This update ensures that property alterations will only take place when the checkout action is triggered.

 

Please take a moment to verify this update on your end. Should you encounter any issues or require further assistance, don’t hesitate to reach out. We are more than happy to help!