/** * Purchase Form Validate Fields * * @access private * @since 1.0.8.1 * @return bool|array */ function edd_purchase_form_validate_fields() { global $edd_options; // check if there is $_POST if (empty($_POST)) { return false; } // start an array to collect valid data $valid_data = array('gateway' => '', 'discount' => 'none', 'need_new_user' => false, 'need_user_login' => false, 'logged_user_data' => array(), 'new_user_data' => array(), 'login_user_data' => array(), 'guest_user_data' => array(), 'cc_info' => array()); // validate the gateway $valid_data['gateway'] = edd_purchase_form_validate_gateway(); // validate discounts $valid_data['discount'] = edd_purchase_form_validate_discounts(); // collect credit card info $valid_data['cc_info'] = edd_get_purchase_cc_info(); // validate agree to terms if (isset($edd_options['show_agree_to_terms'])) { edd_purchase_form_validate_agree_to_terms(); } // check if user is logged in if (is_user_logged_in()) { // collect logged in user data $valid_data['logged_in_user'] = edd_purchase_form_validate_logged_in_user(); } else { if (isset($_POST['edd-purchase-var']) && $_POST['edd-purchase-var'] == 'needs-to-register') { // set new user registrarion as required $valid_data['need_new_user'] = true; // validate new user data $valid_data['new_user_data'] = edd_purchase_form_validate_new_user(); // check if login validation is needed } else { if (isset($_POST['edd-purchase-var']) && $_POST['edd-purchase-var'] == 'needs-to-login') { // set user login as required $valid_data['need_user_login'] = true; // validate users login info $valid_data['login_user_data'] = edd_purchase_form_validate_user_login(); } else { // not registering or logging in, so setup guest user data $valid_data['guest_user_data'] = edd_purchase_form_validate_guest_user(); } } } // return collected data return $valid_data; }
/** * Validates the credit card info * * @access private * @since 1.4.4 * @return array */ function edd_purchase_form_validate_cc() { $card_data = edd_get_purchase_cc_info(); // Validate the card zip if (!empty($card_data['card_zip'])) { if (!edd_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { edd_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid', 'easy-digital-downloads')); } } // This should validate card numbers at some point too return $card_data; }
/** * Validates the credit card info * * @access private * @since 1.4.4 * @return array */ function edd_purchase_form_validate_cc() { $card_data = edd_get_purchase_cc_info(); // Validate the card zip if (!empty($card_data['card_zip'])) { if (!edd_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { edd_set_error('invalid_cc_zip', __('The zip code you entered for your credit card is invalid', 'edd')); } } // This should validate card numbers at some point too return $card_data; }