• Resolved SomewhatMedia

    (@somewhatmedia)


    Hi guys,

    We’ve got a front-end for standard customers where the price includes tax. For Trade Customers we’ve got a price that’s coming in from an external system that doesn’t include tax.

    So for the same product, we’ve got £29.99 INCLUDING TAX for normal customers, and say £10.00 EXCLUDING TAX for trade customers.

    The problem I’ve got is that even if I use the pre_option_woocommerce_tax_display_shop filter to change the trade customer’s price display to EXCL, it removes the tax from the existing £10.00, rather than adds to it.

    So I need the ability to override the “Prices entered with tax” option depending on the user role – but I can’t seem to find a code reference to do this. Any advice?

    For full clarity – this is the option I’m referring to: https://i.imgur.com/ZeHLWjl.png

    Best,
    Matt

Viewing 13 replies - 1 through 13 (of 13 total)
  • Igor H

    (@ihereira)

    Hello,

    If you are implementing custom code, can you please share the part of the code that is changing the prices based on user roles?

    Can you share a copy of your site’s System Status, please? You can locate it under WooCommerce > Status. Select “Get system report” and then “Copy for support”.?

    Thank you.

    Thread Starter SomewhatMedia

    (@somewhatmedia)

    Hi Igor,

    I’ve removed the site URLs before – is there a way I can provide this to you privately if needed?

    
    ### WordPress Environment ###
    
    WordPress address (URL): REMOVED
    Site address (URL): REMOVED
    WC Version: 7.0.1
    REST API Version: ? 7.0.1
    WC Blocks Version: ? 8.5.2
    Action Scheduler Version: ? 3.5.2
    Log Directory Writable: ?
    WP Version: 6.1
    WP Multisite: –
    WP Memory Limit: 256 MB
    WP Debug Mode: –
    WP Cron: ?
    Language: en_GB
    External object cache: –
    
    ### Server Environment ###
    
    Server Info: Apache
    PHP Version: 8.0.15
    PHP Post Max Size: 128 MB
    PHP Time Limit: 300
    PHP Max Input Vars: 2500
    cURL Version: 7.79.1
    OpenSSL/1.1.1g-fips
    
    SUHOSIN Installed: –
    MySQL Version: 5.5.5-10.4.24-MariaDB-log
    Max Upload Size: 128 MB
    Default Timezone is UTC: ?
    fsockopen/cURL: ?
    SoapClient: ?
    DOMDocument: ?
    GZip: ?
    Multibyte String: ?
    Remote Post: ?
    Remote Get: ?
    
    ### Database ###
    
    WC Database Version: 7.0.1
    WC Database Prefix: 48_
    Total Database Size: 452.24MB
    Database Data Size: 260.20MB
    Database Index Size: 192.04MB
    48_woocommerce_sessions: Data: 0.09MB + Index: 0.02MB + Engine InnoDB
    48_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
    48_woocommerce_order_items: Data: 2.52MB + Index: 0.36MB + Engine InnoDB
    48_woocommerce_order_itemmeta: Data: 11.52MB + Index: 14.97MB + Engine InnoDB
    48_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
    48_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    48_woocommerce_shipping_zone_locations: Data: 0.06MB + Index: 0.06MB + Engine InnoDB
    48_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    48_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_actionscheduler_actions: Data: 9.02MB + Index: 12.27MB + Engine InnoDB
    48_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_actionscheduler_logs: Data: 10.02MB + Index: 8.03MB + Engine InnoDB
    48_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_comments: Data: 1.03MB + Index: 0.09MB + Engine InnoDB
    48_gf_draft_submissions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_gf_entry: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_gf_entry_meta: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
    48_gf_entry_notes: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_gf_form: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    48_gf_form_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    48_gf_form_revisions: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_gf_form_view: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_gf_rest_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_options: Data: 7.02MB + Index: 2.11MB + Engine InnoDB
    48_postmeta: Data: 63.55MB + Index: 36.05MB + Engine InnoDB
    48_posts: Data: 32.45MB + Index: 7.84MB + Engine InnoDB
    48_rank_math_404_logs: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_rank_math_analytics_gsc: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
    48_rank_math_analytics_objects: Data: 3.52MB + Index: 2.52MB + Engine InnoDB
    48_rank_math_internal_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_rank_math_internal_meta: Data: 1.52MB + Index: 0.00MB + Engine InnoDB
    48_rank_math_redirections: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_rank_math_redirections_cache: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_relevanssi: Data: 75.67MB + Index: 73.95MB + Engine InnoDB
    48_relevanssi_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_relevanssi_stopwords: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    48_sbi_feeds: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_sbi_feed_caches: Data: 0.14MB + Index: 0.02MB + Engine InnoDB
    48_sbi_instagram_feeds_posts: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_sbi_instagram_feed_locator: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_sbi_instagram_posts: Data: 0.09MB + Index: 0.00MB + Engine InnoDB
    48_sbi_sources: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_termmeta: Data: 0.23MB + Index: 0.34MB + Engine InnoDB
    48_terms: Data: 0.19MB + Index: 0.25MB + Engine InnoDB
    48_term_relationships: Data: 4.13MB + Index: 2.36MB + Engine InnoDB
    48_term_taxonomy: Data: 0.16MB + Index: 0.19MB + Engine InnoDB
    48_tinvwl_analytics: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_tinvwl_items: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    48_tinvwl_lists: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    48_usermeta: Data: 3.52MB + Index: 5.03MB + Engine InnoDB
    48_users: Data: 0.30MB + Index: 0.33MB + Engine InnoDB
    48_wc_admin_notes: Data: 0.05MB + Index: 0.00MB + Engine InnoDB
    48_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_wc_category_lookup: Data: 0.45MB + Index: 0.00MB + Engine InnoDB
    48_wc_customer_lookup: Data: 0.17MB + Index: 0.13MB + Engine InnoDB
    48_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
    48_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
    48_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    48_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_wc_product_meta_lookup: Data: 1.48MB + Index: 2.72MB + Engine InnoDB
    48_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    48_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    48_wdr_order_discounts: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    48_wdr_order_item_discounts: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
    48_wdr_rules: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
    48_wlr_earn_campaign: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
    48_wlr_earn_campaign_transaction: Data: 0.09MB + Index: 0.19MB + Engine InnoDB
    48_wlr_levels: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
    48_wlr_logs: Data: 0.16MB + Index: 0.06MB + Engine InnoDB
    48_wlr_points_ledger: Data: 0.11MB + Index: 0.16MB + Engine InnoDB
    48_wlr_referral: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
    48_wlr_rewards: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
    48_wlr_reward_transactions: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
    48_wlr_users: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
    48_wlr_user_rewards: Data: 0.02MB + Index: 0.11MB + Engine InnoDB
    INEXCEPTION: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
    ivnotify: Data: 0.00MB + Index: 0.00MB + Engine MyISAM
    IVPRICES: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
    IVRETAIL: Data: 29.58MB + Index: 20.09MB + Engine InnoDB
    SYPARAM: Data: 0.14MB + Index: 0.06MB + Engine InnoDB
    v_category: Data: 0.00MB + Index: 0.00MB + Engine
    v_cat_exceptions: Data: 0.00MB + Index: 0.00MB + Engine
    v_customer: Data: 0.00MB + Index: 0.00MB + Engine
    v_details: Data: 0.00MB + Index: 0.00MB + Engine
    v_ivretail_wp: Data: 0.00MB + Index: 0.00MB + Engine
    v_order: Data: 0.00MB + Index: 0.00MB + Engine
    
    ### Post Type Counts ###
    
    astra_adv_header: 3
    astra-advanced-hook: 11
    attachment: 20173
    custom_css: 1
    customize_changeset: 65
    nav_menu_item: 25
    oembed_cache: 1
    page: 19
    post: 139
    product: 12436
    revision: 111
    shop_coupon: 4
    shop_order: 35
    shop_order_refund: 1
    sp_wps_shortcodes: 1
    wp_global_styles: 1
    
    ### Security ###
    
    Secure connection (HTTPS): ?
    Hide errors from visitors: ?
    
    ### Active Plugins (22) ###
    
    Gravity Forms: by Gravity Forms – 2.6.7
    Astra Pro: by Brainstorm Force – 3.9.2
    REMOVED Add-on: by REMOVED – 1.0.0
    Disable Emails: by WebAware – 1.8.1
    Font Awesome: by Font Awesome – 4.3.1
    Google Language Translator: by Translate AI Multilingual Solutions – 6.0.15
    Smash Balloon Instagram Feed: by Smash Balloon – 6.1
    Points and Rewards for WooCommerce: by WP Swings – 1.2.12
    Relevanssi: by Mikko Saari – 4.17.1
    Rank Math SEO: by Rank Math – 1.0.101
    TI WooCommerce Wishlist: by TemplateInvaders – 2.0.9
    Spectra: by Brainstorm Force – 2.0.13
    Points and Rewards For WooCommerce Pro: by WP Swings – 2.0.2
    User Menus: by Code Atlantic – 1.3.0
    User Switching: by John Blackbourn & contributors – 1.7.0
    Woo Discount Rules PRO 2.0: by Flybasket – 2.5.1
    Woo Discount Rules: by Flybasket – 2.5.0
    Product Slider for WooCommerce: by ShapedPlugin – 2.6.2
    WooCommerce Opayo Payment Suite: by Andrew Benbow – 5.8.1
    WooCommerce PayPal Payments: by WooCommerce – 1.9.5
    WooCommerce: by Automattic – 7.0.1
    WP Encryption - One Click SSL & Force HTTPS: by WP Encryption SSL – 5.8.0
    
    ### Inactive Plugins (2) ###
    
    WordPress Importer: by wordpressdotorg – 0.8
    WPLoyalty - WooCommerce Loyalty Points, Rewards and Referral: by Wployalty – 1.1.6
    
    ### Must Use Plugins (1) ###
    
    StackCache: by Stack CP –
    
    ### Settings ###
    
    API Enabled: –
    Force SSL: –
    Currency: GBP (£)
    Currency Position: left
    Thousand Separator: ,
    Decimal Separator: .
    Number of Decimals: 2
    Taxonomies: Product Types: external (external)
    grouped (grouped)
    simple (simple)
    variable (variable)
    
    Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
    exclude-from-search (exclude-from-search)
    featured (featured)
    outofstock (outofstock)
    rated-1 (rated-1)
    rated-2 (rated-2)
    rated-3 (rated-3)
    rated-4 (rated-4)
    rated-5 (rated-5)
    
    Connected to WooCommerce.com: –
    Enforce Approved Product Download Directories: ?
    
    ### WC Pages ###
    
    Shop base: #10 - /shop/
    Basket: #11 - /basket/
    Checkout: #12 - /checkout/
    My account: #13 - /my-account/
    Terms and conditions: ? Page not set
    
    ### Theme ###
    
    Name: REMOVED
    Version: 1.0.0
    Author URL: REMOVED
    Child Theme: ?
    Parent Theme Name: Astra
    Parent Theme Version: 3.9.2 – 3.9.3 is available
    Parent Theme Author URL: REMOVED
    WooCommerce Support: ?
    
    ### Templates ###
    
    Overrides: –
    
    ### WooCommerce PayPal Payments ###
    
    Onboarded: ?
    Shop country code: GB
    WooCommerce currency supported: ?
    Advanced Card Processing available in country: ?
    Pay Later messaging available in country: ?
    Webhook status: –
    Vault enabled: ?
    Logging enabled: –
    Reference Transactions: –
    Used PayPal Checkout plugin: –
    Tracking enabled: ?
    
    ### Admin ###
    
    Enabled Features: activity-panels
    analytics
    coupons
    customer-effort-score-tracks
    experimental-products-task
    experimental-import-products-task
    experimental-fashion-sample-products
    experimental-product-tour
    shipping-smart-defaults
    shipping-setting-tour
    homescreen
    marketing
    multichannel-marketing
    mobile-app-banner
    navigation
    onboarding
    onboarding-tasks
    remote-inbox-notifications
    remote-free-extensions
    payment-gateway-suggestions
    shipping-label-banner
    subscriptions
    store-alerts
    transient-notices
    woo-mobile-welcome
    wc-pay-promotion
    wc-pay-welcome-page
    
    Disabled Features: minified-js
    new-product-management-experience
    settings
    
    Daily Cron: ? Next scheduled: 2022-11-04 08:26:45 +00:00
    Options: ?
    Notes: 60
    Onboarding: completed
    
    ### TI WooCommerce Wishlist Templates ###
    
    Overrides: –
    
    ### Action Scheduler ###
    
    Complete: 27,380
    Oldest: 2022-10-20 01:02:08 +0100
    Newest: 2022-11-03 21:53:14 +0000
    
    Failed: 8
    Oldest: 2022-09-16 10:25:49 +0100
    Newest: 2022-11-02 08:50:08 +0000
    
    Pending: 4
    Oldest: 2022-11-04 08:57:08 +0000
    Newest: 2022-11-14 20:55:57 +0000
    
    ### Opayo ###
    
    Opayo Plugin Version: ? 5.8.1
    Opayo Form Enabled?: ?
    Opayo Direct Enabled?: ?
    Opayo Direct using Protocol 4.00?: ?
    Opayo Server Enabled?: ?
    Opayo Pi Enabled?: ?
    Simple XML Available?: ?
    Opayo Reporting (Test): ?
    Opayo Reporting (Live): ?
    MCrypt: ? No
    OpenSSL: ? Yes
    OpenSSL Methods: ? Yes
    PHP Max_Input_Vars: ? 2500
    
    ### Status report information ###
    
    Generated at: 2022-11-03 23:30:42 +00:00
    

    With the prices – it does a lookup to a custom database table by comparing the user’s price book (set against user meta) then runs the following in a function:

    $results = array(); // Init return values.
    	
    	$price 			= $res["price"];	// Before discount.
    	$price_net 		= $res["price"];	// After discount.
    	$discount 		= 0;
    	
    	$results["price_net"]	= $price_net;
    	$results["price"]		= $price;
    	$results["discount"]	= $discount;
    			
    	return $results;

    This function is then returned in a number of filters such as:

    add_filter('woocommerce_product_get_price', 'usltd_custom_price', 10, 2);
     
    function usltd_custom_price ( $price, $product ) {
    		
    	if ( !is_user_logged_in() ) :	// Standard Retail Pricing
    		return $price;
    	endif;
    	
    	$prices = usltd_get_price ( $product->get_id() );
    	$trade_price = $prices["price_net"];
    	
    	if	($trade_price > 0) {
    		return $trade_price;
    	} else {
    		return $price;
    	}
    	
    }
    Saif

    (@babylon1999)

    Hello @somewhatmedia,

    Just making sure I understand this correctly, you want the tax rule to exclude users with a certain role.

    I wasn’t able to debug your code or find any workarounds, seems like working with tax including prices makes this a bit complicated.

    Also, this is considered a custom solution which is not within our scope of support here in the forums.

    Instead of reinventing the wheel, how about you use a plugin solution: https://woocommerce.com/products/price-display-including-excluding-tax/

    The plugin above allows you to have custom tax rules for certain roles, it’s also maintained by one of our partners.

    I should also note that all our extensions have a 30-day refund policy. If the product doesn’t work the way you need it or you think another product would work better, we are more than happy to provide a full refund.

    Hope this helps!

    Thread Starter SomewhatMedia

    (@somewhatmedia)

    Thanks @babylon1999

    Unfortunately, it looks like that plugin simply shows/hides taxes.

    All I really need is a way to programmatically override the setting above (Prices displayed in shop include/exclude taxes) for a user role – is there no filter for that?

    Best,
    Matt

    Saif

    (@babylon1999)

    Hello @somewhatmedia,

    You are right!

    I did some testing and the plugin also only seems to hide or show the tax on the product page.

    You can consider the following plugin instead, it has many more options to display prices per user role: https://woocommerce.com/products/role-based-pricing-for-woocommerce/

    All I really need is a way to programmatically override the setting above (Prices displayed in shop include/exclude taxes) for a user role – is there no filter for that?

    Achieving this programticly isn’t something that’s within our scope of support here in the forums.

    However, if you’ve already written a few lines of code and want someone to help you with the last bit, you can check the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers!

    Thread Starter SomewhatMedia

    (@somewhatmedia)

    Hi @babylon1999

    I’m not looking for someone to do this for me – I’m just sure there’ll be a filter for this somewhere that I can’t seem to find after pouring through the documentation.

    Best,
    Matt

    Hi @somewhatmedia

    As mentioned by Saif that this is an out-of-the-box solution for WooCommerce, I am leaving this thread open for a bit to see if anyone can chime in to help you out since custom coding is outside our scope of support.

    For questions related to development and custom coding, your best bet is to ask on any of these channels for support. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.

    WooCommerce Developer Resources Portal
    WooCommerce Community Forum
    – Hire a WooCommerce Expert

    Hope this helps!

    hi, i’m finding a solution for the same problem of @somewhatmedia. Can @somewhatmedia tell me how your resolved the problem? i found this tool https://stephensherrardplugins.com/plugins/woocommerce-wholesale-ordering/ that would do the job but if you found a more semple solution i’m glad to pay your service to get it.

    Howdy @nonchiedercilaparola

    From what I gather, the simpler solution for displaying different prices per user role is using a plugin.

    For that, feel free to check out Role Based Pricing for WooCommerce.

    Just to note, it includes:

    • 1-year extension updates
    • 1-year support
    • 30-day money-back guarantee

    I trust that points you in the right direction, but if you have more questions, let us know. We’re happy to help.

    hi, my problem isn’t “displaying different prices per user role” but is insert different price per user role, tax inclued for normal customer and without tax for professional customer.

    my problem isn’t “displaying” different prices per user role?but “inserting” different price per user role on backend side.

    Hi, @nonchiedercilaparola

    We can help you find a solution, please create your own thread for your issue.

    This is to make sure that every user’s issues receive their own thread with proper attention.

    nonchiedercilaparola

    (@nonchiedercilaparola)

    thanks for suggestions. Finally i decided to buy these two tools developed by Stephen Sherrard:
    – Woocommerce Wholesale Ordering
    – User Role Pricing

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Override “Prices entered with tax” option for user role’ is closed to new replies.