Changeset 1894389
- Timestamp:
- 06/18/2018 08:30:59 AM (8 years ago)
- Location:
- shopybot-woocommerce/trunk
- Files:
-
- 3 edited
-
includes/class-wc-shopybot-export.php (modified) (17 diffs)
-
readme.txt (modified) (2 diffs)
-
shopybot-woocommerce.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shopybot-woocommerce/trunk/includes/class-wc-shopybot-export.php
r1893975 r1894389 260 260 261 261 if($attribute['is_taxonomy']) { 262 if($product-> product_type== 'variation' && array_key_exists('attribute_' . $attribute['name'], $product->variation_data)) {262 if($product->get_type() == 'variation' && array_key_exists('attribute_' . $attribute['name'], $product->variation_data)) { 263 263 $value = apply_filters('woocommerce_attribute', $product->variation_data[ 'attribute_' . $attribute['name'] ]); 264 264 } 265 265 266 if($product-> product_type!= 'variation' || empty($value)) {267 $values = wc_get_product_terms($product-> id, $attribute['name'], array('fields' => 'names'));266 if($product->get_type() != 'variation' || empty($value)) { 267 $values = wc_get_product_terms($product->get_id(), $attribute['name'], array('fields' => 'names')); 268 268 $value = apply_filters('woocommerce_attribute', wptexturize(implode(', ', $values)), $attribute, $values); 269 269 } 270 270 } else { 271 if($product-> product_type== 'variation' && array_key_exists('attribute_' . $attribute['name'], $product->variation_data)) {271 if($product->get_type() == 'variation' && array_key_exists('attribute_' . $attribute['name'], $product->variation_data)) { 272 272 $value = apply_filters('woocommerce_attribute', $product->variation_data[ 'attribute_' . $attribute['name'] ]); 273 273 } else { … … 294 294 $images = array(); 295 295 296 if($product-> product_type== 'variation' && method_exists($product, 'get_image_id')) {296 if($product->get_type() == 'variation' && method_exists($product, 'get_image_id')) { 297 297 $image_id = $product->get_image_id(); 298 298 } else { 299 $image_id = get_post_thumbnail_id($product-> id);299 $image_id = get_post_thumbnail_id($product->get_id()); 300 300 } 301 301 … … 306 306 } 307 307 308 $ids = $product->get_gallery_ attachment_ids();308 $ids = $product->get_gallery_image_ids(); 309 309 310 310 if(!empty($ids)) { … … 327 327 final public function setOfferParams($product) { 328 328 329 $terms = wp_get_post_terms($product-> id, 'product_cat');329 $terms = wp_get_post_terms($product->get_id(), 'product_cat'); 330 330 331 331 if(!empty($terms)) { 332 332 $cat = $terms[0]->term_id; 333 333 } else { 334 $this->bread('cat not set id=' . $product-> id);334 $this->bread('cat not set id=' . $product->get_id()); 335 335 336 336 return false; 337 337 } 338 338 339 $excerpt = trim( $product->post->post_excerpt);340 $description = (!empty($excerpt)) ? $excerpt : $product->post->post_content;339 $excerpt = trim(strip_tags($product->get_short_description())); 340 $description = (!empty($excerpt)) ? $excerpt : trim(strip_tags($product->get_description())); 341 341 $description = WC_Shopybot_Functions::substr($description, 500, false); 342 342 343 343 if($this->vendors == false) { 344 $vendor = get_post_meta($product-> id, '_vendor', true);345 } else { 346 $terms = wp_get_post_terms($product-> id, $this->vendors);344 $vendor = get_post_meta($product->get_id(), '_vendor', true); 345 } else { 346 $terms = wp_get_post_terms($product->get_id(), $this->vendors); 347 347 348 348 if(!is_wp_error($terms)) { … … 378 378 'delivery' => ($this->isdeliver and !$this->cpa) ? 'true' : '', 379 379 'vendor' => $vendor, 380 'name' => WC_Shopybot_Functions::del_symvol(strip_tags($product-> post->post_title)),380 'name' => WC_Shopybot_Functions::del_symvol(strip_tags($product->get_title())), 381 381 'description' => WC_Shopybot_Functions::del_symvol(strip_tags($description)), 382 382 'sales_notes' => (!empty($this->salesNote)) ? WC_Shopybot_Functions::substr($this->salesNote, 50, false) : '', … … 388 388 389 389 if(empty($params['vendor'])) { 390 $this->bread('vendor not set id=' . $product-> id);390 $this->bread('vendor not set id=' . $product->get_id()); 391 391 392 392 return false; … … 394 394 395 395 if(empty($params['name'])) { 396 $this->bread('name not set id=' . $product-> id);396 $this->bread('name not set id=' . $product->get_id()); 397 397 398 398 return false; … … 422 422 423 423 if($products->have_posts()) { 424 425 424 $this->bread('found posts'); 426 425 427 426 while($products->have_posts()) { 428 429 427 $products->the_post(); 430 $product = get_product($products->post->ID); 431 432 if($product->product_type == 'simple' || $product->product_type == 'variation') { 433 434 if($product->product_type == 'variation') { 428 $product = wc_get_product($products->post->ID); 429 430 // error_log("PRODUCT_TYPE :: " . var_export($product->get_type(), true)); 431 432 $allowed_product_types = array('external', 'simple', 'variation'); 433 434 if(in_array($product->get_type(), $allowed_product_types)) { 435 if($product->get_type() == 'variation') { 435 436 if(!$this->checkVariationUniqueness($product)) { 436 437 delete_post_meta($product->variation_id, $this->id . '_yml_offer'); 437 $this->bread('WARNING: skipping product variation ID ' . $product->variation_id . ' (product ID ' . $product-> id. ') — variation has no unique attributes');438 $this->bread('WARNING: skipping product variation ID ' . $product->variation_id . ' (product ID ' . $product->get_id() . ') — variation has no unique attributes'); 438 439 continue; 439 440 } 440 441 } 441 442 442 $this->renderPartOffer($product); 443 443 } … … 458 458 $param = $this->setOfferParams($product); 459 459 460 if($product->product_type == 'variation') { 460 // error_log("PARAM :: " . var_export($param, true)); 461 462 if($product->get_type() == 'variation') { 461 463 $product_id = $product->variation_id; 462 464 } else { 463 $product_id = $product-> id;465 $product_id = $product->get_id(); 464 466 } 465 467 … … 478 480 $offer .= '<offer id="' . $product_id . '" type="vendor.model" available="' . $available . '" ' . $bid; 479 481 480 if($product-> product_type== 'variation' && $this->isgroupidattr && isset($product->parent->id)) {482 if($product->get_type() == 'variation' && $this->isgroupidattr && isset($product->parent->id)) { 481 483 $offer .= ' group_id="' . $product->parent->id . '"'; 482 484 } 483 485 484 486 $offer .= '>' . "\n"; 487 488 // error_log("offer :: " . var_export($offer, true)); 485 489 486 490 foreach($param as $key => $value) { … … 522 526 final public function checkVariationUniqueness($variation) { 523 527 524 $product = get_product($variation->id);528 $product = wc_get_product($variation->id); 525 529 526 530 if(!is_object($product) || !($product instanceof WC_Product_Variable)) { … … 539 543 foreach($children as $_id) { 540 544 541 $_variation = get_product($_id);545 $_variation = wc_get_product($_id); 542 546 543 547 if($_variation->variation_id == $variation->variation_id) { … … 635 639 */ 636 640 public function export() { 637 if(!$this->isLock()) {638 639 $this->exportLock();641 // if(!$this->isLock()) { 642 643 // $this->exportLock(); 640 644 641 645 if($this->inProcess()) { 642 646 // error_log("in process"); 643 647 $this->bread('in process'); 644 645 648 $this->renderPartOffers(); 646 647 649 } else { 648 650 // error_log("not in process"); 649 651 $this->bread('not in process'); 650 651 652 652 $this->bread('check time true'); 653 654 653 $this->inProcessSet('yes'); 655 654 $this->renderPartOffers(); 656 657 655 } 658 656 659 657 if($this->yaml_finished) { 660 658 // error_log("yaml finished"); 661 659 $this->bread('is yaml_finished true'); 662 663 660 $this->inProcessSet('no'); 664 661 $this->setPage(1); 665 662 } 666 663 667 $this->exportUnlock();668 } else {669 $this->bread('process is lock');670 }664 // $this->exportUnlock(); 665 // } else { 666 // $this->bread('process is lock'); 667 // } 671 668 } 672 669 … … 850 847 851 848 // Когда всего 200 товаров, нет смысла выгружать партиями. 852 if((int) $ get_ids->found_posts >= 200) {849 if((int) $ids_query->found_posts <= 200) { 853 850 $args['posts_per_page'] == 200; 854 851 } … … 918 915 final public function generateOffer($meta_id, $post_id) { 919 916 920 $product = get_product($post_id);917 $product = wc_get_product($post_id); 921 918 $this->renderPartOffer($product); 922 919 } … … 924 921 final public function wp_insert_post($post_id, $post) { 925 922 if($post->post_type == 'product') { 926 $product = get_product($post_id);923 $product = wc_get_product($post_id); 927 924 $this->renderPartOffer($product); 928 925 } … … 933 930 934 931 if($post->post_type == 'product') { 935 $product = get_product($post_id);932 $product = wc_get_product($post_id); 936 933 $this->renderPartOffer($product); 937 934 } -
shopybot-woocommerce/trunk/readme.txt
r1893975 r1894389 4 4 Requires at least: 3.9 5 5 Tested up to: 4.9.6 6 Stable tag: 1.0. 56 Stable tag: 1.0.6 7 7 License: GNU GENERAL PUBLIC LICENSE Version 3 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 105 105 == Changelog == 106 106 107 = 1.0.6 = 108 Fixed incompatibility issues with WooCommerce 3.0+ 109 107 110 = 1.0.5 = 108 111 Fixed issue with XML file generation -
shopybot-woocommerce/trunk/shopybot-woocommerce.php
r1858541 r1894389 10 10 * 11 11 * @link https://www.shopybot.com 12 * @since 1.0. 412 * @since 1.0.6 13 13 * @package Shopybot_Chatbot_Woocommerce 14 14 * … … 17 17 * Plugin URI: https://www.shopybot.com/connect-bot/woocommerce 18 18 * Description: Create Facebook Chatbot for your WooCommerce E-Store. Showcase with your products in the Facebook Messenger in a few clicks 19 * Version: 1.0. 319 * Version: 1.0.6 20 20 * Author: Shopybot 21 21 * Author URI: https://www.shopybot.com
Note: See TracChangeset
for help on using the changeset viewer.