WC_WCCOM_Site_Installation_Step_Get_Product_Info::run
Run the step installation process.
Method of the class: WC_WCCOM_Site_Installation_Step_Get_Product_Info{}
No Hooks.
Returns
Array.
Usage
$WC_WCCOM_Site_Installation_Step_Get_Product_Info = new WC_WCCOM_Site_Installation_Step_Get_Product_Info(); $WC_WCCOM_Site_Installation_Step_Get_Product_Info->run();
WC_WCCOM_Site_Installation_Step_Get_Product_Info::run() WC WCCOM Site Installation Step Get Product Info::run code WC 10.4.3
public function run() {
$product_id = $this->state->get_product_id();
// Get product info from WooCommerce.com.
$request = WC_Helper_API::get(
add_query_arg(
array( 'product_id' => $product_id ),
'info'
),
array(
'authenticated' => true,
)
);
if ( 200 !== wp_remote_retrieve_response_code( $request ) ) {
throw new Installer_Error( Installer_Error_Codes::FAILED_GETTING_PRODUCT_INFO );
}
$result = json_decode( wp_remote_retrieve_body( $request ), true );
if ( ! isset( $result['_product_type'], $result['name'] ) ) {
throw new Installer_Error( Installer_Error_Codes::INVALID_PRODUCT_INFO_RESPONSE );
}
if ( ! empty( $result['_wporg_product'] ) ) {
$download_url = $this->get_wporg_download_url( $result );
} else {
$download_url = $this->get_wccom_download_url( $product_id );
}
$this->state->set_product_type( $result['_product_type'] );
$this->state->set_product_name( $result['name'] );
$this->state->set_download_url( $download_url );
return $this->state;
}