WC_Helper_Subscriptions_API::install_url
Get the install URL for a WooCommerce.com product.
Метод класса: WC_Helper_Subscriptions_API{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = WC_Helper_Subscriptions_API::install_url( $request );
- $request(WP_REST_Request) (обязательный)
- Request object.
Код WC_Helper_Subscriptions_API::install_url() WC Helper Subscriptions API::install url WC 10.4.0
public static function install_url( $request ) {
$product_key = $request->get_param( 'product_key' );
$subscription = WC_Helper::get_subscription( $product_key );
if ( ! $subscription ) {
wp_send_json_error(
array(
'message' => __( 'We couldn\'t find a subscription for this product.', 'woocommerce' ),
),
400
);
}
if ( true === $subscription['local']['installed'] ) {
wp_send_json_success(
array(
'message' => __( 'This product is already installed.', 'woocommerce' ),
),
);
}
$install_url = WC_Helper::get_subscription_install_url(
$subscription['product_key'],
$subscription['product_slug']
);
if ( ! $install_url ) {
wp_send_json_error(
array(
'message' => __( 'There was an error getting the install URL for this product.', 'woocommerce' ),
),
400
);
}
wp_send_json_success(
array(
'url' => $install_url,
),
);
}