Home Forums WoodMart support forum product title change depend on what variation is chosen.

product title change depend on what variation is chosen.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #571590

    shotyx123
    Participant

    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 5 months, 2 weeks ago by shotyx123.
    #571711

    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.

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