Plugin Directory

Changeset 2981815


Ignore:
Timestamp:
10/20/2023 05:44:35 PM (2 years ago)
Author:
casepress
Message:

Update to version 9.4 from GitHub

Location:
wooms
Files:
2 deleted
36 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wooms/tags/9.4/includes/OrderShipment.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
    46
    57defined('ABSPATH') || exit;
     
    2224    /**
    2325     * skip import service if the service is shipment
    24      * 
     26     *
    2527     * issue https://github.com/wpcraft-ru/wooms/issues/314
    2628     */
     
    4042    /**
    4143     * chg_order_data
    42      * 
     44     *
    4345     * fix https://github.com/wpcraft-ru/wooms/issues/186
    4446     */
     
    7880    public static function get_meta_for_shipment_item($order_shipment_item_code)
    7981    {
    80         $url = 'https://online.moysklad.ru/api/remap/1.2/entity/service';
     82        $url = 'entity/service';
    8183        $url = add_query_arg('filter=code', $order_shipment_item_code, $url);
    82         $data = wooms_request($url);
     84        $data = request($url);
    8385
    8486        if (empty($data['rows'][0]['meta'])) {
  • wooms/tags/9.4/includes/OrderStatusesFromSite.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58/**
     
    9295        $statuses = get_transient('wooms_order_statuses');
    9396        if (empty($statuses)) {
    94             $url_statuses = 'https://online.moysklad.ru/api/remap/1.2/entity/customerorder/metadata';
    95             $statuses = wooms_request($url_statuses);
     97            $url_statuses = 'entity/customerorder/metadata';
     98            $statuses = request($url_statuses);
    9699            $statuses = $statuses["states"];
    97100            set_transient('wooms_order_statuses', $statuses, 600);
  • wooms/tags/9.4/includes/OrderUpdateFromMoySklad.php

    r2826440 r2981815  
    44
    55use Exception;
     6
     7use function WooMS\request;
     8
    69
    710/**
     
    7275    /**
    7376     * update_order_status
    74      * 
     77     *
    7578     * use hook wooms_update_order_from_moysklad
    76      * 
     79     *
    7780     * @param \WC_Order $order
    78      * 
     81     *
    7982     * @return \WC_Order - order object
    8083     */
     
    8689
    8790        $state_url  = $data_api["state"]["meta"]["href"];
    88         $state_data = wooms_request($state_url);
     91        $state_data = request($state_url);
    8992        if (empty($state_data['name'])) {
    9093            return $order;
     
    117120    /**
    118121     * update_order_items
    119      * 
     122     *
    120123     * @param \WC_Order $order
    121      * 
     124     *
    122125     * @return \WC_Order - order object
    123126     */
     
    131134        $url_api = $data_api['positions']['meta']['href'];
    132135
    133         $data = wooms_request($url_api);
     136        $data = request($url_api);
    134137
    135138
     
    220223    /**
    221224     * get item_id from order and wooms_id
    222      * 
     225     *
    223226     * @param string $wooms_uuid
    224227     * @param \WC_Order $order
     
    247250    /**
    248251     * Get wooms id from line item
    249      * 
     252     *
    250253     * @param \WC_Order_Item_Product $line_item
    251254     */
     
    272275    /**
    273276     * Skip order update from site, if exist task to update from MoySklad
    274      * 
     277     *
    275278     * @param bool $skip
    276279     * @param \WC_Order $order
    277      * 
     280     *
    278281     * @return bool - skip or no
    279282     */
     
    304307        }
    305308
    306         $url_api = sprintf('https://online.moysklad.ru/api/remap/1.2/entity/service?filter=code=%s', $code);
    307 
    308         $data = wooms_request($url_api);
     309        $url_api = sprintf('entity/service?filter=code=%s', $code);
     310
     311        $data = request($url_api);
    309312
    310313        if (empty($data['rows'][0]['meta']['href'])) {
     
    384387        }
    385388
    386         $url_api = sprintf('https://online.moysklad.ru/api/remap/1.2/entity/customerorder/%s', $wooms_id);
    387 
    388         $data = wooms_request($url_api);
     389        $url_api = sprintf('entity/customerorder/%s', $wooms_id);
     390
     391        $data = request($url_api);
    389392
    390393        $order = apply_filters('wooms_update_order_from_moysklad', $order, $data);
     
    521524
    522525        $check    = self::check_webhooks_and_try_fix();
    523         $url      = 'https://online.moysklad.ru/api/remap/1.2/entity/webhook?limit=50';
    524         $data     = wooms_request($url);
     526        $url      = 'entity/webhook?limit=50';
     527        $data     = request($url);
    525528
    526529        $webhooks = array();
     
    569572    {
    570573
    571         $url  = 'https://online.moysklad.ru/api/remap/1.2/entity/webhook';
    572         $data = wooms_request($url);
     574        $url  = 'entity/webhook';
     575        $data = request($url);
    573576
    574577        $webhooks = array();
     
    600603                //пытаемся удалить лишний хук
    601604                foreach ($webhooks as $id => $value) {
    602                     $url   = 'https://online.moysklad.ru/api/remap/1.2/entity/webhook/' . $id;
    603                     $check = wooms_request($url, null, 'DELETE');
     605                    $url   = 'entity/webhook/' . $id;
     606                    $check = request($url, null, 'DELETE');
    604607                }
    605608
     
    616619                    "entityType" => "customerorder",
    617620                );
    618                 $result = wooms_request($url, $data);
     621                $result = request($url, $data);
    619622
    620623                if (empty($result)) {
     
    753756            $url = $data["events"][0]["meta"]["href"];
    754757
    755             $data_order = wooms_request($url);
     758            $data_order = request($url);
    756759            if (empty($data_order['id'])) {
    757760                return;
  • wooms/tags/9.4/includes/Orders.php

    r2826597 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
    46
    57defined('ABSPATH') || exit;
     
    133135        }
    134136
    135         $url    = 'https://online.moysklad.ru/api/remap/1.2/entity/customerorder/' . $wooms_id;
    136 
    137         $data = wooms_request($url);
     137        $api_path = 'entity/customerorder/' . $wooms_id;
     138        $data = request($api_path);
    138139
    139140        /**
     
    167168
    168169
    169         $result = wooms_request($url, $data, 'PUT');
     170        $result = request($api_path, $data, 'PUT');
    170171
    171172        if (empty($result["id"])) {
     
    221222
    222223        if (!$data = get_transient('wooms_currency_api')) {
    223             $url = 'https://online.moysklad.ru/api/remap/1.2/entity/currency/';
    224             $data = wooms_request($url);
     224            $data = request('entity/currency/');
    225225            set_transient('wooms_currency_api', $data, HOUR_IN_SECONDS);
    226226        }
     
    443443        $data = apply_filters('wooms_order_data', $data, $order_id, $order);
    444444
    445         $url = 'https://online.moysklad.ru/api/remap/1.2/entity/customerorder';
    446 
    447         $result = wooms_request($url, $data, 'POST');
     445        $result = request('entity/customerorder', $data, 'POST');
    448446
    449447        if (empty($result['id']) || !isset($result['id']) || isset($result['errors'])) {
     
    582580                'assortment' => array(
    583581                    'meta' => array(
    584                         "href"      => "https://online.moysklad.ru/api/remap/1.2/entity/{$product_type}/" . $uuid,
     582                        "href"      => \WooMS\get_api_url("entity/{$product_type}/" . $uuid),
    585583                        "type"      => "{$product_type}",
    586584                        "mediaType" => "application/json",
     
    628626    public static function get_data_organization()
    629627    {
    630         $url  = 'https://online.moysklad.ru/api/remap/1.2/entity/organization';
    631         $data = wooms_request($url);
     628        $data = request('entity/organization');
    632629
    633630        if (empty($data['rows'][0]['meta'])) {
     
    698695
    699696        $url    = $data_order['agent']['meta']['href'];
    700         $result = wooms_request($url, $data, 'PUT');
     697        $result = request($url, $data, 'PUT');
    701698
    702699        return $data_order;
     
    729726
    730727            $phone = self::phone_prepare($phone);
    731             $url_search_agent = 'https://online.moysklad.ru/api/remap/1.2/entity/counterparty?search=' . $phone;
    732 
    733             $data_agents      = wooms_request($url_search_agent);
     728            $data_agents      = request('entity/counterparty?search=' . $phone);
    734729            if (isset($data_agents['rows'][0]['phone'])) {
    735730                $agent_meta = $data_agents['rows'][0];
     
    776771        );
    777772
    778         $url    = 'https://online.moysklad.ru/api/remap/1.2/entity/counterparty';
    779         $result = wooms_request($url, $data, 'POST');
     773        $url    = 'entity/counterparty';
     774        $result = request($url, $data, 'POST');
    780775
    781776        if (empty($result["meta"])) {
     
    821816
    822817        if (!empty($data['email'])) {
    823             $url_search_agent = 'https://online.moysklad.ru/api/remap/1.2/entity/counterparty?filter=email=' . $data['email'];
    824             $data_agents      = wooms_request($url_search_agent);
     818            $url_search_agent = 'entity/counterparty?filter=email=' . $data['email'];
     819            $data_agents      = request($url_search_agent);
    825820            if (isset($data_agents['rows'][0]['email'])) {
    826821                $agent_meta = $data_agents['rows'][0];
     
    848843        }
    849844
    850         $url    = 'https://online.moysklad.ru/api/remap/1.2/entity/counterparty/' . $agent_uuid;
    851         $result = wooms_request($url);
     845        $url    = 'entity/counterparty/' . $agent_uuid;
     846        $result = request($url);
    852847        if (empty($result['id'])) {
    853848            return false;
     
    992987    public static function get_agent_meta_by_email($email = '')
    993988    {
    994         $url_search_agent = 'https://online.moysklad.ru/api/remap/1.2/entity/counterparty?filter=email=' . $email;
    995         $data_agents      = wooms_request($url_search_agent);
     989        $url_search_agent = 'entity/counterparty?filter=email=' . $email;
     990        $data_agents      = request($url_search_agent);
    996991        if (empty($data_agents['rows'][0]['meta'])) {
    997992            return false;
  • wooms/tags/9.4/includes/ProductAttributes.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58if ( ! defined( 'ABSPATH' ) ) {
     
    3740  }
    3841
    39  
     42
    4043  /**
    4144   * Update product
     
    8689
    8790    do_action( 'wooms_logger', __CLASS__,
    88       sprintf('Артибуты Продукта: %s (%s) сохранены', $product->get_title(), $product->get_id()), 
     91      sprintf('Артибуты Продукта: %s (%s) сохранены', $product->get_title(), $product->get_id()),
    8992      $product_attributes
    9093    );
     
    208211    }
    209212
    210     $data_api = wooms_request($url);
     213    $data_api = request($url);
    211214
    212215    if(empty($data_api["name"])){
  • wooms/tags/9.4/includes/ProductGallery.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
    46
    57if (!defined('ABSPATH')) {
     
    245247    $img_data_list = $imgages_url;
    246248
    247     $images_data = wooms_request($imgages_url);
     249    $images_data = request($imgages_url);
    248250
    249251    if (empty($images_data['rows'])) {
  • wooms/tags/9.4/includes/ProductGrouped.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58/**
    69 * Products Bundle Managment
    7  * 
     10 *
    811 * issue https://github.com/wpcraft-ru/wooms/issues/313
    912 */
     
    1316  /**
    1417   * Save state in DB
    15    * 
     18   *
    1619   * @var string
    1720   */
     
    8588    $query_arg = self::get_state('query_arg');
    8689
    87     $url = 'https://online.moysklad.ru/api/remap/1.2/entity/bundle';
     90    $url = 'entity/bundle';
    8891
    8992    $url = add_query_arg($query_arg, $url);
     
    106109      );
    107110
    108       $data = wooms_request($url);
     111      $data = request($url);
    109112
    110113      //Check for errors and send message to UI
     
    133136      self::set_state('count', self::get_state('count') + $i);
    134137
    135       //update offset 
     138      //update offset
    136139      $query_arg['offset'] = $query_arg['offset'] + count($data['rows']);
    137140
     
    289292    $url_api = $value["components"]["meta"]["href"];
    290293
    291     $data_components = wooms_request($url_api);
     294    $data_components = request($url_api);
    292295
    293296    // dd($data_components);
     
    314317    foreach ($data_components["rows"] as $row_component) {
    315318      $product_uuid = str_replace('https://online.moysklad.ru/api/remap/1.2/entity/product/', '', $row_component["assortment"]["meta"]["href"]);
     319      $product_uuid = str_replace('https://api.moysklad.ru/api/remap/1.2/entity/product/', '', $row_component["assortment"]["meta"]["href"]);
    316320      $subproduct_id = self::get_product_id_by_uuid($product_uuid);
    317321
  • wooms/tags/9.4/includes/ProductSingleSync.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
    46
    57if (!defined('ABSPATH')) {
     
    136138    }
    137139
    138     $url = 'https://online.moysklad.ru/api/remap/1.2/entity/variant/?filter=productid=' . $wooms_id;
     140    $url = 'entity/variant/?filter=productid=' . $wooms_id;
    139141    $url = add_query_arg($url_args, $url);
    140142
     
    145147    );
    146148
    147     $data_api = wooms_request($url);
     149    $data_api = request($url);
    148150
    149151    if (empty($data_api['rows'])) {
     
    243245    }
    244246
    245     $url = 'https://online.moysklad.ru/api/remap/1.2/entity/assortment?filter=id=' . $uuid;
    246 
    247     $data = wooms_request($url);
     247    $url = 'entity/assortment?filter=id=' . $uuid;
     248
     249    $data = request($url);
    248250
    249251    if (!isset($data['rows'][0])) {
  • wooms/tags/9.4/includes/ProductStocks.php

    r2842491 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58defined('ABSPATH') || exit; // Exit if accessed directly
     
    8790    }
    8891
    89     $url = 'https://online.moysklad.ru/api/remap/1.2/entity/assortment';
     92    $url = 'entity/assortment';
    9093
    9194    $filters = apply_filters('wooms_assortment_sync_filters', $filters);
     
    101104    );
    102105
    103     $data_api = wooms_request($url);
     106    $data_api = request($url);
    104107
    105108    if (empty($data_api['rows'])) {
     
    349352      $uuid = str_replace('https://online.moysklad.ru/api/remap/1.1/entity/product/', '', $uuid);
    350353      $uuid = str_replace('https://online.moysklad.ru/api/remap/1.2/entity/product/', '', $uuid);
     354      $uuid = str_replace('https://api.moysklad.ru/api/remap/1.2/entity/product/', '', $uuid);
    351355    }
    352356
     
    384388
    385389    if (!$wh_name = get_transient('wooms_warehouse_name')) {
    386       $url = sprintf('https://online.moysklad.ru/api/remap/1.2/entity/store/%s', $warehouse_id);
    387       $data = wooms_request($url);
     390      $url = sprintf('entity/store/%s', $warehouse_id);
     391      $data = request($url);
    388392      if (isset($data["name"])) {
    389393        $wh_name = $data["name"];
     
    406410    }
    407411
    408     $filter[] = 'stockStore=' . sprintf('https://online.moysklad.ru/api/remap/1.2/entity/store/%s', $warehouse_id);
     412    $filter[] = 'stockStore=' . \WooMS\get_api_url(sprintf('entity/store/%s', $warehouse_id));
    409413
    410414    return $filter;
     
    527531      $callback = function ($args) {
    528532
    529         $url  = 'https://online.moysklad.ru/api/remap/1.2/entity/store';
    530         $data = wooms_request($url);
     533        $url  = 'entity/store';
     534        $data = request($url);
    531535        if (empty($data['rows'])) {
    532536          echo 'Система не смогла получить список складов из МойСклад';
  • wooms/tags/9.4/includes/ProductVariable.php

    r2842491 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58// Exit if accessed directly
     
    7679     * issue https://github.com/wpcraft-ru/wooms/issues/296
    7780     */
    78     $url = 'https://online.moysklad.ru/api/remap/1.2/entity/variant';
     81    $url = 'entity/variant';
    7982
    8083    $url = add_query_arg($state['query_arg'], $url);
     
    97100      );
    98101
    99       $data = wooms_request($url);
     102      $data = request($url);
    100103
    101104      //Check for errors and send message to UI
     
    394397      $uuid = str_replace('https://online.moysklad.ru/api/remap/1.1/entity/product/', '', $uuid);
    395398      $uuid = str_replace('https://online.moysklad.ru/api/remap/1.2/entity/product/', '', $uuid);
     399      $uuid = str_replace('https://api.moysklad.ru/api/remap/1.2/entity/product/', '', $uuid);
    396400    }
    397401
  • wooms/tags/9.4/includes/ProductVariableImage.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
    46
    57
     
    99101
    100102        $href = $variant_data['images']['meta']['href'];
    101         $img_metadata = wooms_request($href);
     103        $img_metadata = request($href);
    102104
    103105        if (empty($img_metadata['rows'][0])) {
     
    127129            return;
    128130        }
    129        
     131
    130132        // Adding schedule hook
    131133        as_schedule_single_action(
  • wooms/tags/9.4/includes/ProductsCategories.php

    r2854597 r2981815  
    106106    //if uuid as url - get uuid only
    107107    $id = str_replace('https://online.moysklad.ru/api/remap/1.2/entity/productfolder/', '', $id);
     108    $id = str_replace('https://api.moysklad.ru/api/remap/1.2/entity/productfolder/', '', $id);
    108109
    109110    $terms = get_terms(array(
  • wooms/tags/9.4/includes/ProductsExclusion.php

    r2826440 r2981815  
    2222
    2323    $flag = get_option( OPTION_KEY );
    24     $attr_url = 'https://online.moysklad.ru/api/remap/1.2/entity/product/metadata/attributes/';
     24    $attr_url = \WooMS\get_api_url('entity/product/metadata/attributes/');
    2525
    2626    if ( $flag ) {
     
    3232
    3333
    34 function add_settings() 
     34function add_settings()
    3535{
    3636    register_setting( 'mss-settings', OPTION_KEY );
  • wooms/tags/9.4/includes/ProductsServices.php

    r2826597 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58if (!defined('ABSPATH')) {
     
    9194            $query_arg = self::get_state('query_arg');
    9295
    93             $url = 'https://online.moysklad.ru/api/remap/1.2/entity/service';
     96            $url = 'entity/service';
    9497
    9598            $url = add_query_arg($query_arg, $url);
     
    110113            );
    111114
    112             $data = wooms_request($url);
     115            $data = request($url);
    113116
    114117            //Check for errors and send message to UI
  • wooms/tags/9.4/includes/SendWarehouse.php

    r2826440 r2981815  
    3535
    3636    $data['store']['meta'] = array(
    37       'href' => 'https://online.moysklad.ru/api/remap/1.2/entity/store/' . $warehouse_id,
     37      'href' => \WooMS\get_api_url('entity/store/' . $warehouse_id),
    3838      "type" => "store",
    3939    );
  • wooms/tags/9.4/includes/SiteHealth.php

    r2826440 r2981815  
    22
    33namespace WooMS\SiteHealth;
     4
     5use function WooMS\request;
     6
    47
    58if (!defined('ABSPATH')) {
     
    1316
    1417});
    15 
    16 
    1718
    1819/**
     
    3233        'value'   => sprintf('Для корректной работы плагина нужно сменить тариф %s', '❌'),
    3334    ];
    34    
     35
    3536
    3637    return $debug_info;
     
    106107    }
    107108
    108     $url = 'https://online.moysklad.ru/api/remap/1.2/security/token';
    109     $data_api = wooms_request($url, [], 'POST');
     109    $url = 'security/token';
     110    $data_api = request($url, [], 'POST');
    110111
    111112    $result = [
  • wooms/tags/9.4/readme.txt

    r2979725 r2981815  
    3434Страница плагина: [https://wpcraft.ru/wooms/](https://wpcraft.ru/wooms/)
    3535
    36 Статус задач по разработке: [https://github.com/orgs/wpcraft-ru/projects/2](roadmap)
    37 
    3836Плагин спроектирован таким образом, что относительно просто позволяет дорабатывать механику под задачи и автоматизацию конкретного магазина/каталога.
    3937
     
    7876
    7977== Changelog ==
     78
     79= 9.4 =
     80- Тест совместимости WooCommerce 8.2.1
     81- Реализация новой версии REST API MoySklad
    8082
    8183= 9.3 =
  • wooms/tags/9.4/wooms.php

    r2979725 r2981815  
    2020 * WC tested up to: 7.2.2
    2121 *
    22  * Version: 9.3
     22 * Version: 9.4
    2323 */
    2424
     
    121121}
    122122
     123
     124
     125function get_api_url($path){
     126    return $url = 'https://api.moysklad.ru/api/remap/1.2/' . $path;
     127}
     128
    123129function request($path = '', $data = array(), $type = 'GET'){
    124130  // https://api.moysklad.ru/api/remap/1.2/
     
    129135  }
    130136
    131   $url = 'https://api.moysklad.ru/api/remap/1.2/' . $path;
     137  if(str_contains($path, 'https://api.moysklad.ru/api/remap/1.2/')){
     138    $url = $path;
     139  } else {
     140    $url = 'https://api.moysklad.ru/api/remap/1.2/' . $path;
     141  }
     142
    132143
    133144
  • wooms/trunk/includes/OrderShipment.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
    46
    57defined('ABSPATH') || exit;
     
    2224    /**
    2325     * skip import service if the service is shipment
    24      * 
     26     *
    2527     * issue https://github.com/wpcraft-ru/wooms/issues/314
    2628     */
     
    4042    /**
    4143     * chg_order_data
    42      * 
     44     *
    4345     * fix https://github.com/wpcraft-ru/wooms/issues/186
    4446     */
     
    7880    public static function get_meta_for_shipment_item($order_shipment_item_code)
    7981    {
    80         $url = 'https://online.moysklad.ru/api/remap/1.2/entity/service';
     82        $url = 'entity/service';
    8183        $url = add_query_arg('filter=code', $order_shipment_item_code, $url);
    82         $data = wooms_request($url);
     84        $data = request($url);
    8385
    8486        if (empty($data['rows'][0]['meta'])) {
  • wooms/trunk/includes/OrderStatusesFromSite.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58/**
     
    9295        $statuses = get_transient('wooms_order_statuses');
    9396        if (empty($statuses)) {
    94             $url_statuses = 'https://online.moysklad.ru/api/remap/1.2/entity/customerorder/metadata';
    95             $statuses = wooms_request($url_statuses);
     97            $url_statuses = 'entity/customerorder/metadata';
     98            $statuses = request($url_statuses);
    9699            $statuses = $statuses["states"];
    97100            set_transient('wooms_order_statuses', $statuses, 600);
  • wooms/trunk/includes/OrderUpdateFromMoySklad.php

    r2826440 r2981815  
    44
    55use Exception;
     6
     7use function WooMS\request;
     8
    69
    710/**
     
    7275    /**
    7376     * update_order_status
    74      * 
     77     *
    7578     * use hook wooms_update_order_from_moysklad
    76      * 
     79     *
    7780     * @param \WC_Order $order
    78      * 
     81     *
    7982     * @return \WC_Order - order object
    8083     */
     
    8689
    8790        $state_url  = $data_api["state"]["meta"]["href"];
    88         $state_data = wooms_request($state_url);
     91        $state_data = request($state_url);
    8992        if (empty($state_data['name'])) {
    9093            return $order;
     
    117120    /**
    118121     * update_order_items
    119      * 
     122     *
    120123     * @param \WC_Order $order
    121      * 
     124     *
    122125     * @return \WC_Order - order object
    123126     */
     
    131134        $url_api = $data_api['positions']['meta']['href'];
    132135
    133         $data = wooms_request($url_api);
     136        $data = request($url_api);
    134137
    135138
     
    220223    /**
    221224     * get item_id from order and wooms_id
    222      * 
     225     *
    223226     * @param string $wooms_uuid
    224227     * @param \WC_Order $order
     
    247250    /**
    248251     * Get wooms id from line item
    249      * 
     252     *
    250253     * @param \WC_Order_Item_Product $line_item
    251254     */
     
    272275    /**
    273276     * Skip order update from site, if exist task to update from MoySklad
    274      * 
     277     *
    275278     * @param bool $skip
    276279     * @param \WC_Order $order
    277      * 
     280     *
    278281     * @return bool - skip or no
    279282     */
     
    304307        }
    305308
    306         $url_api = sprintf('https://online.moysklad.ru/api/remap/1.2/entity/service?filter=code=%s', $code);
    307 
    308         $data = wooms_request($url_api);
     309        $url_api = sprintf('entity/service?filter=code=%s', $code);
     310
     311        $data = request($url_api);
    309312
    310313        if (empty($data['rows'][0]['meta']['href'])) {
     
    384387        }
    385388
    386         $url_api = sprintf('https://online.moysklad.ru/api/remap/1.2/entity/customerorder/%s', $wooms_id);
    387 
    388         $data = wooms_request($url_api);
     389        $url_api = sprintf('entity/customerorder/%s', $wooms_id);
     390
     391        $data = request($url_api);
    389392
    390393        $order = apply_filters('wooms_update_order_from_moysklad', $order, $data);
     
    521524
    522525        $check    = self::check_webhooks_and_try_fix();
    523         $url      = 'https://online.moysklad.ru/api/remap/1.2/entity/webhook?limit=50';
    524         $data     = wooms_request($url);
     526        $url      = 'entity/webhook?limit=50';
     527        $data     = request($url);
    525528
    526529        $webhooks = array();
     
    569572    {
    570573
    571         $url  = 'https://online.moysklad.ru/api/remap/1.2/entity/webhook';
    572         $data = wooms_request($url);
     574        $url  = 'entity/webhook';
     575        $data = request($url);
    573576
    574577        $webhooks = array();
     
    600603                //пытаемся удалить лишний хук
    601604                foreach ($webhooks as $id => $value) {
    602                     $url   = 'https://online.moysklad.ru/api/remap/1.2/entity/webhook/' . $id;
    603                     $check = wooms_request($url, null, 'DELETE');
     605                    $url   = 'entity/webhook/' . $id;
     606                    $check = request($url, null, 'DELETE');
    604607                }
    605608
     
    616619                    "entityType" => "customerorder",
    617620                );
    618                 $result = wooms_request($url, $data);
     621                $result = request($url, $data);
    619622
    620623                if (empty($result)) {
     
    753756            $url = $data["events"][0]["meta"]["href"];
    754757
    755             $data_order = wooms_request($url);
     758            $data_order = request($url);
    756759            if (empty($data_order['id'])) {
    757760                return;
  • wooms/trunk/includes/Orders.php

    r2826597 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
    46
    57defined('ABSPATH') || exit;
     
    133135        }
    134136
    135         $url    = 'https://online.moysklad.ru/api/remap/1.2/entity/customerorder/' . $wooms_id;
    136 
    137         $data = wooms_request($url);
     137        $api_path = 'entity/customerorder/' . $wooms_id;
     138        $data = request($api_path);
    138139
    139140        /**
     
    167168
    168169
    169         $result = wooms_request($url, $data, 'PUT');
     170        $result = request($api_path, $data, 'PUT');
    170171
    171172        if (empty($result["id"])) {
     
    221222
    222223        if (!$data = get_transient('wooms_currency_api')) {
    223             $url = 'https://online.moysklad.ru/api/remap/1.2/entity/currency/';
    224             $data = wooms_request($url);
     224            $data = request('entity/currency/');
    225225            set_transient('wooms_currency_api', $data, HOUR_IN_SECONDS);
    226226        }
     
    443443        $data = apply_filters('wooms_order_data', $data, $order_id, $order);
    444444
    445         $url = 'https://online.moysklad.ru/api/remap/1.2/entity/customerorder';
    446 
    447         $result = wooms_request($url, $data, 'POST');
     445        $result = request('entity/customerorder', $data, 'POST');
    448446
    449447        if (empty($result['id']) || !isset($result['id']) || isset($result['errors'])) {
     
    582580                'assortment' => array(
    583581                    'meta' => array(
    584                         "href"      => "https://online.moysklad.ru/api/remap/1.2/entity/{$product_type}/" . $uuid,
     582                        "href"      => \WooMS\get_api_url("entity/{$product_type}/" . $uuid),
    585583                        "type"      => "{$product_type}",
    586584                        "mediaType" => "application/json",
     
    628626    public static function get_data_organization()
    629627    {
    630         $url  = 'https://online.moysklad.ru/api/remap/1.2/entity/organization';
    631         $data = wooms_request($url);
     628        $data = request('entity/organization');
    632629
    633630        if (empty($data['rows'][0]['meta'])) {
     
    698695
    699696        $url    = $data_order['agent']['meta']['href'];
    700         $result = wooms_request($url, $data, 'PUT');
     697        $result = request($url, $data, 'PUT');
    701698
    702699        return $data_order;
     
    729726
    730727            $phone = self::phone_prepare($phone);
    731             $url_search_agent = 'https://online.moysklad.ru/api/remap/1.2/entity/counterparty?search=' . $phone;
    732 
    733             $data_agents      = wooms_request($url_search_agent);
     728            $data_agents      = request('entity/counterparty?search=' . $phone);
    734729            if (isset($data_agents['rows'][0]['phone'])) {
    735730                $agent_meta = $data_agents['rows'][0];
     
    776771        );
    777772
    778         $url    = 'https://online.moysklad.ru/api/remap/1.2/entity/counterparty';
    779         $result = wooms_request($url, $data, 'POST');
     773        $url    = 'entity/counterparty';
     774        $result = request($url, $data, 'POST');
    780775
    781776        if (empty($result["meta"])) {
     
    821816
    822817        if (!empty($data['email'])) {
    823             $url_search_agent = 'https://online.moysklad.ru/api/remap/1.2/entity/counterparty?filter=email=' . $data['email'];
    824             $data_agents      = wooms_request($url_search_agent);
     818            $url_search_agent = 'entity/counterparty?filter=email=' . $data['email'];
     819            $data_agents      = request($url_search_agent);
    825820            if (isset($data_agents['rows'][0]['email'])) {
    826821                $agent_meta = $data_agents['rows'][0];
     
    848843        }
    849844
    850         $url    = 'https://online.moysklad.ru/api/remap/1.2/entity/counterparty/' . $agent_uuid;
    851         $result = wooms_request($url);
     845        $url    = 'entity/counterparty/' . $agent_uuid;
     846        $result = request($url);
    852847        if (empty($result['id'])) {
    853848            return false;
     
    992987    public static function get_agent_meta_by_email($email = '')
    993988    {
    994         $url_search_agent = 'https://online.moysklad.ru/api/remap/1.2/entity/counterparty?filter=email=' . $email;
    995         $data_agents      = wooms_request($url_search_agent);
     989        $url_search_agent = 'entity/counterparty?filter=email=' . $email;
     990        $data_agents      = request($url_search_agent);
    996991        if (empty($data_agents['rows'][0]['meta'])) {
    997992            return false;
  • wooms/trunk/includes/ProductAttributes.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58if ( ! defined( 'ABSPATH' ) ) {
     
    3740  }
    3841
    39  
     42
    4043  /**
    4144   * Update product
     
    8689
    8790    do_action( 'wooms_logger', __CLASS__,
    88       sprintf('Артибуты Продукта: %s (%s) сохранены', $product->get_title(), $product->get_id()), 
     91      sprintf('Артибуты Продукта: %s (%s) сохранены', $product->get_title(), $product->get_id()),
    8992      $product_attributes
    9093    );
     
    208211    }
    209212
    210     $data_api = wooms_request($url);
     213    $data_api = request($url);
    211214
    212215    if(empty($data_api["name"])){
  • wooms/trunk/includes/ProductGallery.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
    46
    57if (!defined('ABSPATH')) {
     
    245247    $img_data_list = $imgages_url;
    246248
    247     $images_data = wooms_request($imgages_url);
     249    $images_data = request($imgages_url);
    248250
    249251    if (empty($images_data['rows'])) {
  • wooms/trunk/includes/ProductGrouped.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58/**
    69 * Products Bundle Managment
    7  * 
     10 *
    811 * issue https://github.com/wpcraft-ru/wooms/issues/313
    912 */
     
    1316  /**
    1417   * Save state in DB
    15    * 
     18   *
    1619   * @var string
    1720   */
     
    8588    $query_arg = self::get_state('query_arg');
    8689
    87     $url = 'https://online.moysklad.ru/api/remap/1.2/entity/bundle';
     90    $url = 'entity/bundle';
    8891
    8992    $url = add_query_arg($query_arg, $url);
     
    106109      );
    107110
    108       $data = wooms_request($url);
     111      $data = request($url);
    109112
    110113      //Check for errors and send message to UI
     
    133136      self::set_state('count', self::get_state('count') + $i);
    134137
    135       //update offset 
     138      //update offset
    136139      $query_arg['offset'] = $query_arg['offset'] + count($data['rows']);
    137140
     
    289292    $url_api = $value["components"]["meta"]["href"];
    290293
    291     $data_components = wooms_request($url_api);
     294    $data_components = request($url_api);
    292295
    293296    // dd($data_components);
     
    314317    foreach ($data_components["rows"] as $row_component) {
    315318      $product_uuid = str_replace('https://online.moysklad.ru/api/remap/1.2/entity/product/', '', $row_component["assortment"]["meta"]["href"]);
     319      $product_uuid = str_replace('https://api.moysklad.ru/api/remap/1.2/entity/product/', '', $row_component["assortment"]["meta"]["href"]);
    316320      $subproduct_id = self::get_product_id_by_uuid($product_uuid);
    317321
  • wooms/trunk/includes/ProductSingleSync.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
    46
    57if (!defined('ABSPATH')) {
     
    136138    }
    137139
    138     $url = 'https://online.moysklad.ru/api/remap/1.2/entity/variant/?filter=productid=' . $wooms_id;
     140    $url = 'entity/variant/?filter=productid=' . $wooms_id;
    139141    $url = add_query_arg($url_args, $url);
    140142
     
    145147    );
    146148
    147     $data_api = wooms_request($url);
     149    $data_api = request($url);
    148150
    149151    if (empty($data_api['rows'])) {
     
    243245    }
    244246
    245     $url = 'https://online.moysklad.ru/api/remap/1.2/entity/assortment?filter=id=' . $uuid;
    246 
    247     $data = wooms_request($url);
     247    $url = 'entity/assortment?filter=id=' . $uuid;
     248
     249    $data = request($url);
    248250
    249251    if (!isset($data['rows'][0])) {
  • wooms/trunk/includes/ProductStocks.php

    r2842491 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58defined('ABSPATH') || exit; // Exit if accessed directly
     
    8790    }
    8891
    89     $url = 'https://online.moysklad.ru/api/remap/1.2/entity/assortment';
     92    $url = 'entity/assortment';
    9093
    9194    $filters = apply_filters('wooms_assortment_sync_filters', $filters);
     
    101104    );
    102105
    103     $data_api = wooms_request($url);
     106    $data_api = request($url);
    104107
    105108    if (empty($data_api['rows'])) {
     
    349352      $uuid = str_replace('https://online.moysklad.ru/api/remap/1.1/entity/product/', '', $uuid);
    350353      $uuid = str_replace('https://online.moysklad.ru/api/remap/1.2/entity/product/', '', $uuid);
     354      $uuid = str_replace('https://api.moysklad.ru/api/remap/1.2/entity/product/', '', $uuid);
    351355    }
    352356
     
    384388
    385389    if (!$wh_name = get_transient('wooms_warehouse_name')) {
    386       $url = sprintf('https://online.moysklad.ru/api/remap/1.2/entity/store/%s', $warehouse_id);
    387       $data = wooms_request($url);
     390      $url = sprintf('entity/store/%s', $warehouse_id);
     391      $data = request($url);
    388392      if (isset($data["name"])) {
    389393        $wh_name = $data["name"];
     
    406410    }
    407411
    408     $filter[] = 'stockStore=' . sprintf('https://online.moysklad.ru/api/remap/1.2/entity/store/%s', $warehouse_id);
     412    $filter[] = 'stockStore=' . \WooMS\get_api_url(sprintf('entity/store/%s', $warehouse_id));
    409413
    410414    return $filter;
     
    527531      $callback = function ($args) {
    528532
    529         $url  = 'https://online.moysklad.ru/api/remap/1.2/entity/store';
    530         $data = wooms_request($url);
     533        $url  = 'entity/store';
     534        $data = request($url);
    531535        if (empty($data['rows'])) {
    532536          echo 'Система не смогла получить список складов из МойСклад';
  • wooms/trunk/includes/ProductVariable.php

    r2842491 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58// Exit if accessed directly
     
    7679     * issue https://github.com/wpcraft-ru/wooms/issues/296
    7780     */
    78     $url = 'https://online.moysklad.ru/api/remap/1.2/entity/variant';
     81    $url = 'entity/variant';
    7982
    8083    $url = add_query_arg($state['query_arg'], $url);
     
    97100      );
    98101
    99       $data = wooms_request($url);
     102      $data = request($url);
    100103
    101104      //Check for errors and send message to UI
     
    394397      $uuid = str_replace('https://online.moysklad.ru/api/remap/1.1/entity/product/', '', $uuid);
    395398      $uuid = str_replace('https://online.moysklad.ru/api/remap/1.2/entity/product/', '', $uuid);
     399      $uuid = str_replace('https://api.moysklad.ru/api/remap/1.2/entity/product/', '', $uuid);
    396400    }
    397401
  • wooms/trunk/includes/ProductVariableImage.php

    r2826440 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
    46
    57
     
    99101
    100102        $href = $variant_data['images']['meta']['href'];
    101         $img_metadata = wooms_request($href);
     103        $img_metadata = request($href);
    102104
    103105        if (empty($img_metadata['rows'][0])) {
     
    127129            return;
    128130        }
    129        
     131
    130132        // Adding schedule hook
    131133        as_schedule_single_action(
  • wooms/trunk/includes/ProductsCategories.php

    r2854597 r2981815  
    106106    //if uuid as url - get uuid only
    107107    $id = str_replace('https://online.moysklad.ru/api/remap/1.2/entity/productfolder/', '', $id);
     108    $id = str_replace('https://api.moysklad.ru/api/remap/1.2/entity/productfolder/', '', $id);
    108109
    109110    $terms = get_terms(array(
  • wooms/trunk/includes/ProductsExclusion.php

    r2826440 r2981815  
    2222
    2323    $flag = get_option( OPTION_KEY );
    24     $attr_url = 'https://online.moysklad.ru/api/remap/1.2/entity/product/metadata/attributes/';
     24    $attr_url = \WooMS\get_api_url('entity/product/metadata/attributes/');
    2525
    2626    if ( $flag ) {
     
    3232
    3333
    34 function add_settings() 
     34function add_settings()
    3535{
    3636    register_setting( 'mss-settings', OPTION_KEY );
  • wooms/trunk/includes/ProductsServices.php

    r2826597 r2981815  
    22
    33namespace WooMS;
     4
     5use function WooMS\request;
     6
    47
    58if (!defined('ABSPATH')) {
     
    9194            $query_arg = self::get_state('query_arg');
    9295
    93             $url = 'https://online.moysklad.ru/api/remap/1.2/entity/service';
     96            $url = 'entity/service';
    9497
    9598            $url = add_query_arg($query_arg, $url);
     
    110113            );
    111114
    112             $data = wooms_request($url);
     115            $data = request($url);
    113116
    114117            //Check for errors and send message to UI
  • wooms/trunk/includes/SendWarehouse.php

    r2826440 r2981815  
    3535
    3636    $data['store']['meta'] = array(
    37       'href' => 'https://online.moysklad.ru/api/remap/1.2/entity/store/' . $warehouse_id,
     37      'href' => \WooMS\get_api_url('entity/store/' . $warehouse_id),
    3838      "type" => "store",
    3939    );
  • wooms/trunk/includes/SiteHealth.php

    r2826440 r2981815  
    22
    33namespace WooMS\SiteHealth;
     4
     5use function WooMS\request;
     6
    47
    58if (!defined('ABSPATH')) {
     
    1316
    1417});
    15 
    16 
    1718
    1819/**
     
    3233        'value'   => sprintf('Для корректной работы плагина нужно сменить тариф %s', '❌'),
    3334    ];
    34    
     35
    3536
    3637    return $debug_info;
     
    106107    }
    107108
    108     $url = 'https://online.moysklad.ru/api/remap/1.2/security/token';
    109     $data_api = wooms_request($url, [], 'POST');
     109    $url = 'security/token';
     110    $data_api = request($url, [], 'POST');
    110111
    111112    $result = [
  • wooms/trunk/readme.txt

    r2979725 r2981815  
    3434Страница плагина: [https://wpcraft.ru/wooms/](https://wpcraft.ru/wooms/)
    3535
    36 Статус задач по разработке: [https://github.com/orgs/wpcraft-ru/projects/2](roadmap)
    37 
    3836Плагин спроектирован таким образом, что относительно просто позволяет дорабатывать механику под задачи и автоматизацию конкретного магазина/каталога.
    3937
     
    7876
    7977== Changelog ==
     78
     79= 9.4 =
     80- Тест совместимости WooCommerce 8.2.1
     81- Реализация новой версии REST API MoySklad
    8082
    8183= 9.3 =
  • wooms/trunk/wooms.php

    r2979725 r2981815  
    2020 * WC tested up to: 7.2.2
    2121 *
    22  * Version: 9.3
     22 * Version: 9.4
    2323 */
    2424
     
    121121}
    122122
     123
     124
     125function get_api_url($path){
     126    return $url = 'https://api.moysklad.ru/api/remap/1.2/' . $path;
     127}
     128
    123129function request($path = '', $data = array(), $type = 'GET'){
    124130  // https://api.moysklad.ru/api/remap/1.2/
     
    129135  }
    130136
    131   $url = 'https://api.moysklad.ru/api/remap/1.2/' . $path;
     137  if(str_contains($path, 'https://api.moysklad.ru/api/remap/1.2/')){
     138    $url = $path;
     139  } else {
     140    $url = 'https://api.moysklad.ru/api/remap/1.2/' . $path;
     141  }
     142
    132143
    133144
Note: See TracChangeset for help on using the changeset viewer.