{"id":5974,"date":"2024-06-17T08:05:42","date_gmt":"2024-06-17T08:05:42","guid":{"rendered":"https:\/\/halkoo.com\/?p=5974"},"modified":"2024-06-17T12:55:15","modified_gmt":"2024-06-17T12:55:15","slug":"mostrare-i-prezzi-delle-varianti-in-woocommerce-con-il-formato-da-xxe","status":"publish","type":"post","link":"https:\/\/halkoo.com\/en\/show-variant-prices-in-woocommerce-with-xxe-format\/","title":{"rendered":"Displaying variant prices in WooCommerce with the format 'From XX\u20ac'."},"content":{"rendered":"<p>In the world of e-commerce, the way you present the price of a product can make the difference between a purchase and an abandonment. One of the most effective ways to make it more attractive is to use the \"From XX\u20ac\" format to display the prices of product variants in WooCommerce. In this article, I will guide you step by step on how to insert a code snippet to achieve this.<\/p>\n\n\n\n<p><strong>Step 1: Preparation<\/strong><\/p>\n\n\n\n<p>Before you start, make sure you have installed and activated the WooCommerce plugin on your website. In addition, you should have a good knowledge of the basic functionality of WooCommerce and the management of products and variants.<\/p>\n\n\n\n<p><strong>Step 2: Create a function file<\/strong><\/p>\n\n\n\n<p>To insert the code snippet, you need to create a custom function file in your WordPress theme. To do this, open the theme editor and create a new file called <code>functions.php<\/code> in the folder <code>wp-content\/themes\/your-theme<\/code>.<\/p>\n\n\n\n<p><em>I recommend you do this in your 'Child' theme folder so that you do not lose these changes when you go to update your theme.<\/em><\/p>\n\n\n\n<p><strong>Step 3: Insert the code snippet<\/strong><\/p>\n\n\n\n<p>In the file <code>functions.php<\/code>, add the following code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/**\n * Snippet Name:\tWooCommerce Show Coupon Code Used In Emails\n * Snippet Author:\thalkoo.com\n *\/\n\nadd_filter( 'woocommerce_get_price_html', 'change_variable_products_price_display', 10, 2 );\n\nfunction change_variable_products_price_display( $price, $product ) {\n    \/\/ Only for variable products type\n    if( ! $product->is_type('variable') ) return $price;\n    $prices = $product->get_variation_prices( true );\n    if ( empty( $prices['price'] ) )\n        return apply_filters( 'woocommerce_variable_empty_price_html', '', $product );\n    $min_price = current( $prices['price'] );\n    $max_price = end( $prices['price'] );\n    $prefix_html = '&lt;span class=\"price-prefix\">' . __('Da ') . '&lt;\/span>';\n    $prefix = $min_price !== $max_price ? $prefix_html : ''; \/\/ HERE the prefix\n    return apply_filters( 'woocommerce_variable_price_html', $prefix . wc_price( $min_price ) . $product->get_price_suffix(), $product );\n}<\/pre>\n\n\n\n<p>Save the file.<\/p>\n\n\n\n<p>After following these steps, the prices of WooCommerce product variants on your website should be displayed in the format 'From XX\u20ac'.<\/p>\n\n\n\n<p>In this way, you can make your website more attractive and increase the chances of conversion for your customers. Happy sales!<\/p>\n\n\n\n<p>Need help? Write to <a href=\"mailto:info@halkoo.com\">info@halkoo.com<\/a> to receive a customised quote for your new website or e-commerce shop.<\/p>","protected":false},"excerpt":{"rendered":"<p>In the world of e-commerce, the way you present the price of a product can make the difference between a purchase and [...].<\/p>","protected":false},"author":1,"featured_media":5977,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[54],"tags":[67,66,50,47],"class_list":["post-5974","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-formato","tag-varianti","tag-woocommerce","tag-wordpress"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/halkoo.com\/en\/wp-json\/wp\/v2\/posts\/5974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/halkoo.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/halkoo.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/halkoo.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/halkoo.com\/en\/wp-json\/wp\/v2\/comments?post=5974"}],"version-history":[{"count":0,"href":"https:\/\/halkoo.com\/en\/wp-json\/wp\/v2\/posts\/5974\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/halkoo.com\/en\/wp-json\/wp\/v2\/media\/5977"}],"wp:attachment":[{"href":"https:\/\/halkoo.com\/en\/wp-json\/wp\/v2\/media?parent=5974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/halkoo.com\/en\/wp-json\/wp\/v2\/categories?post=5974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/halkoo.com\/en\/wp-json\/wp\/v2\/tags?post=5974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}