Automattic\WooCommerce\Abilities
ActionableAbility::save
Save the changed object. The default calls WC_Data::save(). When the save throws or leaves the object without an ID, it logs the error and returns a WP_Error with a fixed message, so the exception text stays out of the response.
Метод класса: ActionableAbility{}
Хуков нет.
Возвращает
null|\WP_Error. Null when the object was saved, a WP_Error when it was not.
Использование
$ActionableAbility = new ActionableAbility(); $ActionableAbility->save( $subject );
- $subject(WC_Data) (обязательный)
- Changed object.
Список изменений
| С версии 11.3.0 | Введена. |
Код ActionableAbility::save() ActionableAbility::save WC 11.3.0
public function save( $subject ) {
try {
$subject->save();
} catch ( \Exception $e ) {
wc_get_logger()->error(
sprintf( 'Ability "%s" failed to save: %s', $this->get_name(), $e->getMessage() ),
array( 'source' => 'woocommerce-abilities' )
);
return self::save_failed();
}
return $subject->get_id() > 0 ? null : self::save_failed();
}