Shopify themes, liquid, logos, and UX
I want to change the functionality of remove button in cart page.
when i am deleting the product it should not refresh the page. right now its refreshing the page.
this is the code from cart.liquid file
<tbody class="order-summary__body">
{%- for line_item in cart.items -%}
{%- assign line_max_quantity = '' -%}
{%- if line_item.variant.inventory_management != blank and line_item.variant.inventory_policy == 'deny' -%}
{%- assign line_max_quantity = line_item.variant.inventory_quantity -%}
{%- endif -%}
<tr>
<td>{%- render 'line-item', line_item: line_item -%}</td>
<td class="hidden align-center text-center text-subdued sm:table-cell">
<line-item-quantity class="v-stack justify-center gap-2">
<input class="quantity-input" type="text" is="quantity-input" inputmode="numeric" {% if line_max_quantity != blank %}max="{{ line_max_quantity }}"{% endif %} data-line-key="{{ line_item.key }}" aria-label="{{ 'cart.order.change_quantity' | t | escape }}" value="{{ line_item.quantity }}">
<span class="text-xs">
<a href="{{ line_item.url_to_remove }}" class="link">{{ 'cart.order.remove' | t }}</a>
</span>
</line-item-quantity>
</td>
<td class="hidden align-center text-subdued text-end sm:table-cell">{{ line_item.final_line_price | money }}</td>
</tr>
{%- endfor -%}
</tbody>
Hi @Prince1995
It will require some knowledge of JS and shopify liquid to do it
instead of using href with cart remove link, you can put simple button and use cart change.js and put this line quantity to zero and after that refresh the cart content using ajax, so it is somewhat long process, this is just an idea how you can do it
Thanks!
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025