WC_Helper_Subscriptions_API::connect()
Connect a WooCommerce.com subscription.
Метод класса: WC_Helper_Subscriptions_API{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$result = WC_Helper_Subscriptions_API::connect( $request );
- $request(WP_REST_Request) (обязательный)
- Request object.
Код WC_Helper_Subscriptions_API::connect() WC Helper Subscriptions API::connect WC 9.4.2
public static function connect( $request ) { $product_key = $request->get_param( 'product_key' ); try { $success = WC_Helper::activate_helper_subscription( $product_key ); } catch ( Exception $e ) { wp_send_json_error( array( 'message' => $e->getMessage(), ), 400 ); } if ( $success ) { wp_send_json_success( array( 'message' => __( 'Your subscription has been connected.', 'woocommerce' ), ) ); } else { wp_send_json_error( array( 'message' => __( 'There was an error connecting your subscription. Please try again.', 'woocommerce' ), ), 400 ); } }