Public Ticket #3080707

display price with- and without vat

Closed
Comments
7 Tickets 4
Manuel Michaelis started the conversation 4 years ago on July 8, 2022 at 9:07am

Dear supporters,

I am using following snippet in my functions.php to display prices with and without VAT in woocommerce:

/* display price with- and without vat */
add_filter( 'woocommerce_get_price_suffix', 'bbloomer_add_price_suffix_price_inc_tax', 99, 4 );
   
function bbloomer_add_price_suffix_price_inc_tax( $suffix, $product, $price, $qty ){
     $suffix = '<span class="excltax">exkl. MwSt. </span>' . wc_price( wc_get_price_including_tax( $product ) ) . ' <span class="incltax">inkl. MwSt.</span>';
    return $suffix;
}

add_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format_min', 9999, 2 );
function bbloomer_variation_price_format_min( $price, $product ) {
   $prices = $product->get_variation_prices( true );
   $min_price = current( $prices['price'] );
   $price = sprintf( __( '%s %s', 'woocommerce' ), wc_price( $min_price ), $product->get_price_suffix() );
   return $price;
}

Unfortunately it doesn't display the prices in tthat way within the b2bking_tiered_price_table

Could you provide me with a simple solution?

Kind regards
Manuel

2,762
KingsPlugins replied 4 years ago on July 10, 2022 at 5:39pm

Hi Manuel,

Thank you for purchasing our plugin,

To make price suffixes also show within the tiered price table, I think you can add the following PHP code snippet to your site:

add_action('b2bking_tiered_table_after_price', function($post_id){
    $product = wc_get_product($post_id);
    echo $product->get_price_suffix();
}, 10, 1);

A PHP snippet can be added to functions.php, or by following our guide here: https://b2bkingplugin.com/docs/how-to-add-a-snippet-php-or-js/

Seems to be working in my tests, and the table becomes displayed like this in my tests:

8218445952.png

Kind regards,

Stefan

7 Tickets 4
Manuel Michaelis replied 4 years ago on July 14, 2022 at 12:04pm

Hi Stefan,

thanks for your reply.
I addet the {price_including_tax} suffix and your script in combination with mine.
Unfortunately it is not showing the correct pricing within the tired price table (see attachment).

Could you provide me with a script for the functions.php that makes it possible to show the prices with and without vat within the tired price table?

If thats not possible, please give me a hint for another solution.

Thanx
Manuel

7 Tickets 4
Manuel Michaelis replied 4 years ago on August 4, 2022 at 6:40am

Hi Stefan,

sorry for getting back that late.
Just wanted to say thank you for your support and work. So far it does exactly what the customer expects.
The question I have is: Will this plugin version be update safe?

...and the next request is already on its way:

I case a product has tired prices - is it possible to display the lowest price on the shop (overview) page instead of the regular price?

Looking foreward for your solution
Manuel

1
2,762
KingsPlugins replied 4 years ago on August 4, 2022 at 4:48pm

Glad to hear that's working!

Yes, that version is safe to update - I've added the hooks to the main plugin code, so it should work with all future updates.


I case a product has tired prices - is it possible to display the lowest price on the shop (overview) page instead of the regular price?

You can go to B2BKing -> Settings-> Tiered Pricing and enable 'Show Tiered Price Range'

and then add this PHP code snippet:

add_filter('b2bking_tiered_range_show_min', function($val){
    return true;
}, 10, 1);



It will then show the minimum like this on category pages:

3655491970.png

and on the single product page:

5421058531.png


Kind regards,

Stefan

7 Tickets 4
Manuel Michaelis replied 4 years ago on August 5, 2022 at 6:48am

Hi Stefan,
thanks for your swift reply.
Unfortunately this solution overwrites the changes we (or you) have accomplished before.

This is how it should be displayed:
5878243908.png
and this is after I followed your instruction:
4964741596.png
Do you think, that it would be possible to show the lowest price with- and without VAT? Preferably with a div or a span around each of them, so that I can access them easily via css.
7 Tickets 4
Manuel Michaelis replied 4 years ago on August 9, 2022 at 8:11am

Hi Wizard,

thanks for your suggestion - in principle this seems to work. However, I would like to ask for a few changes:
1. in the new version the price excl. Vat is under incl. VAT and vice versa. Is it possible to change this?
2. the price excl VAT appears without decimal places and Euro sign.
3. these lowest prices should please appear only on the store overview page and on cross- and upsells. But in no case on the single product.

To clarify this I attach again two screenshots.

If it helps you, I can create an access to the developer page for you.

Sorry, if I am not satisfied yet. I hope my description is clear. If you have any questions, you can reach me at any time.

Thanks
Manuel

2,762
KingsPlugins replied 4 years ago on August 10, 2022 at 12:14am

Hi Manuel,

What I sent you in the previous message requires you to disable the original snippet you posted in the first message here in this thread. Basically I combined that with the other code. I should have been more clear in the previous message.


If that doesn't work for you, I can check directly, but I'd need a backend login to your site or a staging site - there's a lot of code there including other custom code and snippets so it's very hard to look at without working on it directly,


Kind regards,

Stefan

7 Tickets 4
Manuel Michaelis replied 4 years ago on August 16, 2022 at 10:52am

Hi Stefan,
thank you for your effort, so far.
My customer has now changed his mind and wants to show only price including tax - you know how they are...

I am sure that I will get back to you with other modifications, but in the moment we can concider this ticket as solved and close it. Your support was very much appreciated.

Kind regards
Manuel

1

Sign In