Home Forums Basel support forum Problem with sold label on product

Problem with sold label on product

Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #40824

    coris8
    Participant

    Hi there,
    Since the new update I’m having issues with the sold label on product pages as it doesn’t appear anymore on the product image.
    can you help?
    I have the following code snippets in the custom css, but even if i delete it, it still doesn’t work:
    .onsale, .out-of-stock-label {
    border-radius:0;
    width:auto;
    height: auto;
    line-height: 1;
    padding: 10px 10px;
    }

    .product-images .out-of-stock-label {
    z-index: 10;
    right:15px;
    left:auto;
    }

    I attach you a link of a sold out item.
    Many thanks in advance
    Best

    #40835

    Artem Temos
    Keymaster

    Hi,

    Seems that something overrides this functionality. Maybe it is caused by some of the installed plugins or by some custom coding in the child theme.

    Regards

    #40842

    coris8
    Participant

    Hi, it’s not related to the child theme, since when I activate the parent theme, the problem is even worse… on the child theme I have the word “sold out” showing above the product image, on the parent theme there is nothing.
    Can you help?

    #40853

    Artem Temos
    Keymaster

    In this case, please, deactivate all plugins that are not related to our theme and the child theme and provide us your admin access so we can check it.

    #40897

    coris8
    Participant

    Hi,
    Here what i did:
    – I did deactivate one by one all the non theme related plugin – and clear the cache – to check if it would fix the bug, but nothing works… I suspect a bug with woocommerce
    – I did some customization on single-product woocommerce files on my child theme. So I’v tried to remove the files, but the bug is still there and by doing so I loose the text “sold out” above the product image.
    Many thanks in advance for your help

    #40925

    Artem Temos
    Keymaster

    So could you disable plugins now so we can check what is wrong?

    #40934

    coris8
    Participant

    ok done. let me know once you’v check that I can reactivate them

    #40947

    Artem Temos
    Keymaster

    Could you please send us your FTP access as well?

    #40956

    coris8
    Participant

    ok!
    can I reactivate the plugins?

    #40958

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file to do this

    
    function basel_product_label() {
    	global $product;
    	$output = array();
    	
    	$product_attributes = basel_get_product_attributes_label();
    
    	if ( $product->is_on_sale() ) {
    
    		$percentage = '';
    
    		if ( $product->get_type() == 'variable' ) {
    
    			$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' ) {
    			$percentage = round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 );
    		}
    
    		if ( $percentage && basel_get_opt( 'percentage_label' )  ) {
    			$output[] = '<span class="onsale product-label">-' . $percentage . '%' . '</span>';
    		}else{
    			$output[] = '<span class="onsale product-label">' . esc_html__( 'Sale', 'basel' ) . '</span>';
    		}
    	}
    	
    	if( !$product->is_in_stock() ){
    		$output[] = '<span class="out-of-stock product-label">' . esc_html__( 'Sold out', 'basel' ) . '</span>';
    	}
    
    	if ( $product->is_featured() && basel_get_opt( 'hot_label' ) ) {
    		$output[] = '<span class="featured product-label">' . esc_html__( 'Hot', 'basel' ) . '</span>';
    	}
    	
    	if ( get_post_meta( get_the_ID(), '_basel_new_label', true ) && basel_get_opt( 'new_label' ) ) {
    		$output[] = '<span class="new product-label">' . esc_html__( 'New', 'basel' ) . '</span>';
    	}
    	
    	if ( $product_attributes ) {
    		foreach ( $product_attributes as $attribute ) {
    			$output[] = $attribute;
    		}
    	}
    	
    	if ( $output ) {
    		echo '<div class="product-labels labels-' . basel_get_opt( 'label_shape' ) . '">' . implode( '', $output ) . '</div>';
    	}
    }

    and deactivate the child theme as well.

    #40964

    coris8
    Participant

    Ok I did paste the code snippet into my child theme function.php, then deactivate the child theme and activate the parent theme. Still doesn’t work and the plugins are still deactivated…

    #40965

    Artem Temos
    Keymaster

    Sorry, you need to continue using the child theme but remove the file basel-child/woocommerce/single-product/sale-flash.php.

    #40967

    coris8
    Participant

    I must say that this theme update was quite catastrophic, it modified my menu and deleted my footer… Maybe the downloaded file was corrupted?

    #40970

    Artem Temos
    Keymaster

    Theme updates can’t change any content like menu or footer. Such problems may appear when you switch between themes in Appearance -> Themes.

    #40972

    coris8
    Participant

    Yeah it works now, but it’s weird looking.
    https://www.kissthedesign.ch/en/product/jean-prouve-grand-repos-tecta/
    how can we do it look like the normal label (white text on black tag)?

    #40975

    Artem Temos
    Keymaster

    Try to add the following code snippet to the Custom CSS area in Theme Settings to fix this issue.

    body .single-product-content .out-of-stock {
        border: none;
        color: white;
    }
    #40978

    coris8
    Participant

    Awesome it works!!!
    Thank you for the perfect support 🙂

    #40982

    Artem Temos
    Keymaster

    You are welcome!

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

The topic ‘Problem with sold label on product’ is closed to new replies.