我使用WooCommerce成员资格插件在产品页面上显示会员折扣。现在,我想显示您可以得到的折扣与会员的非会员。
,这是我不是会员时所看到的:
,这就是我当会员时所看到的:
,这是我不是会员时想要看到的:
发布于 2021-07-14 17:51:21
我很惊讶这个问题在网络上被问了多少次,但仍然没有答案。以下是我想出的解决方案:
add_action( 'woocommerce_single_product_summary', 'neonbrand_show_member_price_non_members' );
function neonbrand_show_member_price_non_members($price) {
global $product;
if ( $product->is_type( 'variable' ) ) {
$variations = $product->WC_Product_Variable::get_available_variations();
$variations_id = wp_list_pluck( $variations, 'variation_id' );
if ( ! wc_memberships_is_user_active_member( get_current_user_id(), 'vip-membership' ) ) {
$a = get_option( 'wc_memberships_rules' );
foreach($a as $value) {
if(!empty(array_intersect($variations_id, $value['object_ids']))) {
$discount = $value['discount_amount'];
$nonmember_price = $product->get_price();
$member_price[] = $nonmember_price - $discount;
}
}
echo '<p class="price"><b><i>Member Price As Low As: $'.min($member_price).'</i></b></p>';
}
}
}
我在大多数产品上都有不同的版本,所以我不得不实施“会员价格一样低”,因为这些变化有不同的折扣。显然,这一切的动机是让人们成为会员。
这应该是国际海事组织插件的一个特点。但是♂️
发布于 2020-04-24 14:19:16
我找到了一个解决办法:
echo wc_memberships()->get_member_discounts_instance() >get_product_discount($product->id);
有了这段代码,你就能找到折扣。
让我知道。
https://stackoverflow.com/questions/52392153
复制相似问题