【问题标题】:How do I tweak WooCommerce Discount Display如何调整 WooCommerce 折扣显示
【发布时间】:2015-12-06 21:04:59
【问题描述】:

我有一个使用 WooCommerce 插件的 WordPress 网站。对产品应用折扣后,购物车会将价格显示为划掉的价格,并在底部显示折扣价。

我想要一条关于折扣最后日期的消息,例如“100 美元的早鸟价适用于 2015 年 9 月 30 日”。我将如何调整购物车上的折扣显示或者是否有插件?

提前致谢

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    销售结束日期存储为产品元数据,您可以使用get_post_meta拉取它,使用的过滤器是get_price_html

    add_filter( 'woocommerce_get_price_html', 'so32504214_price_html', 20, 2 );
    function so32504214_price_html( $price, $product ){
    
        $date = get_post_meta( $product->id, '_sale_price_dates_to', true );        
    
        if( strstr( $price, "<ins>" ) &&  "" != $date ) {
    
            $date = date("Y-m-d", $date); 
    
            return str_replace( '</ins>', ' </ins> - early bird rate applies up to '. $date , $price );
        }   
    
        return $price;
    }
    

    【讨论】:

      猜你喜欢
      • 2018-02-26
      • 2014-02-12
      • 2016-10-07
      • 1970-01-01
      • 2022-11-21
      • 2021-02-28
      • 2018-03-08
      • 2018-07-06
      • 2020-01-15
      相关资源
      最近更新 更多