Changeset 3261412
- Timestamp:
- 03/25/2025 10:08:46 AM (12 months ago)
- Location:
- seur/trunk
- Files:
-
- 18 edited
-
assets/css/seur-setting.css (modified) (1 diff)
-
assets/js/seur-custom-rates.js (modified) (3 diffs)
-
classes/class-seur-global.php (modified) (1 diff)
-
core/defines/defines-loader.php (modified) (1 diff)
-
core/functions/functions.php (modified) (8 diffs)
-
core/installer.php (modified) (3 diffs)
-
core/labels-cpt/labels-cpt.php (modified) (2 diffs)
-
core/pages/rates/seur-add-form.php (modified) (1 diff)
-
core/pages/rates/seur-create-rate.php (modified) (2 diffs)
-
core/pages/rates/seur-edit-form.php (modified) (3 diffs)
-
core/pages/rates/seur-import-custom-rates.php (modified) (4 diffs)
-
core/pages/rates/seur-update.php (modified) (2 diffs)
-
core/pages/setting-options/advanced-settings.php (modified) (3 diffs)
-
core/woocommerce/includes/seur-woo-functions.php (modified) (4 diffs)
-
languages/seur-es_ES.mo (modified) (previous)
-
languages/seur-es_ES.po (modified) (5 diffs)
-
loader.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
seur/trunk/assets/css/seur-setting.css
r1836328 r3261412 36 36 padding-top: 13px; 37 37 } 38 39 #seur_uploads_dir button { 40 vertical-align: middle; 41 } -
seur/trunk/assets/js/seur-custom-rates.js
r2643080 r3261412 48 48 var custom_rates_page_edit = 'admin.php?page=seur_edit_rate&edit_id='; 49 49 50 function validatePostcodeFormat(postcode) { 51 const pattern = /^(\*|[A-Z0-9]+\*|[A-Z0-9]+\.\.[A-Z0-9]+|[A-Z0-9]+)$/i; 52 return pattern.test(postcode); 53 } 54 55 function validatePostcodes(postcodes) { 56 const lines = postcodes.split("\n").map(line => line.trim()); // Separar por líneas y eliminar espacios 57 return lines.every(line => validatePostcodeFormat(line)); // Verificar que todas las líneas sean válidas 58 } 50 59 51 60 /* Data Insert Starts Here */ 52 61 53 62 $(document).on('submit', '#emp-SaveForm', function() { 54 55 $.post( custom_rates_page_create, $(this).serialize())56 .done(function(data){ 63 const postcode = document.getElementById("postcode").value; 64 if (!validatePostcodes(postcode)) { 65 event.preventDefault(); // Detiene el envío del formulario 57 66 $("#dis").fadeOut(); 58 $("#dis").fadeIn('slow', function(){ 59 $("#dis").html('<div class="alert alert-info">'+data+'</div>'); 60 $("#emp-SaveForm")[0].reset(); 61 }); 62 }); 63 return false; 67 $("#dis").fadeIn('slow', function () { 68 $("#dis").html('<div class="notice notice notice-error"><p>Postcode: Formato inválido</p></div>'); 69 }); 70 } else { 71 $.post(custom_rates_page_create, $(this).serialize()) 72 .done(function (data) { 73 $("#dis").fadeOut(); 74 $("#dis").fadeIn('slow', function () { 75 $("#dis").html('<div class="alert alert-info"><p>' + data + '</p></div>'); 76 $("#emp-SaveForm")[0].reset(); 77 }); 78 }); 79 return false; 80 } 64 81 }); 65 82 /* Data Insert Ends Here */ … … 93 110 var id = $(this).attr("id"); 94 111 var edit_id = id; 95 if(confirm('Sure to Edit ID ' +edit_id)) 96 { 97 $(".content-loader").fadeOut('slow', function() 98 { 99 $(".content-loader").load( custom_rates_page_edit + edit_id ); 100 $(".content-loader").delay( 3000 ).fadeIn('slow'); 101 $("#btn-add").hide(); 102 $("#btn-view").show(); 103 }); 104 } 105 return false; 112 $(".content-loader").fadeOut('slow', function() 113 { 114 $(".content-loader").load( custom_rates_page_edit + edit_id ); 115 $(".content-loader").delay( 3000 ).fadeIn('slow'); 116 $("#btn-add").hide(); 117 $("#btn-view").show(); 118 }); 119 return false; 106 120 }); 107 121 /* Get Edit ID */ … … 109 123 /* Update Record */ 110 124 $(document).on('submit', '#emp-UpdateForm', function() { 111 112 $.post( custom_rates_page_update , $(this).serialize())113 .done(function(data){ 125 const postcode = document.getElementById("postcode").value; 126 if (!validatePostcodes(postcode)) { 127 event.preventDefault(); // Detiene el envío del formulario 114 128 $("#dis").fadeOut(); 115 $("#dis").fadeIn('slow', function(){ 116 $("#dis").html('<div class="alert alert-info">'+data+'</div>'); 117 $("#emp-UpdateForm")[0].reset(); 118 $("body").fadeOut('slow', function() 119 { 120 $("body").delay( 2000 ).fadeOut('slow'); 121 window.location.href=custom_rates_page; 122 }); 123 }); 124 }); 125 return false; 129 $("#dis").fadeIn('slow', function () { 130 $("#dis").html('<div class="notice notice notice-error"><p>Postcode: Formato inválido</p></div>'); 131 }); 132 } else { 133 edit_id = $(this).find('input[name="id"]').val(); 134 $.post(custom_rates_page_update, $(this).serialize()) 135 .done(function (data) { 136 $("#dis").fadeOut(); 137 $("#dis").fadeIn('slow', function () { 138 $("#dis").html('<div class="alert alert-info">' + data + '</div>'); 139 $("#emp-UpdateForm")[0].reset(); 140 }); 141 }); 142 return false; 143 } 126 144 }); 127 145 /* Update Record */ -
seur/trunk/classes/class-seur-global.php
r3254005 r3261412 1071 1071 public function is_seur_order($order_id) { 1072 1072 global $wpdb; 1073 global $post; 1073 1074 $sql = $wpdb->prepare( 1074 "SELECT distinct o.order_id 1075 FROM {$wpdb->prefix}woocommerce_order_items o 1076 inner join {$wpdb->prefix}woocommerce_order_itemmeta om on om.order_item_id = o.order_item_id 1077 where om.meta_key = %s and (om.meta_value like %s) 1078 AND o.order_id = %d", 1079 ['method_id', 'seur', $order_id] 1075 "SELECT distinct o.order_id 1076 FROM {$wpdb->prefix}woocommerce_order_items o 1077 inner join {$wpdb->prefix}woocommerce_order_itemmeta om on om.order_item_id = o.order_item_id 1078 where om.meta_key = %s and (om.meta_value like %s) 1079 AND o.order_id = %d 1080 UNION 1081 SELECT distinct p.ID 1082 FROM {$wpdb->prefix}posts p 1083 inner join {$wpdb->prefix}postmeta m on m.post_id = p.ID 1084 where post_type = %s 1085 and meta_key like %s 1086 and ID = %d", 1087 ['method_id', 'seur', $order_id, 'shop_order', 'shipping', $post->ID] 1080 1088 ); 1081 1089 $sql = str_replace('seur', '%seur%', $sql); 1090 $sql = str_replace('shipping', '_seur_shipping%', $sql); 1091 1082 1092 $result = $wpdb->get_results($sql); 1083 1093 return !empty($result); -
seur/trunk/core/defines/defines-loader.php
r3119152 r3261412 28 28 define( 'SEUR_TBL_SCR', 'seur_custom_rates' ); 29 29 define( 'SEUR_CLASSES', SEUR_PLUGIN_PATH . 'core/classes/' ); 30 30 define('SEUR_RATES_POSTALCODE_DESCRIPTION', esc_html__('Postcodes containing wildcards (e.g. CB23*) or fully numeric ranges (e.g. 90210..99000) are also supported. ', 'seur')); 31 31 32 32 if ( ! defined( 'SEUR_DEBUG' ) ) { -
seur/trunk/core/functions/functions.php
r3254005 r3261412 149 149 wp_enqueue_script( 'seur-tooltip', SEUR_PLUGIN_URL . 'assets/js/tooltip.js', array( 'jquery-ui-tooltip' ), SEUR_OFFICIAL_VERSION ); 150 150 wp_enqueue_script( 'seur-switchery', SEUR_PLUGIN_URL . 'assets/js/switchery.min.js', array(), SEUR_OFFICIAL_VERSION ); 151 wp_enqueue_script( 'seur-admin', SEUR_PLUGIN_URL . 'assets/js/seur-advanced-settings.js', array(), SEUR_OFFICIAL_VERSION ); 151 152 } 152 153 … … 603 604 FROM $table 604 605 WHERE type = %s 605 AND (country = %s)606 AND country = %s 606 607 AND (state = %s OR state = '*') 607 AND (postcode = %s OR postcode = '*')608 608 AND (min".$type." <= %f AND max".$type." > %f) 609 609 LIMIT 1), … … 615 615 WHERE type = %s 616 616 AND (country = %s OR country = '*') 617 AND (state = %s) 618 AND (postcode = %s OR postcode = '*') 619 AND (min".$type." <= %f AND max".$type." > %f) 620 LIMIT 1), 621 '*' 622 ) 623 AND postcode = COALESCE( 624 (SELECT %s 625 FROM $table 626 WHERE type = %s 627 AND (country = %s OR country = '*') 628 AND (state = %s OR state = '*') 629 AND (postcode = %s) 617 AND state = %s 630 618 AND (min".$type." <= %f AND max".$type." > %f) 631 619 LIMIT 1), … … 639 627 $query, 640 628 $type, 641 $country, $type, $country, $state, $postcode, $price_weight, $price_weight, 642 $state, $type, $country, $state, $postcode, $price_weight, $price_weight, 643 $postcode, $type, $country, $state, $postcode, $price_weight, $price_weight, 629 $country, $type, $country, $state, $price_weight, $price_weight, 630 $state, $type, $country, $state, $price_weight, $price_weight, 644 631 $price_weight, $price_weight 645 632 ); … … 647 634 $results = $wpdb->get_results($query, 'ARRAY_A'); 648 635 636 // Filtrar resultados 637 $filteredResults = array_filter($results, function ($row) use ($postcode) { 638 return matchPostcode($postcode, $row['postcode']); 639 }); 640 649 641 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { 650 642 $log = new WC_Logger(); 651 $log->add( 'seur', 'Tarifas disponibles encontradas: ' . print_r( $results, true ) ); 652 } 653 654 return $results; 655 } 656 643 $log->add( 'seur', 'Tarifas disponibles encontradas: ' . print_r( $filteredResults, true ) ); 644 } 645 return $filteredResults; 646 } 647 648 function matchPostcode($postcode, $rules) { 649 $rules = explode("\n", $rules); // Separar líneas en un array 650 651 foreach ($rules as $rule) { 652 $rule = trim($rule); 653 654 // Comprobación por prefijo (ejemplo: 00*) 655 if (str_ends_with($rule, '*')) { 656 $prefix = rtrim($rule, '*'); 657 if (strpos($postcode, $prefix) === 0) { 658 return true; // Coincidencia con prefijo 659 } 660 } 661 662 // Comprobación por rango (ejemplo: 11001..11012) 663 if (strpos($rule, '..') !== false) { 664 [$start, $end] = explode('..', $rule); 665 if ($postcode >= $start && $postcode <= $end) { 666 return true; // Coincidencia con el rango 667 } 668 } 669 670 // Coincidencia exacta 671 if ($postcode === $rule) { 672 return true; 673 } 674 } 675 676 return false; // No hay coincidencia 677 } 657 678 /** 658 679 * SEUR Get User Settings … … 1240 1261 $order->update_meta_data('_seur_shipping_order_label_downloaded', 'yes'); 1241 1262 $order->update_meta_data('_seur_shipping_packages', $numpackages); 1242 $order->update_meta_data('_seur_shipping_weight', $ weight);1263 $order->update_meta_data('_seur_shipping_weight', $labelData['customer_weight']); 1243 1264 $order->update_meta_data('_seur_shipping_change_service', $changeService); 1244 1265 $order->save_meta_data(); … … 1380 1401 $preparedData['customer_city'] = seur_clean_data( $order_data[0]['city'] ); 1381 1402 $preparedData['customer_postcode'] = $order_data[0]['postcode']; 1382 $preparedData['customer_weight'] = $order_data[0]['weight'] ;1403 $preparedData['customer_weight'] = $order_data[0]['weight'] ?: $weight; 1383 1404 $preparedData['customer_first_name'] = seur_clean_data( $order_data[0]['first_name'] ); 1384 1405 $preparedData['customer_last_name'] = seur_clean_data( $order_data[0]['last_name'] ); … … 1749 1770 function seur_get_order_weight($order) { 1750 1771 $label_ids = seur_get_labels_ids($order->get_id()); 1772 1751 1773 $weight = $order->get_meta('_seur_shipping_weight') ?: 1752 1774 isset($label_ids[0]) && get_post_meta($label_ids[0], '_seur_shipping_weight', true) ?: 1753 1775 $order->get_meta('_seur_cart_weight', true); 1754 $order->update_meta_data('_seur_shipping_weight', $weight); 1755 $order->update_meta_data('_seur_cart_weight', $weight); 1756 $order->save_meta_data(); 1757 if ($label_ids) { 1758 update_post_meta($label_ids[0], '_seur_shipping_weight', $weight); 1776 if ($weight) { 1777 $order->update_meta_data('_seur_shipping_weight', $weight); 1778 $order->update_meta_data('_seur_cart_weight', $weight); 1779 $order->save_meta_data(); 1780 if ($label_ids) { 1781 update_post_meta($label_ids[0], '_seur_shipping_weight', $weight); 1782 } 1759 1783 } 1760 1784 return $weight; 1761 1785 } 1786 1787 function seur_regenerate_upload_dir_callback() { 1788 // Asegurar que WordPress está cargado 1789 if (!defined('ABSPATH')) { 1790 exit; 1791 } 1792 1793 // Incluir el archivo PHP que realiza la acción 1794 $file_path = SEUR_PLUGIN_PATH . 'core/pages/regenerate-upload-dir.php'; 1795 1796 if (file_exists($file_path)) { 1797 ob_start(); 1798 include $file_path; 1799 $output = ob_get_clean(); 1800 echo $output; 1801 } else { 1802 echo "Error: No se encontró el archivo de procesamiento."; 1803 } 1804 1805 wp_die(); // Importante para que WordPress finalice correctamente el AJAX 1806 } 1807 add_action('wp_ajax_seur_regenerate_upload_dir', 'seur_regenerate_upload_dir_callback'); 1808 1809 1810 function validatePostcodeFormat($postcode) { 1811 /* 1812 Un asterisco solo 1813 Prefijo alfanumérico seguido de * 1814 Dos valores alfanuméricos separados por .. 1815 Un valor alfanumérico sin * ni .. 1816 */ 1817 $pattern = '/^(\*|[A-Z0-9]+\*|[A-Z0-9]+\.\.[A-Z0-9]+|[A-Z0-9]+)$/i'; 1818 return preg_match($pattern, $postcode); 1819 } 1820 1821 function validatePostcodes($postcodes) { 1822 $lines = explode("\n", $postcodes); 1823 1824 foreach ($lines as $line) { 1825 $line = trim($line); 1826 if (!validatePostcodeFormat($line)) { 1827 return false; 1828 } 1829 } 1830 return true; 1831 } -
seur/trunk/core/installer.php
r3179024 r3261412 36 36 country varchar(50) NOT NULL default '', 37 37 state varchar(200) NOT NULL default '', 38 postcode varchar( 7) NOT NULL default '00000',38 postcode varchar(200) NOT NULL default '*', 39 39 minprice decimal(20,2) unsigned NOT NULL default '0.00', 40 40 maxprice decimal(20,2) unsigned NOT NULL default '0.00', … … 866 866 update_option( 'seur_aduana_origen_field', 'D' ); 867 867 update_option( 'seur_aduana_destino_field', 'D' ); 868 update_option( 'seur_tipo_mercancia_field', 'C' );869 update_option( 'seur_id_mercancia_field', '400' );870 update_option( 'seur_descripcion_field', 'MANUFACTURAS DIVERSAS' );868 update_option( 'seur_tipo_mercancia_field', 'C' ); 869 update_option( 'seur_id_mercancia_field', '400' ); 870 update_option( 'seur_descripcion_field', 'MANUFACTURAS DIVERSAS' ); 871 871 update_option( 'seur_add_advanced_settings_field_pre', '1' ); 872 872 } … … 874 874 } 875 875 876 function seur_upgrade_2222() { 877 seur_upgrade_db_105(); 878 } 879 880 function seur_upgrade_db_105() { 881 global $wpdb; 882 $table_name = $wpdb->prefix . 'seur_custom_rates'; 883 $column_name = 'postcode'; 884 885 // Verificar si la columna 'postcode' existe antes de modificarla 886 $column_exists = $wpdb->get_results("SHOW COLUMNS FROM `$table_name` LIKE '$column_name'"); 887 if (!empty($column_exists)) { 888 // Modificar la columna 'postcode' a VARCHAR(200) con valor por defecto '*' 889 $wpdb->query("ALTER TABLE `$table_name` MODIFY `$column_name` VARCHAR(200) NOT NULL DEFAULT '*'"); 890 update_option('seur_db_version', SEUR_DB_VERSION); 891 } 892 } 893 894 function seur_run_upgrade() { 895 $current_version = get_option('seur-official-version', '2.1.1'); 896 897 if (version_compare($current_version, '2.2.22', '<')) { 898 seur_upgrade_2222(); 899 update_option('seur-official-version', '2.2.22'); 900 } 901 } 902 903 seur_run_upgrade(); -
seur/trunk/core/labels-cpt/labels-cpt.php
r3234068 r3261412 251 251 $customer_city = seur_clean_data( $order_data[0]['city'] ); 252 252 $customer_postcode = $order_data[0]['postcode']; 253 $customer_weight = $order_data[0]['weight']; 254 255 if ( ! $customer_weight ) { 256 $customer_weight = $weight; 257 } 258 253 $customer_weight = $order_data[0]['weight'] ?: $weight; 259 254 $customer_address_1 = seur_clean_data( $order_data[0]['address_1'] ); 260 255 $customer_address_2 = seur_clean_data( $order_data[0]['address_2'] ); … … 334 329 </p> 335 330 336 </div> 337 331 </div> 332 333 <p><strong><?php esc_html_e('Weight: ','seur');?></strong></p><?php echo esc_html( $customer_weight ); ?> 338 334 <p> 339 335 <strong><?php esc_html_e( 'Customer notes about Order: ', 'seur' ); ?></strong><br /> -
seur/trunk/core/pages/rates/seur-add-form.php
r3176965 r3261412 76 76 </tr> 77 77 <tr> 78 <td id="postcode"><?php esc_html_e( 'Postcode', 'seur' ); ?></td> 79 <td><input title="<?php esc_html_e( 'Type a Postcode', 'seur' ); ?>" type='text' name='postcode' class='form-control' placeholder='EX : 08023' required=""></td> 78 <td><?php esc_html_e( 'Postcode', 'seur' ); ?></td> 79 <td><textarea title="<?php esc_html_e( 'Type a Postcode', 'seur' ); ?>" name="postcode" id="postcode" placeholder="<?php echo esc_html("List 1 postcode per line");?>" class="form-control" cols="29" rows="5" required=""></textarea> 80 <br><span class="description"><?php echo SEUR_RATES_POSTALCODE_DESCRIPTION . esc_html__('Add 1 per line'); ?></span> 81 </td> 80 82 </tr> 81 83 <tr> -
seur/trunk/core/pages/rates/seur-create-rate.php
r3119152 r3261412 33 33 $seur_rateprice = sanitize_text_field( wp_unslash( $_POST['rateprice'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated 34 34 $seur_rate_type = sanitize_text_field( wp_unslash( $_POST['rate_type'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated 35 $seur_postcode = s eur_sanitize_postcode( sanitize_text_field( wp_unslash( $_POST['postcode'] ) ), $seur_country); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated35 $seur_postcode = sanitize_textarea_field( wp_unslash( $_POST['postcode'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated 36 36 37 37 if ( empty( $seur_city ) ) { … … 46 46 if ( empty( $seur_postcode ) || '00000' === $seur_postcode || '0000' === $seur_postcode || '*' === $seur_postcode ) { 47 47 $seur_postcode = '*'; 48 } 48 } else { 49 if (!validatePostcodes($seur_postcode)) { 50 echo '<div class="notice notice-error"><p>' . esc_html__( 'The postcode is not valid', 'seur' ) . '</p></div>'; 51 exit; 52 } 53 } 49 54 if ( empty( $seur_rateprice ) ) { 50 55 $seur_rateprice = '0'; -
seur/trunk/core/pages/rates/seur-edit-form.php
r3183810 r3261412 38 38 // translators: %s is the type of rate (e.g., weight, price). 39 39 $title_max = sprintf( __( 'The product %s is less than this field', 'seur' ), esc_html( $rates_type ) ); 40 ?> 40 41 41 42 ?>43 <style type="text/css">44 #dis{45 display:none;46 }47 </style>48 42 <div id="dis"> 49 43 </div> 44 50 45 <form method='post' id='emp-UpdateForm' action='#'> 51 46 <table class='table table-bordered'> … … 141 136 <tr> 142 137 <td><?php esc_html_e( 'Postcode', 'seur' ); ?></td> 143 <td><input title="<?php esc_html_e( 'SEUR field description', 'seur' ); ?>" type='text' name='postcode' value='<?php echo esc_html( $getrate->postcode ); ?>' class='form-control' placeholder='EX : 08023' required=""></td> 138 <td><textarea title="<?php esc_html_e( 'Type a Postcode', 'seur' ); ?>" name="postcode" id="postcode" class="form-control" cols="29" rows="5" required=""><?php echo esc_html( $getrate->postcode ); ?></textarea> 139 <br><span class="description"><?php echo SEUR_RATES_POSTALCODE_DESCRIPTION . esc_html__('Add 1 per line'); ?></span> 140 </td> 144 141 </tr> 145 142 <tr> … … 168 165 <?php 169 166 } 167 //seur_search_availables_rates('ES','*', '*', 0.5); -
seur/trunk/core/pages/rates/seur-import-custom-rates.php
r3254005 r3261412 99 99 $output = fopen( 'php://output', 'w' ); 100 100 101 // Reemplazar los saltos de línea en los códigos postales para exportar 101 102 // Eliminar las columnas "created_at" y "updated_at" 102 103 foreach ( $rates as &$row ) { 104 $row['postcode'] = str_replace("\r\n", "|", $row['postcode']); 103 105 unset( $row['created_at'], $row['updated_at'] ); 104 106 } … … 154 156 // Leer el resto del archivo línea por línea 155 157 foreach ( $csv_lines as $line ) { 158 if (empty($line)) { 159 break; 160 } 156 161 $data = str_getcsv( $line ); 157 162 $record = array_combine( $header, $data ); … … 190 195 } 191 196 } 197 198 // Validar el campo postcode si no está vacío 199 if (!empty($record['postcode'])) { 200 $record_postcode = $record['postcode']; 201 if (strpos($record['postcode'], "|") !== false) { 202 $record['postcode'] = str_replace("|", "\r\n", $record['postcode']); 203 } 204 if (!validatePostcodes($record['postcode'])) { 205 $error_messages[] = "El valor de postcode '{$record_postcode}' no tiene formato válido."; 206 } 207 } 192 208 193 209 // Verificar si el ID existe … … 284 300 <li><strong>country</strong>: País al que se aplica la tarifa. Use "*" para aplicar a todos los países.</li> 285 301 <li><strong>state</strong>: Estado o provincia al que se aplica la tarifa. Use "*" para aplicar a todos los estados.</li> 286 <li><strong>postcode</strong>: Código postal al que se aplica la tarifa. </li>302 <li><strong>postcode</strong>: Código postal al que se aplica la tarifa. <?php echo SEUR_RATES_POSTALCODE_DESCRIPTION .' Separar los valores con "|", por ejemplo: 01*|02*|03001..03010'; ?></li> 287 303 <li><strong>minprice</strong>: Precio mínimo para aplicar la tarifa.</li> 288 304 <li><strong>maxprice</strong>: Precio máximo para aplicar la tarifa.</li> -
seur/trunk/core/pages/rates/seur-update.php
r3119152 r3261412 33 33 $seur_rateprice = sanitize_text_field( wp_unslash( $_POST['rateprice'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated 34 34 $seur_rate_type = sanitize_text_field( wp_unslash( $_POST['rate_type'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated 35 $seur_postcode = sanitize_text _field( wp_unslash( $_POST['postcode'] ), $seur_country); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated35 $seur_postcode = sanitize_textarea_field( wp_unslash( $_POST['postcode'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated 36 36 37 37 if ( empty( $seur_minprice ) ) { … … 40 40 if ( empty( $seur_postcode ) || '00000' === $seur_postcode || '0000' === $seur_postcode || '*' === $seur_postcode ) { 41 41 $seur_postcode = '*'; 42 } 42 } else { 43 if (!validatePostcodes($seur_postcode)) { 44 echo '<div class="notice notice notice-error"><p>' . esc_html__( 'The postcode is not valid', 'seur' ) . '</p></div>'; 45 exit; 46 } 47 } 43 48 if ( empty( $seur_rateprice ) ) { 44 49 $seur_rateprice = '0'; -
seur/trunk/core/pages/setting-options/advanced-settings.php
r3176965 r3261412 205 205 <input title="<?php esc_html_e( 'SEUR field description', 'seur' ); ?>" type="text" name="seur_descripcion_field" value="<?php echo esc_html( seur()->get_option( 'seur_descripcion_field' ) ); ?>" size="40" /> 206 206 <?php 207 } 208 209 210 function seur_uploads_dir_field() { 211 $uploads_dir = seur()->get_option('seur_uploads_dir'); 212 if (!file_exists($uploads_dir)) { 213 echo '<div id="seur_uploads_dir">'.esc_html('Directory not found').' 214 <button type="button" class="button" onclick="seur_create_upload_folder_ajax()">'.esc_html('Regenerate folder').'</button> 215 </div>'; 216 } else { 217 echo '<div id="seur_uploads_dir">'.esc_html($uploads_dir).'</div>'; 218 if (!is_writable($uploads_dir)) { 219 echo '<br><strong>'.esc_html('Directory is not writable').'!!!</strong>'; 220 } 221 } 207 222 } 208 223 … … 227 242 add_settings_field( 'seur_id_mercancia_field', esc_html__( 'ID of goods', 'seur' ), 'seur_id_mercancia_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' ); 228 243 add_settings_field( 'seur_descripcion_field', esc_html__( 'International description', 'seur' ), 'seur_descripcion_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' ); 244 add_settings_field( 'seur_uploads_dir', esc_html__( 'Upload directory', 'seur' ), 'seur_uploads_dir_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' ); 229 245 230 246 // register all setings. … … 244 260 register_setting( 'seur-advanced-settings-section', 'seur_id_mercancia_field' ); 245 261 register_setting( 'seur-advanced-settings-section', 'seur_descripcion_field' ); 262 register_setting( 'seur-advanced-settings-section', 'seur_uploads_dir' ); 246 263 247 264 } -
seur/trunk/core/woocommerce/includes/seur-woo-functions.php
r3254005 r3261412 21 21 return $return; 22 22 } 23 23 24 // Store cart weight in the database. 24 /********************************************* 25 * COMMENT THIS CODE WHILE WOOCOMMERCE RESOLVE THE BUG 26 * woocommerce_checkout_update_order_meta not hiring with new WC Checkout Block 27 ********************************************/ 28 /* add_action( 'woocommerce_checkout_update_order_meta', 'seur_add_cart_weight' ); 29 function seur_add_cart_weight( $order_id ) 25 add_action( 'woocommerce_update_order', 'seur_add_cart_weight_hpos' ); 26 function seur_add_cart_weight_hpos( $order_id ) 30 27 { 31 $order = new WC_Order( $order_id ); 32 33 $ship_methods = maybe_unserialize( $order->get_shipping_methods() ); 34 foreach ( $ship_methods as $ship_method ) { 35 $product_name = $ship_method['name']; 36 } 37 38 $products = seur()->get_products(); 39 foreach ( $products as $code => $product ) { 40 $custom_name = get_option($product['field'].'_custom_name_field')?get_option($product['field'].'_custom_name_field'):$code; 41 if ($custom_name == $product_name) { 42 $order->update_meta_data('_seur_shipping', 'seur' ); 43 $order->update_meta_data('_seur_shipping_method_service_real_name', $code ); 44 $order->update_meta_data('_seur_shipping_method_service', sanitize_title( $product_name ) ); 45 break; 28 if (WC()->cart) { 29 $order = new WC_Order($order_id); 30 31 $ship_methods = maybe_unserialize($order->get_shipping_methods()); 32 foreach ($ship_methods as $ship_method) { 33 $product_name = $ship_method['name']; 46 34 } 47 } 48 49 $weight = WC()->cart->cart_contents_weight; 50 $order->update_meta_data('_seur_cart_weight', $weight ); 51 $order->save_meta_data(); 52 } */ 53 /********************************************* 54 * ADDED THIS ACTION WHILE WOOCOMMERCE RESOLVE THE BUG 55 * woocommerce_checkout_update_order_meta not hiring with new WC Checkout Block 56 ********************************************/ 57 add_action( 'woocommerce_thankyou', 'seur_add_cart_weight_bis' ); 58 function seur_add_cart_weight_bis( $order_id ) 59 { 60 if (!is_numeric($order_id)) { 61 return; 62 } 63 64 $order = new WC_Order( $order_id ); 65 $ship_methods = maybe_unserialize( $order->get_shipping_methods() ); 66 foreach ( $ship_methods as $ship_method ) { 67 $product_name = $ship_method['name']; 68 } 69 70 $products = seur()->get_products(); 71 foreach ( $products as $code => $product ) { 72 $custom_name = get_option($product['field'].'_custom_name_field')?get_option($product['field'].'_custom_name_field'):$code; 73 if ($custom_name == $product_name) { 74 $order->update_meta_data('_seur_shipping', 'seur' ); 75 $order->update_meta_data('_seur_shipping_method_service_real_name', $code ); 76 $order->update_meta_data('_seur_shipping_method_service', sanitize_title( $product_name ) ); 77 break; 35 36 $products = seur()->get_products(); 37 foreach ($products as $code => $product) { 38 $custom_name = get_option($product['field'] . '_custom_name_field') ? get_option($product['field'] . '_custom_name_field') : $code; 39 if ($custom_name == $product_name) { 40 $order->update_meta_data('_seur_shipping', 'seur'); 41 $order->update_meta_data('_seur_shipping_method_service_real_name', $code); 42 $order->update_meta_data('_seur_shipping_method_service', sanitize_title($product_name)); 43 break; 44 } 78 45 } 79 } 80 81 // Compute total order weight if not computed already (by seur_add_cart_weight()) 82 if ( empty($order->get_meta('_seur_cart_weight')) ) { 83 $items = $order->get_items(); 84 $total_weight = 0.0; 85 foreach ( $items as $item ) { 86 $hidden = $item->get_meta( '_bundled_item_hidden' ); 87 // Do not add the hidden items inside the pack 88 if ( $hidden != 'yes' ) { 89 $product_quantity = $item->get_quantity(); 90 $product_weight = $item->get_product()->get_weight(); // Obtiene el peso del producto 91 $total_weight += (float) $product_weight * (float) $product_quantity; 92 } 93 } 94 95 $order->update_meta_data( '_seur_cart_weight', $total_weight ); 96 } 97 98 $order->save_meta_data(); 99 } 100 // When the event woocommerce_checkout_update_order_meta is triggered we can obtain the cart weight 101 // from Woocommerce (which should more accurate that any calculation we can perform). 102 // But the event is not triggered in all versions (see bug), so there is a second point where weight is computed (above). 46 47 $weight = WC()->cart->cart_contents_weight; 48 $order->update_meta_data('_seur_cart_weight', $weight); 49 $order->save_meta_data(); 50 } 51 } 103 52 add_action('woocommerce_checkout_update_order_meta', 'seur_add_cart_weight'); 104 53 function seur_add_cart_weight( $order_id ) { … … 133 82 global $post; 134 83 if ( $column == 'total_weight' ) { 135 $weight = get_post_meta( $post->ID, '_seur_cart_weight', true ); 84 $weight = get_post_meta( $post->ID, '_seur_cart_weight', true ) ?: 85 get_post_meta($post->ID, '_seur_shipping_weight', true); 136 86 if ( $weight > 0 ) { 137 87 print esc_html( $weight ) . ' ' . esc_attr( get_option( 'woocommerce_weight_unit' ) ); … … 143 93 function seur_custom_order_weight_column_hpos( $column, $order) { 144 94 if ( $column == 'total_weight' ) { 145 $weight = $order->get_meta( '_seur_cart_weight', true ); 95 $weight = $order->get_meta( '_seur_cart_weight', true ) ?: 96 $order->get_meta('_seur_shipping_weight', true); 146 97 if ( $weight > 0 ) { 147 98 print esc_html( $weight ) . ' ' . esc_attr( get_option( 'woocommerce_weight_unit' ) ); … … 313 264 $action = $wp_list_table->current_action(); 314 265 315 if ( ! isset( $_REQUEST['id'] ) ) { 266 if (isset($_REQUEST['id'])) { 267 $post_ids = array_map( 'absint', (array) $_REQUEST['id'] ); 268 } 269 if (isset($_REQUEST['post'])) { 270 $post_ids = array_map( 'absint', (array) $_REQUEST['post'] ); 271 } 272 if (!isset($post_ids)) { 316 273 return; 317 274 } 318 275 319 $post_ids = array_map( 'absint', (array) $_REQUEST['id'] );320 276 $report_action = 'marked_seur-createlabel'; 321 277 -
seur/trunk/languages/seur-es_ES.po
r3159775 r3261412 1471 1471 #: core/pages/rates/seur-country-state-process.php:103 1472 1472 msgid "EX : State" 1473 msgstr "Ej: Estado"1473 msgstr "Ej: Provincia" 1474 1474 1475 1475 #: core/pages/rates/seur-country-state-process.php:69 1476 1476 msgid "Type State" 1477 msgstr "Escribir estado"1477 msgstr "Escribir Provincia" 1478 1478 1479 1479 #: core/pages/rates/seur-country-state-process.php:62 … … 1481 1481 #: core/pages/rates/seur-edit-form.php:128 1482 1482 msgid "All States" 1483 msgstr "Tod os los estados"1483 msgstr "Todas las provincias" 1484 1484 1485 1485 #: core/pages/rates/seur-country-state-process.php:61 … … 1489 1489 #: core/pages/rates/seur-edit-form.php:127 1490 1490 msgid "Select State" 1491 msgstr "Selecciona un Estado"1491 msgstr "Selecciona una Provincia" 1492 1492 1493 1493 #: core/pages/rates/seur-country-state-process.php:39 … … 1558 1558 #: core/pages/rates/seur-edit-form.php:145 1559 1559 msgid "State" 1560 msgstr " Estado"1560 msgstr "Provincia" 1561 1561 1562 1562 #: core/pages/rates/seur-add-form.php:67 … … 1744 1744 #: core/menu/menu.php:69 1745 1745 msgid "Process Country State" 1746 msgstr "Procesar pays estado"1746 msgstr "Procesar País Provincia" 1747 1747 1748 1748 #: core/menu/menu.php:68 -
seur/trunk/loader.php
r3254005 r3261412 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.2 16 * Version: 2.2.22 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.2 1' );23 define( 'SEUR_DB_VERSION', '1.0. 4' );22 define( 'SEUR_OFFICIAL_VERSION', '2.2.22' ); 23 define( 'SEUR_DB_VERSION', '1.0.5' ); 24 24 define( 'SEUR_TABLE_VERSION', '1.0.5' ); 25 25 -
seur/trunk/readme.txt
r3254005 r3261412 4 4 Requires at least: 4.0 5 5 Tested up to: 6.6.2 6 Stable tag: 2.2.2 16 Stable tag: 2.2.22 7 7 WC requires at least: 3.0 8 8 WC tested up to: 9.1.4 … … 93 93 94 94 == Changelog == 95 96 == 2.2.22 == 97 98 * ADDED: Regenerate seur uploads dir option in settings 99 * ADDED: Add zip ranges feature 100 * FIXED: Fix no hpos orders to is_seur_order 101 * FIXED: Fix hpos labels weight 102 * FIXED: Fix bulk create label post legacy 95 103 96 104 == 2.2.21 ==
Note: See TracChangeset
for help on using the changeset viewer.