Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.84 KB | None | 0 0
  1. <?php /* Template Name: Products */ ?>
  2.  
  3. <?php
  4. get_header();
  5. $site_url=getSiteURL();
  6. $StateRelatedProducts=productsRelatedToZipcodeState();
  7. $product_categories_data = categories(); //defined in functions.php
  8. $firstCategory=$product_categories_data[0]->name; //get first category name
  9. $firstCategoryslug=$product_categories_data[0]->slug; //get first category slug
  10. $display_domainName = getDomainData()->domain_name; //get domain name
  11. $pagename = get_query_var('pagename'); //get page name
  12. $pagename = urldecode($pagename);
  13. $actual_link = $_SERVER[REQUEST_URI];
  14. $parts = explode('/', $actual_link);
  15. $parent_page_cat = $parts[3];
  16. global $post;
  17. // echo $post->ID;
  18. $submenu = wp_list_pages(
  19. array(
  20. 'child_of' => $post->ID,
  21. 'echo' => false,
  22. )
  23. );
  24. // var_dump($submenu);
  25. if($pagename == "products"){ //products page
  26. $category_pagename = $firstCategoryslug;
  27. }
  28. elseif($submenu){ //if page has children then it is category page name
  29. $category_pagename = urldecode($pagename);
  30. }else{ //if it's not products and page doesn't have categories then it is sub_cat page
  31. $subCat_pagename = urldecode($pagename);
  32. $category_pagename = urldecode($parent_page_cat);
  33. }
  34.  
  35. // function productStyleData(){
  36. $product_style_pod = pods('product_style');
  37. if($category_pagename){
  38. $params = array(
  39. // "where" => "product_category.name='".$category_pagename."'",
  40. "where" => "product_category.slug='".$category_pagename."'",
  41. );
  42. }else{
  43. $params = array(
  44. // "where" => "product_category.name='".$product_categories_data[0]->name."'",
  45. "where" => "product_category.slug='".$firstCategoryslug."'",
  46. );
  47. }
  48. $product_style_pod->find($params,$limit=-1);
  49. $productstyle_dropdown = $product_style_pod->data();
  50. // return $productstyle_dropdown;
  51. // }
  52. // $productstyle_dropdown = productStyleData();
  53. $roofStyle_data = productRoofStyleData();
  54.  
  55. ?>
  56.  
  57. <section class="py-60">
  58. <div class="container">
  59. <h5 class="dealer-heading text-danger text-center">Explore Our Products</h5>
  60. <!-- Nav tabs -->
  61. <!-- Dynamic Categories Start -->
  62. <?php
  63. if($category_pagename){
  64. ?>
  65. <ul class="nav nav-tabs custom-nav-tabs border-bottom-0 mb-5 product_category" role="tablist">
  66. <?php
  67. foreach ($product_categories_data as $key => $product_category){
  68. $product_category_name = $product_category->name;
  69. $productCategorySlug = $product_category->slug;
  70. if($category_pagename == $productCategorySlug){
  71. ?>
  72. <li class="nav-item">
  73. <a class="nav-link mx-0 active override-default-anchor" data-toggle="tab" href="#<?php echo $productCategorySlug ?>" role="tab"><?php echo $product_category_name ?></a>
  74. </li>
  75. <?php
  76. }else{ ?>
  77. <li class="nav-item">
  78. <a class="nav-link mx-0 override-default-anchor" data-toggle="tab" href="#<?php echo $productCategorySlug ?>" role="tab"><?php echo $product_category_name ?></a>
  79. </li>
  80. <?php
  81. }
  82. }?>
  83. </ul>
  84. <?php
  85. }else{
  86. ?>
  87. <ul class="nav nav-tabs custom-nav-tabs border-bottom-0 mb-5 product_category" role="tablist">
  88. <?php
  89. foreach ($product_categories_data as $key => $product_category) {
  90. $product_category_name = $product_category->name;
  91. $productCategorySlug = $product_category->slug;
  92. if($key==0){
  93. ?>
  94. <li class="nav-item active">
  95. <a class="nav-link mx-0 active override-default-anchor" data-toggle="tab" href="#<?php echo $productCategorySlug ?>" role="tab"><?php echo $product_category_name ?></a>
  96. </li>
  97. <?php
  98. }else{
  99. ?>
  100. <li class="nav-item">
  101. <a class="nav-link mx-0 override-default-anchor" data-toggle="tab" href="#<?php echo $productCategorySlug ?>" role="tab"><?php echo $product_category_name ?></a>
  102. </li>
  103. <?php
  104. }
  105. }
  106. ?>
  107. </ul>
  108. <?php
  109. } ?>
  110. <!-- Dynamic Categories End -->
  111.  
  112. <!-- Dynamic SubCategories Start -->
  113. <?php
  114. if($subCat_pagename){?>
  115. <ul class="nav nav-tabs custom-nav-tabs border-bottom-0 mb-5 product_subcategory_list" role="tablist">
  116. <li class="nav-item">
  117. <a class="nav-link mx-0 override-default-anchor" data-toggle="tab" href="#all" role="tab">All</a>
  118. </li>
  119. <?php
  120. foreach ($productstyle_dropdown as $key => $product_sub_category){
  121. $product_subCategory_name = $product_sub_category->name; //name which is displaying
  122. $subCategorySlug = $product_sub_category->slug;
  123. if($subCat_pagename == $subCategorySlug){
  124. ?>
  125. <li class="nav-item">
  126. <a class="nav-link mx-0 active override-default-anchor" data-toggle="tab" href="#<?php echo $subCategorySlug ?>" role="tab"><?php echo $product_subCategory_name ?></a>
  127. </li>
  128. <?php
  129. }else{
  130. ?>
  131. <li class="nav-item">
  132. <a class="nav-link mx-0 override-default-anchor" data-toggle="tab" href="#<?php echo $subCategorySlug ?>" role="tab"><?php echo $product_subCategory_name ?></a>
  133. </li>
  134. <?php
  135. }
  136. }
  137. ?>
  138. </ul>
  139. <?php
  140. }else{
  141. ?>
  142. <ul class="nav nav-tabs custom-nav-tabs border-bottom-0 mb-5 product_subcategory_list" role="tablist">
  143. <li class="nav-item">
  144. <a class="nav-link mx-0 active override-default-anchor" data-toggle="tab" href="#all" role="tab">All</a>
  145. </li>
  146. <?php
  147. foreach ($productstyle_dropdown as $key => $product_sub_category) {
  148. $product_subCategory_name = $product_sub_category->name;
  149. $subCategorySlug = $product_sub_category->slug;
  150. // $subCategory_name = preg_replace("/[^\w]+/", "-", $product_subCategory_name); //for id purpose adding - for spaces
  151. ?>
  152. <li class="nav-item">
  153. <a class="nav-link mx-0 override-default-anchor" data-toggle="tab" href="#<?php echo $subCategorySlug ?>" role="tab"><?php echo $product_subCategory_name ?></a>
  154. </li>
  155. <?php } ?>
  156. </ul>
  157. <?php
  158. }
  159. ?>
  160. <!-- Dynamic SubCategories End -->
  161.  
  162. <?php
  163. $seo_content_display_pod = pods('seo_content_display');
  164. $seo_params = array(
  165. "select" => "*",
  166. "where" => "category.name = '".$category_pagename."'",
  167. "orderby"=>"d.id DESC"
  168. );
  169. $seo_content_display_pod->find($seo_params,$limit=1);
  170. $seo_content_data = $seo_content_display_pod->data()[0];
  171. if(sizeof($seo_content_data) > 0){ ?>
  172. <p><?php echo $seo_content_data->text_above_products; ?></p>
  173. <?php
  174. } ?>
  175.  
  176. <!-- Tab panes -->
  177. <div class="tab-content">
  178. <div class="tab-pane active" id="carport" role="tabpanel">
  179. <div class="mb-3 toogleFilter_btn cp" id="filterId" style="color:#455860;"><img src="<?php bloginfo('template_url'); ?>/images/icons/icon_filter<?php echo $iconName;?>.svg" class="mr-3" height="19px">Filters</div>
  180. <div class="row filters mb-5 toogleFilters">
  181. <?php if($_SESSION['zipcode']){?>
  182. <div class="col-sm-6 col-md-4 col-lg-2 mb-3 mb-lg-0">
  183. <select id="productFilter1" class="form-control" name="productFilter" style="background-image: url(<?php bloginfo('template_url'); ?>/images/icons/icon_dropdown.svg);">
  184. <option value="0" selected>Select Price</option>
  185. <option value="1">Low to high</option>
  186. <option value="2">High to low</option>
  187. </select>
  188. </div>
  189. <?php } ?>
  190. <div class="col-sm-6 col-md-4 col-lg-2 mb-3 mb-lg-0 product-filter2 productfilter">
  191. <select id="productFilter2" class="form-control" name="productFilter" style="background-image: url(<?php bloginfo('template_url'); ?>/images/icons/icon_dropdown.svg);">
  192. </select>
  193. </div>
  194.  
  195. <div class="col-sm-6 col-md-4 col-lg-2 mb-3 mb-lg-0 productFilter4 productfilter">
  196. <select id="productFilter4" class="form-control" name="productFilter" style="background-image: url(<?php bloginfo('template_url'); ?>/images/icons/icon_dropdown.svg);">
  197. </select>
  198. </div>
  199. <div class="col-sm-6 col-md-4 col-lg-2 mb-3 mb-lg-0 productFilter5 productfilter">
  200. <select id="productFilter5" class="form-control" name="productFilter" style="background-image: url(<?php bloginfo('template_url'); ?>/images/icons/icon_dropdown.svg);">
  201. </select>
  202. </div>
  203. <div class="col-sm-6 col-md-4 col-lg-2 mb-3 mb-lg-0 productFilter3 productfilter">
  204. <select id="productFilter3" class="form-control" name="productFilter" style="background-image: url(<?php bloginfo('template_url'); ?>/images/icons/icon_dropdown.svg);">
  205. </select>
  206. </div>
  207. </div>
  208. <div id="mediaDiv" class="mt-5">
  209. <div class="media">
  210. <span id="roofstyle_image"></span>
  211. <div class="media-body align-self-center">
  212. <p id="roofstyle_data"></p>
  213. </div>
  214. </div>
  215. </div>
  216.  
  217. <div class="row" id="row_data">
  218. </div>
  219. <p id="products_notPresent"></p>
  220. </div>
  221. <p id="filters_nodata"></p>
  222. <?php
  223. foreach ($product_categories_data as $key => $product_category){ ?>
  224. <div class="tab-pane" id="<?php echo $product_category->slug ?>" role="tabpanel">...</div>
  225. <?php } ?>
  226. <div class="tab-pane" id="all" role="tabpanel">...</div>
  227. <?php
  228. foreach ($productstyle_dropdown as $key => $product_sub_category) { ?>
  229. <div class="tab-pane" id="<?php echo $product_sub_category->slug ?>" role="tabpanel">...</div>
  230. <?php } ?>
  231. </div>
  232. </div> <!-- container -->
  233. </section>
  234.  
  235. <?php
  236. $seo_content_display_pod = pods('seo_content_display');
  237. $seo_params = array(
  238. "select" => "*",
  239. "where" => "category.name = '".$category_pagename."'",
  240. "orderby"=>"d.id DESC"
  241. );
  242. $seo_content_display_pod->find($seo_params,$limit=1);
  243. $seo_content_data = $seo_content_display_pod->data()[0];
  244. if(sizeof($seo_content_data) > 0){ ?>
  245. <p><?php echo $seo_content_data->text_below_products; ?></p>
  246. <?php } ?>
  247.  
  248.  
  249. <hr class="divider my-0">
  250. <div class="container py-40">
  251. <p class="text-center mb-5"><?php echo $display_domainName ?> metal structures are engineered to protect your most valuable assets, personal or commercial, for years to come! Our buildings are constructed with the strongest steel materials to provide protection, durability and resistance.</p>
  252. </div>
  253.  
  254.  
  255.  
  256. <script type="text/javascript">
  257. var url_productStyle = "<?php echo $subCat_pagename ?>"
  258. <?php
  259. echo "var productDetail_url='".get_page_link( get_page_by_title( 'productDetail' )->ID )."';";
  260. echo "var product_url='".get_page_link( get_page_by_title('Products')->ID )."';";
  261. ?>
  262. // console.log(url_productStyle);
  263.  
  264. $('ul.product_category a').click(function(){
  265. var selected_category = $(this).attr('href');
  266. selected_category = selected_category.replace("#", '').toLowerCase();
  267. return window.location = product_url+"/"+ selected_category;
  268. });
  269.  
  270. $('ul.product_subcategory_list a').click(function(){
  271. var selected_subCategory = $(this).attr('href');
  272. selected_subCategory = selected_subCategory.replace("#", '').toLowerCase();
  273. if(selected_subCategory == "all"){
  274. // alert(selected_subCategory);
  275. return window.location = product_url;
  276. }
  277. var category_pagename_js = "<?php echo $category_pagename ?>"
  278. return window.location = product_url+"/"+category_pagename_js+"/"+selected_subCategory;
  279. console.log(product_url);
  280. });
  281.  
  282. <?php
  283. echo "var roofStyle_dropdown=".json_encode($roofStyle_data).";";
  284.  
  285. //fetch product_style(subcategories) and store it in variable
  286. echo "var productstyle_dropdown=".json_encode($productstyle_dropdown).";";
  287.  
  288. //if SessionOfZipcode present show related StateProducts Else show all products
  289. $queryProductsCondition="";
  290. $noProductsMsg = "";
  291. if($_SESSION['zipcode']){
  292. if (!empty($StateRelatedProducts)) {
  293. if($category_pagename){
  294. $queryProductsCondition = "t.name IN ($StateRelatedProducts) AND category.slug ='".$category_pagename."' " ; //Horizontal,Vertical(related to state LA) products of Carport
  295. }else{
  296. $queryProductsCondition = "t.name IN ($StateRelatedProducts) AND category.slug='".$firstCategoryslug."'" ;//Horizontal,Vertical(related to state LA) products of Agriculture
  297. }
  298. }else{
  299. $queryProductsCondition = null;
  300. $noProductsMsg = "<h6 class='text-danger text-center'><b>Sorry. There are no products for"." ".$_SESSION['state']."</b></h6>";
  301. $_SESSION['noProductsMsg']=$noProductsMsg;
  302. }
  303. }else{
  304. if($category_pagename){
  305. $queryProductsCondition = "category.slug ='".$category_pagename."' " ; //Horizontal,Vertical(related to state LA) products of Carport
  306. }else{
  307. $queryProductsCondition = "category.slug='".$firstCategoryslug."'" ;//Horizontal,Vertical(related to state LA) products of Agriculture
  308. }
  309. }
  310.  
  311. if($queryProductsCondition){
  312. $pod = pods('product');
  313. $params = array(
  314. "select" => "*, product_roofstyle.name as product_roofstyle_name, prod_thumbnail.ID, category.name as category_name",
  315. "where" => $queryProductsCondition, //Horizontal,Vertical(related to state LA) products of Carport
  316. "orderby" => "d.id"
  317. );
  318. $pod->find($params,$limit=-1);
  319. $pod_data = $pod->data();
  320. $product_data = [];
  321. if($pod_data){
  322. while($pod->fetch()){
  323. $model_configuration=$pod->display('model_configuration');
  324. $buildConfig=$pod->field('model_configuration')['config'];
  325. $model_configuration=$pod->display('model_configuration');
  326. $buildConfig=$pod->field('model_configuration')['config'];
  327. $subCatgory_data= $pod->field('product_style');
  328. $category_data = $pod->field('category_name');
  329. $product_style = $subCatgory_data['name'];
  330. $subCategorySlug = $subCatgory_data['slug'];
  331. $categoryName = $category_data['name'];
  332. $categorySlug = $category_data['slug'];
  333. $hash = array(
  334. "image" => $pod->display('prod_thumbnail'),
  335. "title" => $pod->display('product_title'),
  336. "short_description" => $pod->field('product_shortdescription'),
  337. "product_price" => $pod->field('product_price'),
  338. "id" => $pod->field('id'),
  339. "roofstyle" => $pod->field('product_roofstyle_name'),
  340. "product_code" => $pod->field('product_code'),
  341. "product_category" => $categoryName,
  342. "categorySlug" => $categorySlug,
  343. "product_style" => $product_style,
  344. "subCategorySlug" => $subCategorySlug,
  345. "product_id" => $pod->field('id'),
  346. "model_configuration" => $model_configuration,
  347. "item_type"=>$pod->field('taxonomy'),
  348. "height" => $pod->field('height') ,
  349. "width" => $pod->field('width'),
  350. "length" => $pod->field('length'),
  351. "building_config" => $buildConfig
  352. );
  353.  
  354. array_push($product_data,$hash );
  355. } //Ends While Loop
  356. // value['building_config'] = $buildConfig;
  357. // product_data.push(value);
  358. } //Ends if Category Products present
  359. if (empty($product_data)) {
  360. $noProductsMsg = "<h6 class='text-danger text-center'><b>Sorry, there are no products under this category.</b></h6>";
  361. }
  362. } else {
  363. $product_data = [];
  364. }
  365.  
  366. if($noProductsMsg){
  367. $_SESSION['noProductsMsg'] = $noProductsMsg;
  368. }else{
  369. unset($_SESSION['noProductsMsg']); //else unset the session variable if already set.
  370. }
  371. echo "var products=".json_encode($product_data).";";
  372.  
  373. $prices=priceSheetData();
  374. echo "var prices=".json_encode($prices).";";
  375. $price_json = json_decode($prices[0]->price_json);
  376. echo "var price_data = ".json_encode($price_json->price_data).";";
  377. echo "var price_enums = ".json_encode($price_json->enums).";";
  378. ?>
  379.  
  380. var widthoptions;
  381. var lengthOptions;
  382. var heightOptions;
  383. if(price_enums){
  384. price_enums['all width options'].reverse(function(a, b){return b>a;});
  385. price_enums['length'].reverse(function(a, b){return b>a;});
  386. price_enums['height'].reverse(function(a, b){return b>a;});
  387. widthoptions = price_enums['all width options'];
  388. lengthOptions = price_enums['length'];
  389. heightOptions = price_enums['height'];
  390. }
  391.  
  392. if(products.length > 0){
  393. var products = PriceFieldAdding(products,price_data);
  394. }
  395. console.log(products);
  396.  
  397. function requestedProduct(product_id){
  398. document.getElementById('requested_ItemType_id').value = product_id;
  399. }
  400.  
  401. $(document).ready(function(){
  402. roofStyleDropdown();
  403. heightDropdown(products);
  404. widthDropdown(products);
  405. lengthDropdown(products);
  406.  
  407. function roofStyleDropdown(){
  408. var select = $('.product-filter2 select').attr("id","productFilter2").attr("name", "productFilter");
  409. select.append('<option value="Select Roof Style">Select Roof Style </option>');
  410. // console.log(roofStyle_dropdown);
  411. $.each(roofStyle_dropdown, function(key,value){
  412. select.append($("<option></option>").attr("value",value["name"]).text(value["name"]));
  413. });
  414. }
  415.  
  416. function heightDropdown(products){
  417. var height_select = $('.productFilter3 select').attr("id","productFilter3").attr("name", "productFilter");
  418. height_select.append('<option value="Select Height">Select Height </option>');
  419. productHeightArray=[];
  420. $.each(products, function(key,height_value){
  421. int_height=parseInt(height_value["height"]);
  422. if(int_height > 0){
  423. productHeightArray.push(int_height);
  424. }
  425. });
  426. var uniqueHeightItems = Array.from(new Set(productHeightArray));
  427. uniqueHeightItems.sort(function(a, b){return a - b});
  428. $.each(uniqueHeightItems, function(key,height_value){
  429. height_select.append($("<option></option>").attr("value",height_value).text(height_value));
  430. });
  431. }
  432.  
  433. function widthDropdown(products){
  434. var width_select = $('.productFilter4 select').attr("id","productFilter4").attr("name", "productFilter");
  435. width_select.append('<option value="Select Width">Select Width </option>');
  436. productWidthArray=[];
  437. $.each(products, function(key,width_value){
  438. int_width=parseInt(width_value["width"]);
  439. if(int_width > 0){
  440. productWidthArray.push(int_width);
  441. }
  442. });
  443. var uniqueWidthItems = Array.from(new Set(productWidthArray));
  444. uniqueWidthItems.sort(function(a, b){return a - b});
  445. $.each(uniqueWidthItems, function(key,width_value){
  446. width_select.append($("<option></option>").attr("value",width_value).text(width_value));
  447. });
  448. }
  449.  
  450. function lengthDropdown(products){
  451. var length_select = $('.productFilter5 select').attr("id","productFilter5").attr("name", "productFilter");
  452. length_select.append('<option value="Select Length">Select Length </option>');
  453. productLengthArray=[];
  454. $.each(products, function(key,length_value){
  455. int_length=parseInt(length_value["length"]);
  456. if(int_length > 0){
  457. productLengthArray.push(int_length);
  458. }
  459. });
  460. var uniqueLengthItems = Array.from(new Set(productLengthArray));
  461. uniqueLengthItems.sort(function(a, b){return a - b});
  462. $.each(uniqueLengthItems, function(key,length_value){
  463. length_select.append($("<option></option>").attr("value",length_value).text(length_value));
  464. });
  465. }
  466.  
  467. function RoofStyleDropdownText(){
  468. var selected_roofStyle = $("#productFilter2").val();
  469. if($("#productFilter2").val() === "Select Roof Style"){
  470. $('#roofstyle_data').html("");
  471. $('#roofstyle_image').html("");
  472. }
  473. $.each(roofStyle_dropdown, function(key,value){
  474. if(value["name"] == selected_roofStyle){
  475. // console.log(value);
  476. var roofstyle_testImage=value['roofStyle_image'];
  477. var short_description=value["short_description"];
  478. // console.log(short_description);
  479. $('#roofstyle_data').html(short_description);
  480. $('#roofstyle_image').html('<img class="align-self-center mr-3" width="200px" src="'+roofstyle_testImage+'" alt="Product placeholder image">');
  481. }
  482. });
  483. }
  484. $(document).on("change","#productFilter2",RoofStyleDropdownText);
  485.  
  486. function productFilter(){
  487. var filter_list = productStyle_Filter(products);
  488. filter_list = roofstyleFilter(filter_list);
  489. filter_list = heightFilter(filter_list);
  490. filter_list = widthFilter(filter_list);
  491. filter_list = lengthFilter(filter_list);
  492. var sorted_list = priceSort(filter_list);
  493. product_render(sorted_list);
  494. }
  495. productFilter();
  496.  
  497. function roofstyleFilter(prod_list){
  498. var filter_option = $("#productFilter2").val();
  499. if($("#productFilter2").val() === "Select Roof Style"){
  500. return prod_list;
  501. }
  502. var product_filter = [];
  503. var flag="0";
  504. $.each(prod_list, function(key,value){
  505. if (value["roofstyle"].toLowerCase() == filter_option.toLowerCase()){
  506. product_filter.push(value);
  507. flag = "1";
  508. $("#filters_nodata").html("");
  509. }
  510. });
  511. if(flag == "0"){
  512. $("#filters_nodata").html( "<br><h6 class='text-danger text-center'>No Products Available Related To This Filter</h6><br>" );
  513. }
  514. return product_filter
  515. }
  516. $(document).on("change","#productFilter2",productFilter);
  517.  
  518. function heightFilter(prod_list){
  519. // console.log(prod_list);
  520. var selected_height = $("#productFilter3").val();
  521. if($("#productFilter3").val() === "Select Height"){
  522. return prod_list;
  523. }
  524. var height_filter = [];
  525. var flag="0";
  526. $.each(prod_list, function(key,value){
  527. if (value["height"] == selected_height){
  528. height_filter.push(value);
  529. flag = "1";
  530. $("#filters_nodata").html("");
  531. }
  532. });
  533. if(flag == "0"){
  534. $("#filters_nodata").html( "<br><h6 class='text-danger text-center'>No Products Available Related To This Filter</h6><br>" );
  535. }
  536. return height_filter
  537. }
  538. $(document).on("change","#productFilter3",productFilter);
  539. function widthFilter(prod_list){
  540. // console.log(prod_list);
  541. var selected_width = $("#productFilter4").val();
  542. if($("#productFilter4").val() === "Select Width"){
  543. return prod_list;
  544. }
  545. var width_filter = [];
  546. var flag="0";
  547. $.each(prod_list, function(key,value){
  548. if (value["width"] == selected_width){
  549. width_filter.push(value);
  550. flag = "1";
  551. $("#filters_nodata").html("");
  552. }
  553. });
  554. if(flag == "0"){
  555. $("#filters_nodata").html( "<br><h6 class='text-danger text-center'>No Products Available Related To This Filter</h6><br>" );
  556. }
  557. return width_filter
  558. }
  559. $(document).on("change","#productFilter4",productFilter);
  560. function lengthFilter(prod_list){
  561. // console.log(prod_list);
  562. var selected_length = $("#productFilter5").val();
  563. if($("#productFilter5").val() === "Select Length"){
  564. return prod_list;
  565. }
  566. var length_filter = [];
  567. var flag="0";
  568. $.each(prod_list, function(key,value){
  569. if (value["length"] == selected_length){
  570. length_filter.push(value);
  571. flag = "1";
  572. $("#filters_nodata").html("");
  573. }
  574. });
  575. if(flag == "0"){
  576. $("#filters_nodata").html( "<br><h6 class='text-danger text-center'>No Products Available Related To This Filter</h6><br>" );
  577. }
  578. // console.log(length_filter);
  579. return length_filter
  580. }
  581. $(document).on("change","#productFilter5",productFilter);
  582.  
  583. function productStyle_Filter(prod_list){
  584. // alert("subcategory page")
  585. var productStyle_filter = [];
  586. var flag="0";
  587. // console.log(prod_list);
  588. // var selected_style = $("#productFilter6").val();
  589. // console.log(selected_style);
  590. var url_productStyle = "<?php echo $subCat_pagename ?>"
  591. // alert("selected product style"+ url_productStyle);
  592. if(url_productStyle){
  593. $.each(prod_list, function(key,value){
  594. // alert("product Style from db"+" "+value["product_style"]+ typeof value["product_style"]);
  595. if(value["product_style"]){
  596. // if (value["product_style"].toLowerCase() == url_productStyle.toLowerCase()){
  597. if (value["subCategorySlug"].toLowerCase() == url_productStyle.toLowerCase()){
  598. productStyle_filter.push(value);
  599. flag = "1";
  600. $("#filters_nodata").html("");
  601. console.log(productStyle_filter);
  602. }
  603. }
  604. });
  605. if(flag == "0"){
  606. $("#filters_nodata").html( "<br><h6 class='text-danger text-center'>No Products Available Related To This Sub Category</h6><br>" );
  607. }
  608. // alert("after alert")
  609. return productStyle_filter;
  610. }else{
  611. // alert("else")
  612. return prod_list;
  613. }
  614.  
  615. }
  616. $(document).on("click",".product_subcategory_list",productFilter);
  617.  
  618. function priceSort(filter_list){
  619. var product_sort = null;
  620. if($("#productFilter1").val() == "1"){
  621. product_sort = filter_list.slice();
  622. product_sort.sort(function(a,b){
  623. if((a.product_price != "Price N/A") && (b.product_price != "Price N/A")){
  624. if (parseInt(a.product_price) < parseInt(b.product_price)) {
  625. return -1;
  626. }
  627. if (parseInt(a.product_price) > parseInt(b.product_price)) {
  628. return 1;
  629. }
  630. return 0;
  631. }
  632. else {
  633. return 0;
  634. }
  635. });
  636. }else if($("#productFilter1").val() == "2"){
  637. product_sort = filter_list.slice();
  638. product_sort.sort(function(a,b){
  639. if((a.product_price != "Price N/A") && (b.product_price != "Price N/A")){
  640. if (parseInt(a.product_price) > parseInt(b.product_price)) {
  641. return -1;
  642. }
  643. if (parseInt(a.product_price) < parseInt(b.product_price)) {
  644. return 1;
  645. }
  646. return 0;
  647. }
  648. else {
  649. return 0;
  650. }
  651. });
  652. }else{
  653. product_sort = filter_list;
  654. }
  655. return product_sort;
  656. }
  657. $(document).on("change","#productFilter1",productFilter);
  658. function product_render(product_sort){
  659. $("#row_data").html("");
  660. $("#products_notPresent").html( "" );
  661. var noProductsMsg = <?php echo json_encode($_SESSION['noProductsMsg']) ?>;
  662. if((product_sort !== null) && (product_sort.length > 0 )){
  663. var zipcodeSession = <?php echo json_encode($_SESSION['zipcode']) ?>;
  664. $.each(product_sort, function(key,value){
  665. var model_conf = value['model_configuration'];
  666. var product_code = '?code=' + value['model_configuration'];
  667. var data = `
  668. <div class="col-xs-12 col-md-6 col-lg-4 product">
  669. <div class="card mb-5">
  670. <a href="${productDetail_url}?product_code=${value['product_code']}&category=${value['product_category']}">
  671. <div class="card-img-top" style="background-image: url('${value['image']}')"></div>
  672.  
  673. <div class="card-block px-0">
  674. <h4 class="card-title text-capitalize text-danger">${value["title"]}</h4></a>`
  675.  
  676. var config_dimension;
  677. if((value["width"] && value["length"] && value["height"]) && ((value["width"] != "0") && (value["length"] != "0") && (value["height"] != "0"))) {
  678. // if((value["width"] != "0") && (value["length"] != "0") && (value["height"] != "0")){
  679. config_dimension = `<p class="card-text dim-specific text-black" id="config_dimension${value['id']}">${value["width"]+"' W x "+value["length"]+"' L x "+value["height"]+"' H"}</p>`
  680. }else{
  681. config_dimension = `<p class="card-text dim-specific text-black" id="config_dimension${value['id']}"></p>`;
  682. }
  683. var short_description =`<input type="hidden" id="requested_ItemType_id" name="product_quote" value="" >
  684. <input type="hidden" id="item_type" name="item_type" value=${value["item_type"]} >
  685. <p class="card-description text-black" >${value["short_description"]}</p>`
  686.  
  687. if(zipcodeSession){
  688. var price=(value["product_price"] === "Price N/A") ? `<p class="text-danger mb-0 d-inline-flex align-items-end price" id="product_price${value['id']}">${value["product_price"]}</p>` : `<p class="text-danger mb-0 d-inline-flex align-items-end price" id="product_price${value['id']}">$${value["product_price"]}</p></div>`
  689. }else{
  690. var price= `<div class="col-12 col-md-6 col-lg-4 mb-2 align-self-center">
  691.  
  692. </div>
  693. <a data-toggle="modal" data-target="#zipCodeModal">
  694. <div class="media">
  695. <div class="media-body mb-2">
  696. <button id="onclickzipcode_session" class="btn btn-danger" style = "padding : 3px 14px">Price</button>
  697. </div>
  698. </div>
  699.  
  700. </a>`
  701. }
  702. var button=`
  703. <div class="card-modify-build">
  704. <a class="btn btn-danger d-inline-flex link-button-text-white" onclick="requestedProduct(${value['product_id']})" data-toggle="modal" data-target="#requestQuoteModal">Request Quote</a>`
  705.  
  706. var modify_build=(model_conf)?`<a class="btn btn-danger link-button-text-white d-inline-flex ml-2" href='<?php echo get_page_link( get_page_by_title( 'Build & Price' )->ID ) ?>${product_code}'>Modify Build</a>`:``
  707. var div_closeTags=`</div>
  708. <div id="SuccessOrFailRequestQuoteMsg${value['product_id']}"></div>`
  709. var combine_data = data+config_dimension+short_description+price+button+modify_build+div_closeTags;
  710. $( "#row_data").append(combine_data);
  711. });
  712. }else{
  713. $("#products_notPresent").html( noProductsMsg );
  714. }
  715. }
  716. });
  717.  
  718. </script>
  719.  
  720.  
  721. <script>
  722. var url = new URL(window.location.href);
  723. var searchParams = new URLSearchParams(url.search);
  724. // var url_productStyle = searchParams.get('productStyle');
  725. var url_productStyle = "<?php echo $subCat_pagename ?>"
  726. if(url_productStyle){
  727. $('.toogleFilters').show();
  728. }else{
  729. $('.toogleFilters').hide();
  730. }
  731. $('.toogleFilter_btn').on('click',function(){
  732. $('.toogleFilters').toggle();
  733. });
  734.  
  735. </script>
  736.  
  737. <?php
  738. function seo_contentDescription(){
  739. $seo_content_display_pod = pods('seo_content_display');
  740. $seo_params = array(
  741. "select" => "*",
  742. "where" => "category.name = '".$category_pagename."'",
  743. "orderby"=>"d.id DESC"
  744. );
  745. $seo_content_display_pod->find($seo_params,$limit=1);
  746. $seo_content_data = $seo_content_display_pod->data()[0];
  747. // var_dump($seo_content_data);
  748. return $seo_content_data;
  749. }
  750. var_dump(seo_contentDescription());
  751. ?>
  752.  
  753.  
  754. <?php get_footer()?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement