2012-09-12 13:45:42 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Handle data for the current customers session.
|
|
|
|
*
|
|
|
|
* @class WC_Session
|
2012-12-03 19:19:58 +00:00
|
|
|
* @version 2.0.0
|
2013-02-20 17:14:46 +00:00
|
|
|
* @package WooCommerce/Abstracts
|
|
|
|
* @category Abstract Class
|
2012-09-12 13:45:42 +00:00
|
|
|
* @author WooThemes
|
|
|
|
*/
|
2012-09-12 14:21:13 +00:00
|
|
|
abstract class WC_Session {
|
|
|
|
|
2013-01-27 18:54:37 +00:00
|
|
|
/** customer_id */
|
|
|
|
protected $_customer_id;
|
|
|
|
|
2013-01-15 19:51:19 +00:00
|
|
|
/** _data */
|
|
|
|
protected $_data = array();
|
2012-09-12 14:21:13 +00:00
|
|
|
|
2013-01-15 19:51:19 +00:00
|
|
|
/** When something changes */
|
|
|
|
protected $_dirty = false;
|
2012-11-27 16:22:47 +00:00
|
|
|
|
2012-09-12 13:45:42 +00:00
|
|
|
/**
|
|
|
|
* __get function.
|
2012-11-27 16:22:47 +00:00
|
|
|
*
|
2012-09-12 13:45:42 +00:00
|
|
|
* @access public
|
|
|
|
* @param mixed $property
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2012-09-12 14:21:13 +00:00
|
|
|
public function __get( $property ) {
|
|
|
|
return isset( $this->_data[ $property ] ) ? $this->_data[ $property ] : null;
|
|
|
|
}
|
2012-11-27 16:22:47 +00:00
|
|
|
|
2012-09-12 13:45:42 +00:00
|
|
|
/**
|
|
|
|
* __set function.
|
2012-11-27 16:22:47 +00:00
|
|
|
*
|
2012-09-12 13:45:42 +00:00
|
|
|
* @access public
|
|
|
|
* @param mixed $property
|
|
|
|
* @param mixed $value
|
|
|
|
* @return void
|
|
|
|
*/
|
2012-09-12 14:21:13 +00:00
|
|
|
public function __set( $property, $value ) {
|
|
|
|
$this->_data[ $property ] = $value;
|
2013-01-15 19:51:19 +00:00
|
|
|
$this->_dirty = true;
|
2012-09-12 14:21:13 +00:00
|
|
|
}
|
2012-11-27 16:22:47 +00:00
|
|
|
|
2012-09-12 13:45:42 +00:00
|
|
|
/**
|
|
|
|
* __isset function.
|
2012-11-27 16:22:47 +00:00
|
|
|
*
|
2012-09-12 13:45:42 +00:00
|
|
|
* @access public
|
|
|
|
* @param mixed $property
|
|
|
|
* @return bool
|
|
|
|
*/
|
2012-09-12 14:21:13 +00:00
|
|
|
public function __isset( $property ) {
|
|
|
|
return isset( $this->_data[ $property ] );
|
|
|
|
}
|
2012-11-27 16:22:47 +00:00
|
|
|
|
2012-09-12 13:45:42 +00:00
|
|
|
/**
|
|
|
|
* __unset function.
|
2012-11-27 16:22:47 +00:00
|
|
|
*
|
2012-09-12 13:45:42 +00:00
|
|
|
* @access public
|
|
|
|
* @param mixed $property
|
|
|
|
* @return void
|
|
|
|
*/
|
2012-09-12 14:21:13 +00:00
|
|
|
public function __unset( $property ) {
|
2013-01-23 12:27:15 +00:00
|
|
|
if ( isset( $this->_data[ $property ] ) ) {
|
|
|
|
unset( $this->_data[ $property ] );
|
|
|
|
$this->_dirty = true;
|
|
|
|
}
|
2012-09-12 14:21:13 +00:00
|
|
|
}
|
2013-01-27 18:54:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get_customer_id function.
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function get_customer_id() {
|
|
|
|
return $this->_customer_id;
|
|
|
|
}
|
2012-09-12 13:45:42 +00:00
|
|
|
}
|