Delete cart drawer item row with a button

Topic summary

A Shopify store owner using the Impulse theme needs help implementing a functional remove button for individual cart drawer items.

Current Situation:

  • The user successfully added a remove button to each product row in the cart drawer
  • The button displays correctly but triggers an error when clicked
  • The button does not actually delete items from the cart

Code Implementation:

  • User provided Liquid template code showing product details, pricing, and the attempted remove button implementation
  • The code includes product images, titles, variants, pricing logic, and discount allocations

Troubleshooting Attempts:

  • Lucid_Polygon suggested using code from the normal cart page (not drawer) as reference
  • Proposed solution: <a href="/cart/change?line={{forloop.index}}&quantity=0" rel="{{item.id}}">Remove Item</a>
  • This approach redirects users to the cart page instead of removing items directly from the drawer

Current Status:

  • The workaround solution functions but isn’t ideal—it sends users to the cart page rather than updating the drawer in place
  • No direct solution found for removing items within the cart drawer itself
  • Discussion remains open with the issue unresolved
Summarized with AI on November 25. AI used: claude-sonnet-4-5-20250929.

Hello,

We need a help with remove button in a cart drawer. To delete a product row. Theme: Impulse.

This will not help cause it is for emptying all the items. I need

For every item on the cart

Probably, you missunderstood me I need a button to remove an item row. Here is an example.

  • There will be a file in your theme code names Drawer or Cart Drawer or something along this lines
  • Find it in your code - Online Store > Themes > Actions […] > Edit Code
  • You need to add a button there, the code for the button is below this
  • The following code needs tweaking based on your theme as you have a custom paid theme.
  • Please post the code of your cart page here so we can tweak it.


  {%- assign img_url = product | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}
  

    
      
      
    
  

  
    

    

      
        {{ product.product.title }}
      
            
    

      

      {%- unless product.product.has_only_default_variant -%}
        
          {%- for option in product.options_with_values -%}
            
{{ option.name }}: {{ option.value }}

          {%- endfor -%}
        

      {%- endunless -%}
      {%- if product.selling_plan_allocation != empty -%}
        
          {{ product.selling_plan_allocation.selling_plan.name }}
        

      {%- endif -%}
      {%- assign property_size = product.properties | size -%}
      {% if property_size > 0 %}
        {% for p in product.properties %}
          {%- assign first_character_in_key = p.first | truncate: 1, '' -%}
          {% unless p.last == blank or first_character_in_key == '_' %}
            
              {{ p.first }}:
              {% if p.last contains '/uploads/' %}
                {{ p.last | split: '/' | last }}
              {% else %}
                {{ p.last }}
              {% endif %}
            

          {% endunless %}
        {% endfor %}
      {% endif %}
     
    

    
      

        

          
          
          
          
           
        

        
          
            {{ 'cart.general.remove' | t }}
        

      

       

      

        {% if product.original_price != product.final_price %}
          {{ 'products.general.regular_price' | t }}
          <small>
            {{ product.original_price | money }}
          </small>
          {{ 'products.general.sale_price' | t }}
          
            {{ product.final_price | money }}
          
        {% else %}
          
            {{ product.original_price | money }}
          
        {% endif %}

        {%- if product.line_level_discount_allocations != blank -%}
          {%- for discount_allocation in product.line_level_discount_allocations -%}
            <small>{{ discount_allocation.discount_application.title }} (-{{ discount_allocation.amount | money }})</small>
          {%- endfor -%}
        {%- endif -%}

        {%- if product.unit_price_measurement -%}
          {%- capture unit_price_base_unit -%}
            
              {%- if product.unit_price_measurement -%}
                {%- if product.unit_price_measurement.reference_value != 1 -%}
                  {{ product.unit_price_measurement.reference_value }}
                {%- endif -%}
                {{ product.unit_price_measurement.reference_unit }}
              {%- endif -%}
            
          {%- endcapture -%}

          
{{ product.unit_price | money }}/{{ unit_price_base_unit }}

        {%- endif -%}

    
      

    

  

It fits good but after clicking a remove button I am getting an error and it does not delete.

IT fits good but I am getting an error after clicking on it


  {%- assign img_url = product | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}
  

    
      
      
    
  

  
    

    

      
        {{ product.product.title }}
      
            
    

      

      {%- unless product.product.has_only_default_variant -%}
        
          {%- for option in product.options_with_values -%}
            
{{ option.name }}: {{ option.value }}

          {%- endfor -%}
        

      {%- endunless -%}
      {%- if product.selling_plan_allocation != empty -%}
        
          {{ product.selling_plan_allocation.selling_plan.name }}
        

      {%- endif -%}
      {%- assign property_size = product.properties | size -%}
      {% if property_size > 0 %}
        {% for p in product.properties %}
          {%- assign first_character_in_key = p.first | truncate: 1, '' -%}
          {% unless p.last == blank or first_character_in_key == '_' %}
            
              {{ p.first }}:
              {% if p.last contains '/uploads/' %}
                {{ p.last | split: '/' | last }}
              {% else %}
                {{ p.last }}
              {% endif %}
            

          {% endunless %}
        {% endfor %}
      {% endif %}
     
    

    
      

        

          
          
          
          
           
        

        
          
            {{ 'cart.general.remove' | t }}
        

      

       

      

        {% if product.original_price != product.final_price %}
          {{ 'products.general.regular_price' | t }}
          <small>
            {{ product.original_price | money }}
          </small>
          {{ 'products.general.sale_price' | t }}
          
            {{ product.final_price | money }}
          
        {% else %}
          
            {{ product.original_price | money }}
          
        {% endif %}

        {%- if product.line_level_discount_allocations != blank -%}
          {%- for discount_allocation in product.line_level_discount_allocations -%}
            <small>{{ discount_allocation.discount_application.title }} (-{{ discount_allocation.amount | money }})</small>
          {%- endfor -%}
        {%- endif -%}

        {%- if product.unit_price_measurement -%}
          {%- capture unit_price_base_unit -%}
            
              {%- if product.unit_price_measurement -%}
                {%- if product.unit_price_measurement.reference_value != 1 -%}
                  {{ product.unit_price_measurement.reference_value }}
                {%- endif -%}
                {{ product.unit_price_measurement.reference_unit }}
              {%- endif -%}
            
          {%- endcapture -%}

          
{{ product.unit_price | money }}/{{ unit_price_base_unit }}

        {%- endif -%}

    
      

    

  

You will also have code for the normal cart page (not drawer). Could you paste the code for that. We Can use the logic from that page to your drawer.


  {%- render 'breadcrumbs' -%}

  

  {%- if cart.item_count > 0 -%}
    
  {%- endif -%}

{% schema %}
{
  "name": "t:sections.main-cart.name"
}
{% endschema %}

Can you try the following code to remove it, please?

Remove Item

1 Like

If I put it instead of previous code. I am getting error

By using this code down below. After I click remove on cart drawer it sends me to cart page and from there I can delete an item.


1 Like

It’s a workaround. Sorry couldn’t help you with an easier solution.

It seems that this code is removing an item row in cart page. It is strange that there is no button on cart drawer.


          
            {{ 'cart.general.remove' | t }}