Ошибка в плагине "Переход на Shop-Script" при импорте товаров с woocommerce
Авторизация всегда приосходит по OAUTH, как это видно по коду:
private function query($query, $params = array(), $file = null)
{
waSessionStorage::close();
$time = microtime(true);
$hostname = rtrim(preg_replace('@^https?://@', '', $this->getOption('url')), '/');
$params = array_filter($params);
if ($query) {
if (false) {
$url = "https://{$this->getOption('consumer_key')}:{$this->getOption('consumer_secret')}@{$hostname}/wc-api/{$this->getOption('version','v2')}/{$query}";
} else {
$url = "http://{$hostname}/wc-api/{$this->getOption('version')}/{$query}";
$params = $this->getOauthParams($url, $params);
}
} else {
$url = "http://{$hostname}/wc-api/{$this->getOption('version')}/";
}
API Wocommerce ожидает аутентификацию в данном случаи по SSL:
/**
* Authenticate the request. The authentication method varies based on whether the request was made over SSL or not.
*
* @since 2.1
* @param WP_User $user
* @return null|WP_Error|WP_User
*/
public function authenticate( $user ) {
// Allow access to the index by default
if ( '/' === WC()->api->server->path ) {
return new WP_User( 0 );
}
try {
if ( is_ssl() ) {
$keys = $this->perform_ssl_authentication();
} else {
$keys = $this->perform_oauth_authentication();
}
// Check API key-specific permission
$this->check_api_key_permissions( $keys['permissions'] );
$user = $this->get_user_by_id( $keys['user_id'] );
$this->update_api_key_last_access( $keys['key_id'] );
} catch ( Exception $e ) {
$user = new WP_Error( 'woocommerce_api_authentication_error', $e->getMessage(), array( 'status' => $e->getCode() ) );
}
return $user;
}
Выполнится условие if ( is_ssl() ) { ...
Если с http, то тоже не сработает и выдаст ошибку "Пользовательский ключ утерян (woocommerce_api_authentication_error)"
Версия woocommerce 3.1.1
0 комментариев