Join our new community forum for support & discussion
Join NowShow prices with taxes in listing
-
AuthorPosts
-
rosendo 10 months, 2 weeks ago
Hi HivePress team,
I would like to know if there is a workaround to show the product prices with taxes included in the listing. I checked this option in the Woocommerce configuration but it only worked for the checkout page. I understand that this config does not “override” or take effect in the TaskHive theme, but there is some config that I can do to achieve this?
Thankd in advance.
There is no such option at the moment (the final price is displayed on the checkout page depending on the selected quantity, taxes, coupons etc), but it may be possible with customizations, e.g. this hook https://hivepress.github.io/hook-reference/hivepress_v1_fields_%257Bfield_type%257D_display_value.html Also, we plan to replace the listing Price attribute with the actual WooCommerce price display in future Marketplace updates.
rosendo 10 months, 2 weeks agoHi yevhen, thank you so much for your support. Sorry, another question, could you please point me to the code I need to modify to achieve that? Final question, is there a date you are planning for an update that fixes the listing price attribute?
Sorry, there’s no specific ETA yet, but if you are familiar with WP customization basics or have a developer for custom work please check the filter hook suggested above, it is possible to use it to override the displayed price (by checking if the field name is
price
and if it is a listing page), getting the related product ID and replacing the price. Hope this helps.rosendo 10 months, 2 weeks agoThanks for your response. I am still struggling trying to achieve this since I did not find any field called price or listing_price in the code. Can you please provide me some code example just to override the listing price please? I think this can be helpful also for other users that have the same requirement. Thank you advance.
Please try using this code snippet, it replaces the price attribute with the related WooCommerce product price:
add_filter( 'hivepress/v1/fields/currency/display_value', function( $value, $field ) { if ( $field->get_name() === 'price' && is_singular( 'hp_listing' ) ) { $product = hivepress()->woocommerce->get_related_product( get_the_ID() ); if ( $product ) { $value = hivepress()->woocommerce->format_price( $product->get_price() ); } } return $value; }, 100, 2 );
rosendo 10 months, 2 weeks agoHi ihor. Thank you so much for your support. I tried this snippet and it works for override the displayed prices but it is not taking the WooCommerce prices with taxes.
I modified it so it takes WooCommerce prices including taxes. Here’s the code snippet.
add_filter( 'hivepress/v1/fields/currency/display_value', function( $value, $field ) { if ( $field->get_name() == 'price' ) { $product = hivepress()->woocommerce->get_related_product( get_the_ID() ); if ( $product ) { $value = hivepress()->woocommerce->format_price( $product->get_price_including_tax()); } } return $value; }, 100, 2 );
I just changed the
$product->get_price()
to$product->get_price_including_tax()
. Hope it helps other people searching for this.Thank you again for your incredible support.
Thank you for posting solution
-
AuthorPosts
New Reply
This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.