/** * This is the main routine that acts when the visitor makes a change to their cart. * First we save the user id and useragent info (if the option is set to "on") Next we * populate the receipt object with the products, owner (if exists) and session id. */ public function save_receipt() { global $woocommerce_cart_reports_options, $woocommerce; if (isset($_SERVER) && isset($woocommerce_cart_reports_options['logip']) && $woocommerce_cart_reports_options['logip'] == 'on') { $this->ip_address = $_SERVER['SERVER_ADDR']; $this->user_agent = $_SERVER['HTTP_USER_AGENT']; } //Get current user, generate full name for use later $person = get_current_user_id(); //$person is '' if guest if (function_exists('get_product')) { $session = COOKIEVALUE; } else { $session = session_id(); } // Don't save if is a search engine if (!detect_search_engines($_SERVER['HTTP_USER_AGENT']) && !is_restricted_role()) { $receipt = new AV8_Cart_Receipt($session); $receipt->set_owner($person); $receipt->set_products($woocommerce); //Grab products from woocommerce global object $receipt->save_receipt(); //Save the object to the database } }