Changeset 3382654
- Timestamp:
- 10/22/2025 01:52:33 PM (5 months ago)
- Location:
- seur/trunk
- Files:
-
- 19 edited
-
classes/class-seur-global.php (modified) (9 diffs)
-
classes/class-seur-seguimiento.php (modified) (1 diff)
-
core/functions/functions.php (modified) (16 diffs)
-
core/installer.php (modified) (4 diffs)
-
core/labels-cpt/labels-cpt.php (modified) (1 diff)
-
core/pages/rates/seur-country-state-process.php (modified) (1 diff)
-
core/pages/rates/seur-rates.php (modified) (5 diffs)
-
core/pages/setting-options/advanced-settings.php (modified) (4 diffs)
-
core/pages/setting-options/user-settings.php (modified) (3 diffs)
-
core/pages/seur-get-labels.php (modified) (2 diffs)
-
core/pages/seur-nomenclator.php (modified) (5 diffs)
-
core/pages/seur-settings.php (modified) (1 diff)
-
core/pages/status/status-check.php (modified) (4 diffs)
-
core/woocommerce/includes/class-seur_local_shipping_method.php (modified) (5 diffs)
-
core/woocommerce/includes/class-wc-shipping-seur.php (modified) (1 diff)
-
core/woocommerce/includes/seur-woo-functions.php (modified) (1 diff)
-
loader.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
seur/trunk/classes/class-seur-global.php
r3312581 r3382654 10 10 exit; // Exit if accessed directly. 11 11 } 12 12 if ( ! class_exists( 'Seur_Global' ) ) { 13 13 class Seur_Global { 14 14 … … 18 18 private $log; 19 19 20 public function __construct() { 21 $this->log = new WC_Logger(); 22 } 20 private static $instance = null; 21 22 public static function get_instance() { 23 if ( self::$instance === null ) { 24 self::$instance = new self(); 25 } 26 return self::$instance; 27 } 28 29 private function __construct() { 30 $this->log = new WC_Logger(); 31 } 23 32 24 33 public function get_ownsetting() { … … 492 501 } 493 502 494 $preparedData['notification'] = $preparedData['reparto_notificar']; // CORRECTO ?495 $preparedData['advice_checkbox'] = $preparedData['preaviso_notificar'];496 $preparedData['distribution_checkbox'] = $preparedData['tipo_aviso'];497 503 $preparedData['servicio'] = $servicio; 498 504 $preparedData['producto'] = $producto; … … 555 561 "idNumber" => $preparedData['nif'], 556 562 "phone" => $preparedData['telefono'], 557 "accountNumber" => $preparedData[' ccc'].'-'.$preparedData['franquicia'],563 "accountNumber" => $preparedData['accountNumber'], 558 564 "email" => $preparedData['email'], 559 565 "contactName" => $preparedData['contacto_nombre'] . ' ' . $preparedData['contacto_apellidos'], … … 1001 1007 $parcelNumbers = $response['data']['parcelNumbers']; 1002 1008 1003 $this->log->log(WC_Log_Levels::INFO, "getLabel OK ");1009 $this->log->log(WC_Log_Levels::INFO, "getLabel OK - order: $order_id - weight: ".$label_data['customer_weight_kg']." - packages: ".$label_data['total_bultos']." - expeditionCode: $expeditionCode"); 1004 1010 return [ 1005 1011 'status' => true, … … 1113 1119 1114 1120 1115 public function getCountries($countries ) {1121 public function getCountries($countries, $minimal = false) { 1116 1122 $allCountries = seur_get_countries(); 1117 1123 $aroundESCountries = seur_get_countries_around_ES(); 1118 1124 $UECountries = seur_get_countries_EU(); 1119 1125 if ($countries[0] == 'OUT-EU') { 1126 if ($minimal) { 1127 return ['*' => '*']; 1128 } 1120 1129 return array_diff($allCountries, $UECountries); 1121 1130 } 1122 1131 if ($countries[0] == 'INTERNATIONAL') { 1132 if ($minimal) { 1133 return ['*' => '*']; 1134 } 1123 1135 return $allCountries; 1124 1136 } … … 1131 1143 } 1132 1144 1133 public function getStates( $country, $states ) {1145 public function getStates( $country, $states, $minimal = false ) { 1134 1146 1135 1147 $country_states = seur_get_countries_states($country); 1136 1148 if (!$country_states) { 1149 if ($minimal) { 1150 return ['*' => '*']; 1151 } 1137 1152 return false; 1138 1153 } … … 1140 1155 foreach ($states as $state) { 1141 1156 if ($state == 'all') { 1157 if ($minimal) { 1158 return ['*' => '*']; 1159 } 1142 1160 $result = $country_states; 1143 1161 } else { 1144 $result[$state] = $country_states[$state];1162 $result[$state] = ($minimal) ? $state : $country_states[$state]; 1145 1163 } 1146 1164 } … … 1203 1221 } 1204 1222 } 1205 1206 function seur() {1207 return new Seur_Global();1208 1223 } 1224 if ( ! function_exists( 'seur' ) ) { 1225 function seur() { 1226 return Seur_Global::get_instance(); 1227 } 1228 } -
seur/trunk/classes/class-seur-seguimiento.php
r3283287 r3382654 57 57 $this->reftype = 'REFERENCE'; 58 58 $this->full_account_number = seur()->get_option( 'seur_accountnumber_field' ); 59 $this->accoun_number = substr( $this->full_account_number, 0, strpos( $this->full_account_number, '-' ) );60 $this->business_unit = s eur()->get_option( 'seur_franquicia_field');59 $this->accoun_number = substr( $this->full_account_number, 0, strpos( $this->full_account_number, '-' ) ); 60 $this->business_unit = substr( $this->full_account_number, strpos( $this->full_account_number, '-' ) + 1 ); 61 61 } 62 62 -
seur/trunk/core/functions/functions.php
r3283287 r3382654 466 466 */ 467 467 function seur_get_countries() { 468 $countries = array(); 469 if ( ! $countries ) { 470 $countries = include_once SEUR_PLUGIN_PATH . 'core/places/countries.php'; 471 } 472 asort( $countries ); 468 $countries = include_once SEUR_PLUGIN_PATH . 'core/places/countries.php'; 469 asort( $countries ); 473 470 return $countries; 474 471 } … … 792 789 $seur_contacto_apellidos_field = ''; 793 790 } 794 if ( get_option( 'seur_ccc_field' ) ) { 795 $seur_ccc_field = get_option( 'seur_ccc_field' ); 796 } else { 797 $seur_ccc_field = ''; 798 } 799 if ( get_option( 'seur_int_ccc_field' ) ) { 800 $seur_int_ccc_field = get_option( 'seur_int_ccc_field' ); 801 } else { 802 $seur_int_ccc_field = ''; 803 } 804 if ( get_option( 'seur_franquicia_field' ) ) { 805 $seur_franquicia_field = get_option( 'seur_franquicia_field' ); 806 } else { 807 $seur_franquicia_field = ''; 808 } 791 if ( get_option( 'seur_accountNumber_field' ) ) { 792 $accountNumber = get_option( 'seur_accountNumber_field' ); 793 } else { 794 $accountNumber = ''; 795 } 809 796 if ( $seur_pais_field ) { 810 797 if ( 'ES' === $seur_pais_field ) { … … 836 823 'contacto_nombre', 837 824 'contacto_apellidos', 838 'ccc', 839 'int_ccc', 840 'franquicia', 825 'accountNumber', 841 826 ); 842 827 … … 858 843 $seur_contacto_nombre_field, 859 844 $seur_contacto_apellidos_field, 860 $seur_ccc_field, 861 $seur_int_ccc_field, 862 $seur_franquicia_field, 845 $accountNumber, 863 846 ); 864 847 $seur_user_settings[] = array_combine( $option, $value ); … … 874 857 $seur_advanced_settings = array(); 875 858 876 if ( get_option( 'seur_preaviso_notificar_field' ) ) {877 $seur_preaviso_notificar_field = get_option( 'seur_preaviso_notificar_field' );878 } else {879 $seur_preaviso_notificar_field = ''; }880 if ( get_option( 'seur_reparto_notificar_field' ) ) {881 $seur_reparto_notificar_field = get_option( 'seur_reparto_notificar_field' );882 } else {883 $seur_reparto_notificar_field = ''; }884 if ( get_option( 'seur_tipo_notificacion_field' ) ) {885 $seur_tipo_notificacion_field = get_option( 'seur_tipo_notificacion_field' );886 } else {887 $seur_tipo_notificacion_field = ''; }888 859 if ( get_option( 'seur_tipo_etiqueta_field' ) ) { 889 860 $seur_tipo_etiqueta_field = get_option( 'seur_tipo_etiqueta_field' ); … … 910 881 } else { 911 882 $seur_descripcion_field = ''; } 912 if ( get_option( 'seur_activate_geolabel_field' ) ) {913 $seur_activate_geolabel_field = get_option( 'seur_activate_geolabel_field' );914 } else {915 $seur_activate_geolabel_field = ''; }916 883 917 884 $option = array( 918 'preaviso_notificar',919 'reparto_notificar',920 'tipo_notificacion',921 885 'tipo_etiqueta', 922 886 'aduana_origen', … … 925 889 'id_mercancia', 926 890 'descripcion', 927 'geolabel',928 891 ); 929 892 $value = array( 930 $seur_preaviso_notificar_field,931 $seur_reparto_notificar_field,932 $seur_tipo_notificacion_field,933 893 $seur_tipo_etiqueta_field, 934 894 $seur_aduana_origen_field, … … 937 897 $seur_id_mercancia_field, 938 898 $seur_descripcion_field, 939 $seur_activate_geolabel_field,940 899 ); 941 900 … … 1325 1284 $preparedData['mobile_shipping'] = cleanPhone($order->get_meta('_shipping_mobile_phone', true )); 1326 1285 $preparedData['mobile_billing'] = cleanPhone($order->get_meta('_billing_mobile_phone', true )); 1327 $preparedData['log'] = new WC_Logger();1328 1286 1329 1287 // All needed Data return Array. … … 1356 1314 $preparedData['contacto_apellidos'] = $user_data[0]['contacto_apellidos']; 1357 1315 $preparedData['nif'] = $user_data[0]['nif']; 1358 $preparedData['franquicia'] = $user_data[0]['franquicia']; 1359 $preparedData['nat_ccc'] = $user_data[0]['ccc']; 1360 $preparedData['int_ccc'] = $user_data[0]['int_ccc']; 1316 $preparedData['accountNumber'] = $user_data[0]['accountNumber']; 1317 $preparedData['ccc'] = substr($user_data[0]['accountNumber'], 0, strpos($user_data[0]['accountNumber'],'-')); 1361 1318 1362 1319 $paisgl = $user_data[0]['pais']; … … 1371 1328 1372 1329 // Advanced User Settings. 1373 $preparedData['geolabel'] = $advanced_data[0]['geolabel'];1374 1330 $preparedData['aduana_origen'] = $advanced_data[0]['aduana_origen']; 1375 1331 $preparedData['aduana_destino'] = $advanced_data[0]['aduana_destino']; … … 1378 1334 $preparedData['descripcion'] = $advanced_data[0]['descripcion']; 1379 1335 $preparedData['tipo_etiqueta'] = $advanced_data[0]['tipo_etiqueta']; 1380 1381 $preaviso_notificar = $advanced_data[0]['preaviso_notificar']==='1'?'S':'N';1382 $reparto_notificar = $advanced_data[0]['reparto_notificar']==='1'?'S':'N';1383 $tipo_aviso = $advanced_data[0]['tipo_notificacion'];1384 1385 $preaviso_sms = 'N';1386 if ( 'SMS' === $tipo_aviso && 'S' === $preaviso_notificar ) {1387 $preaviso_sms = 'S';1388 }1389 $reparto_sms = 'N';1390 if ( 'SMS' === $tipo_aviso && 'S' === $reparto_notificar ) {1391 $reparto_sms = 'S';1392 }1393 $preaviso_email = 'N';1394 if ( 'EMAIL' === $tipo_aviso && 'S' === $preaviso_notificar ) {1395 $preaviso_email = 'S';1396 }1397 $reparto_email = 'N';1398 if ( 'EMAIL' === $tipo_aviso && 'S' === $reparto_notificar ) {1399 $reparto_email = 'S';1400 }1401 if ( 'both' === $tipo_aviso && 'S' === $preaviso_notificar ) {1402 $preaviso_email = 'S';1403 $preaviso_sms = 'S';1404 } else {1405 $preaviso_email = 'N';1406 $preaviso_sms = 'N';1407 }1408 if ( 'both' === $tipo_aviso && 'S' === $reparto_notificar ) {1409 $reparto_email = 'S';1410 $reparto_sms = 'S';1411 } else {1412 $reparto_email = 'N';1413 $reparto_sms = 'N';1414 }1415 $preparedData['preaviso_notificar'] = $preaviso_notificar;1416 $preparedData['reparto_notificar'] = $reparto_notificar;1417 $preparedData['tipo_aviso'] = $tipo_aviso;1418 $preparedData['preaviso_sms'] = $preaviso_sms;1419 $preparedData['preaviso_email'] = $preaviso_email;1420 $preparedData['reparto_email'] = $reparto_email;1421 $preparedData['reparto_sms'] = $reparto_sms;1422 1336 1423 1337 // Customer/Order Data. … … 1437 1351 $preparedData['order_pay_method'] = seur_clean_data( $order_data[0]['order_pay_method'] ); 1438 1352 1439 if ( 'ES' === $customer_country || 'AD' === $customer_country || 'PT' === $customer_country ) {1440 $preparedData['ccc'] = $preparedData['nat_ccc'];1441 } else {1442 $preparedData['ccc'] = $preparedData['int_ccc'];1443 }1444 1445 1353 if ( $post_weight ) { 1446 1354 $preparedData['customer_weight_kg'] = seur_always_kg( $weight ); … … 1511 1419 } 1512 1420 1513 $preaviso_notificar_geo = 'N';1514 if ( 'S' === $preaviso_notificar ) {1515 $preaviso_notificar_geo = 'S';1516 }1517 $reparto_notificar_geo = 'N';1518 if ( 'S' === $reparto_notificar ) {1519 $reparto_notificar_geo = 'S';1520 }1521 $seur_tcheck_geo = '';1522 $seur_sms = 'N';1523 if ( 'S' === $preaviso_sms || 'S' === $reparto_sms ) {1524 $seur_tcheck_geo = '1';1525 $seur_sms = 'S';1526 }1527 $seur_email_geo = '';1528 if ( 'S' === $preaviso_email || 'S' === $reparto_email ) {1529 $seur_email_geo = '3';1530 }1531 1532 if ( '1' === $seur_tcheck_geo && '3' === $seur_email_geo ) {1533 $seur_email_geo = '4';1534 $seur_tcheck_geo = '';1535 }1536 1537 1421 $mobile_billing = $preparedData['mobile_billing']; 1538 1422 $mobile_shipping = $preparedData['mobile_shipping']; 1539 if ( ( $mobile_shipping || $mobile_billing ) ) {1540 $seur_sms_mobile_geo = $mobile_billing;1541 if ( $mobile_shipping ) {1542 $seur_sms_mobile_geo = $mobile_shipping;1543 }1544 } else {1545 $seur_tcheck_geo = 'N';1546 $seur_sms_mobile_geo = '';1547 $seur_sms = 'N';1548 $seur_sms_mobile = '';1549 }1550 1423 1551 1424 if ( $order_data[0]['code_centro_2shop'] ) { 1552 $reparto_notificar = 'N';1553 $preaviso_notificar = 'N';1554 1425 $preparedData['seur_email'] = 'N'; 1555 1426 $preparedData['customer_phone'] = $mobile_billing; 1556 1427 } 1557 $preparedData['preaviso_notificar_geo'] = $preaviso_notificar_geo;1558 $preparedData['reparto_notificar_geo'] = $reparto_notificar_geo;1559 $preparedData['seur_tcheck_geo'] = $seur_tcheck_geo;1560 $preparedData['seur_email_geo'] = $seur_email_geo;1561 $preparedData['seur_sms_mobile_geo'] = $seur_sms_mobile_geo;1562 $preparedData['seur_sms'] = $seur_sms;1563 $preparedData['seur_sms_mobile'] = $seur_sms_mobile??$seur_sms_mobile_geo;1564 $preparedData['reparto_notificar'] = $reparto_notificar;1565 $preparedData['preaviso_notificar'] = $preaviso_notificar;1566 1567 1428 $log->add( 'seur', 'preparedData: ' . print_r( $preparedData, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r 1568 1429 … … 1699 1560 1700 1561 if (!seur()->updateShipment($shipmentData)) { 1701 wp_redirect(wp_get_raw_referer()); 1702 exit; 1562 return false; 1703 1563 } 1704 1564 return true; … … 1810 1670 $order->update_meta_data('_seur_shipping_weight', $weight); 1811 1671 $order->update_meta_data('_seur_cart_weight', $weight); 1672 seur()->slog( "seur_get_order_weight() -> _seur_cart_weight: $weight - order:". $order->get_id()); 1812 1673 $order->save_meta_data(); 1813 1674 if ($label_ids) { 1814 1675 update_post_meta($label_ids[0], '_seur_shipping_weight', $weight); 1676 seur()->slog("seur_get_order_weight() -> _seur_shipping_weight: $weight - label:". $label_ids[0]); 1815 1677 } 1816 1678 } -
seur/trunk/core/installer.php
r3283287 r3382654 11 11 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 12 12 require_once(dirname(__FILE__) . '/functions/functions.php'); 13 require_once(SEUR_PLUGIN_PATH . 'classes/class-seur-global.php'); 13 14 14 15 function deleteTableSeurSpvr() { … … 544 545 } 545 546 547 function insertFreeSeurCustomRates() 548 { 549 global $wpdb; 550 $table_name = $wpdb->prefix . 'seur_custom_rates'; 551 $wpdb->query('START TRANSACTION'); 552 553 $file = SEUR_PLUGIN_PATH . 'data/seur_preloaded_rates.csv'; 554 if (($h = fopen($file, 'r')) !== false) { 555 while (($row = fgetcsv($h)) !== false) { 556 list($id,$type,$country,$state,$postcode,$minp,$maxp,$minw,$maxw,$rate,$rateprice) = $row; 557 $wpdb->replace($table_name, [ 558 'ID' => (int) $id, 559 'type' => (string) $type, 560 'country' => (string) $country, 561 'state' => (string) $state, 562 'postcode' => (string) $postcode, 563 'minprice' => (float) $minp, 564 'maxprice' => (float) $maxp, 565 'minweight' => (float) $minw, 566 'maxweight' => (float) $maxw, 567 'rate' => (string) $rate, 568 'rateprice' => (float) $rateprice, 569 ], ['%d','%s','%s','%s','%s','%f','%f','%f','%f','%s','%f']); 570 } 571 fclose($h); 572 } 573 574 $wpdb->query('COMMIT'); 575 } 576 546 577 function insertIntoSeurCustomRates() { 547 578 global $wpdb; … … 795 826 796 827 if ( ! $seur_table_version_saved || '' === $seur_table_version_saved ) { 797 insertIntoSeurCustomRates(); 828 //insertIntoSeurCustomRates(); 829 insertFreeSeurCustomRates(); 798 830 } 799 831 if ( $seur_table_version_saved && ($seur_table_version_saved !== '1.0.4') && ( SEUR_TABLE_VERSION === '1.0.4') ) { … … 876 908 if ( ! $seur_add ) { 877 909 update_option( 'seur_after_get_label_field', 'shipping' ); 878 update_option( 'seur_preaviso_notificar_field', null );879 update_option( 'seur_reparto_notificar_field', null );880 update_option( 'seur_tipo_notificacion_field', 'EMAIL' );881 910 update_option( 'seur_tipo_etiqueta_field', 'PDF' ); 882 911 update_option( 'seur_aduana_origen_field', 'D' ); -
seur/trunk/core/labels-cpt/labels-cpt.php
r3283287 r3382654 496 496 foreach ($merchants as $ccc => $orders) 497 497 { 498 $manifest['ccc'] = $ccc; 498 $accountNumber = get_option('seur_accountNumber_field'); 499 $manifest['ccc'] = substr( $accountNumber, 0, strpos( $accountNumber, '-' ) ); 499 500 $manifest['company'] = get_option( 'seur_empresa_field' ); 500 501 $manifest['cif']= get_option( 'seur_nif_field' ); 501 $manifest['franchise'] = get_option( 'seur_franquicia_field');502 $manifest['franchise'] = substr( $accountNumber, strpos( $accountNumber, '-' ) + 1 ); 502 503 $manifest['street_type'] = get_option( 'seur_viatipo_field' ); 503 504 $manifest['street_name'] = get_option( 'seur_vianombre_field' ); -
seur/trunk/core/pages/rates/seur-country-state-process.php
r3183810 r3382654 48 48 $placeholder = 'EX : State'; 49 49 $value = ''; 50 $readonly = ''; 50 51 if ( '*' === $country) { 51 52 $title = 'No needed'; 52 53 $placeholder = 'No needed'; 53 $value = 'value="*" readonly'; 54 $value = '*'; 55 $readonly = 'readonly'; 54 56 } 55 57 echo '<input title="' . esc_html( $title ) . '" type="text" name="state" 56 class="form-control" placeholder="' . esc_html( $placeholder ) . '" value="' . esc_attr( $value ) . '">'; 57 58 58 class="form-control" placeholder="' . esc_html( $placeholder ) .'" 59 value="' . esc_attr( $value ) . '" '.$readonly.'>'; 59 60 } 60 61 unset( $country ); -
seur/trunk/core/pages/rates/seur-rates.php
r3176965 r3382654 36 36 $kilos = ''; 37 37 } 38 if ( isset( $_POST[' pais'] ) ) {39 $pais = trim( sanitize_text_field( wp_unslash( $_POST[' pais'] ) ) );38 if ( isset( $_POST['seur_country'] ) ) { 39 $pais = trim( sanitize_text_field( wp_unslash( $_POST['seur_country'] ) ) ); 40 40 } else { 41 41 $pais = ''; … … 72 72 <label> 73 73 <span class="screen-reader-text"><?php esc_html_e( 'Country', 'seur' ); ?></span> 74 <select class="select country" id=" country" title="<?php esc_html_e( 'Select Country', 'seur' ); ?>" name="pais" required>74 <select class="select country" id="seur_country" title="<?php esc_html_e( 'Select Country', 'seur' ); ?>" name="seur_country" required> 75 75 <?php 76 76 if ( ! empty( $pais ) && 'ES' === $pais ) { … … 146 146 </label> 147 147 </div> 148 148 149 <?php 149 150 if ( isset( $_POST['seur_rates_seur_nonce_field'] ) ) { … … 172 173 173 174 if ( isset( $_POST['seur_rates_seur_nonce_field'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['seur_rates_seur_nonce_field'] ) ), 'seur_rates_seur' ) ) { 174 // *****************************************175 // ** RECUPERAR LOS DATOS DEL COMERCIANTE **176 // *****************************************177 $useroptions = seur_get_user_settings();178 $advancedoptions = seur_get_advanced_settings();179 $ccc = $useroptions[0]['ccc'];180 $int_ccc = $useroptions[0]['int_ccc'];181 $franquicia = $useroptions[0]['franquicia'];182 175 183 176 if ( ( 'ES' === $pais ) || ( 'PT' === $pais ) || ( 'AD' === $pais ) ) { … … 186 179 'postalCode' => $postal 187 180 ]; 188 if ( false === seur()->seur_api_check_city( $datos ) ) { 181 $result = seur()->seur_api_check_city( $datos ); 182 if ( $result === false ) { 189 183 echo "<hr><b><font color='#e53920'>"; 190 184 echo '<br>Código postal y país no se han encontrado en Nomenclator de SEUR.<br>Consulte Nomenclator y ajuste ambos parámetros.<br></font>'; 191 185 echo "<font color='#0074a2'><br>Par no Encontrado:<br>" . esc_html( $postal ) . ' - ' . esc_html( $pais ); 192 186 return; 193 } 194 } else { 195 $postal = '08023'; 196 $poblacion = 'BARCELONA'; 187 } else { 188 //print_r($result); 189 } 197 190 } 198 $mensaje = '';199 $products = seur()->get_products();200 foreach ( $products as $code => $product ) {201 if ($product['product']==$producto && $product['service']==$servicio) {202 $mensaje .= '<br>' . $code;203 break;204 }205 }206 if ( strlen( $mensaje ) < 1 ) {207 $mensaje .= '<br>Servicio Producto sin IDENTIFICAR';208 }209 210 /*211 $consulta = '';212 $sc_options = array(213 'connection_timeout' => 30,214 );215 $cliente = new SoapClient( 'https://ws.seur.com/WSEcatalogoPublicos/servlet/XFireServlet/WSServiciosWebPublicos?wsdl', $sc_options );216 $parametros = array(217 'in0' => $consulta,218 );219 $respuesta = $cliente->tarificacionPrivadaStr( $parametros );220 221 if ( empty( $respuesta->out ) || ( isset( $respuesta->error ) && ! empty( $respuesta->error ) ) ) {222 */223 echo '<div class="error notice"><p>';224 esc_html_e( 'There was an error getting rate.', 'seur' );225 echo '<br>'; esc_html_e( 'Deprecated SOAP Service.', 'seur' );226 echo '</p>';227 echo '</div>';228 return;229 /* } else {230 $xml = simplexml_load_string( $respuesta->out );231 $lineasantes = ( $xml->attributes()->NUM );232 $lineas = (int) $lineasantes - 1;233 $total = 0;234 235 ?>236 <table width='25%' style='color:ed734d;font-weight:bold; font-size:14px;'>237 <tr>238 <td colspan='2'>239 <hr>240 </td>241 </tr>242 <?php243 while ( -1 !== $lineas ) {244 $nom_concept_imp = (string) $xml->REG[ $lineas ]->NOM_CONCEPTO_IMP; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase245 $valor = $xml->REG[ $lineas ]->VALOR; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase246 $total = $total + (float) $xml->REG[ $lineas ]->VALOR; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase247 echo '<tr>';248 echo '<td>' . utf8_decode( $nom_concept_imp ) . '</td>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped249 echo "<td style='text-align:right'>" . esc_html( $valor ) . '</td>';250 --$lineas;251 echo '</tr>';252 }253 echo "<tr><td colspan=2><hr></td><tr><td>Total</td><td style='text-align:right;color:red;font-weight:bold; font-size:20px;'>" . esc_html( $total ) . '</td></tr></table>';254 echo '<br>' . esc_html( $mensaje ) . '<br><br>';255 ?>256 </table>257 <?php258 return;259 } */260 191 } 261 192 ?> -
seur/trunk/core/pages/setting-options/advanced-settings.php
r3312581 r3382654 11 11 12 12 /** 13 * SEUR active geolabel14 */15 function seur_activate_geolabel_field() {16 ?>17 <input type="checkbox" class="js-switch-geolabel" title="<?php esc_html_e( 'Activate GeoLabel', 'seur' ); ?>" name="seur_activate_geolabel_field" value="1" <?php checked( 1, seur()->get_option( 'seur_activate_geolabel_field' ), true ); ?>/>18 <?php19 }20 21 /**22 13 * SEUR active local pickup 23 14 */ … … 65 56 ?> 66 57 ><?php esc_html_e( 'Mark as Complete', 'seur' ); ?></option> 67 </select>68 <?php69 }70 71 /**72 * SEUR preaviso notificar73 */74 function seur_preaviso_notificar_field() {75 ?>76 <input type="checkbox" class="js-switch-preavisonotificar" title="<?php esc_html_e( 'SEUR field description', 'seur' ); ?>" name="seur_preaviso_notificar_field" value="1" <?php checked( 1, seur()->get_option( 'seur_preaviso_notificar_field' ), true ); ?>/>77 <?php78 }79 80 /**81 * SEUR reparto notificar82 */83 function seur_reparto_notificar_field() {84 ?>85 <input type="checkbox" class="js-switch-repartonotificar" title="<?php esc_html_e( 'SEUR field description', 'seur' ); ?>" name="seur_reparto_notificar_field" value="1" <?php checked( 1, seur()->get_option( 'seur_reparto_notificar_field' ), true ); ?>/>86 <?php87 }88 89 /**90 * SEUR tipo notificacion91 */92 function seur_tipo_notificacion_field() {93 94 $option = seur()->get_option( 'seur_tipo_notificacion_field' );95 ?>96 <select id="notification_type" name="seur_tipo_notificacion_field">97 <option value="SMS"98 <?php99 if ( 'SMS' === $option ) {100 echo ' selected';}101 ?>102 ><?php esc_html_e( 'SMS (this option has an extra cost)', 'seur' ); ?></option>103 <option value="EMAIL"104 <?php105 if ( 'EMAIL' === $option ) {106 echo ' selected';}107 ?>108 ><?php esc_html_e( 'Email', 'seur' ); ?></option>109 <option value="both"110 <?php111 if ( 'both' === $option ) {112 echo ' selected';}113 ?>114 ><?php esc_html_e( 'Both (this option has an extra cost)', 'seur' ); ?></option>115 58 </select> 116 59 <?php … … 237 180 238 181 add_settings_section( 'seur-advanced-settings-section', null, null, 'seur-advanced-settings-options' ); 239 add_settings_field( 'seur_activate_geolabel_field', esc_html__( 'Activate GeoLabel', 'seur' ), 'seur_activate_geolabel_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' );240 182 add_settings_field( 'seur_activate_free_shipping_field', esc_html__( 'Show WooCommerce Free Shipping at Checkout (by default SEUR hide the Free Shipping)', 'seur' ), 'seur_activate_free_shipping_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' ); 241 183 add_settings_field( 'seur_after_get_label_field', esc_html__( 'What to do after get order label', 'seur' ), 'seur_after_get_label_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' ); 242 184 add_settings_field( 'seur_activate_local_pickup_field', esc_html__( 'Activate Local Pickup', 'seur' ), 'seur_activate_local_pickup_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' ); 243 185 add_settings_field( 'seur_google_maps_api_field', esc_html__( 'Google Maps API Key', 'seur' ), 'seur_google_maps_api_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' ); 244 add_settings_field( 'seur_preaviso_notificar_field', esc_html__( 'Notify collection', 'seur' ), 'seur_preaviso_notificar_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' );245 add_settings_field( 'seur_reparto_notificar_field', esc_html__( 'Notify distribution', 'seur' ), 'seur_reparto_notificar_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' );246 add_settings_field( 'seur_tipo_notificacion_field', esc_html__( 'Notifications by SMS or Email', 'seur' ), 'seur_tipo_notificacion_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' );247 186 add_settings_field( 'seur_tipo_etiqueta_field', esc_html__( 'Type of label', 'seur' ), 'seur_tipo_etiqueta_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' ); 248 187 add_settings_field( 'seur_aduana_origen_field', esc_html__( 'Customs of origin', 'seur' ), 'seur_aduana_origen_field', 'seur-advanced-settings-options', 'seur-advanced-settings-section' ); … … 254 193 255 194 // register all setings. 256 register_setting( 'seur-advanced-settings-section', 'seur_activate_geolabel_field', [ 'sanitize_callback' => 'rest_sanitize_boolean' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known257 195 register_setting( 'seur-advanced-settings-section', 'seur_activate_free_shipping_field', [ 'sanitize_callback' => 'rest_sanitize_boolean' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known 258 register_setting( 'seur-advanced-settings-section', 'seur_preaviso_notificar_field', [ 'sanitize_callback' => 'rest_sanitize_boolean' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known259 196 register_setting( 'seur-advanced-settings-section', 'seur_activate_local_pickup_field', [ 'sanitize_callback' => 'rest_sanitize_boolean' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known 260 197 register_setting( 'seur-advanced-settings-section', 'seur_after_get_label_field', [ 'sanitize_callback' => 'sanitize_text_field' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known 261 register_setting( 'seur-advanced-settings-section', 'seur_reparto_notificar_field', [ 'sanitize_callback' => 'rest_sanitize_boolean' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known262 198 263 199 register_setting( 'seur-advanced-settings-section', 'seur_google_maps_api_field', [ 'sanitize_callback' => 'sanitize_text_field' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known 264 register_setting( 'seur-advanced-settings-section', 'seur_tipo_notificacion_field', [ 'sanitize_callback' => 'sanitize_text_field' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known265 200 register_setting( 'seur-advanced-settings-section', 'seur_tipo_etiqueta_field', [ 'sanitize_callback' => 'sanitize_text_field' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known 266 201 register_setting( 'seur-advanced-settings-section', 'seur_tipo_mercancia_field', [ 'sanitize_callback' => 'sanitize_text_field' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known -
seur/trunk/core/pages/setting-options/user-settings.php
r3283287 r3382654 281 281 ?> 282 282 <input title="<?php esc_html_e( 'Contact Surnames', 'seur' ); ?>" type="text" name="seur_contacto_apellidos_field" value="<?php echo esc_html( seur()->get_option( 'seur_contacto_apellidos_field' ) ); ?>" size="40" /> 283 <?php284 }285 286 /**287 * SEUR CCC288 */289 function seur_ccc_field() {290 ?>291 <input title="<?php esc_html_e( 'Country Account Code with SEUR (given by SEUR)', 'seur' ); ?>" type="text" name="seur_ccc_field" value="<?php echo esc_html( seur()->get_option( 'seur_ccc_field' ) ); ?>" size="40" maxlength="5" />292 <?php293 }294 295 /**296 * SEUR CCC Internacional297 */298 function seur_int_ccc_field() {299 ?>300 <input title="<?php esc_html_e( 'International Account Code with SEUR (given by SEUR)', 'seur' ); ?>" type="text" name="seur_int_ccc_field" value="<?php echo esc_html( seur()->get_option( 'seur_int_ccc_field' ) ); ?>" size="40" maxlength="5" />301 <?php302 }303 304 /**305 * SEUR franquicia306 */307 function seur_franquicia_field() {308 ?>309 <input title="<?php esc_html_e( 'Two-digit numeric code (given by SEUR)', 'seur' ); ?>" type="text" name="seur_franquicia_field" value="<?php echo esc_html( seur()->get_option( 'seur_franquicia_field' ) ); ?>" size="40" maxlength="2" />310 283 <?php 311 284 } … … 342 315 add_settings_field( 'seur_client_id_field', __( 'Client id<sup>*</sup>', 'seur' ), 'seur_client_id_field', 'seur-user-settings-options', 'seur-user-settings-section' ); 343 316 add_settings_field( 'seur_accountnumber_field', __( 'accountNumber<sup>*</sup>', 'seur' ), 'seur_accountnumber_field', 'seur-user-settings-options', 'seur-user-settings-section' ); 344 add_settings_field( 'seur_ccc_field', __( 'CCC<sup>*</sup>', 'seur' ), 'seur_ccc_field', 'seur-user-settings-options', 'seur-user-settings-section' );345 add_settings_field( 'seur_int_ccc_field', __( 'International CCC<sup>*</sup>', 'seur' ), 'seur_int_ccc_field', 'seur-user-settings-options', 'seur-user-settings-section' );346 add_settings_field( 'seur_franquicia_field', __( 'Franchise<sup>*</sup>', 'seur' ), 'seur_franquicia_field', 'seur-user-settings-options', 'seur-user-settings-section' );347 317 348 318 // register all setings. … … 373 343 register_setting( 'seur-user-settings-section', 'seur_client_id_field', [ 'sanitize_callback' => 'sanitize_text_field' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known 374 344 register_setting( 'seur-user-settings-section', 'seur_accountnumber_field', [ 'sanitize_callback' => 'sanitize_text_field' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known 375 register_setting( 'seur-user-settings-section', 'seur_ccc_field', [ 'sanitize_callback' => 'sanitize_text_field' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known376 register_setting( 'seur-user-settings-section', 'seur_int_ccc_field', [ 'sanitize_callback' => 'sanitize_text_field' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known377 register_setting( 'seur-user-settings-section', 'seur_franquicia_field', [ 'sanitize_callback' => 'sanitize_text_field' ] ); // phpcs:ignore PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic -- Sanitization callback is safe and known378 345 } 379 346 add_action( 'admin_init', 'display_seur_user_sittings_panel_fields' ); -
seur/trunk/core/pages/seur-get-labels.php
r3283287 r3382654 169 169 update_post_meta($order_id, '_seur_shipping_packages', $label_shipping_packages); 170 170 update_post_meta($order_id, '_seur_shipping_weight', $label_shipping_weight); 171 seur()->slog("seur_modify_packages() -> _seur_shipping_weight: $label_shipping_weight - order:". $order_id); 171 172 } 172 173 … … 235 236 $order->update_meta_data('_seur_shipping_packages', $total_packages); 236 237 $order->update_meta_data('_seur_shipping_weight', $new_weight); 238 seur()->slog( "seur_modify_packages() -> _seur_shipping_weight: $new_weight - order:". $order_id); 237 239 $order->update_meta_data('_seur_label_ecbs', $ecbs_serialized); 238 240 $order->update_meta_data('_seur_label_parcelNumbers', $parcelNumbers_serialized); -
seur/trunk/core/pages/seur-nomenclator.php
r3119152 r3382654 16 16 */ 17 17 function seur_search_nomenclator( $post ) { ?> 18 18 <form method="post" name="formulario" width="100%"> 19 19 <div class="wrap"> 20 20 <h1 class="wp-heading-inline"><?php esc_html_e( 'Nomenclator', 'seur' ); ?></h1> … … 27 27 ?> 28 28 <hr class="wp-header-end"> 29 < ?php esc_html_e( 'Check ZIP or city associated to Seur system.', 'seur' ); ?>30 <form method="post" name="formulario" width="100%"> 29 <p><?php esc_html_e( 'Check ZIP or city associated to Seur system.', 'seur' ); ?></p> 30 31 31 <?php 32 32 if ( isset( $_POST['codigo_postal'] ) ) { … … 76 76 <?php 77 77 foreach ( $result as $item) { 78 echo '<tr><td><a href="https://www.google.es/maps/search/' . esc_html( $item ->cityName) . '+' .79 esc_html( $item ->postalCode ) . '+seur" target="_blank">' . esc_html( $item->postalCode) . '</a>'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase78 echo '<tr><td><a href="https://www.google.es/maps/search/' . esc_html( $item['cityName'] ) . '+' . 79 esc_html( $item['postalCode'] ) . '+seur" target="_blank">' . esc_html( $item['postalCode'] ) . '</a>'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 80 80 echo '</td>'; 81 echo '<td>' . esc_html( $item ->cityName) . '</td>'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase81 echo '<td>' . esc_html( $item['cityName'] ) . '</td>'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 82 82 } 83 83 ?> … … 92 92 } 93 93 } 94 ?> 95 </form> 94 } ?> 96 95 </div> 97 <?php98 }99 ?>100 96 <div class="wp-filter"> 101 97 <label> … … 112 108 </div> 113 109 <?php wp_nonce_field( 'nomenclator_seur', 'nomenclator_seur_nonce_field' ); ?> 110 </form> 114 111 <?php 115 112 } -
seur/trunk/core/pages/seur-settings.php
r3159775 r3382654 66 66 var switchery = new Switchery(log, { size: 'small' } ); 67 67 } 68 var geolabel = document.querySelector( '.js-switch-geolabel' );69 if ( geolabel ) {70 var switchery = new Switchery(geolabel, { size: 'small' } );71 }72 var preavisonotificar = document.querySelector( '.js-switch-preavisonotificar' );73 if ( preavisonotificar ) {74 var switchery = new Switchery(preavisonotificar, { size: 'small' } );75 }76 var repartonotificar = document.querySelector( '.js-switch-repartonotificar' );77 if ( repartonotificar ) {78 var switchery = new Switchery(repartonotificar, { size: 'small' } );79 }80 68 var localpickup = document.querySelector( '.js-switch-pickup' ); 81 69 if ( localpickup ) { -
seur/trunk/core/pages/status/status-check.php
r3283287 r3382654 616 616 <table class="seur-status-table widefat" cellspacing="0"> 617 617 <?php 618 $seur_ccc_field = get_option( 'seur_ccc_field' ); 619 $seur_int_ccc_field = get_option( 'seur_int_ccc_field' ); 620 $seur_franquicia_field = get_option( 'seur_franquicia_field' ); 618 $seur_accountNumber_field = get_option('seur_accountNumber_field'); 621 619 ?> 622 620 <thead> … … 627 625 <tbody> 628 626 <tr> 629 <td data-export-label="CCC"><?php esc_html_e( 'CCC:', 'seur' ); ?></td> 630 <?php if ( $seur_ccc_field ) { ?> 631 <td><?php echo esc_html( $seur_ccc_field ); ?></td> 632 <?php 633 } else { 634 ?> 635 <td><span class="error">No.</span></td> 636 <?php } ?> 637 </tr> 638 <tr> 639 <td data-export-label="International CCC"><?php esc_html_e( 'International CCC:', 'seur' ); ?></td> 640 <?php if ( $seur_int_ccc_field ) { ?> 641 <td><?php echo esc_html( $seur_int_ccc_field ); ?></td> 642 <?php 643 } else { 644 ?> 645 <td><span class="error">No.</span></td> 646 <?php } ?> 647 </tr> 648 <tr> 649 <td data-export-label="Franchise"><?php esc_html_e( 'Franchise:', 'seur' ); ?></td> 650 <?php if ( $seur_franquicia_field ) { ?> 651 <td><?php echo esc_html( $seur_franquicia_field ); ?></td> 627 <td data-export-label="Account Number"><?php esc_html_e( 'Account number:', 'seur' ); ?></td> 628 <?php if ( $seur_accountNumber_field ) { ?> 629 <td><?php echo esc_html( $seur_accountNumber_field ); ?></td> 652 630 <?php 653 631 } else { … … 667 645 $seur_google_maps_api_field = get_option( 'seur_google_maps_api_field' ); 668 646 $seur_after_get_label_field = get_option( 'seur_after_get_label_field' ); 669 $seur_preaviso_notificar_field = get_option( 'seur_preaviso_notificar_field' );670 $seur_reparto_notificar_field = get_option( 'seur_reparto_notificar_field' );671 $seur_tipo_notificacion_field = get_option( 'seur_tipo_notificacion_field' );672 647 $seur_tipo_etiqueta_field = get_option( 'seur_tipo_etiqueta_field' ); 673 648 $seur_aduana_origen_field = get_option( 'seur_aduana_origen_field' ); … … 724 699 </tr> 725 700 <tr> 726 <td data-export-label="Notify collection"><?php esc_html_e( 'Notify collection:', 'seur' ); ?></td>727 <?php if ( '1' === $seur_preaviso_notificar_field ) { ?>728 <td><span><?php esc_html_e( 'Yes', 'seur' ); ?></span></td>729 <?php730 } else {731 ?>732 <td><span><?php esc_html_e( 'No', 'seur' ); ?></span></td>733 <?php } ?>734 </tr>735 <tr>736 <td data-export-label="Notify distribution"><?php esc_html_e( 'Notify distribution:', 'seur' ); ?></td>737 <?php if ( '1' === $seur_reparto_notificar_field ) { ?>738 <td><span><?php esc_html_e( 'Yes', 'seur' ); ?></span></td>739 <?php740 } else {741 ?>742 <td><span><?php esc_html_e( 'No', 'seur' ); ?></span></td>743 <?php } ?>744 </tr>745 <tr>746 <td data-export-label="Notifications by SMS or Email"><?php esc_html_e( 'Notifications by SMS or Email:', 'seur' ); ?></td>747 <?php if ( $seur_tipo_notificacion_field ) { ?>748 <td><?php echo esc_html( $seur_tipo_notificacion_field ); ?></td>749 <?php750 } else {751 ?>752 <td><span class="error">No.</span></td>753 <?php } ?>754 </tr>755 <tr>756 701 <td data-export-label="Type of label"><?php esc_html_e( 'Type of label:', 'seur' ); ?></td> 757 702 <?php if ( $seur_tipo_etiqueta_field ) { ?> -
seur/trunk/core/woocommerce/includes/class-seur_local_shipping_method.php
r3283287 r3382654 32 32 $this->method_title = __( 'SEUR Local Pickup', 'seur' ); 33 33 $this->method_description = __( 'SEUR Local Pickup Shipping Method, Please configure SEUR data in <code>SEUR -> Settings</code>', 'seur' ); 34 $this->method_description .= '<br>' . __( 'Si usa el Checkout de Bloques, no se activará este método.', 'seur' ); 34 35 $this->supports = array( 35 36 'shipping-zones', … … 179 180 function seur_map_checkout_load_js() { 180 181 if ( is_checkout() ) { 181 $seur_gmap_api = get_option( 'seur_google_maps_api_field' );182 if ( empty( $seur_gmap_api ) ) {182 $seur_gmap_api = get_option( 'seur_google_maps_api_field' ); 183 /*if ( empty( $seur_gmap_api ) ) { 183 184 return; 184 } 185 }*/ 185 186 wp_enqueue_script( 'seur-gmap', 'https://maps.google.com/maps/api/js?libraries=geometry&v=3&key=' . $seur_gmap_api, array(), SEUR_OFFICIAL_VERSION, false ); 186 wp_enqueue_script( 'seur-map', SEUR_PLUGIN_URL . 'assets/js/maplace.min.js', array( 'jquery' ), SEUR_OFFICIAL_VERSION, false );187 }187 wp_enqueue_script( 'seur-map', SEUR_PLUGIN_URL . 'assets/js/maplace.min.js', array( 'jquery' ), SEUR_OFFICIAL_VERSION, false ); 188 } 188 189 } 189 190 … … 304 305 && ( $method->id === $chosen_shipping ) && is_checkout() ) { 305 306 $local_pickups_array = seur_get_local_pickups( $country_seur, $city, $postcode_seur ); 307 $print_js = ''; 306 308 for ( $i = 0; $i < count( $local_pickups_array ); $i++ ) { // phpcs:ignore Squiz.PHP.DisallowSizeFunctionsInLoops.Found,Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed 307 if ( 0 === $i ) {309 if ( 0 === $i ) { 308 310 $print_js = '{'; 309 311 } else { … … 351 353 html = '', 352 354 title, 353 a; 355 a; 354 356 if (this.ln > 1) { 355 357 html += '<select name=\"seur_pickup\" required=\"required\" class=\"seur-pickup-select2' + this.o.controls_cssclass + '\">'; … … 410 412 controls_on_map: false, 411 413 controls_type: 'seurdropdown' 412 }); 413 }); 414 });"; 415 if (empty($seur_gmap_api)) { 416 echo "$('#seur-gmap').hide();"; 417 } 418 echo "}); 414 419 </script>"; 420 415 421 } 416 422 } -
seur/trunk/core/woocommerce/includes/class-wc-shipping-seur.php
r3283287 r3382654 441 441 $rate_requests = array(); 442 442 $rates_type = get_option( 'seur_rates_type_field' ); 443 $this->log->add( 'seur', 'calculate_shipping( $package = array() ): PROBANDO' );444 $this->log->add( 'seur', 'calculate_shipping( $package = array() ): ' . print_r( $package, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r443 //$this->log->add( 'seur', 'calculate_shipping( $package = array() ): PROBANDO' ); 444 //$this->log->add( 'seur', 'calculate_shipping( $package = array() ): ' . print_r( $package, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r 445 445 446 446 // Only return rates if the package has a destination including country. -
seur/trunk/core/woocommerce/includes/seur-woo-functions.php
r3283287 r3382654 22 22 } 23 23 24 // Store cart weight in the database. 25 add_action( 'woocommerce_update_order', 'seur_add_cart_weight_hpos' ); 26 function seur_add_cart_weight_hpos( $order_id ) 27 { 28 if (WC()->cart && WC()->cart->cart_contents_count > 0) { 29 $order = new WC_Order($order_id); 30 31 $product_name = ''; 32 $ship_methods = maybe_unserialize($order->get_shipping_methods()); 33 foreach ($ship_methods as $ship_method) { 34 $product_name = $ship_method['name']; 35 } 36 37 $products = seur()->get_products(); 38 foreach ($products as $code => $product) { 39 $custom_name = get_option($product['field'] . '_custom_name_field') ? get_option($product['field'] . '_custom_name_field') : $code; 24 /* 25 function seur_recalculate_order_weight( $order_id ) { 26 $order = wc_get_order( $order_id ); 27 if ( ! $order ) { 28 return; 29 } 30 31 $total_weight = 0.0; 32 foreach ( $order->get_items() as $item ) { 33 if ( ! $item instanceof WC_Order_Item_Product ) { 34 continue; 35 } 36 $product = $item->get_product(); 37 if ( ! $product ) { 38 continue; 39 } 40 $qty = (float) $item->get_quantity(); 41 $p_w = (float) $product->get_weight(); // Peso del producto (en la unidad configurada en WooCommerce) 42 $total_weight += $p_w * $qty; 43 } 44 $order->update_meta_data( '_seur_cart_weight', $total_weight ); 45 46 if ( function_exists( 'seur' ) && is_object( seur() ) && method_exists( seur(), 'slog' ) ) { 47 seur()->slog( sprintf( 'recalculate -> _seur_cart_weight: %s - order: %s', $total_weight, $order_id ) ); 48 } 49 50 $order->save_meta_data(); 51 } 52 53 // --- Cuando se modifican líneas en el admin (añadir/quitar/cantidad) --- 54 add_action( 'woocommerce_before_save_order_items', function( $order_id ) { 55 seur_recalculate_order_weight( $order_id ); 56 }, 20, 1 ); 57 58 add_action( 'woocommerce_order_item_added', function( $item_id, $item, $order_id ) { 59 seur_recalculate_order_weight( $order_id ); 60 }, 20, 3 ); 61 62 add_action( 'woocommerce_after_order_item_quantity_update', function( $item, $order_id ) { 63 seur_recalculate_order_weight( $order_id ); 64 }, 20, 2 ); 65 */ 66 67 function seur_set_shipping_metas($order) { 68 // Shipping method meta 69 $product_name = ''; 70 foreach ($order->get_shipping_methods() as $ship_method) { 71 $product_name = $ship_method['name']; 72 break; 73 } 74 $products = seur()->get_products(); 75 foreach ($products as $code => $product) { 76 $custom_name = get_option($product['field'] . '_custom_name_field') ? get_option($product['field'] . '_custom_name_field') : $code; 40 77 if ($custom_name == $product_name) { 41 78 $order->update_meta_data('_seur_shipping', 'seur'); 42 79 $order->update_meta_data('_seur_shipping_method_service_real_name', $code); 43 80 $order->update_meta_data('_seur_shipping_method_service', sanitize_title($product_name)); 44 break; 45 } 46 } 47 48 $weight = WC()->cart->cart_contents_weight; 81 break; 82 } 83 } 84 } 85 function seur_set_cart_weight_meta($order) { 86 // Asegura que el carrito está disponible y con contenido 87 if ( WC()->cart && WC()->cart->get_cart_contents_count() > 0 ) { 88 $weight = (float) WC()->cart->get_cart_contents_weight(); 49 89 $order->update_meta_data('_seur_cart_weight', $weight); 50 $order->save_meta_data(); 51 } 52 } 53 add_action('woocommerce_checkout_update_order_meta', 'seur_add_cart_weight'); 54 function seur_add_cart_weight( $order_id ) { 55 global $woocommerce; 56 if ( $woocommerce->cart->cart_contents_count > 0 ) { 57 $weight = $woocommerce->cart->cart_contents_weight; 58 update_post_meta($order_id, '_seur_cart_weight', $weight); 59 } 60 } 90 if ( function_exists('seur') ) { 91 seur()->slog("checkout_create_order -> _seur_cart_weight={$weight} order_id={$order->get_id()}"); 92 } 93 } 94 } 95 // Se ejecuta durante la creación del pedido en el checkout (frontend) 96 add_action('woocommerce_checkout_create_order', function( $order, $data ) { 97 seur_set_cart_weight_meta($order); 98 seur_set_shipping_metas($order); 99 }, 10, 2); 61 100 62 101 // Add order new column in administration. -
seur/trunk/loader.php
r3312581 r3382654 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 66 * Version: 2.2.27 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 6' );22 define( 'SEUR_OFFICIAL_VERSION', '2.2.27' ); 23 23 define( 'SEUR_DB_VERSION', '1.0.5' ); 24 24 define( 'SEUR_TABLE_VERSION', '1.0.5' ); … … 202 202 } 203 203 add_action( 'admin_enqueue_scripts', 'seur_notice_style' ); 204 205 /** 206 * Check if the shipping method is compatible with Block Checkout. 207 */ 208 const TARGET_SHIPPING_METHOD = 'seurlocal'; 209 210 /******************************************************************************************************************* 211 * CHECKOUT BLOCKS or CLASSIC ? 212 */ 213 function seur_uses_block_checkout(): bool { 214 215 $uses_blocks = false; 216 // WooCommerce 8.3+ — use the official utility. 217 if ( class_exists( '\Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils' ) ) { 218 $uses_blocks = \Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils::is_checkout_block_default(); 219 } else { 220 // Fallback — check if the checkout page contains the block. 221 if ( function_exists( 'has_block' ) ) { 222 $checkout_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'checkout' ) : 0; 223 if ( $checkout_id && has_block( 'woocommerce/checkout', $checkout_id ) ) { 224 $uses_blocks = true; 225 226 // Block themes — check the Site Editor template. 227 } elseif ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() && function_exists( 'get_block_template' ) ) { 228 $tpl = get_block_template( get_stylesheet() . '//page-checkout', 'wp_template' ); 229 if ( $tpl && ! empty( $tpl->content ) && has_block( 'woocommerce/checkout', $tpl->content ) ) { 230 $uses_blocks = true; 231 } 232 } 233 } 234 } 235 return $uses_blocks; 236 } 237 238 /** 239 * Is this method compatible with Blocks Checkout? 240 * By default, ONLY the target method is incompatible; others are compatible. 241 * You can override from outside via the `seur_is_method_blocks_compatible` filter. 242 * 243 * @param string $method_id ID of the shipping method. 244 * @param int $instance_id Method instance ID. 245 * @param int $zone_id Shipping zone ID. 246 */ 247 function seur_is_method_blocks_compatible( string $method_id, int $instance_id = 0, int $zone_id = 0 ): bool { 248 $compatible = ( $method_id !== TARGET_SHIPPING_METHOD ); 249 return (bool) apply_filters( 'seur_is_method_blocks_compatible', $compatible, $method_id, $instance_id, $zone_id ); 250 } 251 252 /** ---------- Helpers / Utilidades ---------- */ 253 254 /** 255 * Disable a shipping method instance and clear shipping caches. 256 */ 257 function seur_disable_zone_method_instance( int $instance_id ): void { 258 global $wpdb; 259 260 $wpdb->update( 261 "{$wpdb->prefix}woocommerce_shipping_zone_methods", 262 [ 'is_enabled' => 0 ], 263 [ 'instance_id' => absint( $instance_id ) ] 264 ); 265 266 // Bust shipping caches so the change is reflected in the admin UI. 267 if ( class_exists( 'WC_Cache_Helper' ) ) { 268 WC_Cache_Helper::get_transient_version( 'shipping', true ); 269 } 270 } 271 272 /** 273 * Show an admin notice indicating the method is not compatible with blocks. 274 */ 275 function seur_admin_notice_blocks_incompatible( string $method_id, int $instance_id ): void { 276 if ( class_exists( 'WC_Admin_Notices' ) ) { 277 seur_add_error_admin_notice_once( 278 'seur_method_blocks_incompatible_' . $instance_id, 279 __( 'El método de envío <strong>SEUR Local Pickup</strong> no es compatible con el Checkout de bloques y no se pintará el selector de puntos pickup. Puedes usar el checkout clásico mientras trabajamos en la compatibilidad.', 'seur' ) 280 ); 281 } 282 } 283 284 /** ---------- Hooks ---------- */ 285 286 /** 287 * Status toggle (enable/disable) from Shipping Zones. 288 * If enabling and it’s not blocks-compatible, keep it disabled and show a notice. 289 */ 290 function seur_woocommerce_shipping_zone_method_status_toggled( int $instance_id, string $method_id, int $zone_id, int $is_enabled ): void { 291 // Only care when enabling. 292 if ( 1 !== (int) $is_enabled ) { 293 return; 294 } 295 // If Blocks Checkout isn’t used, don’t block anything. 296 if ( ! seur_uses_block_checkout() ) { 297 return; 298 } 299 // If NOT compatible, disable and notify. 300 if ( ! seur_is_method_blocks_compatible( $method_id, $instance_id, $zone_id ) ) { 301 seur_disable_zone_method_instance( $instance_id ); 302 seur_admin_notice_blocks_incompatible( $method_id, $instance_id ); 303 } 304 } 305 add_action( 'woocommerce_shipping_zone_method_status_toggled', 'seur_woocommerce_shipping_zone_method_status_toggled', 10, 4 ); 306 307 /** 308 * “Add method” case. 309 * If it’s not blocks-compatible, it’s created but immediately disabled and a notice is shown. 310 */ 311 function seur_woocommerce_shipping_zone_method_added( int $instance_id, string $method_id, int $zone_id ): void { 312 // If Blocks Checkout isn’t used, do nothing. 313 if ( ! seur_uses_block_checkout() ) { 314 return; 315 } 316 // If NOT compatible, disable and notify. 317 if ( ! seur_is_method_blocks_compatible( $method_id, $instance_id, $zone_id ) ) { 318 seur_disable_zone_method_instance( $instance_id ); 319 seur_admin_notice_blocks_incompatible( $method_id, $instance_id ); 320 } 321 } 322 add_action( 'woocommerce_shipping_zone_method_added', 'seur_woocommerce_shipping_zone_method_added', 10, 3 ); 323 324 /* 325 * Audit: disable all enabled, blocks-incompatible instances across all zones. 326 */ 327 function seur_audit_and_disable_incompatible_methods(): void { 328 if ( ! is_admin() || ! seur_uses_block_checkout() ) { 329 return; 330 } 331 332 global $wpdb; 333 // Find all enabled instances of your target method. 334 $instance_ids = $wpdb->get_col( 335 $wpdb->prepare( 336 "SELECT instance_id FROM {$wpdb->prefix}woocommerce_shipping_zone_methods 337 WHERE method_id = %s AND is_enabled = 1", 338 TARGET_SHIPPING_METHOD 339 ) 340 ); 341 342 if ( empty( $instance_ids ) ) { 343 return; 344 } 345 346 foreach ( $instance_ids as $instance_id ) { 347 // In case you later expand per-instance/zone compatibility logic. 348 if ( ! seur_is_method_blocks_compatible( TARGET_SHIPPING_METHOD, (int) $instance_id, 0 ) ) { 349 seur_disable_zone_method_instance( (int) $instance_id ); 350 } 351 } 352 353 // Single admin notice to avoid noise. 354 if ( class_exists( 'WC_Admin_Notices' ) ) { 355 seur_add_error_admin_notice_once( 356 'seur_bulk_blocks_incompatible', 357 __( 'Se han desactivado instancias incompatibles con el Checkout de bloques para el método "SEUR Local Pickup".', 'seur' ) 358 ); 359 } 360 } 361 add_action( 'admin_init', 'seur_audit_and_disable_incompatible_methods' ); 362 363 364 /** 365 * Show a red (error) admin notice once (persisted across page loads). 366 */ 367 function seur_add_error_admin_notice_once(string $key, string $html): void 368 { 369 $stack = get_option('seur_admin_error_notices', array()); 370 $stack[$key] = wp_kses_post($html); 371 update_option('seur_admin_error_notices', $stack); 372 } 373 374 /** 375 * Output stored notices and delete them (global hook). 376 */ 377 function seur_output_error_admin_notices(): void 378 { 379 $stack = get_option('seur_admin_error_notices', array()); 380 if (empty($stack)) { 381 return; 382 } 383 384 // Opcional: limítalo a pantallas de WooCommerce. 385 $screen = function_exists('get_current_screen') ? get_current_screen() : null; 386 if ($screen && !in_array($screen->id, function_exists('wc_get_screen_ids') ? wc_get_screen_ids() : array(), true)) { 387 return; 388 } 389 390 foreach ($stack as $key => $html) { 391 // notice-error => red border; is-dismissible => close button. 392 printf( 393 '<div class="notice notice-error is-dismissible"><p>%s</p></div>', 394 $html 395 ); 396 unset($stack[$key]); // Mostrar solo una vez / Only once. 397 } 398 update_option('seur_admin_error_notices', $stack); 399 } 400 add_action('admin_notices', 'seur_output_error_admin_notices'); -
seur/trunk/readme.txt
r3312581 r3382654 4 4 Requires at least: 4.0 5 5 Tested up to: 6.8 6 Stable tag: 2.2.2 66 Stable tag: 2.2.27 7 7 WC requires at least: 3.0 8 8 WC tested up to: 9.1.4 … … 87 87 == Changelog == 88 88 89 == 2.2.27 == 90 91 * ADDED: Default free shipping rates at install 92 * ADDED: Show incompatibility message when checkout page is set as blocks 93 * CHANGED: Update shipment response to continue with the process 94 * CHANGED: Set weight action 95 * CHANGED: Config options cleanup 96 * FIXED: Behaviour when no google maps api key 97 89 98 == 2.2.26 == 90 99 91 100 * FIXED: Wrong order status after generating SEUR label 92 101 * FIXED: SEUR metabox not visible with legacy order storage (HPOS inactive) 93 * FIXED: Weight calculation94 102 95 103 == 2.2.25 == -
seur/trunk/uninstall.php
r3283287 r3382654 25 25 $options = array( 26 26 'seur_after_get_label_field', 27 'seur_preaviso_notificar_field',28 'seur_reparto_notificar_field',29 'seur_tipo_notificacion_field',30 27 'seur_tipo_etiqueta_field', 31 28 'seur_change_service_enabled_field', … … 54 51 'seur_cit_usuario_field', 55 52 'seur_cit_contra_field', 56 'seur_ccc_field',57 'seur_franquicia_field',58 53 'seur_seurcom_usuario_field', 59 54 'seur_seurcom_contra_field',
Note: See TracChangeset
for help on using the changeset viewer.