Hi,
All my products in the shop are on a sale so they have a regular price and sale price.
When customer adds product to the cart, I want to show product sale price for even items in the cart 2.4,6 etc and regular price for odd items in the cart. (Note - All the items are on a sale, so odd items need to show regular price instead of sale price)
Can anyone please help how can I achieve this?
Thank You.
Hi @zoyascoot1 , Here is the products on cart. It did not take the regular price for first product but instead takes sale price for both.
And their original and sale price -
I tried the below code on main-cart-items.liquid file but it did not update the pricing.
{% assign itemIndex = 0 %}
{% for item in cart.items %}
{% assign itemIndex = itemIndex | plus: 1 %}
<tr class="cart-item" id="CartItem-{{ itemIndex }}">
<!-- Existing code for image, details, and other columns -->
<td class="cart-item__totals right medium-hide large-up-hide">
<div class="loading-overlay hidden">
<!-- Existing code for loading overlay -->
</div>
<div class="cart-item__price-wrapper">
{% assign isEven = itemIndex | minus: 1 | times: -1 %}
{% if isEven %}
{%- if item.original_line_price != item.final_line_price -%}
<dl class="cart-item__discounted-prices">
<!-- Existing code for discounted prices -->
</dl>
{%- else -%}
<span class="price price--end">
{{ item.final_line_price | money }}
</span>
{%- endif -%}
{% else %}
<span class="price price--end">
{{ item.original_line_price | money }}
</span>
{% endif %}
{%- if item.variant.available and item.unit_price_measurement -%}
<div class="unit-price caption">
<!-- Existing code for unit price -->
</div>
{%- endif -%}
</div>
</td>
<!-- Remaining code for quantity, remove button, and error -->
</tr>
{% endfor %}
Hi @zoyascoot1 , On product page I need to show both the price and on cart to show orginal price for odd items and sale price for even items..