Can’t add to cart after changing variations

Question

I’ve been working on the modifications of the select list of the variations (WordPress,Woocommerce). There are 2 buttons up and down that are expected to change them. They are working but ‘Add to cart’ isn’t active when I change one variation to another.

//buttons up and down

$(document).ready(function() {

$('<div class="select_arow_wrap"><span id="select-up" class="select-up"></span><span id="select-down" class="select-down"></span><div/>').appendTo('td.value:first');
 
$('<img id="upArrow" src="https://www.wptricks.com/wp-content/uploads/2020/08/1490129325-rounded01_82184.png" style="float : right; width: 30px; height: 20px;" />').appendTo('td.value:first');
$('<img id="downArrow" src="https://www.wptricks.com/wp-content/uploads/2020/08/1490129347-rounded02_82188.png" style="float : right; width: 30px; margin-left: -30px; height: 20px;   margin-top: 20px;" />').appendTo('td.value:first');
});

//actions
$(document).ready(function() {

    var nextListitem;
        var noOfListItems = $("select#pa_couleur > option").length-1;
        var curListItem = $("select#pa_couleur")[0].selectedIndex;
        $("#upArrow").on("click", function(){
            nextListitem = (curListItem-1 < 0) ? noOfListItems : curListItem-1;
            curListItem = nextListitem;
            $("select#pa_couleur")[0].selectedIndex = nextListitem;
        });
        $("#downArrow").on("click", function(){
           nextListitem = (curListItem+1 > noOfListItems) ? 0 : curListItem+1;
            curListItem = nextListitem;
            $("select#pa_couleur")[0].selectedIndex = nextListitem;
        });

});
                            <td class="label">
                              <label for="pa_couleur">Color</label>
                            </td>
                            <td class="value" data-children-count="1">
                                <select id="pa_couleur" class="" name="attribute_pa_couleur" data-attribute_name="attribute_pa_couleur" data-show_option_none="yes">
                                <option value="">Option:</option>
                                <option value="blue" class="attached enabled">Blue</option>
                                <option value="grey" class="attached enabled">Grey</option>
                                </select><div class="select_arow_wrap"><span id="select-up" class="select-up"></span>
                                <span id="select-down" class="select-down"></span>
                                <div></div></div><img id="upArrow" src="https://www.wptricks.com/wp-content/uploads/2020/08/1490129325-rounded01_82184.png" style="float : right; width: 30px; height: 20px;">
                                <img id="downArrow" src="https://www.wptricks.com/wp-content/uploads/2020/08/1490129347-rounded02_82188.png" style="float : right; width: 30px; margin-left: -30px; height: 20px;   margin-top: 20px;">
                            </td>
0
, , Henry49 2 years 2020-08-28T08:10:29-05:00 0 Answers 51 views 0

Leave an answer

Browse
Browse