Home New Guten Forums WoodMart support forum Price function

Price function

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #445562

    fred-3577
    Participant

    I 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;
    }
    #445685

    Hello,

    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.php

    Hope this helps !

    Best Regards.

    #445917

    fred-3577
    Participant

    If I copy these into the child theme will that work? I want to make sure it does not get removed when updating

    #446061

    Hello,

    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

Viewing 4 posts - 1 through 4 (of 4 total)