Changeset 1893975
- Timestamp:
- 06/16/2018 07:08:39 PM (8 years ago)
- Location:
- shopybot-woocommerce/trunk
- Files:
-
- 2 edited
-
includes/class-wc-shopybot-export.php (modified) (52 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shopybot-woocommerce/trunk/includes/class-wc-shopybot-export.php
r1794656 r1893975 2 2 3 3 class WC_Shopybot_Export { 4 4 5 5 private $id; // plugin ID 6 6 7 7 private $currentpage; // current export page 8 8 private $vendors; // brand … … 11 11 private $debug; // debug on/off 12 12 private $isgroupidattr; // adding group_id to var. products 13 13 14 14 function __construct($export_id, $settings) { 15 15 $this->id = $export_id; 16 16 $this->shellPrefix = $export_id; 17 17 18 18 $this->currentpage = (get_option($this->id . '_page')) ? get_option($this->id . '_page') : 1; 19 19 $this->pages = (get_option($this->id . '_pages')) ? get_option($this->id . '_pages') : 1; … … 22 22 $this->posts = get_option($this->id . '_get_ids'); 23 23 $this->md5offer = array(); 24 24 25 25 $def_settings = array( 26 26 'isdeliver' => true, … … 36 36 'salesNote' => '' 37 37 ); 38 38 39 39 foreach($def_settings as $set => $val) { 40 40 41 41 if(isset($settings[ $set ])) { 42 42 $this->{$set} = $settings[ $set ]; … … 44 44 $this->{$set} = $val; 45 45 } 46 47 } 48 46 47 } 48 49 49 add_action('init', array($this, 'init')); 50 50 51 51 if(isset($_GET['tab']) && $_GET['tab'] == $this->id and isset($_REQUEST['save'])) { 52 52 $this->action_unlock(); 53 53 } 54 54 } 55 55 56 56 /** 57 57 * Init … … 59 59 public function init() { 60 60 add_filter('mod_rewrite_rules', array($this, 'add_htaccess_rule')); 61 61 62 62 add_action("added_post_meta", array($this, 'generateOffer'), 10, 2); 63 63 add_action('updated_postmeta', array($this, 'generateOffer'), 10, 2); 64 64 add_action('wp_insert_post', array($this, 'wp_insert_post'), 1, 2); 65 65 add_action('set_object_terms', array($this, 'set_object_terms'), 1); 66 66 67 67 add_action('wp_ajax_shopybot_woocommerce_ajaxUpdateOffers', array($this, 'ajaxUpdateOffers')); 68 68 69 69 $this->shell(); 70 70 $this->getYmlAction(); 71 71 } 72 72 73 73 public function add_htaccess_rule($rules) { 74 74 $rules .= "RewriteRule ^" . $this->id . ".xml index.php\n"; 75 75 $rules .= "RewriteRule ^" . $this->id . ".xml.gz index.php\n"; 76 76 77 77 return $rules; 78 78 } 79 79 80 80 public function getYmlAction() { 81 81 if(get_option('permalink_structure') != '') { 82 82 $url = parse_url($this->siteURL() . $_SERVER['REQUEST_URI']); 83 83 84 84 if($url['path'] == '/' . $this->id . '.xml') { 85 85 $this->getYml(); 86 86 die; 87 87 } 88 88 89 89 if($url['path'] == '/' . $this->id . '.xml.gz') { 90 90 $this->getYml(true); … … 93 93 } else { 94 94 if(isset($_GET[ $this->id . '_export' ])) { 95 95 96 96 $gzip = (isset($_GET['gzip'])) ? true : false; 97 97 $this->getYml($gzip); … … 100 100 } 101 101 } 102 102 103 103 private function siteURL() { 104 104 $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; 105 105 $domainName = $_SERVER['HTTP_HOST']; 106 106 107 107 return $protocol . $domainName; 108 108 } 109 110 109 110 111 111 public function bread($text) { 112 112 if(is_string($text)) { … … 115 115 $result = print_r($text, true) . "\n"; 116 116 } 117 117 118 118 $this->bread[] = $result; 119 119 120 120 if($this->debug) { 121 121 echo $result; 122 122 } 123 123 } 124 124 125 125 final public function inProcess() { 126 126 $inProcess = get_option($this->id . '_in_process'); 127 127 128 128 if(empty($inProcess)) { 129 129 update_option($this->id . '_in_process', 'no'); 130 130 131 131 return false; 132 132 } 133 133 134 134 if($inProcess == 'no') { 135 135 return false; … … 138 138 } 139 139 } 140 140 141 141 /** 142 142 * Sets the export status: yes/no … … 147 147 } 148 148 } 149 150 149 150 151 151 /** 152 152 * set current page of the export … … 156 156 update_option($this->id . '_page', $page); 157 157 } 158 159 158 159 160 160 public function debugOn() { 161 161 $this->debug = true; 162 162 } 163 163 164 164 /** 165 165 * Debug off … … 168 168 $this->debug = false; 169 169 } 170 170 171 171 /** 172 172 * Blocks the export (multiple button click error) … … 175 175 update_option($this->id . '_lock', true); 176 176 } 177 177 178 178 /** 179 179 * Unblocks the export … … 182 182 update_option($this->id . '_lock', false); 183 183 } 184 184 185 185 /** 186 186 * Checks whether export is blocked … … 189 189 return get_option($this->id . '_lock'); 190 190 } 191 191 192 192 final public function numberOffers() { 193 193 global $wpdb; 194 194 $ids = $this->getIdsQueryForExport(); 195 195 $ids = implode(',', $ids->posts); 196 196 197 197 $offers = $wpdb->get_results("SELECT COUNT(*) as num_offers FROM {$wpdb->prefix}postmeta WHERE meta_key='" . $this->id . "_yml_offer' AND post_id IN ($ids)"); 198 198 199 199 return $offers[0]->num_offers; 200 200 } 201 201 202 202 /** 203 203 * Export categories … … 205 205 final public function renderCats() { 206 206 $get_terms = $this->getRelationsTax(); 207 207 208 208 if(!empty($get_terms['product_cat'])) { 209 209 if(in_array('all', $get_terms['product_cat'])) { … … 215 215 $terms = get_terms('product_cat'); 216 216 } 217 217 218 218 if(!empty($terms)) { 219 219 $yml = '<categories>' . "\n"; 220 220 221 221 foreach($terms as $key => $cat) { 222 222 $parent = ($cat->parent) ? 'parentId="' . $cat->parent . '"' : ''; 223 224 $yml .= "\t\t" . '<category id="' . $cat->term_id . '" ' . $parent . '>' . $cat->name . '</category>' . "\n"; 225 } 226 223 $yml .= "\t\t" . '<category id="' . $cat->term_id . '" ' . $parent . '>' . htmlspecialchars($cat->name) . '</category>' . "\n"; 224 } 225 227 226 $yml .= '</categories>' . "\n"; 228 227 229 228 $yml = apply_filters($this->id . '_render_cats', $yml); 230 229 231 230 return $yml; 232 231 } 233 232 } 234 233 235 234 /** 236 235 * Export currencies … … 238 237 final public function renderCurrency() { 239 238 $yml = '<currency id="' . $this->getWooCurrency() . '" rate="1"/>'; 240 239 241 240 $yml = apply_filters($this->id . '_render_currency', $yml); 242 241 243 242 return $yml; 244 243 } 245 246 244 245 247 246 /** 248 247 * Gets product attrs … … 251 250 $attributes = $product->get_attributes(); 252 251 $out_attr = ''; 253 252 254 253 foreach($attributes as $key => $attribute) { 255 254 256 255 if($attribute['is_taxonomy'] && !taxonomy_exists($attribute['name'])) { 257 256 continue; 258 257 } 259 258 260 259 $name = wc_attribute_label($attribute['name']); 261 260 262 261 if($attribute['is_taxonomy']) { 263 262 if($product->product_type == 'variation' && array_key_exists('attribute_' . $attribute['name'], $product->variation_data)) { 264 265 263 $value = apply_filters('woocommerce_attribute', $product->variation_data[ 'attribute_' . $attribute['name'] ]); 266 267 } 268 264 } 265 269 266 if($product->product_type != 'variation' || empty($value)) { 270 267 $values = wc_get_product_terms($product->id, $attribute['name'], array('fields' => 'names')); … … 273 270 } else { 274 271 if($product->product_type == 'variation' && array_key_exists('attribute_' . $attribute['name'], $product->variation_data)) { 275 276 272 $value = apply_filters('woocommerce_attribute', $product->variation_data[ 'attribute_' . $attribute['name'] ]); 277 278 273 } else { 279 274 // Convert pipes to commas and display values … … 282 277 } 283 278 } 284 279 285 280 if(!empty($value) and !empty($name)) { 286 $out_attr .= '<param name="' . $name . '">' . $value. '</param>' . "\n";287 } 288 } 289 281 $out_attr .= '<param name="' . $name . '">' . htmlspecialchars($value) . '</param>' . "\n"; 282 } 283 } 284 290 285 $out_attr = apply_filters($this->id . '_export_attributes', $out_attr, $product, $attributes); 291 286 292 287 return $out_attr; 293 288 } 294 289 295 290 /** 296 291 * Product images … … 298 293 final public function getImagesProduct($product) { 299 294 $images = array(); 300 295 301 296 if($product->product_type == 'variation' && method_exists($product, 'get_image_id')) { 302 297 $image_id = $product->get_image_id(); … … 304 299 $image_id = get_post_thumbnail_id($product->id); 305 300 } 306 301 307 302 $general_image = WC_Shopybot_Functions::sanitize(wp_get_attachment_url($image_id)); 308 303 309 304 if(!empty($general_image)) { 310 305 $images[] = $general_image; 311 306 } 312 307 313 308 $ids = $product->get_gallery_attachment_ids(); 314 309 315 310 if(!empty($ids)) { 316 311 317 312 foreach($ids as $id) { 318 313 $image = wp_get_attachment_image_src($id, 'full'); … … 320 315 $images[] = WC_Shopybot_Functions::sanitize($image[0]); 321 316 } 322 323 } 324 } 325 317 318 } 319 } 320 326 321 return $images; 327 322 } 328 323 329 324 /** 330 325 * Sets export params 331 326 */ 332 327 final public function setOfferParams($product) { 333 328 334 329 $terms = wp_get_post_terms($product->id, 'product_cat'); 335 330 336 331 if(!empty($terms)) { 337 332 $cat = $terms[0]->term_id; 338 333 } else { 339 334 $this->bread('cat not set id=' . $product->id); 340 335 341 336 return false; 342 337 } 343 338 344 339 $excerpt = trim($product->post->post_excerpt); 345 340 $description = (!empty($excerpt)) ? $excerpt : $product->post->post_content; 346 341 $description = WC_Shopybot_Functions::substr($description, 500, false); 347 342 348 343 if($this->vendors == false) { 349 344 $vendor = get_post_meta($product->id, '_vendor', true); 350 345 } else { 351 352 346 $terms = wp_get_post_terms($product->id, $this->vendors); 353 347 354 348 if(!is_wp_error($terms)) { 355 349 if(!empty($terms[0])) { … … 357 351 } 358 352 } 359 360 } 361 353 } 354 362 355 if(empty($vendor)) { 363 356 $vendor = get_option($this->id . '_def_vendor'); 364 357 } 365 358 366 359 if(empty($vendor)) { 367 360 $vendor = 'none'; 368 361 } 369 370 362 363 371 364 $pictures = $this->getImagesProduct($product); 372 365 373 366 if(empty($pictures)) { 374 367 return false; 375 368 } 376 377 369 378 370 $params = array( 379 371 'url' => WC_Shopybot_Functions::sanitize(urldecode(esc_attr($product->get_permalink()))), … … 391 383 'cpa' => ($this->cpa) ? $this->cpa : '', 392 384 ); 393 394 385 386 395 387 $params = apply_filters($this->id . '_set_offer_params', $params, $product); 396 388 397 389 if(empty($params['vendor'])) { 398 390 $this->bread('vendor not set id=' . $product->id); 399 391 400 392 return false; 401 393 } 402 394 403 395 if(empty($params['name'])) { 404 396 $this->bread('name not set id=' . $product->id); 405 397 406 398 return false; 407 399 } 408 409 400 401 410 402 if($params['price'] == 0) { 411 403 return false; 412 404 } 413 414 405 406 415 407 $params['sales_notes'] = WC_Shopybot_Functions::substr($params['sales_notes'], 50, false); 416 408 417 409 return $params; 418 410 } 419 420 411 412 421 413 /** 422 414 * Exports page of the products … … 424 416 final public function renderPartOffers() { 425 417 $products = $this->makeQuery(); 426 418 427 419 if($products->post_count == $products->found_posts) { 428 420 $this->yaml_finished = true; 429 421 } 430 422 431 423 if($products->have_posts()) { 432 424 433 425 $this->bread('found posts'); 434 426 435 427 while($products->have_posts()) { 436 428 437 429 $products->the_post(); 438 430 $product = get_product($products->post->ID); 439 431 440 432 if($product->product_type == 'simple' || $product->product_type == 'variation') { 441 442 //не нужно включать вариации, у которых нет отличий от основного товара и других вариаций 433 443 434 if($product->product_type == 'variation') { 444 445 435 if(!$this->checkVariationUniqueness($product)) { 446 447 436 delete_post_meta($product->variation_id, $this->id . '_yml_offer'); 448 437 $this->bread('WARNING: skipping product variation ID ' . $product->variation_id . ' (product ID ' . $product->id . ') — variation has no unique attributes'); 449 438 continue; 450 451 439 } 452 453 440 } 454 441 455 442 $this->renderPartOffer($product); 456 457 } 458 459 } 460 443 } 444 } 445 461 446 wp_reset_postdata(); 462 447 463 448 $this->setPage($this->currentpage + 1); 464 449 465 450 } else { 466 451 $this->bread('no have posts'); 467 452 $this->yaml_finished = true; 468 453 } 469 470 } 471 454 455 } 456 472 457 final public function renderPartOffer($product) { 473 458 $param = $this->setOfferParams($product); 474 459 475 460 if($product->product_type == 'variation') { 476 461 $product_id = $product->variation_id; … … 478 463 $product_id = $product->id; 479 464 } 480 481 465 482 466 if(!empty($param)) { 483 467 $offer = ''; 484 468 485 469 $available = ($product->is_in_stock() == 'instock') ? "true" : "false"; 486 470 $available = apply_filters($this->id . '_set_offer_param_available', $available, $product); 487 471 488 472 if($this->isbid == true) { 489 473 $bid = ($this->bid) ? 'bid="' . $this->bid . '"' : ''; … … 491 475 $bid = ""; 492 476 } 493 477 494 478 $offer .= '<offer id="' . $product_id . '" type="vendor.model" available="' . $available . '" ' . $bid; 495 479 496 480 if($product->product_type == 'variation' && $this->isgroupidattr && isset($product->parent->id)) { 497 481 $offer .= ' group_id="' . $product->parent->id . '"'; 498 482 } 499 500 483 501 484 $offer .= '>' . "\n"; 502 485 503 486 foreach($param as $key => $value) { 504 487 if(!empty($value)) { 505 488 if(is_array($value)) { 506 489 foreach($value as $values) { 507 $offer .= "<$key>" . $values. "</$key>\n";490 $offer .= "<$key>" . htmlspecialchars($values) . "</$key>\n"; 508 491 } 509 492 } else { 510 $offer .= "<$key>" . $value. "</$key>\n";493 $offer .= "<$key>" . htmlspecialchars($value) . "</$key>\n"; 511 494 } 512 495 } 513 496 } 514 497 515 498 $offer .= $this->getProductAttributes($product); 516 499 $offer .= '</offer>' . "\n"; 517 500 if(!empty($offer)) { 518 501 $md5offer = md5($offer); 519 502 520 503 if(!in_array($md5offer, $this->md5offer)) { 521 504 $this->md5offer[] = $md5offer; 522 505 update_post_meta($product_id, $this->id . '_yml_offer', $offer); 523 524 506 return true; 525 507 } 526 508 } else { 527 509 update_post_meta($product_id, $this->id . '_yml_offer', ''); 528 529 510 return false; 530 511 } 531 512 532 513 } else { 533 514 update_post_meta($product_id, $this->id . '_yml_offer', ''); 534 535 515 return false; 536 516 } 537 517 } 538 518 539 519 /** 540 520 * Check variation 541 521 */ 542 522 final public function checkVariationUniqueness($variation) { 543 523 544 524 $product = get_product($variation->id); 545 525 546 526 if(!is_object($product) || !($product instanceof WC_Product_Variable)) { 547 527 return false; 548 528 } 549 529 550 530 if(method_exists($product, 'get_children')) { 551 531 $children = $product->get_children(); … … 553 533 return false; 554 534 } 555 535 556 536 $differs = false; 557 537 $pairs_differ = array(); 558 538 559 539 foreach($children as $_id) { 560 540 561 541 $_variation = get_product($_id); 562 542 563 543 if($_variation->variation_id == $variation->variation_id) { 564 544 continue; 565 545 } 566 567 546 568 547 $pair_differs = false; 569 548 570 549 foreach($variation->variation_data as $attr => $value) { 571 572 550 foreach($_variation->variation_data as $attr_compare => $value_compare) { 573 574 551 if($attr === $attr_compare && $value !== $value_compare) { 575 552 $pair_differs = true; 576 553 break; 577 554 } 578 579 } 580 555 } 556 581 557 if($pair_differs) { 582 558 break; 583 559 } 584 585 } 586 560 } 561 587 562 $pairs_differ[] = $pair_differs; 588 589 } 590 563 } 564 591 565 $differs = in_array(false, $pairs_differ) ? false : true; 592 566 593 567 return $differs; 594 595 } 596 568 569 } 570 597 571 final public function getShellArg() { 598 572 $shell_arg = @getopt("", array("wooexportyml_" . $this->shellPrefix . "::", "debug::", "unlock::", 'fullexport::', "unittests::")); 599 573 600 574 if(empty($shell_arg)) { 601 575 $shell_arg = array(); … … 603 577 $shell_arg = array_keys($shell_arg); 604 578 } 605 579 606 580 return $shell_arg; 607 581 } 608 582 609 583 /** 610 584 * shell params … … 617 591 public function shell() { 618 592 global $wpdb; 619 593 620 594 $shell_arg = $this->getShellArg(); 621 595 622 596 if(in_array('wooexportyml_' . $this->shellPrefix, $shell_arg)) { 623 597 if(in_array('unlock', $shell_arg)) { … … 625 599 die; 626 600 } 627 601 628 602 if(in_array('debug', $shell_arg)) { 629 603 $this->debugOn(); 630 604 } 631 605 632 606 $this->action_fullexport(); 633 607 die; 634 608 } 635 609 } 636 610 637 611 /** 638 612 * Unlocks the export … … 643 617 $this->exportUnlock(); 644 618 } 645 619 646 620 /** 647 621 * Full re-export, not paginated … … 651 625 $this->setPage(1); 652 626 $this->exportUnlock(); 653 627 654 628 while(!$this->yaml_finished) { 655 629 $this->export(); 656 630 } 657 631 } 658 632 659 633 /** 660 634 * Main export function … … 662 636 public function export() { 663 637 if(!$this->isLock()) { 664 638 665 639 $this->exportLock(); 666 640 667 641 if($this->inProcess()) { 668 642 669 643 $this->bread('in process'); 670 644 671 645 $this->renderPartOffers(); 672 646 673 647 } else { 674 648 675 649 $this->bread('not in process'); 676 677 650 651 678 652 $this->bread('check time true'); 679 653 680 654 $this->inProcessSet('yes'); 681 655 $this->renderPartOffers(); 682 683 } 684 656 657 } 658 685 659 if($this->yaml_finished) { 686 660 687 661 $this->bread('is yaml_finished true'); 688 662 689 663 $this->inProcessSet('no'); 690 664 $this->setPage(1); 691 665 } 692 666 693 667 $this->exportUnlock(); 694 668 } else { … … 696 670 } 697 671 } 698 699 672 673 700 674 /** 701 675 * Renders YAML head … … 717 691 <offers> 718 692 '; 719 720 } 721 722 693 694 } 695 696 723 697 /** 724 698 * Renders YAML footer … … 730 704 </yml_catalog> 731 705 '; 732 733 } 734 706 707 } 708 735 709 final public function renderOffers() { 736 710 global $wpdb; 737 711 738 712 $ids = $this->getIdsQueryForExport(); 739 713 $ids = implode(',', $ids->posts); 740 714 741 715 $offers = $wpdb->get_results("SELECT DISTINCT meta_value, post_id FROM {$wpdb->prefix}postmeta WHERE meta_key='" . $this->id . "_yml_offer' AND post_id IN ($ids)"); 742 716 743 717 foreach($offers as $offer) { 744 718 echo apply_filters($this->id . '_renderOffers', $offer->meta_value, $offer->post_id); 745 719 } 746 720 } 747 748 721 722 749 723 /** 750 724 * Fetches offers from postmeta and generates YML file … … 757 731 header("Content-Type:text/xml; charset=utf-8"); 758 732 } 759 760 733 734 761 735 $arg = array( 762 736 'name' => get_option('blogname'), … … 765 739 // 'this' => $this, 766 740 ); 767 741 768 742 $arg = apply_filters($this->id . '_make_yml_arg', $arg); 769 743 770 744 $this->renderHead($arg); 771 745 $this->renderOffers(); 772 746 $this->renderFooter(); 773 747 774 748 if($gzip) { 775 749 WC_Shopybot_Functions::print_gzencode_output($this->id . '.xml.gz'); 776 750 } 777 751 } 778 779 752 753 780 754 final public function getIdsQueryForExport() { 781 755 782 756 $this->bread('Generate ids'); 783 757 784 758 $args = array( 785 759 'posts_per_page' => - 1, … … 788 762 'fields' => 'ids' 789 763 ); 790 764 791 765 $relations = $this->getRelationsTax(); 792 766 793 767 foreach($relations as $tax => $terms) { 794 768 if(!empty($terms)) { 795 769 796 770 if(!in_array('all', $terms)) { 797 771 $args['tax_query'][] = array( … … 801 775 ); 802 776 } else if($tax == 'product_cat' and in_array('all', $terms)) { 803 777 804 778 $get_terms = get_terms($tax); 805 779 $terms = array(); 806 780 807 781 foreach($get_terms as $term) { 808 782 $terms[] = $term->term_id; 809 783 } 810 784 811 785 $args['tax_query'][] = array( 812 786 'taxonomy' => $tax, … … 817 791 } 818 792 } 819 820 793 794 821 795 $args = apply_filters($this->id . '_make_query_get_ids', $args); 822 796 $products_ids = new WP_Query($args); 823 797 824 798 $variations_ids = $this->getVariationsIds(); 825 799 826 800 $ids_query = new WP_Query(); 827 801 $ids_query->posts = array_merge($products_ids->posts, $variations_ids->posts); 828 802 $ids_query->post_count = $products_ids->post_count + $variations_ids->post_count; 829 803 830 804 return $ids_query; 831 805 } 832 806 833 807 final public function getVariationsIds() { 834 808 835 809 $args = array( 836 810 'posts_per_page' => - 1, … … 846 820 ) 847 821 ); 848 822 849 823 return new WP_Query($args); 850 824 } 851 825 852 826 /** 853 827 * Export DB query 854 828 */ 855 829 final public function makeQuery() { 856 830 857 831 if($this->currentpage == 1) { 858 832 $ids_query = $this->getIdsQueryForExport(); … … 860 834 update_option($this->id . '_get_ids', $this->posts); 861 835 } 862 863 836 837 864 838 $this->bread('Current page - ' . $this->currentpage); 865 839 866 840 $shell_arg = $this->getShellArg(); 867 841 868 842 $perpage = (in_array('wooexportyml', $shell_arg)) ? 500 : 150; 869 843 870 844 $args = array( 871 845 'post__in' => (array) $this->posts, … … 874 848 'post_type' => array('product', 'product_variation'), 875 849 ); 876 850 877 851 // Когда всего 200 товаров, нет смысла выгружать партиями. 878 852 if((int) $get_ids->found_posts >= 200) { 879 853 $args['posts_per_page'] == 200; 880 854 } 881 855 882 856 $args = apply_filters($this->id . '_make_query_get_products', $args); 883 857 884 858 $query = new WP_Query($args); 885 859 update_option($this->id . '_pages', $query->max_num_pages); 886 860 887 861 return $query; 888 862 } 889 890 863 864 891 865 /** 892 866 * Get list of taxonomies … … 894 868 final public function getRelationsTax() { 895 869 $tax = get_taxonomies(array('object_type' => array('product')), 'objects'); 896 870 897 871 $relations = array(); 898 872 899 873 foreach($tax as $key => $tax_val) { 900 874 901 875 if($key == 'product_type') { 902 876 continue; 903 877 } 904 878 905 879 if(strripos($key, 'pa_') !== false) { 906 880 continue; 907 881 } 908 882 909 883 $relations[ $key ] = get_option($this->id . '_tax_' . $key); 910 884 } 911 885 912 886 if(!isset($relations['product_cat'])) { 913 887 $relations['product_cat'] = array(); 914 888 } 915 916 889 890 917 891 $options = get_option($this->id . '_filters'); 918 892 919 893 if(!empty($options)) { 920 894 foreach($options as $key => $value) { … … 922 896 continue; 923 897 } 924 898 925 899 $relations[ $key ] = $value; 926 900 } 927 901 } 928 902 929 903 return $relations; 930 904 } 931 932 905 906 933 907 public function ajaxUpdateOffers() { 934 908 if($_POST['unlock'] == 'yes') { 935 909 $this->action_unlock(); 936 910 } 937 911 938 912 $this->export(); 939 913 940 914 echo json_encode(array('yaml_finished' => $this->yaml_finished, 'bread' => $this->bread)); 941 915 die; 942 916 } 943 917 944 918 final public function generateOffer($meta_id, $post_id) { 945 919 946 920 $product = get_product($post_id); 947 921 $this->renderPartOffer($product); 948 922 } 949 923 950 924 final public function wp_insert_post($post_id, $post) { 951 925 if($post->post_type == 'product') { … … 954 928 } 955 929 } 956 930 957 931 final public function set_object_terms($post_id) { 958 932 $post = get_post($post_id); 959 933 960 934 if($post->post_type == 'product') { 961 935 $product = get_product($post_id); 962 936 $this->renderPartOffer($product); 963 937 } 964 965 } 966 938 939 } 940 967 941 /** 968 942 * @return mixed|void … … 971 945 return apply_filters('woocommerce_currency', get_option('woocommerce_currency')); 972 946 } 973 947 974 948 } -
shopybot-woocommerce/trunk/readme.txt
r1858541 r1893975 3 3 Tags: bot, chat-bot, chatbot, facebook, woocommerce, integration, ShopyBot, ai, machine learning, artificial intelligence 4 4 Requires at least: 3.9 5 Tested up to: 4.9. 16 Stable tag: 1.0. 35 Tested up to: 4.9.6 6 Stable tag: 1.0.5 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.5 = 108 Fixed issue with XML file generation 109 107 110 = 1.0.4 = 108 111 Fixed issue with injecting styles and scripts
Note: See TracChangeset
for help on using the changeset viewer.