• Resolved terzag

    (@terzag)


    Hello,
    Is there a way to style the currently selected variation? e.g. a class like “active” or “selected” that is added to the default one then added to the one clicked (and removed from the others)?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WPClever

    (@wpclever)

    Hi @terzag,
    For getting specific instructions on your question, you can kindly contact our developers via this page, they will give you help. Be specific with your question.
    Best regards.

    @terzag

    Hope you already have the solution by now. I had exactly the same wish as you have (styling the currently selected variation), and after diving into the code I made a very simple change. This is what you do:

    01. After downloading and installing this plugin go to ../plugins/wpc-variations-radio-buttons/assets/js and open frontend.js file.

    02. On line 6 you will see the following code

      $('body').on('click', '.woovr-variation-radio', function() {
        var _this = $(this);
        var _variations = _this.closest('.woovr-variations');
        var _variations_form = _this.closest('.variations_form');
    
        woovr_do_select(_this, _variations, _variations_form);
    
        _this.find('input[type="radio"]').prop('checked', true);
      });

    03. After inserting the code, this is what it should look like

      $('body').on('click', '.woovr-variation-radio', function() {
    
        // Remove all 'selected' classes 
        $('.woovr-variation-radio').removeClass('selected');
        // Add class 'selected' to clicked item
        var _this = $(this).addClass('selected');
    
        var _variations = _this.closest('.woovr-variations');
        var _variations_form = _this.closest('.variations_form');
    
        woovr_do_select(_this, _variations, _variations_form);
    
        _this.find('input[type="radio"]').prop('checked', true);
      });

    That’s it! @wpclever please update these kind of requests. Frontend is very, VERY IMPORTANT(!!!), when having multiple radio buttons it is necessary to have a visual on which variation is selected/active.

    Thread Starter terzag

    (@terzag)

    Oh, yeah, the issue has been fixed a while ago, I opened a ticked on the devs website. They actually updated the plugin to make selecting the right element possible without changing the code of the plugin, though you still have to add a bit of JS code to your functions.php (in your theme) to handle the variations switch.

    See there for more details: https://wpc.ticksy.com/ticket/2308660/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to style selected variation?’ is closed to new replies.