Refresh issue while removing the product from cart page

Refresh issue while removing the product from cart page

Prince1995
New Member
7 0 0

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>

Reply 1 (1)

pawankumar
Shopify Partner
673 98 121

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!

- Need a Shopify developer? Chat on WhatsApp +91-9467121281
- Coffee Tip: Buymeacoffee  | Email: thepkpawankumar@gmail.com
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Best regards,
Pawan