WC_Helper_Subscriptions_API::set_auto_update
Turn auto-updates on or off for a subscription's installed plugin or theme.
Метод класса: WC_Helper_Subscriptions_API{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$result = WC_Helper_Subscriptions_API::set_auto_update( $request ): void;
- $request(обязательный)
- .
Код WC_Helper_Subscriptions_API::set_auto_update() WC Helper Subscriptions API::set auto update WC 11.3.0
public static function set_auto_update( $request ): void {
if ( ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_themes' ) ) {
wp_send_json_error(
array(
'message' => __( 'Sorry, you are not allowed to modify plugins or themes.', 'woocommerce' ),
),
403
);
}
try {
WC_Helper::set_subscription_auto_update( $request->get_param( 'product_key' ), (bool) $request->get_param( 'enabled' ) );
} catch ( Exception $e ) {
wp_send_json_error(
array(
'message' => $e->getMessage(),
),
400
);
}
wp_send_json_success(
array(
'message' => $request->get_param( 'enabled' )
? __( 'Auto-updates are now on for this product.', 'woocommerce' )
: __( 'Auto-updates are now off for this product.', 'woocommerce' ),
)
);
}