在WooCommerce中,使用以下代码在简单和变量产品中的产品价格之后添加自定义标签:
add_filter('woocommerce_variation_price_html','prices_custom_labels', 10, 2 );
add_filter('woocommerce_price_html','prices_custom_labels', 10, 2 );
function prices_custom_labels( $price, $product ){
// Set HERE your custom labels names
$per_dozen = ' '. __('per dozen', 'woocommerce' );
$per_case = ' '. __('per case (20 dozens)', 'woocommerce' );
// 1) Variable products
if ($product->product_type != 'simple' && $product->variation_id ) {
// Getting the array of existing attributes values for a variation
$variation_attribute_value = $product->variation_data;
// Here we keep only the last value in this array
$last_variation_attribute_slug_value = ' ' …Run Code Online (Sandbox Code Playgroud) 在WooCommerce产品单页上,如果产品拥有销售价格,则正常价格被划掉并在其后面,突出显示销售价格.
我的问题:
如何添加标签"Old Price: XX Dollar","New Price: XX Dollar"而不仅仅是划掉的价格和新价格(销售价格)?