php 显示Woocommerce购物车小计划掉正常价格与销售价格

ktca8awb  于 2023-01-16  发布在  PHP
关注(0)|答案(1)|浏览(147)

有一个问题,让Woocommerce购物车小计价格显示一个划掉的正常价格和销售价格。
我试过和

<?php
    echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
?>

以及

<?php
    echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // PHPCS: XSS ok.
?>

不过,我运气不好有什么建议吗?

ltskdhd1

ltskdhd11#

<?php
                            if($cart_item[ 'data' ]->is_on_sale()){

                            echo '<del aria-hidden="true"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">'.get_woocommerce_currency_symbol().'</span>'.$cart_item[ 'data' ]->get_regular_price() * $cart_item['quantity'].'</bdi></span></del> <ins><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">'.get_woocommerce_currency_symbol().'</span>'.$cart_item[ 'data' ]->get_price() * $cart_item['quantity'].'</bdi></span></ins>'; // PHPCS: XSS ok.
                        }else{
                            
                            echo '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">'.get_woocommerce_currency_symbol().'</span>'.$cart_item[ 'data' ]->get_price() * $cart_item['quantity'].'</bdi></span>'; // PHPCS: XSS ok.
                        }
                        ?>

相关问题