1

In Woocommerce, on the product page, i want to customize the "Available for back order" text for specific variations (size L and XL). So when a customer selects size L or XL, the "Available for back order" text will show "Custom Made to Measure". I know how to change the text, but how do i do it only for size L and XL? Thank you!

function change_backorder_message( $text, $product ){ if ( $product->managing_stock() && $product->is_on_backorder( 1 ) ) { $text = __( 'Custom Made to Measure ', 'your-textdomain' ); } return $text; } add_filter( 'woocommerce_get_availability_text', 'change_backorder_message', 10, 2 ); 

1 Answer 1

1

I did it.

The "stock.available-on-backorder.step-1" is the css class of the availability text ( Available- made to measure

).

<?php add_action( 'woocommerce_before_add_to_cart_quantity', 'made_to_measure' ); function made_to_measure() { global $product; if ( $product->is_type('variable') ) { ?> <script> jQuery(document).ready(function($) { $('input.variation_id').change( function(){ if( '' != $('input.variation_id').val() ) { //var var_id = $('input.variation_id').val(); var pa_size = jQuery( "#pa_size" ).val(); if (pa_size=='l' || pa_size=='xl') { $('.stock.available-on-backorder.step-1').html("Available- made to measure"); } } }); 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.