function assign_pmpro_level_to_role($user_id, $role)
{
global $current_user;
//checks if the user doesn't have a membership level yet
if(!$current_user->user_id) {
//we found a role related to pmpro level
if($role == "customer")
{
pmpro_changeMembershipLevel(6, $user_id); //gives default customers the level 20 free registration membership
}
}
}
add_action('add_user_role', 'assign_pmpro_level_to_role', 10, 2);
function cw_change_product_price_display( $price ) {
$user = wp_get_current_user();
if ( in_array( 'subscriber', $user->roles, true ) ) {
$text = 'text for user subscriber';
} elseif ( in_array( 'administrator', $user->roles, true ) ) {
$text = 'text for user administrator';
} elseif ( in_array( 'editor', $user->roles, true ) ) {
$text = 'text for user editor';
} elseif ( in_array( 'author', $user->roles, true ) ) {
$text = 'text for user author';
} elseif ( in_array( 'contributor', $user->roles, true ) ) {
$text = 'text for user contributor';
} else {
$text = 'default text';
}
$price .= sprintf( '<span style="color: #8e8181;font-size: 13px;">%s</span>', $text );
return $price;
}
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
#https://wordpress.stackexchange.com/questions/275213/remove-child-products-from-woocommerce-category-page#answer-275260
function exclude_product_cat_children( $wp_query ) {
if ( isset( $wp_query->query_vars['product_cat'] ) && $wp_query->is_main_query() ) {
$wp_query->set(
'tax_query', array( array (
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $wp_query->query_vars['product_cat'],
'include_children' => false
) )
);
}
}
add_filter('pre_get_posts', 'exclude_product_cat_children');
$order->get_total()
При этом информация внутри одного бренда/типа никак не пересекалась с другим в момент покупки
При этом важно чтоб внешний вид (стили или шаблоны) у витрин отличался.