} else { $data = array("status" => "fail", "msg" => "New user name must be present - value was '{$newTitle}' for '{$sku}'."); } echo json_encode($data, JSON_FORCE_OBJECT); return; } else { if ($action == 'add') { //$data = array("action" => $action, "user_name" => $user_name); $newSKU = $parameters->getValue('newSKU'); $newTitle = $parameters->getValue('newTitle'); $newPrice = $parameters->getValue('newPrice'); $newQty = $parameters->getValue('newQty'); if (!empty($newSKU) && !empty($newTitle) && !empty($newPrice) && !empty($newQty)) { $data = array("status" => "success", "msg" => "Product added."); $um = new ProductManager(); $um->addAdminProduct($newSKU, $newTitle, $newPrice, $newQty); } else { $data = array("status" => "fail", "msg" => "First name, last name, and user name cannot be empty."); } echo json_encode($data, JSON_FORCE_OBJECT); return; } else { $data = array("status" => "fail", "msg" => "Action not understood."); } } } echo json_encode($data, JSON_FORCE_OBJECT); return; } else { $data = array("status" => "error", "msg" => "Only GET allowed."); }