无需立即更改woocommerce产品中的html即可节省价格

因此,我在商店中拥有的产品现在已经可以使用自定义html节省价格。 现在,我需要更改没有那些只有单一价格(正常价格)的属性的产品价格。

问题是它们具有相同的类,并且由于某些原因,当我更改html时,仅更改了was-now-save类,而具有正常价格的产品却没有更改。

   add_filter( 'woocommerce_get_price_html','bbloomer_simple_product_price_format',10,2 );

   function bbloomer_simple_product_price_format( $price,$product ) {

       $str = "Ušteda:";
       if ( $product->is_on_sale() && $product->is_type('simple') ) {
           $price = sprintf( __( '<div class="was-now-save"><ul>
           <li>
           <div class="was">
           <span class="text">MP cena:</span>%1$s</div>
           </li><li><div class="save"><span class="text">' . $str . '</span>%3$s</div></li></li><div class="now"><span class="text">Cena:</span>%2$s</div></li></ul></div>','woocommerce' ),wc_price ( $product->get_regular_price() ),wc_price( $product->get_sale_price() ),wc_price( $product->get_regular_price() - $product->get_sale_price() )  );        
       }

       return $price;
   }
endy1009 回答:无需立即更改woocommerce产品中的html即可节省价格

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3168097.html

大家都在问