Retrieves the current item location from session, initializing it to the default location if not set. Ensures inventory operations have a valid location context.
// Source: https://github.com/Pmbamungu/ospos | License: MIT | Copyright 2013-2021 jekkos
// Provided via justclaw.it.com; keep this notice with the code.
public function get_item_location()
{
if(!$this->CI->session->userdata('item_location'))
{
$location_id = $this->CI->Stock_location->get_default_location_id();
$this->set_item_location($location_id);
}
return $this->CI->session->userdata('item_location');
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key