Home Forums WoodMart support forum Changing the product label "HOT"

Changing the product label "HOT"

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #282504

    kiansalout
    Participant

    Hi Guys,
    I would like to know how can I change the featured product label “HOT” to “Trending” so it doesn’t override on every update.

    So far I’ve been changing it from this file and it works.
    wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.php

    if( ! function_exists( 'woodmart_product_label' ) ) {
    	function woodmart_product_label() {
    		global $product;
    
    		$output = array();
    
    		$product_attributes = woodmart_get_product_attributes_label();
    		$percentage_label = woodmart_get_opt( 'percentage_label' );
    
    		if ( $product->is_on_sale() ) {
    
    			$percentage = '';
    
    			if ( $product->get_type() == 'variable' && $percentage_label ) {
    
    				$available_variations = $product->get_variation_prices();
    				$max_percentage = 0;
    
    				foreach( $available_variations['regular_price'] as $key => $regular_price ) {
    					$sale_price = $available_variations['sale_price'][$key];
    
    					if ( $sale_price < $regular_price ) {
    						$percentage = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
    
    						if ( $percentage > $max_percentage ) {
    							$max_percentage = $percentage;
    						}
    					}
    				}
    
    				$percentage = $max_percentage;
    			} elseif ( ( $product->get_type() == 'simple' || $product->get_type() == 'external' || $product->get_type() == 'variation' ) && $percentage_label ) {
    				$percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
    			}
    
    			if ( $percentage ) {
    				$output[] = '<span class="onsale product-label">-' . $percentage . '%' . '</span>';
    			}else{
    				$output[] = '<span class="onsale product-label">' . esc_html__( 'Sale', 'woodmart' ) . '</span>';
    			}
    		}
    		
    		if( !$product->is_in_stock() ){
    			$output[] = '<span class="out-of-stock product-label">' . esc_html__( 'Sold out', 'woodmart' ) . '</span>';
    		}
    
    		if ( $product->is_featured() && woodmart_get_opt( 'hot_label' ) ) {
    			$output[] = '<span class="featured product-label">' . esc_html__( 'Hot', 'woodmart' ) . '</span>';
    		}
    		
    		if ( woodmart_get_opt( 'new_label' ) && woodmart_is_new_label_needed( get_the_ID() ) ) {
    			$output[] = '<span class="new product-label">' . esc_html__( 'New', 'woodmart' ) . '</span>';
    		}
    		
    		if ( $product_attributes ) {
    			foreach ( $product_attributes as $attribute ) {
    				$output[] = $attribute;
    			}
    		}
    		
    		if ( $output ) {
    			echo '<div class="product-labels labels-' . woodmart_get_opt( 'label_shape' ) . '">' . implode( '', $output ) . '</div>';
    		}
    	}
    }
    add_filter( 'woocommerce_sale_flash', 'woodmart_product_label', 10 );
    

    but as you can guess it’s overwritten on every update.

    I’ve tried to create an exact same path and copied the file in child theme and edited it but it doesn’t work.

    Could guide me please?

    #282546

    Hello,

    You can translate/rewrite all theme and plugin texts via PO file in WordPress. Here is a video tutorial that should help you translate your website texts with a Loco Translate plugin https://www.youtube.com/watch?v=D3NsDdMzsls&list=PLMw6W4rAaOgKKv0oexGHzpWBg1imvrval&index=3

    Please check the video tutorial to see how to save the translation file correctly. You can remove the plugin and translations would remain. Also, translations would remain after each theme update.

    Best Regards

    #282548

    kiansalout
    Participant

    Elise, I don’t need to translate because it’s English to English.
    Also at first I tried to change it in woodmart.pot directly but didn’t work which I ended up to change it as I mentioned on previous post.

    Are you suggesting me to translate English to English?

    #282742

    Hello,

    You can change the file and then delete the loco translate, the changes would remain, if you would change in the code, all the changes would be lost after the nearest update.

    We do not provide assistance replacing strings in the code.

    Best Regards

    #283361

    kiansalout
    Participant

    Yes you are right. I added english translation from woodmart.pot with loco translate and it works.

    Thank you, case solved!

    #283375

    You are welcome! If you have any questions please feel free to contact us.

    Best Regards

Tagged: 

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