product title change depend on what variation is chosen.
-
So imagine you’re the customer and this is what happens:
1) you choose Black Belt
2) You see the different variations and change black to red
3) The description says its red and the image shows the red version but the title still says that this product is Black
can you help me?
-
This topic was modified 1 year, 1 month ago by
shotyx123.
Hello,
Navigate to Theme Settings > Custom JS > Add the following code.
jQuery( document ).ready( function( $ ) {
var title_text = $( '.product-type-variable .product_title' ).text(); // get default title
function add_variation_txt_to_title() {
var new_title_text = '';
$( '.variations select' ).each( function() {
new_title_text += ' ' + $( this ).find( ':selected' ).val(); // collect all variation selected <options>
})
$( '.product-type-variable .product_title' ).text( title_text + new_title_text ); // set new title
}
add_variation_txt_to_title(); // call on load
$( '.variations select' ).change( function() { // call on <select >change
add_variation_txt_to_title();
})
})
Best Regards.