Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 62 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. echo "var products=".json_encode($product_data).";";
  2. ?>
  3.  
  4.  
  5. $(document).ready(function(){
  6.     product_render(products)
  7.    
  8.     function priceSort(products){  // i need to send products to pricesort
  9.         var product_sort = null;
  10.         if($(this).val() === "1"){
  11.             product_sort  = products.slice();
  12.             product_sort.sort(function(a,b){
  13.                 return parseInt(a.product_price) > parseInt(b.product_price);
  14.             });
  15.             console.log(products);
  16.         }else if($(this).val() === "2"){
  17.             product_sort  = products.slice();
  18.             product_sort.sort(function(a,b){
  19.                 return parseInt(a.product_price) < parseInt(b.product_price);
  20.             });
  21.             console.log(products);
  22.         }else{
  23.             product_sort = products;
  24.         }
  25.         product_render(product_sort);
  26.     }
  27.     $(document).on("change", "#productFilter1", priceSort);  // $(document).on("change", "#productFilter1", priceSort(products));
  28.     // onchange parameters will give value  ot text selected by user
  29.   /*
  30.  
  31.   You can also pass a named function to $( document ).ready() instead of passing an anonymous function.
  32. // Passing a named function instead of an anonymous function.
  33.  
  34. function readyFn( jQuery ) {
  35.     // Code to run when the document is ready.
  36. }
  37.  
  38. $( document ).ready( readyFn );
  39.  
  40.   What you are doing is perfectly fine, since the click event passes an event object as the first parameter, the variable word in your saySomething function will be that event object.
  41. If you want to define yourself what word will be, there is no way around wrapping it in some other function and call it with the value you want.
  42.   */
  43.  
  44.  
  45.  
  46.   function productsFilter(){
  47.     filter_list = roofstyleFilter();  ///------>an array of roofstyle seleceted products will be in filter_list
  48.     //products of array
  49.     sorted_list = priceSort(filter_list);   //only selected roodstyle products need to be sended as prodcuts into priceSort()
  50.   }
  51.  
  52.    
  53.    
  54. function roofstyleFilter(){
  55.         var filter_option = $("#productFilter2 :selected").text();
  56.         alert(filter_option);
  57.         console.log(typeof filter_option);
  58.         var product_filter = [];
  59.         $.each(products, function(key,value){
  60.             console.log(typeof value["roofstyle"]);
  61.             if (value["roofstyle"] == filter_option){
  62.                 product_filter.push(value);
  63.             }
  64.         });
  65.         console.log(product_filter);
  66.         console.log(typeof product_filter);
  67.     }
  68.     $(document).on("change", "#productFilter2",roofstyleFilter);
  69.    
  70.  
  71. function product_render(product_sort){
  72.         $("#row_data").html("");
  73.         $.each(product_sort, function(key,value){
  74.             var data = `
  75.             <div class="col-xs-12 col-md-6 col-lg-6 product">
  76.             <div class="card">
  77.             <a href="<?php echo get_page_link( get_page_by_title( productDetail )->ID ); ?>">
  78.             <img class="card-img-top" src="<?php bloginfo('template_url'); ?>/images/carport/open_horizontal_carport.png" height="250px">
  79.             <div class="card-block px-0">
  80.             <h4 class="card-title">${value["title"]}</h4>
  81.             <p class="card-text" >${value["dimension"]}</p>
  82.             <p class="card-description mb-0" >${value["short_discription"]}</p>
  83.             </div>
  84.             </a>
  85.             <div class="d-flex justify-content-between card-modify-build">
  86.             <p class="text-danger mb-0 d-inline-flex align-items-end price" >${value["product_price"]}</p>
  87.             <a class="btn btn-danger d-inline-flex text-white" data-toggle="modal" data-target="#requestQuoteModal">Request Quote</a>
  88.             <a class="btn btn-danger d-inline-flex" href="#">Modify Build</a>
  89.             </div>
  90.             </div>
  91.             </div>`
  92.             $( "#row_data").append(data);
  93.         });
  94.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top