Change the title to variation title according variation selection

5 votes

Change the title to variation title according variation selection

It would be very useful to set up an option: possibility to change the title to variation title according variation selection.
Category: Show Single Variations Avatar stotzbalazs shared this idea

6 Comments

  1. Avatar Ira Rabinowitz says:

    Add this to functions.php to set titles on variation change

    // Save the titles for the variations in an object
    var titles = new Object();
    titles[‘0’] = ‘get_title(); ?>’;
    get_available_variations();
    foreach ($variations as $key => $variation) { ?>
    titles[“”] = ”;

    jQuery(document).ready(function($) {

    // If we start with a variation in the address bar set the title

    if ($(‘input.variation_id’).val() > 0) {
    $(‘.product_title.entry-title’).html(titles[$(‘input.variation_id’).val()]);
    }

    $(‘input.variation_id’).change(function() {

    // Change the title on variable product when variation changes
    var var_id = $(‘input.variation_id’).val();
    if (” != var_id) {
    $(‘.product_title.entry-title’).html(titles[var_id]);
    }
    });

    $(“.variations_form”).on(“reset_data”, function() {
    $(‘.product_title.entry-title’).html(titles[‘0’]);
    });

    });

    <?PHP
    }

  2. Avatar Ira Rabinowitz says:

    It messed up my post. Let me try again

  3. Avatar Ira Rabinowitz says:

    It keeps messing up my code. Please find the code here to do this.

    https://pastebin.com/WMnc4Ch4

  4. Avatar Domenico says:

    hi I tried but I get this code syntax error, unexpected ‘var’ (T_VAR), expecting end of file.

    I’m interested in this feature

  5. Avatar frank.walle says:

    Hi. We would like to request this type of feature also.
    It would be very helpful.

    Thanks
    Frank

Leave a Reply

Your email address will not be published. Required fields are marked *

Powered by Simple feature Requests