1
我试图抓住woocommerce产品的销售价格,并显示价格20%的折扣。获取woocommerce销售价格而不是正常价格?
我现在有的代码是有点工作。它抓住了“正常”的价格,并显示为20%的折扣。但我希望它能够抓住销售价格。
这是如何做woocommerce?
这是我的PHP
<?php
if($product->product_type=='variable') {
global $product;
$sales_price = esc_attr($product->get_display_price());
$discount = 20;
$currency = esc_attr(get_woocommerce_currency());
$new_price = ($sales_price * $discount)/20;
echo 'Get this product for '.$new_price.$currency.' with (Promo code)';
}
?>
这个尝试使用['$ sales_price = esc_attr($产品 - > get_sale_price()); '](https://docs.woocommerce.com/wc-apidocs/class-WC_Product.html#_is_on_sale) – LoicTheAztec