public function set_props($props, $context = 'set')
{
$errors = new WP_Error();
foreach ($props as $prop => $value) {
try {
if ('meta_data' === $prop) {
continue;
}
$setter = "set_{$prop}";
if (!is_null($value) && is_callable(array($this, $setter))) {
$reflection = new ReflectionMethod($this, $setter);
if ($reflection->isPublic()) {
$this->{$setter}($value);
}
}
} catch (WC_Data_Exception $e) {
$errors->add($e->getErrorCode(), $e->getMessage());
}
}
return sizeof($errors->get_error_codes()) ? $errors : true;
}