Forum

Thread tagged as: Question, Shop

Perch if: Variant on sale

How I can find if the variant is on sale? "variant_on_sale" does not work. I can check "on_sale" but this is for "parent" only. How I can reach "on_sale" for variant?

Thanks

                                        <perch:if exists="has_variants AND variant_on_sale ">
                                            <div class="variant-price">
                                                <perch:variants>
                                                    <div class="variant-price__item" id="<perch:variant id="productID" type="text" />">
                                                        <span class="on-sale"><perch:variant id="price" type="shop_currency_value"  /></span>
                                                        <span class="on-sale-price"><perch:variant id="sale_price" type="shop_currency_value"   /></span>
                                                    </div>
                                                </perch:variants>
                                            </div>  
                                        </perch:if>
Maciej Pieńczewski

Maciej Pieńczewski 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd need to check details on an individual variant within the perch:variants tags.

Thank You Drew! Works great!

                                            <perch:if exists="has_variants">
                                                <div class="variant-price">
                                                    <perch:variants>
                                                       <perch:if exists="on_sale">
                                                            <div class="variant-price__item" id="<perch:variant id="productID" type="text" />">
                                                                <span class="on-sale"><perch:variant id="price" type="shop_currency_value"  /></span>
                                                                <span class="on-sale-price"><perch:variant id="sale_price" type="shop_currency_value"   /></span>
                                                            </div>
                                                       <perch:else />
                                                            <div class="variant-price__item" id="<perch:variant id="productID" type="text" />">
                                                                <perch:variant id="price" type="shop_currency_value"/>
                                                            </div>
                                                       </perch:if>
                                                    </perch:variants>
                                                </div> 
                                            </perch:if>