在WooCommerce中,我有3个会员等级(银,金和白金),并且为更高的会员等级应用了更高的折扣率。
我想向所有人显示4种不同的价格(非会员,白银,黄金和白金),这样他们知道加入会员后可以在每种产品上节省多少。例如:
常规价格:US $ 100
银卡会员:$ 90
金卡会员:$ 80
白金会员:70美元
我尝试了下面的代码:
function bsc_wc_memberships_members_only_product_price() {
global $product;
$user = wp_get_current_user();
if ( !wc_memberships_is_user_active_member($user->ID, 'test') ) {
$id = $product->get_id();
$discount = get_post_meta( $id, 'member_price', true );
$price = $product->get_price();
echo 'Member price: $'.$total = $price - $discount;
}
}
add_action( 'woocommerce_before_add_to_cart_button', 'bsc_wc_memberships_members_only_product_price' );
不幸的是,它并没有真正起作用……任何建议将不胜感激。
慕盖茨4494581