Comments 1Bram started the conversationJanuary 31, 2021 at 5:07pmHi,Do you have a code snippet to hide prices for subaccounts? The subaccounts need to order items without seeing the price. Only the mainaccounts are allowed to see the prices.Thanks in advance,Bram Gesthuizen1 Like 2,214WebWizards repliedFebruary 1, 2021 at 11:07pmHi Bram,I have replied to this ticket with more details:https://webwizards.ticksy.com/ticket/2672746I will post the snippet here as well: since this ticket is public perhaps it can help more people: add_action('plugins_loaded', function(){ if (get_user_meta(get_current_user_id(),'b2bking_account_type', true) === 'subaccount'){ add_filter( 'woocommerce_get_price_html', 'b2bking_hide_prices_subaccounts', 99999, 2 ); add_filter( 'woocommerce_variation_get_price_html', 'b2bking_hide_prices_subaccounts', 99999, 2 ); function b2bking_hide_prices_subaccounts( $price, $product ) { return ''; } // Hide prices on cart page add_filter( 'woocommerce_cart_item_price', 'b2bking_hide_prices_cart_subaccounts', 99999, 3 ); add_filter( 'woocommerce_cart_item_subtotal', 'b2bking_hide_prices_cart_subaccounts', 99999, 3 ); add_filter( 'woocommerce_cart_subtotal', 'b2bking_hide_prices_cart_subaccounts', 99999, 3 ); add_filter( 'woocommerce_cart_total', 'b2bking_hide_prices_cart_subaccounts', 99999, 3 ); function b2bking_hide_prices_cart_subaccounts(){ return 'Cart'; } // Hide cart totals entirely remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 ); remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 ); remove_action('woocommerce_thankyou', 'woocommerce_order_details_table', 10); // Hide "on sale" flash badge add_filter( 'woocommerce_sale_flash', '__return_false' ); // Hide coupon add_filter( 'woocommerce_coupons_enabled', '__return_false' ); // If go to checkout page, redirect to cart add_action( 'template_redirect', 'b2bking_cart_redirect_to_checkout', 100 ); add_filter('woocommerce_get_formatted_order_total', function($price){ return 'Order'; }); remove_action( 'woocommerce_email_order_details', array( WC()->mailer(), 'order_details' ), 10 ); function b2bking_cart_redirect_to_checkout(){ // only for checkout if ( ! is_cart() ) return; wp_redirect( get_permalink( wc_get_page_id( 'checkout' ) ) ); // redirect to cart. exit(); } } }); Sign in to reply ...
Hi,
Do you have a code snippet to hide prices for subaccounts? The subaccounts need to order items without seeing the price. Only the mainaccounts are allowed to see the prices.
Thanks in advance,
Bram Gesthuizen
Hi Bram,
I have replied to this ticket with more details:
https://webwizards.ticksy.com/ticket/2672746
I will post the snippet here as well: since this ticket is public perhaps it can help more people: