woocommerce/classes/gateways/mijireh/includes/Address.php

49 lines
1011 B
PHP
Raw Normal View History

<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2012-06-08 10:46:10 +00:00
class Mijireh_Address extends Mijireh_Model {
2012-11-27 16:22:47 +00:00
2012-06-08 10:46:10 +00:00
public function __construct() {
$this->init();
}
2012-11-27 16:22:47 +00:00
2012-06-08 10:46:10 +00:00
public function init() {
$this->_data = array(
'first_name' => '',
'last_name' => '',
'street' => '',
'city' => '',
'state_province' => '',
'zip_code' => '',
'country' => '',
'company' => '',
'apt_suite' => '',
'phone' => ''
);
}
2012-11-27 16:22:47 +00:00
2012-06-08 10:46:10 +00:00
public function validate() {
$is_valid = $this->_check_required_fields();
return $is_valid;
}
2012-11-27 16:22:47 +00:00
2012-06-08 10:46:10 +00:00
/**
* Return true if all of the required fields have a non-empty value
2012-11-27 16:22:47 +00:00
*
2012-06-08 10:46:10 +00:00
* @return boolean
*/
private function _check_required_fields() {
$pass = true;
$fields = array('street', 'city', 'state_province', 'zip_code', 'country');
foreach($fields as $f) {
if(empty($this->_data[$f])) {
$pass = false;
$this->add_error("$f is required");
}
}
return $pass;
}
2012-11-27 16:22:47 +00:00
2012-06-08 10:46:10 +00:00
}