mbparrinello Posted May 29, 2007 Share Posted May 29, 2007 Hello, I am trying to add something to this php script and I don't know how...The following is a validation type script which is used within an online store. It's purpose is to make sure that when a person chooses a certain size of mattress, that person can then remove a certain size of box spring - and the size must match or they get an error message in their cart via this validation. This is in a "checkbox" form and I need to add the ability for the person to choose "no thanks" which would include the box spring..(change their mind), and still allow this validation to work. If you need to see this in action, please go to http://www.bedstore.com/store/index.php?main_page=product_info&cPath=1_9&products_id=2 Thanks for any help <?php function valid_cart(&$reason) { $products = $_SESSION['cart']->get_products(); $total = 0; for ($i=0, $n=sizeof($products); $i<$n; $i++) { $no_foundation = 0; // no foundation attribute id is 2 // values: 6 (full), 8 (King), 7 (Queeen), 5 (Twin) if (isset($products[$i]['attributes']['2'])) { $no_foundation = $products[$i]['attributes']['2']; } // size attribute id is 1 // values 1 (Twin), 2 (Full), 3 (Queen), 4 (King) $size = 0; if (isset($products[$i]['attributes']['1'])) { $size = $products[$i]['attributes']['1']; } if ($no_foundation != 0) { if ($no_foundation == 6 && $size == 2) continue; if ($no_foundation == 8 && $size == 4) continue; if ($no_foundation == 7 && $size == 3) continue; if ($no_foundation == 5 && $size == 1) continue; $reason = VALID_FAIL; return false; } } return true; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53440-please-help-a-novice/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.