WC_Data::set_props PHP Method

set_props() public method

Only sets using public methods.
public set_props ( array $props, $context = 'set' ) : WP_Error | boolean
$props array Key value pairs to set. Key is the prop and should map to a setter function name.
return WP_Error | boolean
    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;
    }