Home New Guten › Forums › WoodMart support forum › Price function
Price function
- This topic has 3 replies, 2 voices, and was last updated 2 years, 5 months ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
February 23, 2023 at 3:20 am #445562
fred-3577ParticipantI am using the following to change teh price shown on the shop pages and it is working great. But if I use the search field the product preview displays is not respecting this code. Any idea why?
function cw_change_product_price_display( $html ) { if(is_product_category() || is_front_page()) { $costpersqft = get_field('cost_sqft'); if($costpersqft) { $end_of_before = strpos($html, '</span>'); $end_of_after = strpos($html, '</bdi>'); $mystart = substr($html, 0, ($end_of_before + 7)); $myend = substr($html, $end_of_after); $costpersqft = number_format($costpersqft, 2); $html = $mystart . $costpersqft . $myend; } } return $html; } add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' ); add_filter( 'woocommerce_get_price_suffix', 'add_some_text_after_price', 99, 4 ); function add_some_text_after_price ($html, $product, $price, $qty){ if(is_product_category() || is_front_page()) { $html .= ' / sq. ft.'; } else { if(get_field('selling_uom') == 'CA') { $html .= ' per case'; } else { $html .= ' each'; } } return $html; }
February 23, 2023 at 1:08 pm #445685
Aizaz Imtiaz AwanKeymasterHello,
Sorry to say but the change that you are trying out is related to Customization and this is beyond our limitations and support policy scope. Hope you can understand our limitations.
Further, for your ease and convenience we are sharing here the Theme file names related to Search which you can check and try out the Customization in those too which you done otherwise.
Here are the Theme files related to Search:
wp-content/themes/woodmart/inc/modules/header-builder/elements/Search.php
wp-content/themes/woodmart/inc/modules/header-builder/elements/Mobilesearch.phpHope this helps !
Best Regards.
February 24, 2023 at 9:04 am #445917
fred-3577ParticipantIf I copy these into the child theme will that work? I want to make sure it does not get removed when updating
February 24, 2023 at 4:57 pm #446061
Aizaz Imtiaz AwanKeymasterHello,
Yes, if you want to make changes in any of the Theme files then you need to make sure that you do that change under the Child Theme because if the changes are done in the Parent Theme then with the Theme Update, the changes will get lost or wiped out.
Hope we have cleared your doubt now !
Best Regards
-
AuthorPosts
- You must be logged in to create new topics. Login / Register