Changeset 2226076
- Timestamp:
- 01/12/2020 01:32:07 PM (6 years ago)
- Location:
- wooms/trunk
- Files:
-
- 4 edited
-
inc/class-import-product-categories.php (modified) (3 diffs)
-
inc/class-logger.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
-
wooms.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wooms/trunk/inc/class-import-product-categories.php
r2059144 r2226076 17 17 public static function init() { 18 18 19 add_filter('wooms_product_save', array(__CLASS__, ' load_category_for_product'), 10, 3);19 add_filter('wooms_product_save', array(__CLASS__, 'product_save'), 10, 3); 20 20 21 21 /** … … 31 31 * Загрузка данных категории для продукта 32 32 */ 33 public static function load_category_for_product($product, $value, $data){33 public static function product_save($product, $value, $data){ 34 34 35 35 //Если опция отключена - пропускаем обработку … … 53 53 do_action('wooms_logger_error', __CLASS__, $result->get_error_code(), $result->get_error_message() ); 54 54 } elseif($result === false) { 55 do_action('wooms_logger_error', __CLASS__, 'Не удалось выбрать термин', $term_id );55 do_action('wooms_logger_error', __CLASS__, 'Не удалось выбрать категорию', $term_id ); 56 56 } else { 57 do_action( 'wooms_logger', __CLASS__, sprintf('Выбран термин %s, для продукта %s (url: %s)', $term_id, $product_id, $url) ); 57 do_action( 'wooms_logger', __CLASS__, 58 'Выбор категории продукта', 59 [ 60 '$url' => $url, 61 '$term_id' => $term_id, 62 'term_name' => get_term_by('id', $term_id, 'product_cat')->name, 63 '$product_id' => $product_id, 64 'select_cat_pid' => $product_id, 65 ] 66 ); 58 67 } 59 68 } -
wooms/trunk/inc/class-logger.php
r2092603 r2226076 36 36 } 37 37 38 39 38 $data = ''; 40 39 41 $data .= $title;40 $data .= strval($title); 42 41 43 42 if( ! empty($description) ){ 44 43 $description = wc_print_r( $description, true ); 45 44 $description = wp_trim_words( $description, $num_words = 300, $more = null ); 46 $data .= ': ' . '<pre>' . $description . '</pre>';45 $data .= ':' . PHP_EOL . $description; 47 46 } 48 47 … … 67 66 } 68 67 69 $description = wp_trim_words( $description, $num_words = 300, $more = null );70 71 68 $data = ''; 72 69 73 $data .= $title;70 $data .= strval($title); 74 71 75 72 if( ! empty($description) ){ 76 $data .= ': ' . wc_print_r( $description, true ); 73 $description = wc_print_r( $description, true ); 74 $description = wp_trim_words( $description, $num_words = 300, $more = null ); 75 $data .= ':' . PHP_EOL . $description; 77 76 } 78 77 -
wooms/trunk/readme.txt
r2172269 r2226076 76 76 == Changelog == 77 77 78 = 6.0 = 79 * добавлена поддержка галлереи изображений продукта https://github.com/wpcraft-ru/wooms/issues/27 80 * XT улучшена работа обновления статусов из Сайта на Склад - удалено накопление очереди без активной опции 81 * XT улучшен лог передачи данных по юр лицам 78 82 79 83 = 5.7 = -
wooms/trunk/wooms.php
r2172269 r2226076 10 10 * Text Domain: wooms 11 11 * Domain Path: /languages 12 * WC requires at least: 3. 013 * WC tested up to: 3. 5.012 * WC requires at least: 3.3 13 * WC tested up to: 3.6 14 14 * PHP requires at least: 5.6 15 * WP requires at least: 4.815 * WP requires at least: 5.0 16 16 * License: GPLv2 or later 17 17 * License URI: http://www.gnu.org/licenses/gpl-2.0.html 18 * Version: 5.719 * WooMS XT Latest: 5.718 * Version: 6.0 19 * WooMS XT Latest: 6.0 20 20 */ 21 21 … … 47 47 * Птм что иначе хук wooms_activate не срабатывает 48 48 */ 49 require_once 'inc/class-logger.php'; 49 require_once __DIR__ . '/inc/class-logger.php'; 50 require_once __DIR__ . '/functions.php'; 50 51 51 52 /** … … 69 70 * Подключение компонентов 70 71 */ 71 require_once 'inc/class-menu-settings.php'; 72 require_once 'inc/class-menu-tool.php'; 73 require_once 'inc/class-products-walker.php'; 74 require_once 'inc/class-import-product-images.php'; 75 require_once 'inc/class-import-product-categories.php'; 76 require_once 'inc/class-import-prices.php'; 77 require_once 'inc/class-hide-old-products.php'; 72 require_once __DIR__ . '/inc/class-menu-settings.php'; 73 require_once __DIR__ . '/inc/class-menu-tool.php'; 74 require_once __DIR__ . '/inc/class-products-walker.php'; 75 require_once __DIR__ . '/inc/class-import-product-categories.php'; 76 require_once __DIR__ . '/inc/class-import-prices.php'; 77 require_once __DIR__ . '/inc/class-hide-old-products.php'; 78 79 require_once __DIR__ . '/inc/MSImagesTrait.php'; 80 require_once __DIR__ . '/inc/ProductGallery.php'; 81 require_once __DIR__ . '/inc/ProductImage.php'; 78 82 79 83 add_action( 'admin_notices', array(__CLASS__, 'show_notices_35') ); … … 202 206 203 207 WooMS_Core::init(); 204 205 /**206 * Helper new function for responses data from moysklad.ru207 *208 * @param string $url209 * @param array $data210 * @param string $type211 *212 * @return array|bool|mixed|object213 */214 function wooms_request( $url = '', $data = array(), $type = 'GET' ) {215 if ( empty( $url ) ) {216 return false;217 }218 219 $url = wooms_fix_url($url);220 221 if ( isset( $data ) && ! empty( $data ) && 'GET' == $type ) {222 $type = 'POST';223 }224 if ( 'GET' == $type ) {225 $data = null;226 } else {227 $data = json_encode( $data );228 }229 230 $args = array(231 'method' => $type,232 'timeout' => 45,233 'redirection' => 5,234 'headers' => array(235 "Content-Type" => 'application/json',236 'Authorization' => 'Basic ' .237 base64_encode( get_option( 'woomss_login' ) . ':' . get_option( 'woomss_pass' ) ),238 ),239 'body' => $data,240 );241 242 $request = wp_remote_request( $url, $args);243 if ( is_wp_error( $request ) ) {244 do_action(245 'wooms_logger_error',246 $type = 'Request',247 $title = 'Ошибка REST API',248 $desc = $request->get_error_message()249 );250 251 return false;252 }253 254 if ( empty( $request['body'] ) ) {255 do_action(256 'wooms_logger_error',257 $type = 'Request',258 $title = 'REST API вернулся без требуемых данных'259 );260 261 return false;262 }263 264 $response = json_decode( $request['body'], true );265 266 if( ! empty($response["errors"]) and is_array($response["errors"]) ){267 foreach ($response["errors"] as $error) {268 do_action(269 'wooms_logger_error',270 $type = 'Request',271 $title = $error['error']272 );273 }274 }275 276 return $response;277 }278 279 /**280 * Get product id by UUID from metafield281 * or false282 *283 * XXX move to \WooMS\Products\Bundle::get_product_id_by_uuid284 */285 function wooms_get_product_id_by_uuid( $uuid ) {286 287 $posts = get_posts( 'post_type=product&meta_key=wooms_id&meta_value=' . $uuid );288 if ( empty( $posts[0]->ID ) ) {289 return false;290 } else {291 return $posts[0]->ID;292 }293 }294 295 /**296 * fix bug with url297 *298 * @link https://github.com/wpcraft-ru/wooms/issues/177299 */300 function wooms_fix_url($url = ''){301 $url = str_replace('product_id', 'product.id', $url);302 $url = str_replace('store_id', 'store.id', $url);303 $url = str_replace('consignment_id', 'consignment.id', $url);304 $url = str_replace('variant_id', 'variant.id', $url);305 $url = str_replace('productFolder_id', 'productFolder.id', $url);306 return $url;307 }
Note: See TracChangeset
for help on using the changeset viewer.