WordPress:根据价格更改div的内容

时间:2019-10-22 11:52:51

标签: php wordpress

当商品的价格为“ 1”时,尝试对.php进行更改以返回字符串:“ Verkocht”。

原始工作代码:

<span class="b-goods-1__price_th text-primary visible-th">';
            if( $validate['auto-price_show'] ):
            $price = is_numeric($this->get_meta('_auto_price')) || $this->get_meta('_auto_price') == ''  ? $this->get_price() : $auto_translate[$this->get_price()];
                $pixad_out .= wp_kses_post($price);

            endif;
    $pixad_out .= '
</span>

当我输入“ 1”作为价格时,我尝试返回字符串“ Verkocht”。

<span class="b-goods-1__price_th text-primary visible-th">';
             if( $validate['auto-price_show'] ):
            $price = is_numeric($this->get_meta('_auto_price')) || $this->get_meta('_auto_price') == ''  ? $this->get_price() : $auto_translate[$this->get_price()];
                and wp_kses_post($price) == 1){
                    echo '<div class="b-goods-1__price_th text-primary visible-th">Verkocht</div>';
                }else{
             echo $pixad_out .= wp_kses_post($price);
                }
            endif;
$pixad_out .= '

</span>

1 个答案:

答案 0 :(得分:0)

我可以使用它

<span class="b-goods-1__price_th text-primary visible-th">';
            if( $validate['auto-price_show'] ):
            $price = is_numeric($this->get_meta('_auto_price')) || $this->get_meta('_auto_price') == ''  ? $this->get_price() : $auto_translate[$this->get_price()];

            if($this->get_meta('_auto_price') == 1){
                $pixad_out .= 'Verkocht';
            }else{
                $pixad_out .= wp_kses_post($price); 
            }

            endif;
$pixad_out .= '
</span>