Ejemplo n.º 1
0
$smarty->assign('discount_amt', $cart->get_discount($subtotal));
$smarty->assign('discount_descrip', $cart->get_discount_descrip());
if (isset($payment_error_type)) {
    $smarty->assign('payment_error_msg', $payment_error);
    $smarty->assign('payment_error', $payment_error_type);
}
if ($pay) {
    if (!($billing = $user->fetchBillingAddr())) {
        trigger_error("did not get billing address for uid {$uid}", E_USER_ERROR);
    } else {
        $smarty->assign('billing', $billing);
        $billing['country'] = formex_field::_get_countries(true, $billing['country']);
    }
}
if (!$cart->requires_shipping()) {
    $shipping = array('name' => 'n/a');
} else {
    if (!($shipping = $user->fetchShippingAddr())) {
        trigger_error("did not get shipping address for uid {$uid}", E_USER_ERROR);
    }
    $shipping['country'] = formex_field::_get_countries(true, $shipping['country']);
}
if (defined('CSHOP_ACCEPT_GIFTCARDS') && CSHOP_ACCEPT_GIFTCARDS) {
    $gc_total = $cart->get_giftcard_total();
    $smarty->assign('giftcards', $cart->get_giftcards());
    $smarty->assign('gc_total', $gc_total);
}
$smarty->assign('user', $user->fetch());
$smarty->assign('user_email', $user->get_email());
$smarty->assign('shipping', $shipping);
$smarty->display('float:checkout_confirm.tpl');
Ejemplo n.º 2
0
 function _field_captcha($val)
 {
     $phrasefield = new formex_field($this->fex, $this->name, array('for the phrase', 'text', 1, array('size' => $this->attribs['text_length'])));
     $res = $phrasefield->get_html($fval);
     $res .= '<div id="captchaHelp">';
     $res .= $this->attribs['help_text'];
     $res .= ' [<a href="#" onclick="toggleCaptchaHelp(); return false">close</a>]</div>';
     return $res;
 }
Ejemplo n.º 3
0
 /**
  * check $posted against the current instance's colmap versi on for validity
  * @param $posted array the values to be checked (usually $_POST or $_GET)
  * @return false if passed, otherwise an list of error messages
  */
 function validate($posted = null)
 {
     if (!$posted) {
         $posted = $this->posted_vars;
     }
     if (!is_array($posted)) {
         trigger_error("validate(): argument is not an array", E_USER_NOTICE);
         return false;
     }
     foreach (array_keys($this->_elems) as $k) {
         $ferr = null;
         $ff = $this->field_prefix . $k;
         //shorthand
         $attribs = $this->_elems[$k]->attribs;
         if ($this->_elems[$k]->error_state === FORMEX_FIELD_REQUIRED) {
             switch ($this->_elems[$k]->type) {
                 case 'date':
                 case 'date_us':
                 case 'datetime':
                     $day = !empty($attribs['suppress_day']) ? '01' : sprintf("%d", $posted[$ff . "_day"]);
                     $datefields = array(sprintf("%d", $posted[$ff . "_month"]), $day, sprintf("%04d", $posted[$ff . "_year"]));
                     if (!self::is_proper_date($datefields)) {
                         $ferr = "'%s' is not a valid date. ";
                     } elseif (!empty($attribs['date_min']) or !empty($attribs['date_max'])) {
                         if (!($date = strtotime(join('/', $datefields)))) {
                             $ferr = "'%s' is not a valid date. ";
                         } elseif (!empty($attribs['date_min']) and $date < strtotime($attribs['date_min'])) {
                             $ferr = sprintf("Date must be greater than '%s'", $attribs['date_min']);
                         } elseif (!empty($attribs['date_max']) and $date > strtotime($attribs['date_max'])) {
                             $ferr = sprintf("Date must be before '%s'", $attribs['date_max']);
                         }
                     }
                     $posted[$ff] = join('/', $datefields);
                     // to avoid a notice only
                     break;
                 case 'date_text':
                     if (!self::is_proper_date($posted[$ff])) {
                         $ferr = "'%2\$s' in '%1\$s' is not a valid date.";
                     }
                     break;
                 case 'numeric':
                     if (!empty($posted[$ff]) && !is_numeric(trim($posted[$ff]))) {
                         $ferr = "'%s' must be a numeric value.";
                     }
                     break;
                 case 'file':
                 case 'image_upload':
                     if (!self::is_uploaded_file($ff)) {
                         $ferr = "%s' must be uploaded";
                     }
                     break;
                 case 'select_or':
                     if (empty($posted[$ff]) and empty($posted[$ff . '_aux'])) {
                         $ferr = "'%s' is a required field.";
                     }
                     break;
                 case 'state_abbr':
                     // if US or Canada based on "country", or there no "country", make sure is a 2-letter abbr.
                     $country_formfield = $this->field_prefix . 'country';
                     if (empty($posted[$country_formfield]) or $posted[$country_formfield] == 'US') {
                         if (strlen($posted[$ff]) != 2 or !formex_field::get_states_opts(true, strtoupper($posted[$ff]))) {
                             $ferr = "Please use a valid 2-letter state abbreviation";
                         }
                     } elseif (!empty($posted[$country_formfield]) and $posted[$country_formfield] == 'CA') {
                         if (strlen($posted[$ff]) != 2 or !formex_field::get_canadian_provs(true, strtoupper($posted[$ff]))) {
                             $ferr = "Please use a valid 2-letter Canadian province abbreviation";
                         }
                     }
                     break;
                 case 'email':
                     if (!empty($posted[$ff]) && !self::is_proper_email($posted[$ff])) {
                         $ferr = "'%2\$s' is not a valid email address. Please enter a complete\n                                        email address, i.e. '*****@*****.**', in the '%1\$s' field.";
                         break;
                     }
                 default:
                     if (isset($posted[$ff]) && is_array($posted[$ff]) && 0 == count($posted[$ff])) {
                         $ferr = "'%s' is a required selection.";
                     } elseif (!isset($posted[$ff]) or is_string($posted[$ff]) && strlen(trim($posted[$ff])) == 0) {
                         $ferr = "'%s' is a required field.";
                     }
             }
         }
         /* check if the image is not too crazy huge */
         if (empty($ferr) && $this->_elems[$k]->type == 'image_upload' && self::is_uploaded_file($ff)) {
             $ferr = $this->_validate_image_dims($k);
         }
         /* attrib 'validate' in any field can point to a function or method that should return a error message on error */
         if (empty($ferr) and isset($attribs['validate']) and is_callable($attribs['validate'])) {
             $val = !empty($posted[$ff]) ? $posted[$ff] : null;
             $ferr = call_user_func($attribs['validate'], $ff, $val);
         }
         if ($ferr) {
             $this->_elems[$k]->set_error();
             $this->add_error($k, sprintf($ferr, $this->_elems[$k]->descrip, $posted[$ff]));
         }
     }
     return count($this->errors) == 0;
 }