if (!isset($_SESSION['registration'])) { $_SESSION['registration'] = array(); } if (isset($_POST['variable'])) { $_SESSION['registration'][$_POST['variable']] = $_POST['data']; $ret = $_SESSION['registration'][$_POST['variable']]; } if (isset($_POST['method'])) { if ($_POST['method'] === 'removeSerialNumber') { $products = snRemove($_POST['data']); } if ($_POST['method'] === 'saveMagentoAccount') { $_SESSION['registration']['customer']['magento_account'] = $_POST['data']; $ret = $_SESSION['registration']['customer']['magento_account']; } if ($_POST['method'] === 'vacWarrantyOptIn') { // Value from user (checking the checkbox) $flag = $_POST['data'] === 'y' ? true : false; // Set the session value $_SESSION['registration']['opt_in']['vac_warranty'] = $flag; // Set the file_required property based on the flag $ret = vacWarrantyOptIn($flag); } else { if ($_POST['method'] === 'promoOptIn') { $flag = $_POST['optIn'] === 'y' ? true : false; setPromotionOptIn($_POST['promoId'], $flag, $_POST['serialNumber']); $ret = true; } } } echo json_encode($ret);
// Serial number is valid if: // 1. Product data is returned 2. No R account exists if (!$return['r_account']) { if (!isset($_SESSION['registration']['products'])) { $_SESSION['registration']['products'] = array(); } // Run snRules function $product = snRules($return); // Set product purchase date (based on customer entry) $product['date_of_purchase'] = $data['date_of_purchase']; $product['uploaded_file'] = ''; array_push($_SESSION['registration']['products'], $product); // Run Vac Warranty Opt In function $opt_in = $_SESSION['registration']['opt_in']; if (array_key_exists('vac_warranty', $opt_in)) { vacWarrantyOptIn($opt_in['vac_warranty']); } // Check for any registration promotions $registration_promotions = getRegistrationPromotions($return['serial_number']); if (isset($registration_promotions)) { setRegistrationPromotions($return['serial_number'], $registration_promotions); } } else { $return = array(); $return['error'] = 'This serial number has already been registered.'; } } } else { $return['error'] = 'Serial number has already been added to your registry.'; } } else {