我没有找到如何使用WooCommerce插件在我的WordPress WebShop中自定义我的定价。
我想: 第A条12欧元/千克 B条3€/件 第C条12€/ colli
请问这怎么可能?
招呼 维姆
答案 0 :(得分:1)
您可以在functions.php上添加此内容
// Filter on cart price
add_filter( 'woocommerce_cart_product_price' , 'custom_price', 10, 2);
// Filter on product page
add_filter( 'woocommerce_get_price_html' , 'custom_price', 10, 2);
function custom_price( $price, WC_Product $product ){
// You can store the unit as custom fields
$unit = get_post_meta( $product->id, 'unit', true );
// Then concatenate with the price
$price .= $unit;
return $price;
}
然后您必须在每个产品上添加自定义字段: