Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hello
    Do you have any progress? I try the same.
    With this code you successfully change the text of the buttons and the message:

    function change_specific_availability_text( $availability ) {
    
        if ($availability[ 'class' ] == 'available-on-backorder') {
    
            $availability[ 'availability' ] = __( 'In the central warehouse', 'your-theme-textdomain' );
    
        }
    
        return $availability;
    
    }
    
    add_filter( 'woocommerce_get_availability', 'change_specific_availability_text', 20, 1 );
    
    add_filter( 'woocommerce_loop_add_to_cart_link', 'zmena_textu_button_vypis_produktu', 10, 2 );
    function zmena_textu_button_vypis_produktu( $text, $product ){
    	if ( $product->is_on_backorder( 1 ) ) {
    		$text = __( sprintf(
    		'<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
    		esc_url( $product->add_to_cart_url() ),
    		esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
    		esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ),
    		isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
    		esc_html( ''Pre-Order' )
    	), 'woocommerce' );
    	}
    	return $text;
    }
    
    add_filter( 'woocommerce_product_single_add_to_cart_text', 'wc_ninja_change_backorder_button', 10, 2 );
    function wc_ninja_change_backorder_button( $text, $product ){
    	if ( $product->is_on_backorder( 1 ) ) {
    		$text = __( 'Pre-Order', 'woocommerce' );
    	}
    	return $text;
    }
Viewing 1 replies (of 1 total)