<div class="pfw-product-table "><table id="pfw-table-76570" class="display" width="100%"></table></div><script>(function($){  $(document).ready(function(){ pfw_init_table("#pfw-table-76570", [{"name":"<a class='pfw-product-name-url' target='_blank' href='https:\/\/ees.net.pk\/index.php\/product\/ees-210001-1-electricity-magnetism\/'>EES-210001-1 Electricity & Magnetism<\/a>","raw_price":"","raw_price_max":"","raw_rating":"0","raw_categories":"Basic Electronics,Modular Series"},{"name":"<a class='pfw-product-name-url' target='_blank' href='https:\/\/ees.net.pk\/index.php\/product\/new-product1-copy\/'>EES-21001 Electricity & Magnetism Trainer<\/a>","raw_price":"","raw_price_max":"","raw_rating":"0","raw_categories":"Basic Electronics,Bread Board Series"},{"name":"<a class='pfw-product-name-url' target='_blank' href='https:\/\/ees.net.pk\/index.php\/product\/ees-22002-analog-electronic-trainer\/'>EES-22002 Analog\/Electronic Trainer<\/a>","raw_price":"","raw_price_max":"","raw_rating":"0","raw_categories":"Basic Electronics,Bread Board Series"},{"name":"<a class='pfw-product-name-url' target='_blank' href='https:\/\/ees.net.pk\/index.php\/product\/ees-23003-digital-logic-trainer\/'>EES-23003 Digital Logic Trainer<\/a>","raw_price":"","raw_price_max":"","raw_rating":"0","raw_categories":"Basic Electronics,Bread Board Series"},{"name":"<a class='pfw-product-name-url' target='_blank' href='https:\/\/ees.net.pk\/index.php\/product\/ees-24004-digital-analog-trainer\/'>EES-24004 Digital \/ Analog Trainer<\/a>","raw_price":"","raw_price_max":"","raw_rating":"0","raw_categories":"Basic Electronics,Bread Board Series"},{"name":"<a class='pfw-product-name-url' target='_blank' href='https:\/\/ees.net.pk\/index.php\/product\/ees-29005-power-electronics-trainer\/'>EES-29005 Power Electronics Trainer<\/a>","raw_price":"","raw_price_max":"","raw_rating":"0","raw_categories":"Basic Electronics,Bread Board Series"},{"name":"<a class='pfw-product-name-url' target='_blank' href='https:\/\/ees.net.pk\/index.php\/product\/ees-220002-1-electronic-trainer\/'>EES-220002-1 Electronic Trainer<\/a>","raw_price":"","raw_price_max":"","raw_rating":"0","raw_categories":"Basic Electronics,Modular Series"}], [{"title":"Product Name","data":"name"},{"title":"raw_price","data":"raw_price","visible":false},{"title":"raw_price_max","data":"raw_price_max","visible":false},{"title":"raw_rating","data":"raw_rating","visible":false},{"title":"raw_categories","data":"raw_categories","visible":false}], [{"orderable":false,"responsivePriority":"1","targets":0,"className":"pfw-cell-name"}], '', false)   }); })(jQuery)</script><script>

    function pfw_init_table(tableID, tableData, tableColumns, columnDefs, filterString, hasCheckbox)
    {
        console.log('columndefs are ', columnDefs);
        console.log('columns are', tableColumns);
        console.log('table data e', tableData);
        //save the current table to the global array of tables
        pfw_tables[tableID + '_wrapper'] = jQuery(tableID).DataTable({
            data: tableData,
            columns: tableColumns,
            dom: '<"pfw-top"l<"pfw-filters">f>r<"pfw-table-wrapper"t><"pfw-bottom"ip><"clear"><"pfw-bulk-add">',
            responsive: { details: { display: jQuery.fn.dataTable.Responsive.display.childRow } },
            columnDefs: columnDefs,
            language: {
                lengthMenu: "Show _MENU_"
            }
        });

        let category_column_index = 0;
        let rating_column_index = 0;
        let price_column_index = 0;

        console.log('table data is: ', tableData);

        for (let i = 0; i < tableColumns.length; i++)
        {
            if (tableColumns[i].data === 'raw_categories')
                category_column_index = i;
            else if (tableColumns[i].data === 'raw_rating')
                rating_column_index = i;
            else if (tableColumns[i].data === 'raw_price')
                price_column_index = i;
        }


        jQuery.fn.dataTable.ext.search.push(
            function(settings, data, dataIndex){
                let min_price = (jQuery(tableID + '_wrapper .pfw-filters .pfw-price-greater-than').val());
                let max_price = (jQuery(tableID + '_wrapper .pfw-filters .pfw-price-less-than').val());
                let min_rating = (jQuery(tableID + '_wrapper .pfw-filters .pfw-rating-filter').val());
                let selected_categories = jQuery(tableID + '_wrapper .pfw-filters .pfw-filter-categories select').val();

                console.log(data);
                //get data from the column
                let price = parseInt(data[price_column_index]);
                let rating = parseInt(data[rating_column_index]);
                let categories = data[category_column_index].split(",");

                let match_price = true;
                let match_rating = true;
                let match_category = true;

                if (typeof min_price !== 'undefined' && typeof max_price !== 'undefined')
                {
                    if ( min_price !== '' &&  max_price !== '')
                    {
                        console.log('min and max price are set');
                        match_price = price >= parseInt(min_price) && price <= parseInt(max_price);
                    }
                    else if( min_price !== '')
                    {
                        console.log('only min price is set');
                        match_price = price >= parseInt(min_price);
                    }
                    else if ( max_price !== '')
                    {

                        match_price = price <= parseInt(max_price);
                    }
                }



                if (typeof min_rating !== 'undefined' && min_rating !== '')
                    match_rating = rating >= min_rating;

                if (typeof selected_categories !== 'undefined' && selected_categories != null && selected_categories.length > 0)
                {
                    match_category = _.intersection(selected_categories, categories).length > 0;
                }


                return (match_rating && match_category && match_price);

            }
        );

        jQuery(function(){
            jQuery(tableID + '_wrapper .pfw-filters').html(decodeURIComponent(filterString));
            if (hasCheckbox)
                jQuery(tableID + '_wrapper .pfw-bulk-add').html('<button class="pfw-bulk-add-button">Add selected products to cart</button>');

        });

    }

</script>
{"id":790,"date":"2019-11-16T15:19:24","date_gmt":"2019-11-16T10:19:24","guid":{"rendered":"http:\/\/ees.net.pk\/?page_id=790"},"modified":"2019-11-19T18:59:57","modified_gmt":"2019-11-19T13:59:57","slug":"catalog","status":"publish","type":"page","link":"https:\/\/ees.net.pk\/index.php\/catalog\/","title":{"rendered":"catalog"},"content":{"rendered":"\n<p><noframes><\/p>\n<p><\/noframes><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/ees.net.pk\/index.php\/wp-json\/wp\/v2\/pages\/790"}],"collection":[{"href":"https:\/\/ees.net.pk\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ees.net.pk\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ees.net.pk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ees.net.pk\/index.php\/wp-json\/wp\/v2\/comments?post=790"}],"version-history":[{"count":7,"href":"https:\/\/ees.net.pk\/index.php\/wp-json\/wp\/v2\/pages\/790\/revisions"}],"predecessor-version":[{"id":955,"href":"https:\/\/ees.net.pk\/index.php\/wp-json\/wp\/v2\/pages\/790\/revisions\/955"}],"wp:attachment":[{"href":"https:\/\/ees.net.pk\/index.php\/wp-json\/wp\/v2\/media?parent=790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}