我目前在数据库中有以下产品:
Woocommerce目前正在使用“价格”字段。我想这样做,如果“price\\u percent”大于0,它会将“price\\u percent”折扣添加到价格中,并使用新的价格。基本上,当我打开购物车时,我希望得到折扣价格并向客户收取费用(如果有折扣的话)。
WooCommerce/Wordpress是个新手,所以我不知道该在哪里做。
我目前在数据库中有以下产品:
Woocommerce目前正在使用“价格”字段。我想这样做,如果“price\\u percent”大于0,它会将“price\\u percent”折扣添加到价格中,并使用新的价格。基本上,当我打开购物车时,我希望得到折扣价格并向客户收取费用(如果有折扣的话)。
WooCommerce/Wordpress是个新手,所以我不知道该在哪里做。
您可以在主题或插件中使用此过滤器来过滤产品价格:
function filter_woocommerce_price( $price, $product ) {
// 1. Set your $price_percent variable
// 2. Subtract the price_percent from the price $price - $price_percent
// 3. Set the new $price
return $price;
}
add_filter( \'woocommerce_product_get_regular_price\', \'filter_woocommerce_price\', 10, 2 );
顺便说一下,您可以使用$product->get_id()
在功能内。