/** * Return the Kiala point returned by the Kiala webservice * * @return boolean|KialaPoint Kiala point or false */ public function getPointFromWs() { global $smarty, $cart; $kiala_request = new KialaRequest(); // If the customer used Kiala before, get the latest point he selected $existing_point = KialaOrder::getLatestByCustomer($cart->id_customer); if (Validate::isLoadedObject($existing_point)) { $points = $kiala_request->getPointList($existing_point->point_short_id); } else { $points = $kiala_request->getPointList(); } if (!$points || !is_array($points)) { return false; } // If the customer used a Kiala point before, is the point still available? if (Validate::isLoadedObject($existing_point) && $points[0]->short_id == $existing_point->point_short_id) { if ($points[0]->available == "1") { $point = $points[0]; $point->status = 'point_already_selected'; } elseif (count($points) == 2) { $point = $points[1]; $point->status = 'point_unavailable'; $smarty->assign('unavailable_point_name', Tools::safeOutput($points[0]->name)); } } else { $point = $points[0]; $point->status = 'new_point'; } return $point; }