dongxun6690 2019-07-04 13:29
浏览 43

自定义价格未显示在购物车和结帐页面中

I need snipet for encrease price of product in woocommerce by *x time but only for certain tag. Eg. if product tag is "test" then price is multiply by 2.5 times. I tryed with this code but in cart and checkout page not shown new price, only on shop and single product page.

function return_custom_price($price, $product) {
    if ( has_term( 'test', 'product_tag' ) ) {
        global $post, $blog_id;
        $product = wc_get_product( $post_id );
        $post_id = $post->ID;
        $price = ($price*2.5);
        return $price;
    } else {
        return $price;
    }
}
add_filter('woocommerce_get_price', 'return_custom_price', 10, 2);
  • 写回答

0条回答 默认 最新

    报告相同问题?