Advertisement
johncarlson21

Untitled

Jul 15th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.95 KB | None | 0 0
  1. <?php
  2. /* current data being output to page
  3.  
  4. sizes : new Array(
  5.     "Small -- 3\' 6\" (h) x 8\' 0\" (w) - 1 Panel",
  6.     "Medium -- 4\' 0\" (h) x 9\' 1\" (w) - 3 Panel",
  7.     "Mini -- 1\' 0\" (h) x 2\' 3\" (w) - 1 Panel",
  8.     "Mini -- 1\' 0\" (h) x 2\' 3\" (w) - 1 Panel",
  9.     "Mini -- 1\' 0\" (h) x 2\' 3\" (w) - 1 Panel",
  10.     ""
  11. ),
  12.                
  13. sqFeet : new Array(
  14.     28,
  15.     36,
  16.     "6",
  17.     "6",
  18.     "6",
  19.     0
  20. ),
  21.  
  22. Sizes input values:
  23. mini: 5
  24. small: 0
  25. medium: 1
  26. large: 2
  27. custom: 3
  28. */
  29.  
  30. your code:
  31.  
  32.  sizes : new Array(<?php
  33.  $sku = $_product->getSku();
  34.         echo ($_product->getSmallSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getSmallSize()).'",':'';
  35.         echo ($_product->getMediumSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMediumSize()).'",':'';
  36.         echo ($_product->getLargeSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getLargeSize()).'",':'';
  37. if (substr($sku,0,3) == "DPC") {
  38.         echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSize()).'",':'';
  39.         echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSize()).'",':'';
  40.         echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSize()).'",':'';
  41. }
  42. ?>""),
  43.  
  44.  sqFeet : new Array(<?php
  45.         echo ($_product->getSmallSize() && $_product->getSmallSqft()) ? addslashes($_product->getSmallSqft()).',':'';
  46.         echo ($_product->getMediumSize() && $_product->getSmallSqft()) ? addslashes($_product->getMedSqft()).',':'';
  47.         echo ($_product->getLargeSize() && $_product->getSmallSqft()) ? addslashes($_product->getLargeSqft()).',':'';
  48. if (substr($sku,0,3) == "DPC") {
  49.         echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSqft()).'",':'';
  50.         echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSqft()).'",':'';
  51.         echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSqft()).'",':'';
  52. }
  53. ?>0),
  54.  
  55.  
  56. now I see another problem, what if there is no small size or medium size.. you will have the same problem.
  57.  
  58. why don't you just do this:
  59. also, there is no reason to check for DPC on this, what if they decide to have mini in other skus.
  60. this will output a value or 0 for each possible size.
  61. also, the mini or other sizes won't show because you are only showing available ones as inputs.
  62. another thing, no reason to do the check you were doing the if product size and product sqft
  63. this is cleaner and makes more sense, and you don't need to duplicate dummy data.
  64.  
  65. sizes : new Array(
  66. <?php
  67.     $sku = $_product->getSku();
  68.     echo !empty($product->getSmallSize()) || $product->getSmallSize() != "" ? '"'.$product->getSmallSize().'", ' : '"", ';
  69.     echo !empty($product->getMediumSize()) || $product->getMediumSize() != "" ? '"'.$product->getMediumSize().'", ' : '"", ';
  70.     echo !empty($product->getLargeSize()) || $product->getLargeSize() != "" ? '"'.$product->getLargeSize().'", ' : '"", ';
  71. ?>
  72.     "", // this is the one for custom
  73.     "", // this is a blank one because you don't have a value of 4
  74. <?php
  75.     echo !empty($product->getMiniSize()) || $product->getMiniSize() != "" ? '"'.$product->getMiniSize().'", ' : '"", ';
  76. ?>
  77.     ""), // this would be for value 6 but there isn't one anyway
  78.  
  79. sqFeet : new Array(
  80. <?php
  81.     echo !empty($product->getSmallSqft()) || $product->getSmallSqft() != "" ? '"'.$product->getSmallSqft().'", ' : '0, ';
  82.     echo !empty($product->getMediumSqft()) || $product->getMediumSqft() != "" ? '"'.$product->getMediumSqft().'", ' : '0, ';
  83.     echo !empty($product->getLargeSqft()) || $product->getLargeSqft() != "" ? '"'.$product->getLargeSqft().'", ' : '0, ';
  84. ?>
  85.     0, // this is the one for custom
  86.     0, // again an empty one because no value of 4
  87. <?php
  88.     echo !empty($product->getMiniSqft()) || $product->getMiniSqft() != "" ? '"'.$product->getMiniSqft().'", ' : '0, ';
  89. ?>
  90.     0),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement