Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BasketSnoop extends AdminController {
- protected $shoppingdata = array();
- public function admin () {
- // Load the shopping data and bring into scope
- $this->loadshopping();
- $data = $this->shoppingdata;
- // Display the data
- include dirname(__FILE__).'/view.php';
- }
- protected function loadshopping () {
- $db = DB::instance();
- $prefix = $db->table_prefix;
- // Run our query
- $results = (array) DB::query("SELECT SQL_CALC_FOUND_ROWS
- session, data, modified FROM {$prefix}shopp_shopping LIMIT 0, 10");
- // Extract the data
- foreach ($results as $result)
- $this->organizedata($result);
- }
- protected function organizedata ( $result ) {
- $result->data = unserialize($result->data);
- $cart = $result->data->Order->Cart;
- $viewed = $result->data->viewed;
- $customer = $this->pullCustomerData($result->data->Order);
- // Add to the shopping data array
- $this->shoppingdata[$result->session] = array(
- 'modified' => $result->modified,
- 'cart' => $cart,
- 'viewed' => $viewed,
- 'customer' => $customer
- );
- }
- protected function pullCustomerData($order) {
- // Pull available customer details
- $customer = array_merge(
- (array) $order->Shipping, // Least interest
- (array) $order->Billing, // Preferable
- (array) $order->Customer // Ideal
- );
- // Consolidate firstname/lastname
- if (array_key_exists('firstname', $customer) and !empty($customer['firstname']))
- $customer['name'] = $customer['firstname'].' '.$customer['lastname'];
- // Distill the array down to a limited number of fields
- $desired = array_flip(array(
- 'name', 'address', 'xaddress', 'city', 'state',
- 'country', 'postcode', 'email'));
- return array_intersect_key($customer, $desired);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement