Load price prefix for dynamic update option (WooCommerce Wholesale Prices, by Rymera Web Co )
Implement functionality to add a price prefix dynamically, compatible with the WooCommerce Wholesale Prices plugin by Rymera Web Co.
add_filter('advanced_woo_discount_rules_dynamic_price_html_update', function($strikeout_html, $product, $initial_price, $discounted_price, $discount_details, $prices){
if ( get_option( 'wwpp_settings_wholesale_price_title_text' , false ) ){
if (function_exists('wp_get_current_user') && class_exists('\Wdr\App\Helpers\Woocommerce')) {
$current_user = wp_get_current_user();
$current_user_roles = is_array( $current_user->roles ) ? $current_user->roles : array();
$product_id = \Wdr\App\Helpers\Woocommerce::getProductId($product);
$wholesale_price = 0;
if(isset($current_user_roles[0]) && !empty($current_user_roles[0])){
$wholesale_price = get_post_meta($product_id, $current_user_roles[0] . '_wholesale_price', true);
if(!empty($wholesale_price)){
$price_prefix = esc_attr(trim(get_option('wwpp_settings_wholesale_price_title_text')));
return $price_prefix.$strikeout_html;
}
}
}
}
return $strikeout_html;
}, 10, 6);