Changeset 3026071
- Timestamp:
- 01/24/2024 06:23:05 AM (2 years ago)
- Location:
- clickmis
- Files:
-
- 5 edited
- 1 copied
-
tags/1.0.4 (copied) (copied from clickmis/trunk)
-
tags/1.0.4/ClickPlugin.php (modified) (13 diffs)
-
tags/1.0.4/README.txt (modified) (2 diffs)
-
tags/1.0/ClickPlugin.php (modified) (1 diff)
-
trunk/ClickPlugin.php (modified) (13 diffs)
-
trunk/README.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
clickmis/tags/1.0.4/ClickPlugin.php
r2840265 r3026071 3 3 /** 4 4 * @link https://clickmis.net/ 5 * @since 1.0. 05 * @since 1.0.4 6 6 * @package ClickPlugin 7 7 * … … 9 9 * Plugin URI: https://clickmis.net/ 10 10 * Description: اتصال و همگامسازی وب سایت فروش ووکامرس با حسابداری آنلاین کلیک 11 * Version: 1.0. 011 * Version: 1.0.4 12 12 * Author: ClickMis 13 13 * Author URI: https://clickmis.net/ … … 17 17 **/ 18 18 19 20 function ClickMisPlugin_cleans() 21 { 22 try { 23 header("Access-Control-Allow-Origin: *"); 24 ini_set('memory_limit', '-1'); 25 set_time_limit(1000); 26 ini_set('display_errors', 'Off'); 27 ini_set('error_reporting', 0); 28 wc_set_time_limit(1000); 29 30 if (!defined('WP_DEBUG')) define('WP_DEBUG', false); 31 if (!defined('WP_DEBUG_LOG')) define('WP_DEBUG_LOG', false); 32 if (!defined('WP_DEBUG_DISPLAY')) define('WP_DEBUG_DISPLAY', false); 33 34 function ClickMisPlugin_overrule_webhook_disable_limit($number) 35 { 36 return 999999; 37 } 38 add_filter('woocommerce_max_webhook_delivery_failures', 'ClickMisPlugin_overrule_webhook_disable_limit'); 39 } catch (\Throwable $e) { 40 } 41 } 42 43 ClickMisPlugin_cleans(); 44 45 46 try { 47 function ClickMisPlugin_my_woocommerce_rest_check_permissions($permission, $context, $object_id, $post_type) 48 { 49 return true; 50 } 51 add_filter('woocommerce_rest_check_permissions', 'ClickMisPlugin_my_woocommerce_rest_check_permissions', 90, 4); 52 } catch (\Throwable $e) { 53 } 54 55 // Hook before calculate fees 56 // add_action('woocommerce_cart_calculate_fees', 'ClickMisPlugin_rayehe_discount'); 57 // /** 58 // * Add custom fee if more than three article 59 // * @param WC_Cart $cart 60 // */ 61 // function ClickMisPlugin_rayehe_discount(WC_Cart $cart) 62 // { 63 // //any of your rules 64 // // Calculate the amount to reduce 65 // $totalPrice = $cart->get_subtotal(); 66 // $discount = 0; 67 68 // $coupon_code = null; 69 // if ($totalPrice >= 500000 && $totalPrice <= 3000000) { 70 // //10% 71 // $coupon_code = 'Emam_Reza_10'; 72 // $discount = 10; 73 // } else if ($totalPrice > 3000000 && $totalPrice <= 10000000) { 74 // //15% 75 // $coupon_code = 'Emam_Reza_15'; 76 // $discount = 15; 77 // } else if ($totalPrice > 10000000 && $totalPrice <= 25000000) { 78 // //20% 79 // $coupon_code = 'Emam_Reza_20'; 80 // $discount = 20; 81 // } else if ($totalPrice > 25000000 && $totalPrice <= 50000000) { 82 // //22% 83 // $coupon_code = 'Emam_Reza_22'; 84 // $discount = 22; 85 // } else if ($totalPrice > 50000000 && $totalPrice <= 75000000) { 86 // //24% 87 // $coupon_code = 'Emam_Reza_24'; 88 // $discount = 24; 89 // } else if ($totalPrice > 75000000 && $totalPrice <= 100000000) { 90 // //26% 91 // $coupon_code = 'Emam_Reza_26'; 92 // $discount = 26; 93 // } else if ($totalPrice > 100000000 && $totalPrice <= 150000000) { 94 // //28% 95 // $coupon_code = 'Emam_Reza_28'; 96 // $discount = 28; 97 // } else if ($totalPrice > 150000000) { 98 // //30% 99 // $discount = 30; 100 // $coupon_code = 'Emam_Reza_30'; 101 // } 102 103 104 // if ($discount > 0) { 105 // $cart->add_fee( 'تخفیف ویژه میلاد امامرضا(ع)' .' '. $discount. 'درصد', - ($discount * $totalPrice / 100)); 106 // } 107 108 // } 109 110 function ClickMisPlugin_init_copons($data) 111 { 112 $couponList = array( 113 "Emam_Reza_10" => 10, 114 "Emam_Reza_15" => 15, 115 "Emam_Reza_20" => 20, 116 "Emam_Reza_22" => 22, 117 "Emam_Reza_24" => 24, 118 "Emam_Reza_26" => 26, 119 "Emam_Reza_28" => 28, 120 "Emam_Reza_30" => 30 121 ); 122 123 foreach ($couponList as $x => $val) { 124 ClickMisPlugin_create_coupon( 125 $x, 126 array( 127 'discount_type' => 'percent', 128 'coupon_amount' => $val, 129 'usage_limit' => 1000000 130 ) 131 ); 132 } 133 } 134 135 function ClickMisPlugin_create_coupon($coupon_name, $args = array()) 136 { 137 138 $coupon_args = array( 139 'post_title' => $coupon_name, 140 'post_content' => '', 141 'post_status' => 'publish', 142 'post_author' => 1, 143 'post_type' => 'shop_coupon' 144 ); 145 146 $coupon_id = wp_insert_post($coupon_args); 147 148 if (!empty($coupon_id) && !is_wp_error($coupon_id)) { 149 foreach ($args as $key => $val) { 150 update_post_meta($coupon_id, $key, $val); 151 } 152 } 153 154 return $coupon_id; 155 } 156 157 // add_action('woocommerce_before_cart_table', 'ClickMisPlugin_rayehe_takhfif'); 158 // function ClickMisPlugin_rayehe_takhfif() 159 // { 160 // global $woocommerce; 161 162 // $totalPrice = $woocommerce->cart->get_cart_total(); 163 // $coupon_code = null; 164 // if ($totalPrice >= 500000 && $totalPrice <= 3000000) { 165 // //10% 166 // $coupon_code = 'Emam_Reza_10'; 167 // } else if ($totalPrice > 3000000 && $totalPrice <= 10000000) { 168 // //15% 169 // $coupon_code = 'Emam_Reza_15'; 170 // } else if ($totalPrice > 10000000 && $totalPrice <= 25000000) { 171 // //20% 172 // $coupon_code = 'Emam_Reza_20'; 173 // } else if ($totalPrice > 25000000 && $totalPrice <= 50000000) { 174 // //22% 175 // $coupon_code = 'Emam_Reza_22'; 176 // } else if ($totalPrice > 50000000 && $totalPrice <= 75000000) { 177 // //24% 178 // $coupon_code = 'Emam_Reza_24'; 179 // } else if ($totalPrice > 75000000 && $totalPrice <= 100000000) { 180 // //26% 181 // $coupon_code = 'Emam_Reza_26'; 182 // } else if ($totalPrice > 100000000 && $totalPrice <= 150000000) { 183 // //28% 184 // $coupon_code = 'Emam_Reza_28'; 185 // } else if ($totalPrice > 150000000) { 186 // //30% 187 // $coupon_code = 'Emam_Reza_30'; 188 // } 189 190 191 // if ($coupon_code != null) { 192 193 // if (!$woocommerce->cart->add_discount(sanitize_text_field($coupon_code))) { 194 // $woocommerce->show_messages(); 195 // } 196 // // echo '<div class="woocommerce_message"><strong>Your order is over 100 lbs so a 10% Discount has been Applied!</strong> Your total order weight is <strong>' . $total_weight . '</strong> lbs.</div>'; 197 // } 198 // } 199 200 /* Mod: Remove 10% Discount for weight less than or equal to 100 lbs */ 201 // add_action('woocommerce_before_cart_table', 'ClickMisPlugin_rayehe_takhfif_remove'); 202 // function ClickMisPlugin_rayehe_takhfif_remove() 203 // { 204 // global $woocommerce; 205 206 // $totalPrice = $woocommerce->cart->get_cart_total(); 207 // $coupon_code = null; 208 // if ($totalPrice >= 500000 && $totalPrice <= 3000000) { 209 // //10% 210 // $coupon_code = 'Emam_Reza_10'; 211 // } else if ($totalPrice > 3000000 && $totalPrice <= 10000000) { 212 // //15% 213 // $coupon_code = 'Emam_Reza_15'; 214 // } else if ($totalPrice > 10000000 && $totalPrice <= 25000000) { 215 // //20% 216 // $coupon_code = 'Emam_Reza_20'; 217 // } else if ($totalPrice > 25000000 && $totalPrice <= 50000000) { 218 // //22% 219 // $coupon_code = 'Emam_Reza_22'; 220 // } else if ($totalPrice > 50000000 && $totalPrice <= 75000000) { 221 // //24% 222 // $coupon_code = 'Emam_Reza_24'; 223 // } else if ($totalPrice > 75000000 && $totalPrice <= 100000000) { 224 // //26% 225 // $coupon_code = 'Emam_Reza_26'; 226 // } else if ($totalPrice > 100000000 && $totalPrice <= 150000000) { 227 // //28% 228 // $coupon_code = 'Emam_Reza_26'; 229 // } else if ($totalPrice > 150000000) { 230 // //30% 231 // $coupon_code = 'Emam_Reza_30'; 232 // } 233 234 // if ($coupon_code != null) { 235 236 // $woocommerce->cart->get_applied_coupons(); 237 // if (!$woocommerce->cart->remove_coupons(sanitize_text_field($coupon_code))) { 238 // $woocommerce->show_messages(); 239 // } 240 // $woocommerce->cart->calculate_totals(); 241 // } 242 // } 19 243 20 244 function ClickMisPlugin_prepare_date_response($date) … … 190 414 function ClickMisPlugin_get_attribute_taxonomy_label($name) 191 415 { 192 //wp functions 193 $tax = get_taxonomy($name); 194 $labels = get_taxonomy_labels($tax); 195 196 return $labels->singular_name; 416 try { 417 //wp functions 418 $tax = get_taxonomy($name); 419 $labels = get_taxonomy_labels($tax); 420 421 return $labels->singular_name; 422 } catch (\Throwable $e) { 423 return ''; 424 } 197 425 } 198 426 … … 287 515 } 288 516 517 function ClickMisPlugin_get_productsFull2($data) 518 { 519 try { 520 521 ClickMisPlugin_cleans(); 522 523 $products = array(); 524 525 function ClickMisPlugin_get_productsFull_get2($index, &$products, $data) 526 { 527 528 $args = array( 529 'limit' => 500, 530 'page' => $index + 1, 531 // 'status' => 'publish', 532 ); 533 534 535 if (isset($data['ids']) && !empty($data['ids'])) { 536 $args['include'] = json_decode($data['ids']); 537 } 538 539 $products_query = wc_get_products($args); 540 541 foreach ($products_query as $product) { 542 $products[] = ClickMisPlugin_get_product_data($product); 543 } 544 545 if (count($products_query) != 500 || empty($products_query)) { 546 } else { 547 ClickMisPlugin_get_productsFull_get2($index + 1, $products, $data); 548 } 549 } 550 551 ClickMisPlugin_get_productsFull_get2(0, $products, $data); 552 553 return $products; 554 } catch (\Throwable $e) { 555 return $e->getMessage(); 556 } 557 } 558 289 559 function ClickMisPlugin_get_productsFull($data) 290 560 { 561 ClickMisPlugin_cleans(); 291 562 292 563 try { 293 564 294 565 $args = array( 295 'status' => 'publish',566 // 'status' => 'publish', 296 567 'posts_per_page' => -1, 297 568 ); 298 569 570 $all_products = array(); 571 572 if (isset($data['ids']) && !empty($data['ids'])) { 573 $args = array( 574 'posts_per_page' => -1, 575 ); 576 $args['include'] = json_decode($data['ids']); 577 } else if (isset($data['includeDraft'])) { 578 $args2 = array( 579 'status' => 'draft', 580 'posts_per_page' => -1, 581 ); 582 $all_products = wc_get_products($args2); 583 } 584 585 $products_query = wc_get_products($args); 586 587 $all_products = array_merge($products_query, $all_products); 588 589 $products = array(); 590 foreach ($all_products as $product) { 591 $products[] = ClickMisPlugin_get_product_data($product); 592 } 593 594 return $products; 595 } catch (\Throwable $e) { 596 597 return $e->getMessage(); 598 } 599 } 600 601 function ClickMisPlugin_get_full_products2($data) 602 { 603 604 $products = array(); 605 606 function ClickMisPlugin_get_products_get2($index, &$products, $data) 607 { 608 609 $args = array( 610 'limit' => 500, 611 'page' => $index + 1, 612 // 'status' => 'publish', 613 ); 614 615 616 if (isset($data['ids']) && !empty($data['ids'])) { 617 $args['include'] = json_decode($data['ids']); 618 } 619 620 $products_query = wc_get_products($args); 621 622 623 624 foreach ($products_query as $product) { 625 array_push( 626 $products, 627 array( 628 'id' => $product->get_id(), 629 'name' => $product->get_name(), 630 'stock_quantity' => $product->get_stock_quantity(), 631 'price' => $product->get_price(), 632 633 'sku' => $product->get_sku(), 634 'date_created_gmt' => ClickMisPlugin_prepare_date_response($product->get_date_created()), 635 'categories' => ClickMisPlugin_get_taxonomy_terms($product), 636 ) 637 ); 638 } 639 640 if (count($products_query) != 500 || empty($products_query)) { 641 } else { 642 ClickMisPlugin_get_products_get2($index + 1, $products, $data); 643 } 644 } 645 646 ClickMisPlugin_get_products_get2(0, $products, $data); 647 648 return $products; 649 } 650 651 function ClickMisPlugin_get_products2($data) 652 { 653 try { 654 655 $result = array(); 656 657 function ClickMisPlugin_get_products_get($index, &$result, $request) 658 { 659 $args = array( 660 'limit' => 100, 661 'page' => $index + 1, 662 // 'status' => 'publish', 663 ); 664 665 666 if (isset($request['ids']) && !empty($request['ids'])) { 667 $args['include'] = json_decode($request['ids']); 668 } 669 670 $products = wc_get_products($args); 671 672 foreach ($products as $product) { 673 674 $variations = array(); 675 if ($product->product_type == 'variable') { 676 $childs = $product->get_children(); 677 678 foreach ($childs as $child) { 679 $variation = wc_get_product($child); 680 $data = $variation->get_data(); 681 // $variations[] = $variation->get_data(); 682 $variations[] = array( 683 'id' => $data['id'], 684 'regular_price' => $data['regular_price'], 685 'stock_quantity' => $data['stock_quantity'], 686 'price' => $data['price'], 687 ); 688 } 689 } 690 691 $result[] = array( 692 'id' => $product->get_id(), 693 'regular_price' => $product->get_regular_price(), 694 'stock_quantity' => $product->get_stock_quantity(), 695 'price' => $product->get_price(), 696 'variations' => $variations 697 ); 698 } 699 700 if (count($products) != 100 || empty($products)) { 701 } else { 702 ClickMisPlugin_get_products_get($index + 1, $result, $data); 703 } 704 } 705 706 707 ClickMisPlugin_get_products_get(0, $result, $data); 708 709 710 if (empty($result)) { 711 return new WP_Error('no product', array('status' => 404)); 712 } 713 714 return $result; 715 } catch (\Throwable $e) { 716 717 return $e->getMessage(); 718 } 719 } 720 721 722 function ClickMisPlugin_get_full_products($data) 723 { 724 725 $args = array( 726 // 'status' => 'publish', 727 'posts_per_page' => -1, 728 ); 729 730 $all_products = array(); 731 732 if (isset($data['ids']) && !empty($data['ids'])) { 733 $args = array( 734 'posts_per_page' => -1, 735 ); 736 $args['include'] = json_decode($data['ids']); 737 } else if (isset($data['includeDraft'])) { 299 738 $args2 = array( 300 739 'status' => 'draft', 301 740 'posts_per_page' => -1, 302 741 ); 303 304 if (isset($data['ids']) && !empty($data['ids'])) { 305 $args['include'] = json_decode($data['ids']); 306 } 307 308 $products_query = wc_get_products($args); 309 310 // $all_products = array_merge($products_query, wc_get_products($args2)); 311 $all_products = $products_query; 312 313 314 $products = array(); 315 foreach ($all_products as $product) { 316 $products[] = ClickMisPlugin_get_product_data($product); 317 } 318 319 return $products; 320 } catch (\Throwable $e) { 321 322 return $e->getMessage(); 323 } 324 } 325 326 function ClickMisPlugin_get_full_products($data) 327 { 328 329 $args = array( 330 'status' => 'publish', 331 'posts_per_page' => -1, 332 ); 333 334 335 if (isset($data['ids']) && !empty($data['ids'])) { 336 $args['include'] = json_decode($data['ids']); 742 $all_products = wc_get_products($args2); 337 743 } 338 744 339 745 $products_query = wc_get_products($args); 340 746 747 $all_products = array_merge($products_query, $all_products); 748 $products_query = $all_products; 341 749 342 750 $products = array(); … … 365 773 366 774 $args = array( 367 'status' => 'publish',775 // 'status' => 'publish', 368 776 'posts_per_page' => -1, 369 777 ); … … 407 815 function ClickMisPlugin_get_products($data) 408 816 { 409 $args = array( 410 'status' => 'publish', 411 'posts_per_page' => -1, 412 ); 413 414 if (isset($data['ids']) && !empty($data['ids'])) { 415 $args['include'] = json_decode($data['ids']); 416 } 417 418 $products = wc_get_products($args); 419 420 $result = array(); 421 422 foreach ($products as $product) { 423 424 $variations = array(); 425 if ($product->product_type == 'variable') { 426 $childs = $product->get_children(); 427 428 foreach ($childs as $child) { 429 $variation = wc_get_product($child); 430 $data = $variation->get_data(); 431 // $variations[] = $variation->get_data(); 432 $variations[] = array( 433 'id' => $data['id'], 434 'regular_price' => $data['regular_price'], 435 'stock_quantity' => $data['stock_quantity'], 436 'price' => $data['price'], 437 ); 438 439 // array_push( 440 // $variations, 441 // array( 442 // 'id' => $variation->get_id(), 443 // 'regular_price' => $variation->get_regular_price(), 444 // 'stock_quantity' => $variation->get_stock_quantity(), 445 // 'price' => $variation->get_price(), 446 // 'data' => $variation->get_data(), 447 // ) 448 // ); 449 } 450 } 451 452 $result[] = array( 453 'id' => $product->get_id(), 454 'regular_price' => $product->get_regular_price(), 455 'stock_quantity' => $product->get_stock_quantity(), 456 'price' => $product->get_price(), 457 'variations' => $variations 817 try { 818 819 $args = array( 820 // 'status' => 'publish', 821 'posts_per_page' => -1, 458 822 ); 459 } 460 461 462 if (empty($products)) { 463 return new WP_Error('no product', array('status' => 404)); 464 } 465 466 return $result; 823 824 $all_products = array(); 825 826 if (isset($data['ids']) && !empty($data['ids'])) { 827 $args = array( 828 'posts_per_page' => -1, 829 ); 830 $args['include'] = json_decode($data['ids']); 831 } else if (isset($data['includeDraft'])) { 832 $args2 = array( 833 'status' => 'draft', 834 'posts_per_page' => -1, 835 ); 836 $all_products = wc_get_products($args2); 837 } 838 839 $products_query = wc_get_products($args); 840 841 $all_products = array_merge($products_query, $all_products); 842 843 $products = $all_products; 844 845 $result = array(); 846 847 foreach ($products as $product) { 848 849 $variations = array(); 850 if ($product->product_type == 'variable') { 851 $childs = $product->get_children(); 852 853 foreach ($childs as $child) { 854 $variation = wc_get_product($child); 855 $data = $variation->get_data(); 856 // $variations[] = $variation->get_data(); 857 $variations[] = array( 858 'id' => $data['id'], 859 'regular_price' => $data['regular_price'], 860 'stock_quantity' => $data['stock_quantity'], 861 'price' => $data['price'], 862 ); 863 864 // array_push( 865 // $variations, 866 // array( 867 // 'id' => $variation->get_id(), 868 // 'regular_price' => $variation->get_regular_price(), 869 // 'stock_quantity' => $variation->get_stock_quantity(), 870 // 'price' => $variation->get_price(), 871 // 'data' => $variation->get_data(), 872 // ) 873 // ); 874 } 875 } 876 877 $result[] = array( 878 'id' => $product->get_id(), 879 'regular_price' => $product->get_regular_price(), 880 'stock_quantity' => $product->get_stock_quantity(), 881 'price' => $product->get_price(), 882 'variations' => $variations 883 ); 884 } 885 886 887 if (empty($products)) { 888 return new WP_Error('no product', array('status' => 404)); 889 } 890 891 return $result; 892 } catch (\Throwable $e) { 893 894 return $e->getMessage(); 895 } 467 896 } 468 897 … … 510 939 } 511 940 512 if ( array_key_exists('name', $syncItem))$item->set_name($syncItem->name);513 if ( array_key_exists('short_description', $syncItem)) $item->set_short_description($syncItem->short_description);941 if (isset($syncItem->name)) $item->set_name($syncItem->name); 942 if (isset($syncItem->short_description)) $item->set_short_description($syncItem->short_description); 514 943 515 944 516 945 if ($syncItem->product_type != 'variable') { 517 if ( array_key_exists('stock_status', $syncItem)) $item->set_stock_status($syncItem->stock_status);518 if ( array_key_exists('stock_quantity', $syncItem)) $item->set_stock_quantity($syncItem->stock_quantity);519 if ( array_key_exists('manage_stock', $syncItem)) $item->set_manage_stock($syncItem->manage_stock);520 if ( array_key_exists('regular_price', $syncItem)) $item->set_regular_price($syncItem->regular_price);521 if ( array_key_exists('price', $syncItem)) $item->set_price($syncItem->price);522 if ( array_key_exists('price', $syncItem)) $item->set_sale_price($syncItem->price);523 if ( array_key_exists('sale_price', $syncItem)) $item->set_sale_price($syncItem->sale_price);946 if (isset($syncItem->stock_status)) $item->set_stock_status($syncItem->stock_status); 947 if (isset($syncItem->stock_quantity)) $item->set_stock_quantity($syncItem->stock_quantity); 948 if (isset($syncItem->manage_stock)) $item->set_manage_stock($syncItem->manage_stock); 949 if (isset($syncItem->regular_price)) $item->set_regular_price(intval($syncItem->regular_price)); 950 if (isset($syncItem->price)) $item->set_price(intval($syncItem->price)); 951 if (isset($syncItem->price)) $item->set_sale_price(intval($syncItem->price)); 952 if (isset($syncItem->sale_price)) $item->set_sale_price(intval($syncItem->sale_price)); 524 953 } 525 954 526 955 527 956 //TODO rayeheyesib 528 if ( array_key_exists('meta_data', $syncItem)) {957 if (isset($syncItem->meta_data)) { 529 958 foreach ($syncItem->meta_data as $meta_data) { 530 959 $item->update_meta_data($meta_data->key, $meta_data->value); … … 719 1148 } 720 1149 1150 $fee_items = []; 1151 foreach ($order->get_items('fee') as $item_id => $item_fee) { 1152 $fee_items[] = $item_fee->get_data(); 1153 } 1154 1155 721 1156 $data['line_items'] = $line_items; 1157 $data['fee_items'] = $fee_items; 722 1158 $data['shipping_lines'] = $shipping_lines; 723 1159 … … 753 1189 $q['include'] = json_decode($data['ids']); 754 1190 } 1191 1192 if (isset($data['date'])) { 1193 1194 $q['date_query'] = array( 1195 'column' => 'post_date', 1196 'after' => $data['date'] 1197 ); 1198 } 1199 755 1200 756 1201 $customer_orders = get_posts($q); … … 906 1351 add_action('rest_api_init', function () { 907 1352 1353 // register_rest_route('ClickPlugin/v1', '/copons', array( 1354 // 'methods' => 'GET', 1355 // 'callback' => 'ClickMisPlugin_init_copons', 1356 // 'permission_callback' => '__return_true', 1357 // )); 1358 908 1359 register_rest_route('ClickPlugin/v1', '/products', array( 909 1360 'methods' => 'GET', 910 'callback' => 'ClickMisPlugin_get_products ',1361 'callback' => 'ClickMisPlugin_get_products2', 911 1362 'permission_callback' => '__return_true', 912 1363 )); … … 914 1365 register_rest_route('ClickPlugin/v1', '/full_products', array( 915 1366 'methods' => 'GET', 916 'callback' => 'ClickMisPlugin_get_full_products ',1367 'callback' => 'ClickMisPlugin_get_full_products2', 917 1368 'permission_callback' => '__return_true', 918 1369 )); … … 938 1389 register_rest_route('ClickPlugin/v1', '/productsFull', array( 939 1390 'methods' => 'GET', 940 'callback' => 'ClickMisPlugin_get_productsFull ',1391 'callback' => 'ClickMisPlugin_get_productsFull2', 941 1392 'permission_callback' => '__return_true', 942 1393 )); -
clickmis/tags/1.0.4/README.txt
r2840265 r3026071 5 5 Tested up to: 6.1 6 6 Requires PHP: 5.6 7 Stable tag: 1.0. 07 Stable tag: 1.0.4 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 21 21 22 22 == Changelog == 23 = 1.0. 024 * نسخه اولیه 23 = 1.0.4 24 رفع خطا در برخی از سایت ها -
clickmis/tags/1.0/ClickPlugin.php
r2840267 r3026071 518 518 if (array_key_exists('stock_quantity', $syncItem)) $item->set_stock_quantity($syncItem->stock_quantity); 519 519 if (array_key_exists('manage_stock', $syncItem)) $item->set_manage_stock($syncItem->manage_stock); 520 if (array_key_exists('regular_price', $syncItem)) $item->set_regular_price( $syncItem->regular_price);521 if (array_key_exists('price', $syncItem)) $item->set_price( $syncItem->price);522 if (array_key_exists('price', $syncItem)) $item->set_sale_price( $syncItem->price);523 if (array_key_exists('sale_price', $syncItem)) $item->set_sale_price( $syncItem->sale_price);520 if (array_key_exists('regular_price', $syncItem)) $item->set_regular_price(intval($syncItem->regular_price)); 521 if (array_key_exists('price', $syncItem)) $item->set_price(intval($syncItem->price)); 522 if (array_key_exists('price', $syncItem)) $item->set_sale_price(intval($syncItem->price)); 523 if (array_key_exists('sale_price', $syncItem)) $item->set_sale_price(intval($syncItem->sale_price)); 524 524 } 525 525 -
clickmis/trunk/ClickPlugin.php
r2840265 r3026071 3 3 /** 4 4 * @link https://clickmis.net/ 5 * @since 1.0. 05 * @since 1.0.4 6 6 * @package ClickPlugin 7 7 * … … 9 9 * Plugin URI: https://clickmis.net/ 10 10 * Description: اتصال و همگامسازی وب سایت فروش ووکامرس با حسابداری آنلاین کلیک 11 * Version: 1.0. 011 * Version: 1.0.4 12 12 * Author: ClickMis 13 13 * Author URI: https://clickmis.net/ … … 17 17 **/ 18 18 19 20 function ClickMisPlugin_cleans() 21 { 22 try { 23 header("Access-Control-Allow-Origin: *"); 24 ini_set('memory_limit', '-1'); 25 set_time_limit(1000); 26 ini_set('display_errors', 'Off'); 27 ini_set('error_reporting', 0); 28 wc_set_time_limit(1000); 29 30 if (!defined('WP_DEBUG')) define('WP_DEBUG', false); 31 if (!defined('WP_DEBUG_LOG')) define('WP_DEBUG_LOG', false); 32 if (!defined('WP_DEBUG_DISPLAY')) define('WP_DEBUG_DISPLAY', false); 33 34 function ClickMisPlugin_overrule_webhook_disable_limit($number) 35 { 36 return 999999; 37 } 38 add_filter('woocommerce_max_webhook_delivery_failures', 'ClickMisPlugin_overrule_webhook_disable_limit'); 39 } catch (\Throwable $e) { 40 } 41 } 42 43 ClickMisPlugin_cleans(); 44 45 46 try { 47 function ClickMisPlugin_my_woocommerce_rest_check_permissions($permission, $context, $object_id, $post_type) 48 { 49 return true; 50 } 51 add_filter('woocommerce_rest_check_permissions', 'ClickMisPlugin_my_woocommerce_rest_check_permissions', 90, 4); 52 } catch (\Throwable $e) { 53 } 54 55 // Hook before calculate fees 56 // add_action('woocommerce_cart_calculate_fees', 'ClickMisPlugin_rayehe_discount'); 57 // /** 58 // * Add custom fee if more than three article 59 // * @param WC_Cart $cart 60 // */ 61 // function ClickMisPlugin_rayehe_discount(WC_Cart $cart) 62 // { 63 // //any of your rules 64 // // Calculate the amount to reduce 65 // $totalPrice = $cart->get_subtotal(); 66 // $discount = 0; 67 68 // $coupon_code = null; 69 // if ($totalPrice >= 500000 && $totalPrice <= 3000000) { 70 // //10% 71 // $coupon_code = 'Emam_Reza_10'; 72 // $discount = 10; 73 // } else if ($totalPrice > 3000000 && $totalPrice <= 10000000) { 74 // //15% 75 // $coupon_code = 'Emam_Reza_15'; 76 // $discount = 15; 77 // } else if ($totalPrice > 10000000 && $totalPrice <= 25000000) { 78 // //20% 79 // $coupon_code = 'Emam_Reza_20'; 80 // $discount = 20; 81 // } else if ($totalPrice > 25000000 && $totalPrice <= 50000000) { 82 // //22% 83 // $coupon_code = 'Emam_Reza_22'; 84 // $discount = 22; 85 // } else if ($totalPrice > 50000000 && $totalPrice <= 75000000) { 86 // //24% 87 // $coupon_code = 'Emam_Reza_24'; 88 // $discount = 24; 89 // } else if ($totalPrice > 75000000 && $totalPrice <= 100000000) { 90 // //26% 91 // $coupon_code = 'Emam_Reza_26'; 92 // $discount = 26; 93 // } else if ($totalPrice > 100000000 && $totalPrice <= 150000000) { 94 // //28% 95 // $coupon_code = 'Emam_Reza_28'; 96 // $discount = 28; 97 // } else if ($totalPrice > 150000000) { 98 // //30% 99 // $discount = 30; 100 // $coupon_code = 'Emam_Reza_30'; 101 // } 102 103 104 // if ($discount > 0) { 105 // $cart->add_fee( 'تخفیف ویژه میلاد امامرضا(ع)' .' '. $discount. 'درصد', - ($discount * $totalPrice / 100)); 106 // } 107 108 // } 109 110 function ClickMisPlugin_init_copons($data) 111 { 112 $couponList = array( 113 "Emam_Reza_10" => 10, 114 "Emam_Reza_15" => 15, 115 "Emam_Reza_20" => 20, 116 "Emam_Reza_22" => 22, 117 "Emam_Reza_24" => 24, 118 "Emam_Reza_26" => 26, 119 "Emam_Reza_28" => 28, 120 "Emam_Reza_30" => 30 121 ); 122 123 foreach ($couponList as $x => $val) { 124 ClickMisPlugin_create_coupon( 125 $x, 126 array( 127 'discount_type' => 'percent', 128 'coupon_amount' => $val, 129 'usage_limit' => 1000000 130 ) 131 ); 132 } 133 } 134 135 function ClickMisPlugin_create_coupon($coupon_name, $args = array()) 136 { 137 138 $coupon_args = array( 139 'post_title' => $coupon_name, 140 'post_content' => '', 141 'post_status' => 'publish', 142 'post_author' => 1, 143 'post_type' => 'shop_coupon' 144 ); 145 146 $coupon_id = wp_insert_post($coupon_args); 147 148 if (!empty($coupon_id) && !is_wp_error($coupon_id)) { 149 foreach ($args as $key => $val) { 150 update_post_meta($coupon_id, $key, $val); 151 } 152 } 153 154 return $coupon_id; 155 } 156 157 // add_action('woocommerce_before_cart_table', 'ClickMisPlugin_rayehe_takhfif'); 158 // function ClickMisPlugin_rayehe_takhfif() 159 // { 160 // global $woocommerce; 161 162 // $totalPrice = $woocommerce->cart->get_cart_total(); 163 // $coupon_code = null; 164 // if ($totalPrice >= 500000 && $totalPrice <= 3000000) { 165 // //10% 166 // $coupon_code = 'Emam_Reza_10'; 167 // } else if ($totalPrice > 3000000 && $totalPrice <= 10000000) { 168 // //15% 169 // $coupon_code = 'Emam_Reza_15'; 170 // } else if ($totalPrice > 10000000 && $totalPrice <= 25000000) { 171 // //20% 172 // $coupon_code = 'Emam_Reza_20'; 173 // } else if ($totalPrice > 25000000 && $totalPrice <= 50000000) { 174 // //22% 175 // $coupon_code = 'Emam_Reza_22'; 176 // } else if ($totalPrice > 50000000 && $totalPrice <= 75000000) { 177 // //24% 178 // $coupon_code = 'Emam_Reza_24'; 179 // } else if ($totalPrice > 75000000 && $totalPrice <= 100000000) { 180 // //26% 181 // $coupon_code = 'Emam_Reza_26'; 182 // } else if ($totalPrice > 100000000 && $totalPrice <= 150000000) { 183 // //28% 184 // $coupon_code = 'Emam_Reza_28'; 185 // } else if ($totalPrice > 150000000) { 186 // //30% 187 // $coupon_code = 'Emam_Reza_30'; 188 // } 189 190 191 // if ($coupon_code != null) { 192 193 // if (!$woocommerce->cart->add_discount(sanitize_text_field($coupon_code))) { 194 // $woocommerce->show_messages(); 195 // } 196 // // echo '<div class="woocommerce_message"><strong>Your order is over 100 lbs so a 10% Discount has been Applied!</strong> Your total order weight is <strong>' . $total_weight . '</strong> lbs.</div>'; 197 // } 198 // } 199 200 /* Mod: Remove 10% Discount for weight less than or equal to 100 lbs */ 201 // add_action('woocommerce_before_cart_table', 'ClickMisPlugin_rayehe_takhfif_remove'); 202 // function ClickMisPlugin_rayehe_takhfif_remove() 203 // { 204 // global $woocommerce; 205 206 // $totalPrice = $woocommerce->cart->get_cart_total(); 207 // $coupon_code = null; 208 // if ($totalPrice >= 500000 && $totalPrice <= 3000000) { 209 // //10% 210 // $coupon_code = 'Emam_Reza_10'; 211 // } else if ($totalPrice > 3000000 && $totalPrice <= 10000000) { 212 // //15% 213 // $coupon_code = 'Emam_Reza_15'; 214 // } else if ($totalPrice > 10000000 && $totalPrice <= 25000000) { 215 // //20% 216 // $coupon_code = 'Emam_Reza_20'; 217 // } else if ($totalPrice > 25000000 && $totalPrice <= 50000000) { 218 // //22% 219 // $coupon_code = 'Emam_Reza_22'; 220 // } else if ($totalPrice > 50000000 && $totalPrice <= 75000000) { 221 // //24% 222 // $coupon_code = 'Emam_Reza_24'; 223 // } else if ($totalPrice > 75000000 && $totalPrice <= 100000000) { 224 // //26% 225 // $coupon_code = 'Emam_Reza_26'; 226 // } else if ($totalPrice > 100000000 && $totalPrice <= 150000000) { 227 // //28% 228 // $coupon_code = 'Emam_Reza_26'; 229 // } else if ($totalPrice > 150000000) { 230 // //30% 231 // $coupon_code = 'Emam_Reza_30'; 232 // } 233 234 // if ($coupon_code != null) { 235 236 // $woocommerce->cart->get_applied_coupons(); 237 // if (!$woocommerce->cart->remove_coupons(sanitize_text_field($coupon_code))) { 238 // $woocommerce->show_messages(); 239 // } 240 // $woocommerce->cart->calculate_totals(); 241 // } 242 // } 19 243 20 244 function ClickMisPlugin_prepare_date_response($date) … … 190 414 function ClickMisPlugin_get_attribute_taxonomy_label($name) 191 415 { 192 //wp functions 193 $tax = get_taxonomy($name); 194 $labels = get_taxonomy_labels($tax); 195 196 return $labels->singular_name; 416 try { 417 //wp functions 418 $tax = get_taxonomy($name); 419 $labels = get_taxonomy_labels($tax); 420 421 return $labels->singular_name; 422 } catch (\Throwable $e) { 423 return ''; 424 } 197 425 } 198 426 … … 287 515 } 288 516 517 function ClickMisPlugin_get_productsFull2($data) 518 { 519 try { 520 521 ClickMisPlugin_cleans(); 522 523 $products = array(); 524 525 function ClickMisPlugin_get_productsFull_get2($index, &$products, $data) 526 { 527 528 $args = array( 529 'limit' => 500, 530 'page' => $index + 1, 531 // 'status' => 'publish', 532 ); 533 534 535 if (isset($data['ids']) && !empty($data['ids'])) { 536 $args['include'] = json_decode($data['ids']); 537 } 538 539 $products_query = wc_get_products($args); 540 541 foreach ($products_query as $product) { 542 $products[] = ClickMisPlugin_get_product_data($product); 543 } 544 545 if (count($products_query) != 500 || empty($products_query)) { 546 } else { 547 ClickMisPlugin_get_productsFull_get2($index + 1, $products, $data); 548 } 549 } 550 551 ClickMisPlugin_get_productsFull_get2(0, $products, $data); 552 553 return $products; 554 } catch (\Throwable $e) { 555 return $e->getMessage(); 556 } 557 } 558 289 559 function ClickMisPlugin_get_productsFull($data) 290 560 { 561 ClickMisPlugin_cleans(); 291 562 292 563 try { 293 564 294 565 $args = array( 295 'status' => 'publish',566 // 'status' => 'publish', 296 567 'posts_per_page' => -1, 297 568 ); 298 569 570 $all_products = array(); 571 572 if (isset($data['ids']) && !empty($data['ids'])) { 573 $args = array( 574 'posts_per_page' => -1, 575 ); 576 $args['include'] = json_decode($data['ids']); 577 } else if (isset($data['includeDraft'])) { 578 $args2 = array( 579 'status' => 'draft', 580 'posts_per_page' => -1, 581 ); 582 $all_products = wc_get_products($args2); 583 } 584 585 $products_query = wc_get_products($args); 586 587 $all_products = array_merge($products_query, $all_products); 588 589 $products = array(); 590 foreach ($all_products as $product) { 591 $products[] = ClickMisPlugin_get_product_data($product); 592 } 593 594 return $products; 595 } catch (\Throwable $e) { 596 597 return $e->getMessage(); 598 } 599 } 600 601 function ClickMisPlugin_get_full_products2($data) 602 { 603 604 $products = array(); 605 606 function ClickMisPlugin_get_products_get2($index, &$products, $data) 607 { 608 609 $args = array( 610 'limit' => 500, 611 'page' => $index + 1, 612 // 'status' => 'publish', 613 ); 614 615 616 if (isset($data['ids']) && !empty($data['ids'])) { 617 $args['include'] = json_decode($data['ids']); 618 } 619 620 $products_query = wc_get_products($args); 621 622 623 624 foreach ($products_query as $product) { 625 array_push( 626 $products, 627 array( 628 'id' => $product->get_id(), 629 'name' => $product->get_name(), 630 'stock_quantity' => $product->get_stock_quantity(), 631 'price' => $product->get_price(), 632 633 'sku' => $product->get_sku(), 634 'date_created_gmt' => ClickMisPlugin_prepare_date_response($product->get_date_created()), 635 'categories' => ClickMisPlugin_get_taxonomy_terms($product), 636 ) 637 ); 638 } 639 640 if (count($products_query) != 500 || empty($products_query)) { 641 } else { 642 ClickMisPlugin_get_products_get2($index + 1, $products, $data); 643 } 644 } 645 646 ClickMisPlugin_get_products_get2(0, $products, $data); 647 648 return $products; 649 } 650 651 function ClickMisPlugin_get_products2($data) 652 { 653 try { 654 655 $result = array(); 656 657 function ClickMisPlugin_get_products_get($index, &$result, $request) 658 { 659 $args = array( 660 'limit' => 100, 661 'page' => $index + 1, 662 // 'status' => 'publish', 663 ); 664 665 666 if (isset($request['ids']) && !empty($request['ids'])) { 667 $args['include'] = json_decode($request['ids']); 668 } 669 670 $products = wc_get_products($args); 671 672 foreach ($products as $product) { 673 674 $variations = array(); 675 if ($product->product_type == 'variable') { 676 $childs = $product->get_children(); 677 678 foreach ($childs as $child) { 679 $variation = wc_get_product($child); 680 $data = $variation->get_data(); 681 // $variations[] = $variation->get_data(); 682 $variations[] = array( 683 'id' => $data['id'], 684 'regular_price' => $data['regular_price'], 685 'stock_quantity' => $data['stock_quantity'], 686 'price' => $data['price'], 687 ); 688 } 689 } 690 691 $result[] = array( 692 'id' => $product->get_id(), 693 'regular_price' => $product->get_regular_price(), 694 'stock_quantity' => $product->get_stock_quantity(), 695 'price' => $product->get_price(), 696 'variations' => $variations 697 ); 698 } 699 700 if (count($products) != 100 || empty($products)) { 701 } else { 702 ClickMisPlugin_get_products_get($index + 1, $result, $data); 703 } 704 } 705 706 707 ClickMisPlugin_get_products_get(0, $result, $data); 708 709 710 if (empty($result)) { 711 return new WP_Error('no product', array('status' => 404)); 712 } 713 714 return $result; 715 } catch (\Throwable $e) { 716 717 return $e->getMessage(); 718 } 719 } 720 721 722 function ClickMisPlugin_get_full_products($data) 723 { 724 725 $args = array( 726 // 'status' => 'publish', 727 'posts_per_page' => -1, 728 ); 729 730 $all_products = array(); 731 732 if (isset($data['ids']) && !empty($data['ids'])) { 733 $args = array( 734 'posts_per_page' => -1, 735 ); 736 $args['include'] = json_decode($data['ids']); 737 } else if (isset($data['includeDraft'])) { 299 738 $args2 = array( 300 739 'status' => 'draft', 301 740 'posts_per_page' => -1, 302 741 ); 303 304 if (isset($data['ids']) && !empty($data['ids'])) { 305 $args['include'] = json_decode($data['ids']); 306 } 307 308 $products_query = wc_get_products($args); 309 310 // $all_products = array_merge($products_query, wc_get_products($args2)); 311 $all_products = $products_query; 312 313 314 $products = array(); 315 foreach ($all_products as $product) { 316 $products[] = ClickMisPlugin_get_product_data($product); 317 } 318 319 return $products; 320 } catch (\Throwable $e) { 321 322 return $e->getMessage(); 323 } 324 } 325 326 function ClickMisPlugin_get_full_products($data) 327 { 328 329 $args = array( 330 'status' => 'publish', 331 'posts_per_page' => -1, 332 ); 333 334 335 if (isset($data['ids']) && !empty($data['ids'])) { 336 $args['include'] = json_decode($data['ids']); 742 $all_products = wc_get_products($args2); 337 743 } 338 744 339 745 $products_query = wc_get_products($args); 340 746 747 $all_products = array_merge($products_query, $all_products); 748 $products_query = $all_products; 341 749 342 750 $products = array(); … … 365 773 366 774 $args = array( 367 'status' => 'publish',775 // 'status' => 'publish', 368 776 'posts_per_page' => -1, 369 777 ); … … 407 815 function ClickMisPlugin_get_products($data) 408 816 { 409 $args = array( 410 'status' => 'publish', 411 'posts_per_page' => -1, 412 ); 413 414 if (isset($data['ids']) && !empty($data['ids'])) { 415 $args['include'] = json_decode($data['ids']); 416 } 417 418 $products = wc_get_products($args); 419 420 $result = array(); 421 422 foreach ($products as $product) { 423 424 $variations = array(); 425 if ($product->product_type == 'variable') { 426 $childs = $product->get_children(); 427 428 foreach ($childs as $child) { 429 $variation = wc_get_product($child); 430 $data = $variation->get_data(); 431 // $variations[] = $variation->get_data(); 432 $variations[] = array( 433 'id' => $data['id'], 434 'regular_price' => $data['regular_price'], 435 'stock_quantity' => $data['stock_quantity'], 436 'price' => $data['price'], 437 ); 438 439 // array_push( 440 // $variations, 441 // array( 442 // 'id' => $variation->get_id(), 443 // 'regular_price' => $variation->get_regular_price(), 444 // 'stock_quantity' => $variation->get_stock_quantity(), 445 // 'price' => $variation->get_price(), 446 // 'data' => $variation->get_data(), 447 // ) 448 // ); 449 } 450 } 451 452 $result[] = array( 453 'id' => $product->get_id(), 454 'regular_price' => $product->get_regular_price(), 455 'stock_quantity' => $product->get_stock_quantity(), 456 'price' => $product->get_price(), 457 'variations' => $variations 817 try { 818 819 $args = array( 820 // 'status' => 'publish', 821 'posts_per_page' => -1, 458 822 ); 459 } 460 461 462 if (empty($products)) { 463 return new WP_Error('no product', array('status' => 404)); 464 } 465 466 return $result; 823 824 $all_products = array(); 825 826 if (isset($data['ids']) && !empty($data['ids'])) { 827 $args = array( 828 'posts_per_page' => -1, 829 ); 830 $args['include'] = json_decode($data['ids']); 831 } else if (isset($data['includeDraft'])) { 832 $args2 = array( 833 'status' => 'draft', 834 'posts_per_page' => -1, 835 ); 836 $all_products = wc_get_products($args2); 837 } 838 839 $products_query = wc_get_products($args); 840 841 $all_products = array_merge($products_query, $all_products); 842 843 $products = $all_products; 844 845 $result = array(); 846 847 foreach ($products as $product) { 848 849 $variations = array(); 850 if ($product->product_type == 'variable') { 851 $childs = $product->get_children(); 852 853 foreach ($childs as $child) { 854 $variation = wc_get_product($child); 855 $data = $variation->get_data(); 856 // $variations[] = $variation->get_data(); 857 $variations[] = array( 858 'id' => $data['id'], 859 'regular_price' => $data['regular_price'], 860 'stock_quantity' => $data['stock_quantity'], 861 'price' => $data['price'], 862 ); 863 864 // array_push( 865 // $variations, 866 // array( 867 // 'id' => $variation->get_id(), 868 // 'regular_price' => $variation->get_regular_price(), 869 // 'stock_quantity' => $variation->get_stock_quantity(), 870 // 'price' => $variation->get_price(), 871 // 'data' => $variation->get_data(), 872 // ) 873 // ); 874 } 875 } 876 877 $result[] = array( 878 'id' => $product->get_id(), 879 'regular_price' => $product->get_regular_price(), 880 'stock_quantity' => $product->get_stock_quantity(), 881 'price' => $product->get_price(), 882 'variations' => $variations 883 ); 884 } 885 886 887 if (empty($products)) { 888 return new WP_Error('no product', array('status' => 404)); 889 } 890 891 return $result; 892 } catch (\Throwable $e) { 893 894 return $e->getMessage(); 895 } 467 896 } 468 897 … … 510 939 } 511 940 512 if ( array_key_exists('name', $syncItem))$item->set_name($syncItem->name);513 if ( array_key_exists('short_description', $syncItem)) $item->set_short_description($syncItem->short_description);941 if (isset($syncItem->name)) $item->set_name($syncItem->name); 942 if (isset($syncItem->short_description)) $item->set_short_description($syncItem->short_description); 514 943 515 944 516 945 if ($syncItem->product_type != 'variable') { 517 if ( array_key_exists('stock_status', $syncItem)) $item->set_stock_status($syncItem->stock_status);518 if ( array_key_exists('stock_quantity', $syncItem)) $item->set_stock_quantity($syncItem->stock_quantity);519 if ( array_key_exists('manage_stock', $syncItem)) $item->set_manage_stock($syncItem->manage_stock);520 if ( array_key_exists('regular_price', $syncItem)) $item->set_regular_price($syncItem->regular_price);521 if ( array_key_exists('price', $syncItem)) $item->set_price($syncItem->price);522 if ( array_key_exists('price', $syncItem)) $item->set_sale_price($syncItem->price);523 if ( array_key_exists('sale_price', $syncItem)) $item->set_sale_price($syncItem->sale_price);946 if (isset($syncItem->stock_status)) $item->set_stock_status($syncItem->stock_status); 947 if (isset($syncItem->stock_quantity)) $item->set_stock_quantity($syncItem->stock_quantity); 948 if (isset($syncItem->manage_stock)) $item->set_manage_stock($syncItem->manage_stock); 949 if (isset($syncItem->regular_price)) $item->set_regular_price(intval($syncItem->regular_price)); 950 if (isset($syncItem->price)) $item->set_price(intval($syncItem->price)); 951 if (isset($syncItem->price)) $item->set_sale_price(intval($syncItem->price)); 952 if (isset($syncItem->sale_price)) $item->set_sale_price(intval($syncItem->sale_price)); 524 953 } 525 954 526 955 527 956 //TODO rayeheyesib 528 if ( array_key_exists('meta_data', $syncItem)) {957 if (isset($syncItem->meta_data)) { 529 958 foreach ($syncItem->meta_data as $meta_data) { 530 959 $item->update_meta_data($meta_data->key, $meta_data->value); … … 719 1148 } 720 1149 1150 $fee_items = []; 1151 foreach ($order->get_items('fee') as $item_id => $item_fee) { 1152 $fee_items[] = $item_fee->get_data(); 1153 } 1154 1155 721 1156 $data['line_items'] = $line_items; 1157 $data['fee_items'] = $fee_items; 722 1158 $data['shipping_lines'] = $shipping_lines; 723 1159 … … 753 1189 $q['include'] = json_decode($data['ids']); 754 1190 } 1191 1192 if (isset($data['date'])) { 1193 1194 $q['date_query'] = array( 1195 'column' => 'post_date', 1196 'after' => $data['date'] 1197 ); 1198 } 1199 755 1200 756 1201 $customer_orders = get_posts($q); … … 906 1351 add_action('rest_api_init', function () { 907 1352 1353 // register_rest_route('ClickPlugin/v1', '/copons', array( 1354 // 'methods' => 'GET', 1355 // 'callback' => 'ClickMisPlugin_init_copons', 1356 // 'permission_callback' => '__return_true', 1357 // )); 1358 908 1359 register_rest_route('ClickPlugin/v1', '/products', array( 909 1360 'methods' => 'GET', 910 'callback' => 'ClickMisPlugin_get_products ',1361 'callback' => 'ClickMisPlugin_get_products2', 911 1362 'permission_callback' => '__return_true', 912 1363 )); … … 914 1365 register_rest_route('ClickPlugin/v1', '/full_products', array( 915 1366 'methods' => 'GET', 916 'callback' => 'ClickMisPlugin_get_full_products ',1367 'callback' => 'ClickMisPlugin_get_full_products2', 917 1368 'permission_callback' => '__return_true', 918 1369 )); … … 938 1389 register_rest_route('ClickPlugin/v1', '/productsFull', array( 939 1390 'methods' => 'GET', 940 'callback' => 'ClickMisPlugin_get_productsFull ',1391 'callback' => 'ClickMisPlugin_get_productsFull2', 941 1392 'permission_callback' => '__return_true', 942 1393 )); -
clickmis/trunk/README.txt
r2840265 r3026071 5 5 Tested up to: 6.1 6 6 Requires PHP: 5.6 7 Stable tag: 1.0. 07 Stable tag: 1.0.4 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 21 21 22 22 == Changelog == 23 = 1.0. 024 * نسخه اولیه 23 = 1.0.4 24 رفع خطا در برخی از سایت ها
Note: See TracChangeset
for help on using the changeset viewer.