Home › Forums › WoodMart support forum › Remove price from Tooltip
Remove price from Tooltip
- This topic has 3 replies, 2 voices, and was last updated 7 years, 1 month ago by
Artem Temos.
-
AuthorPosts
-
February 28, 2018 at 3:24 pm #42925
miguel1876ParticipantHi guys
I added this code to show the variation price next to each variation.
//Add prices to variations add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' ); function display_price_in_variation_option_name( $term ) { global $wpdb, $product; $result = $wpdb->get_col( "SELECT slug FROM {$wpdb->prefix}terms WHERE name = '$term'" ); $term_slug = ( !empty( $result ) ) ? $result[0] : $term; $query = "SELECT postmeta.post_id AS product_id FROM {$wpdb->prefix}postmeta AS postmeta LEFT JOIN {$wpdb->prefix}posts AS products ON ( products.ID = postmeta.post_id ) WHERE postmeta.meta_key LIKE 'attribute_%' AND postmeta.meta_value = '$term_slug' AND products.post_parent = $product->id"; $variation_id = $wpdb->get_col( $query ); $parent = wp_get_post_parent_id( $variation_id[0] ); if ( $parent > 0 ) { $_product = new WC_Product_Variation( $variation_id[0] ); //this is where you can actually customize how the price is displayed return $term . ' <span>(' . woocommerce_price( $_product->get_price() ) . ')</span>'; } return $term; }
This works, however the price also appears in the tooltip. Do you have a solution to remove it? You can see in the code there is a span tag wrapping the price, so I could use that in the CSS to remove the price, however it appears that the HTML is stripped out of the Tooltip.
I thought maybe this would allow HTML, but it didn’t work:<script type="text/javascript"> jQuery(document).ready(function () { jQuery(".tooltip").tooltip({html:true}); }); </script>
Please help.
Thanks so much.
February 28, 2018 at 3:57 pm #42946
Artem TemosKeymasterHi,
You can try to modify this tooltips initialization code in the file
js/functions.js
https://gyazo.com/10d6ca5e7fde48ab86fc8f1278db9ac1
There, you can try to change some parameters or strip unnecessary HTML code somehow. Sorry, but we don’t have a working solution for this.Regards
February 28, 2018 at 5:16 pm #42970
miguel1876ParticipantHi
Thanks but it doesn’t work.
What if we wrap the code in an if statement with a conditional tag for a specific attribute (variation)?
February 28, 2018 at 6:56 pm #42986
Artem TemosKeymasterSorry, but we don’t have such customizations tips since it is out of our theme support scope.
-
AuthorPosts
- You must be logged in to create new topics. Login / Register