Automattic\WooCommerce\Abilities
ActionableAbility::apply_fields
Write the checked values to the object in memory with the update_callback of each field.
Method of the class: ActionableAbility{}
No Hooks.
Returns
\WP_Error|null. A WP_Error when a callback rejects a value or throws.
Usage
// private - for code of main (parent) class only $result = $this->apply_fields( $subject, $updates ): ?\WP_Error;
- $subject(WC_Data) (required)
- Object to change.
- $updates(array) (required)
- Pairs of update_callback and value from prepare_fields().
ActionableAbility::apply_fields() ActionableAbility::apply fields code WC 11.3.0
private function apply_fields( $subject, array $updates ): ?\WP_Error {
foreach ( $updates as $param => list( $callback, $value ) ) {
$rejected = self::run_callback( $callback, array( $subject, $value ), array( 'field' => $param ) );
if ( null !== $rejected ) {
return $rejected;
}
}
return null;
}