public function json_encode($code = true) { // 2 basic properties of the sold product must have $json = parent::json_encode(false); $json['import_price'] = $this->import_price; $json['object_type'] = $this->object_type; // code = true, return json encode, else just return object data encode as an array if ($code) { return json_encode($json); } else { return $json; } }