Using CheckBoxes for products in PLP Page -magento

Here we are trying to use checkboxes for the products and select a product individually from the list

All the opertions are taking place at Magento_Catalog/product/list.phtml

Here is script for making a single selection of the product:

<script>   
     require([
        'jquery',
        'cloudflare'
        ],
        function($,cloudflare) {
        $(document).ready(function () {
            $('.product-list').click(function () {
                $('.product-list').not(this).prop('checked', false);
            });
        });
    });
</script>

//on click function is given to the checkbox

<input type="checkbox" class="product-list" onclick="checkboxdata();">

we also need to link a jqurey api of cloudflare for this functionality. it is linked using require.js file

 map: {
        '*': {
            'slick': 'js/slick',
            'sweetAlert': 'js/sweetAlert',
            "amaran": "js/jquery.amaran.min",
            "cloudflare":"js/jquery.min", //our jquery file
            "matchHeight": "js/jquery.matchHeight"
        }

    },
    "shim": {
        "bootstrap": ["jquery"],
        "slick": ["jquery"],
        "sweetAlert": ["jquery"],
        "cloudflare":["jquery"], //our jquery file
        "matchHeight": ["jquery"]
    }

js file link

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

Leave a comment

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