Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* current data being output to page
- sizes : new Array(
- "Small -- 3\' 6\" (h) x 8\' 0\" (w) - 1 Panel",
- "Medium -- 4\' 0\" (h) x 9\' 1\" (w) - 3 Panel",
- "Mini -- 1\' 0\" (h) x 2\' 3\" (w) - 1 Panel",
- "Mini -- 1\' 0\" (h) x 2\' 3\" (w) - 1 Panel",
- "Mini -- 1\' 0\" (h) x 2\' 3\" (w) - 1 Panel",
- ""
- ),
- sqFeet : new Array(
- 28,
- 36,
- "6",
- "6",
- "6",
- 0
- ),
- Sizes input values:
- mini: 5
- small: 0
- medium: 1
- large: 2
- custom: 3
- */
- your code:
- sizes : new Array(<?php
- $sku = $_product->getSku();
- echo ($_product->getSmallSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getSmallSize()).'",':'';
- echo ($_product->getMediumSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMediumSize()).'",':'';
- echo ($_product->getLargeSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getLargeSize()).'",':'';
- if (substr($sku,0,3) == "DPC") {
- echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSize()).'",':'';
- echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSize()).'",':'';
- echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSize()).'",':'';
- }
- ?>""),
- sqFeet : new Array(<?php
- echo ($_product->getSmallSize() && $_product->getSmallSqft()) ? addslashes($_product->getSmallSqft()).',':'';
- echo ($_product->getMediumSize() && $_product->getSmallSqft()) ? addslashes($_product->getMedSqft()).',':'';
- echo ($_product->getLargeSize() && $_product->getSmallSqft()) ? addslashes($_product->getLargeSqft()).',':'';
- if (substr($sku,0,3) == "DPC") {
- echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSqft()).'",':'';
- echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSqft()).'",':'';
- echo ($_product->getMiniSize() && $_product->getSmallSqft()) ? '"'.addslashes($_product->getMiniSqft()).'",':'';
- }
- ?>0),
- now I see another problem, what if there is no small size or medium size.. you will have the same problem.
- why don't you just do this:
- also, there is no reason to check for DPC on this, what if they decide to have mini in other skus.
- this will output a value or 0 for each possible size.
- also, the mini or other sizes won't show because you are only showing available ones as inputs.
- another thing, no reason to do the check you were doing the if product size and product sqft
- this is cleaner and makes more sense, and you don't need to duplicate dummy data.
- sizes : new Array(
- <?php
- $sku = $_product->getSku();
- echo !empty($product->getSmallSize()) || $product->getSmallSize() != "" ? '"'.$product->getSmallSize().'", ' : '"", ';
- echo !empty($product->getMediumSize()) || $product->getMediumSize() != "" ? '"'.$product->getMediumSize().'", ' : '"", ';
- echo !empty($product->getLargeSize()) || $product->getLargeSize() != "" ? '"'.$product->getLargeSize().'", ' : '"", ';
- ?>
- "", // this is the one for custom
- "", // this is a blank one because you don't have a value of 4
- <?php
- echo !empty($product->getMiniSize()) || $product->getMiniSize() != "" ? '"'.$product->getMiniSize().'", ' : '"", ';
- ?>
- ""), // this would be for value 6 but there isn't one anyway
- sqFeet : new Array(
- <?php
- echo !empty($product->getSmallSqft()) || $product->getSmallSqft() != "" ? '"'.$product->getSmallSqft().'", ' : '0, ';
- echo !empty($product->getMediumSqft()) || $product->getMediumSqft() != "" ? '"'.$product->getMediumSqft().'", ' : '0, ';
- echo !empty($product->getLargeSqft()) || $product->getLargeSqft() != "" ? '"'.$product->getLargeSqft().'", ' : '0, ';
- ?>
- 0, // this is the one for custom
- 0, // again an empty one because no value of 4
- <?php
- echo !empty($product->getMiniSqft()) || $product->getMiniSqft() != "" ? '"'.$product->getMiniSqft().'", ' : '0, ';
- ?>
- 0),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement