سؤال

first one simple product it is getting discount price but configurable does not getting discount price in recently viewed product.

enter image description here

getRegularPrice: function (row) {
        return row['price_info']['formatted_prices']['regular_price'];
    },
    
<if args="isSalable($row())">
    <if args="getRegularPrice($row())">
        <span css="'old-price': hasSpecialPrice($row()), 'regular-price': !hasSpecialPrice($row())">
            <span class="price-container"
                  css="getAdjustmentCssClasses($row())">
                <span if="label && hasSpecialPrice($row())"
                      class="price-label"
                      text="label"/>

                <span class="price-wrapper"
                      css="priceWrapperCssClasses"
                      attr="priceWrapperAttr"
                      data-price-amount=""
                      data-price-type=""
                      html="getRegularPrice($row())"/>

                <if args="!hasSpecialPrice($row())">
                    <each args="data: getAdjustments(), as: '$adj'">
                        <render args="$adj.getBody()"/>
                    </each>
                </if>
            </span>
                
            <span class="percent-discount" html="getPercentDiscount($row())"/>
        </span>
    </if>
</if>
##this function not working for configurable product.

how to solve this issue anyone help me

هل كانت مفيدة؟

المحلول

i have solved this issue. hope work for you

enter image description here

final-price.js to changes like that

   getPrice: function (row) {
            return row['price_info']['formatted_prices']['final_price'];            
        },

        /**
         * Get product regular price.
         *
         * @param {Object} row
         * @return {HTMLElement} regular price html
         */
        getRegularPrice: function (row) {
            return row['price_info']['formatted_prices']['regular_price'];
        },
        
        getPercentDiscount: function(row){
            if(row['price_info']['regular_price'] > row['price_info']['final_price']){
                var regular_price  = row['price_info']['regular_price'];
                var special_price  = row['price_info']['final_price'];
                var regular_price = parseInt(regular_price, 10);
                var special_price = parseInt(special_price, 10);
                var discount = 100 - Math.round((special_price/regular_price)*100);
                var discount = '('+discount+'% off)';
                return(discount);
            }
        },

special_price.html need to change

<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<if args="isSalable($row()) && hasSpecialPrice($row())">
    <span class="special-price">
        <span class="price-container"
              css="getAdjustmentCssClasses($row())">
            <span if="label"
                  class="price-label"
                  text="label"/>

            <span class="price-wrapper"
                  css="priceWrapperCssClasses"
                  attr="priceWrapperAttr"
                  data-price-amount=""
                  data-price-type="finalPrice"
                  html="getPrice($row())"/>  

            <span class="price-wrapper regularprices"
                      css="priceWrapperCssClasses"
                      attr="priceWrapperAttr"
                      data-price-amount=""
                      data-price-type=""
                      html="getRegularPrice($row())"/>

            <each args="data: getAdjustments(), as: '$adj'">
                <render args="$adj.getBody()"/>
            </each>
        </span>
          <span class="percent-discount" html="getPercentDiscount($row())"/>
    </span>
</if>

now price and discount price are showing on both simple and configurable products

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top