Thread Starter
nateta
(@nateta)
I don’t need it to actually give me a time frame just a confirmation to alert people its a back order item and it can be a standard message for all backorder items if that’s easier
Thread Starter
nateta
(@nateta)
Basically what I need is a pop up box that states its a backorder when clicking add to cart that they can accept or cancel
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;
}