Changeset 3209024
- Timestamp:
- 12/17/2024 10:12:05 AM (16 months ago)
- Location:
- seur/trunk
- Files:
-
- 4 edited
-
core/functions/functions.php (modified) (2 diffs)
-
core/woocommerce/includes/class-wc-shipping-seur.php (modified) (1 diff)
-
loader.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
seur/trunk/core/functions/functions.php
r3176965 r3209024 556 556 */ 557 557 function seur_get_custom_rates( $output_type = 'OBJECT', $type = 'price' ) { 558 global $wpdb; 559 560 $table = $wpdb->prefix . SEUR_TBL_SCR; 561 $getrates = $wpdb->get_results( "SELECT * FROM $table WHERE type = '$type' ORDER BY ID ASC", $output_type ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 562 return $getrates; 563 } 564 565 /** 566 * SEUR Seach Allowed Rates by Country. 567 * 568 * @param string $allowedcountry Alloweb Country. 569 */ 570 function seur_search_allowed_rates_by_country( $allowedcountry ) { 571 572 $filtered_rates_by_country = array(); 573 $rates_type = get_option( 'seur_rates_type_field' ); 574 $output_type = 'OBJECT'; 575 $getrates = seur_get_custom_rates( $output_type, $rates_type ); 576 577 foreach ( $getrates as $rate ) { 578 $country = $rate->country; 579 $rateid = $rate->ID; 580 581 if ( $allowedcountry === $country ) { 582 $columns = array( 583 'ID', 584 'country', 585 'state', 586 'postcode', 587 'minprice', 588 'maxprice', 589 'minweight', 590 'maxweight', 591 'rate', 592 'rateprice', 593 'type', 594 ); 595 $valors = array( 596 $rate->ID, 597 $rate->country, 598 $rate->state, 599 $rate->postcode, 600 $rate->minprice, 601 $rate->maxprice, 602 $rate->minweight, 603 $rate->maxweight, 604 $rate->rate, 605 $rate->rateprice, 606 $rate->type, 607 ); 608 $filtered_rates_by_country[] = array_combine( $columns, $valors ); 609 } 610 } 611 612 if ( $filtered_rates_by_country ) { 613 return $filtered_rates_by_country; 614 } else { 615 foreach ( $getrates as $rate ) { 616 $country = $rate->country; 617 $rateid = $rate->ID; 618 if ( '*' === $country ) { 619 $columns = array( 620 'ID', 621 'country', 622 'state', 623 'postcode', 624 'minprice', 625 'maxprice', 626 'minweight', 627 'maxweight', 628 'rate', 629 'rateprice', 630 'type', 631 ); 632 633 $valors = array( 634 $rate->ID, 635 $rate->country, 636 $rate->state, 637 $rate->postcode, 638 $rate->minprice, 639 $rate->maxprice, 640 $rate->minweight, 641 $rate->maxweight, 642 $rate->rate, 643 $rate->rateprice, 644 $rate->type, 645 ); 646 $filtered_rates_by_country[] = array_combine( $columns, $valors ); 647 } 648 } 649 } 650 return $filtered_rates_by_country; 651 } 652 653 /** 654 * SEUR Search Allowed States Filtered by Country 655 * 656 * @param string $allowedstate state. 657 * @param array $filtered_rates_by_country countries array. 658 */ 659 function seur_seach_allowed_states_filtered_by_countries( $allowedstate, $filtered_rates_by_country ) { 660 661 $log = new WC_Logger(); 662 $log->add( 'seur', 'seur_seach_allowed_states_filtered_by_countries()' ); 663 $log->add( 'seur', '$allowedstate:' . $allowedstate ); 664 $log->add( 'seur', '$filtered_rates_by_country:' . print_r( $filtered_rates_by_country, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r 665 666 $filtered_rates_by_state = array(); 667 668 foreach ( $filtered_rates_by_country as $allowedrate ) { 669 $state = $allowedrate['state']; 670 $rateid = $allowedrate['ID']; 671 672 $log->add( 'seur', '$state:' . $state ); 673 $log->add( 'seur', '$rateid:' . $rateid ); 674 675 if ( $allowedstate === $state ) { 676 $columns = array( 677 'ID', 678 'country', 679 'state', 680 'postcode', 681 'minprice', 682 'maxprice', 683 'minweight', 684 'maxweight', 685 'rate', 686 'rateprice', 687 'type', 688 ); 689 690 $valors = array( 691 $allowedrate['ID'], 692 $allowedrate['country'], 693 $allowedrate['state'], 694 $allowedrate['postcode'], 695 $allowedrate['minprice'], 696 $allowedrate['maxprice'], 697 $allowedrate['minweight'], 698 $allowedrate['maxweight'], 699 $allowedrate['rate'], 700 $allowedrate['rateprice'], 701 $allowedrate['type'], 702 ); 703 $filtered_rates_by_state[] = array_combine( $columns, $valors ); 704 } 705 } 706 707 if ( $filtered_rates_by_state ) { 708 return $filtered_rates_by_state; 709 } else { 710 foreach ( $filtered_rates_by_country as $allowedrate ) { 711 $state = $allowedrate['state']; 712 $rateid = $allowedrate['ID']; 713 714 if ( '*' === $state ) { 715 $columns = array( 716 'ID', 717 'country', 718 'state', 719 'postcode', 720 'minprice', 721 'maxprice', 722 'minweight', 723 'maxweight', 724 'rate', 725 'rateprice', 726 'type', 727 ); 728 729 $valors = array( 730 $allowedrate['ID'], 731 $allowedrate['country'], 732 $allowedrate['state'], 733 $allowedrate['postcode'], 734 $allowedrate['minprice'], 735 $allowedrate['maxprice'], 736 $allowedrate['minweight'], 737 $allowedrate['maxweight'], 738 $allowedrate['rate'], 739 $allowedrate['rateprice'], 740 $allowedrate['type'], 741 ); 742 $filtered_rates_by_state[] = array_combine( $columns, $valors ); 743 } 744 } 745 } 746 return $filtered_rates_by_state; 747 } 748 749 /** 750 * SEUR Search Allowed postcodes filtered by country 751 * 752 * @param string $allowedpostcode Postcode. 753 * @param array $filtered_rates_by_state States. 754 */ 755 function seur_seach_allowed_postcodes_filtered_by_states( $allowedpostcode, $filtered_rates_by_state ) { 756 757 $log = new WC_Logger(); 758 $log->add( 'seur', 'seur_seach_allowed_postcodes_filtered_by_states()' ); 759 $log->add( 'seur', '$allowedpostcode:' . $allowedpostcode ); 760 $log->add( 'seur', '$filtered_rates_by_state:' . print_r( $filtered_rates_by_state, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r 761 762 $filtered_rates_by_postcode = array(); 763 foreach ( $filtered_rates_by_state as $allowedrate ) { 764 $postcode = $allowedrate['postcode']; 765 $rateid = $allowedrate['ID']; 766 767 $log->add( 'seur', '$postcode: ' . $postcode ); 768 $log->add( 'seur', '$rateid:' . $rateid ); 769 if ( $allowedpostcode === $postcode ) { 770 $columns = array( 771 'ID', 772 'country', 773 'state', 774 'postcode', 775 'minprice', 776 'maxprice', 777 'minweight', 778 'maxweight', 779 'rate', 780 'rateprice', 781 'type', 782 ); 783 $valors = array( 784 $allowedrate['ID'], 785 $allowedrate['country'], 786 $allowedrate['state'], 787 $allowedrate['postcode'], 788 $allowedrate['minprice'], 789 $allowedrate['maxprice'], 790 $allowedrate['minweight'], 791 $allowedrate['maxweight'], 792 $allowedrate['rate'], 793 $allowedrate['rateprice'], 794 $allowedrate['type'], 795 ); 796 $filtered_rates_by_postcode[] = array_combine( $columns, $valors ); 797 } 798 } 799 if ( $filtered_rates_by_postcode ) { 800 return $filtered_rates_by_postcode; 801 } else { 802 foreach ( $filtered_rates_by_state as $allowedrate ) { 803 $postcode = $allowedrate['postcode']; 804 $rateid = $allowedrate['ID']; 805 if ( '*' === $postcode ) { 806 $columns = array( 807 'ID', 808 'country', 809 'state', 810 'postcode', 811 'minprice', 812 'maxprice', 813 'minweight', 814 'maxweight', 815 'rate', 816 'rateprice', 817 'type', 818 ); 819 $valors = array( 820 $allowedrate['ID'], 821 $allowedrate['country'], 822 $allowedrate['state'], 823 $allowedrate['postcode'], 824 $allowedrate['minprice'], 825 $allowedrate['maxprice'], 826 $allowedrate['minweight'], 827 $allowedrate['maxweight'], 828 $allowedrate['rate'], 829 $allowedrate['rateprice'], 830 $allowedrate['type'], 831 ); 832 $filtered_rates_by_postcode[] = array_combine( $columns, $valors ); 833 } 834 } 835 } 836 return $filtered_rates_by_postcode; 837 } 838 839 /** 840 * SEUR Search Allowed rates filtered by postcodes 841 * 842 * @param string $allowedPriceWeight Price. 843 * @param array $filtered_rates_by_postcode Postcodes. 844 */ 845 function seur_seach_allowed_rates_filtered_by_postcode( $allowedPriceWeight, $filtered_rates_by_postcode ) { 846 847 $log = new WC_Logger(); 848 $log->add( 'seur', 'seur_seach_allowed_prices_filtered_by_postcode()' ); 849 $log->add( 'seur', '$allowedPriceWeight:' . $allowedPriceWeight ); 850 $log->add( 'seur', '$filtered_rates_by_postcode:' . print_r( $filtered_rates_by_postcode, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r 851 852 $filtered_rates_by_price = array(); 853 854 foreach ( $filtered_rates_by_postcode as $allowedRate ) { 855 $filterField = get_option('seur_rates_type_field'); 856 $minvalue = $allowedRate['minprice']; 857 $maxvalue = $allowedRate['maxprice']; 858 if ($filterField === 'weight') { 859 $minvalue = $allowedRate['minweight']; 860 $maxvalue = $allowedRate['maxweight']; 861 } 862 $rateid = $allowedRate['ID']; 863 864 $log->add( 'seur', 'filter by: ' . $filterField ); 865 $log->add( 'seur', '$minvalue: ' . $minvalue ); 866 $log->add( 'seur', '$maxvalue: ' . $maxvalue ); 867 $log->add( 'seur', '$rateid: ' . $rateid ); 868 869 if ( ( $minvalue <= $allowedPriceWeight && $maxvalue > $allowedPriceWeight ) ) { 870 $columns = array( 871 'ID', 872 'country', 873 'state', 874 'postcode', 875 'rate', 876 'rateprice', 877 'type', 878 ); 879 $values = array( 880 $allowedRate['ID'], 881 $allowedRate['country'], 882 $allowedRate['state'], 883 $allowedRate['postcode'], 884 $allowedRate['rate'], 885 $allowedRate['rateprice'], 886 $allowedRate['type'], 887 ); 888 $filterColumns = ['minprice','maxprice']; 889 $filterValues = [$allowedRate['minprice'],$allowedRate['maxprice']]; 890 if ($filterField === 'weight') { 891 $filterColumns = ['minweight','maxweight']; 892 $filterValues = [$allowedRate['minweight'],$allowedRate['maxweight']]; 893 } 894 $columns = array_merge($columns, $filterColumns); 895 $values = array_merge($values, $filterValues); 896 897 $filtered_rates_by_price[] = array_combine( $columns, $values ); 898 } 899 } 900 return $filtered_rates_by_price; 558 global $wpdb; 559 $table = $wpdb->prefix . SEUR_TBL_SCR; 560 $query = $wpdb->prepare( "SELECT * FROM $table WHERE type = %s ORDER BY ID ASC", $type ); 561 return $wpdb->get_results( $query, $output_type ); 901 562 } 902 563 … … 911 572 function seur_show_availables_rates( $country = null, $state = null, $postcode = null, $price_weight = null ) { 912 573 913 $log = new WC_Logger(); 914 $log->add( 'seur', ' ARRAIVE TO seur_show_availables_rates( $country = NULL, $state = NULL, $postcode = NULL, $price = NULL )' ); 915 if ( ! $country ) { 916 $country = '*'; 917 } 918 if ( ! $state ) { 919 $state = '*'; 920 } 921 if ( ! $postcode ) { 922 $postcode = '*'; 923 } 924 if ( '00000' === $postcode ) { 925 $postcode = '*'; 926 } 927 if ( ! $price_weight ) { 928 $price_weight = '0'; 929 } 930 $log->add( 'seur', '$country:' . $country ); 931 $log->add( 'seur', '$state:' . $state ); 932 $log->add( 'seur', '$postcode:' . $postcode ); 933 $log->add( 'seur', '$price_weight:' . $price_weight ); 934 935 $filtered_rates_by_country = array(); 936 $filtered_rates_by_state = array(); 937 $filtered_rates_by_postcode = array(); 938 $ratestoscreen = array(); 939 940 $filtered_rates_by_country = seur_search_allowed_rates_by_country( $country ); 941 $filtered_rates_by_state = seur_seach_allowed_states_filtered_by_countries( $state, $filtered_rates_by_country ); 942 $filtered_rates_by_postcode = seur_seach_allowed_postcodes_filtered_by_states( $postcode, $filtered_rates_by_state ); 943 $ratestoscreen = seur_seach_allowed_rates_filtered_by_postcode( $price_weight, $filtered_rates_by_postcode ); 944 945 return $ratestoscreen; 574 $country = $country?? '*'; 575 $state = $state?? '*'; 576 $postcode = ( '00000' === $postcode )?'*':$postcode; 577 $price_weight = $price_weight?? '0'; 578 579 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { 580 $log = new WC_Logger(); 581 $log->add('seur', ' ARRAIVE TO seur_show_availables_rates( $country = NULL, $state = NULL, $postcode = NULL, $price = NULL )'); 582 $log->add('seur', '$country:' . $country); 583 $log->add('seur', '$state:' . $state); 584 $log->add('seur', '$postcode:' . $postcode); 585 $log->add('seur', '$price_weight:' . $price_weight); 586 } 587 $ratestoscreen = seur_search_availables_rates( $country, $state, $postcode, $price_weight ); 588 589 return $ratestoscreen; 590 } 591 592 function seur_search_availables_rates( $country = '*', $state = '*', $postcode = '*', $price_weight = 0 ) { 593 global $wpdb; 594 $type = get_option( 'seur_rates_type_field' ); // 'price' o 'weight', definido en la configuración de SEUR 595 $table = $wpdb->prefix . SEUR_TBL_SCR; 596 597 $query = $wpdb->prepare( 598 "SELECT * FROM $table 599 WHERE type = %s 600 AND (country = %s OR country = '*') 601 AND (state = %s OR state = '*') 602 AND (postcode = %s OR postcode = '*') 603 AND (min".$type." <= %f AND max".$type." > %f) 604 ORDER BY ID ASC", 605 $type, $country, $state, $postcode, $price_weight, $price_weight 606 ); 607 608 $results = $wpdb->get_results( $query, 'ARRAY_A' ); 609 610 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { 611 $log = new WC_Logger(); 612 $log->add( 'seur', 'Tarifas disponibles encontradas: ' . print_r( $results, true ) ); 613 } 614 615 return $results; 946 616 } 947 617 -
seur/trunk/core/woocommerce/includes/class-wc-shipping-seur.php
r3176965 r3209024 407 407 * @param array $value Array. 408 408 */ 409 public function seur_option_woocommerce_cod_settings( $value ) { 410 if ( is_checkout() ) { 411 if ( 412 ! empty( $value ) 413 && is_array( $value ) 414 && 'yes' === $value['enabled'] 415 && ! empty( $value['enable_for_methods'] ) 416 && is_array( $value['enable_for_methods'] ) 417 ) { 418 foreach ( $value['enable_for_methods'] as $method ) { 419 if ( 'seur' === $method ) { 420 $seur_rates = seur_get_custom_rates(); 421 foreach ( $seur_rates as $seur_rate ) { 422 $value['enable_for_methods'][] = $seur_rate->ID; 423 } 424 break; 425 } 426 } 427 } 428 } 429 return $value; 430 } 409 public function seur_option_woocommerce_cod_settings( $value ) { 410 if ( is_checkout() && 411 ! empty( $value ) && 412 is_array( $value ) && 413 'yes' === $value['enabled'] && 414 ! empty( $value['enable_for_methods'] ) && 415 is_array( $value['enable_for_methods'] ) && 416 in_array( 'seur', $value['enable_for_methods'], true ) 417 ) { 418 $seur_rates = seur_get_custom_rates(); 419 420 // Extraer solo los IDs de las tarifas. 421 $seur_rate_ids = array_map( fn( $rate ) => $rate->ID, $seur_rates ); 422 423 // Añadir los IDs de tarifas SEUR. 424 $value['enable_for_methods'] = array_unique( 425 array_merge( $value['enable_for_methods'], $seur_rate_ids ) 426 ); 427 } 428 return $value; 429 } 431 430 432 431 /** -
seur/trunk/loader.php
r3196410 r3209024 4 4 * Plugin URI: http://www.seur.com/ 5 5 * Description: Add SEUR shipping method to WooCommerce. The SEUR plugin for WooCommerce allows you to manage your order dispatches in a fast and easy way 6 * Version: 2.2.1 86 * Version: 2.2.19 7 7 * Author: SEUR Oficial 8 8 * Author URI: http://www.seur.com/ … … 20 20 use Automattic\WooCommerce\Utilities\FeaturesUtil; 21 21 22 define( 'SEUR_OFFICIAL_VERSION', '2.2.1 8' );22 define( 'SEUR_OFFICIAL_VERSION', '2.2.19' ); 23 23 define( 'SEUR_DB_VERSION', '1.0.4' ); 24 24 define( 'SEUR_TABLE_VERSION', '1.0.5' ); -
seur/trunk/readme.txt
r3196410 r3209024 4 4 Requires at least: 4.0 5 5 Tested up to: 6.6.2 6 Stable tag: 2.2.1 86 Stable tag: 2.2.19 7 7 WC requires at least: 3.0 8 8 WC tested up to: 9.1.4 … … 39 39 = Quick set-up = 40 40 41 [Leave your details here](https://info.notificaciones.e-seur.com/Formulario-Web-Seur?ecommerce=checked). Ask SEUR for your registration details, fill in the configuration form and set the transport rate for your buyers. Trust your shipments to the leading e-commerce logistics partner in just 3 steps. 41 [Leave your details here](https://pub.s7.exacttarget.com/thi131hffjt). Ask SEUR for your registration details, fill in the configuration form and set the transport rate for your buyers. Trust your shipments to the leading e-commerce logistics partner in just 3 steps. 42 42 43 43 44 == Installation == … … 92 93 93 94 == Changelog == 95 96 == 2.2.19 == 97 98 * FIXED: Refactor get rates 94 99 95 100 == 2.2.18 ==
Note: See TracChangeset
for help on using the changeset viewer.