Plugin Directory

Changeset 3382654


Ignore:
Timestamp:
10/22/2025 01:52:33 PM (5 months ago)
Author:
seuroficial
Message:

v2.2.27

Location:
seur/trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • seur/trunk/classes/class-seur-global.php

    r3312581 r3382654  
    1010    exit; // Exit if accessed directly.
    1111}
    12 
     12if ( ! class_exists( 'Seur_Global' ) ) {
    1313class Seur_Global {
    1414
     
    1818    private $log;
    1919
    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    }
    2332
    2433    public function get_ownsetting() {
     
    492501        }
    493502
    494         $preparedData['notification'] = $preparedData['reparto_notificar']; // CORRECTO ?
    495         $preparedData['advice_checkbox'] = $preparedData['preaviso_notificar'];
    496         $preparedData['distribution_checkbox'] = $preparedData['tipo_aviso'];
    497503        $preparedData['servicio'] = $servicio;
    498504        $preparedData['producto'] = $producto;
     
    555561                "idNumber" => $preparedData['nif'],
    556562                "phone" => $preparedData['telefono'],
    557                 "accountNumber" => $preparedData['ccc'].'-'.$preparedData['franquicia'],
     563                "accountNumber" => $preparedData['accountNumber'],
    558564                "email" => $preparedData['email'],
    559565                "contactName" => $preparedData['contacto_nombre'] . ' ' . $preparedData['contacto_apellidos'],
     
    10011007            $parcelNumbers = $response['data']['parcelNumbers'];
    10021008
    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");
    10041010            return [
    10051011                'status' => true,
     
    11131119
    11141120
    1115     public function getCountries($countries) {
     1121    public function getCountries($countries, $minimal = false) {
    11161122        $allCountries = seur_get_countries();
    11171123        $aroundESCountries = seur_get_countries_around_ES();
    11181124        $UECountries = seur_get_countries_EU();
    11191125        if ($countries[0] == 'OUT-EU') {
     1126            if ($minimal) {
     1127                return ['*' => '*'];
     1128            }
    11201129            return array_diff($allCountries, $UECountries);
    11211130        }
    11221131        if ($countries[0] == 'INTERNATIONAL') {
     1132            if ($minimal) {
     1133                return ['*' => '*'];
     1134            }
    11231135            return $allCountries;
    11241136        }
     
    11311143    }
    11321144
    1133     public function getStates( $country, $states ) {
     1145    public function getStates( $country, $states, $minimal = false ) {
    11341146
    11351147        $country_states = seur_get_countries_states($country);
    11361148        if (!$country_states) {
     1149            if ($minimal) {
     1150                return ['*' => '*'];
     1151            }
    11371152            return false;
    11381153        }
     
    11401155        foreach ($states as $state) {
    11411156            if ($state == 'all') {
     1157                if ($minimal) {
     1158                    return ['*' => '*'];
     1159                }
    11421160                $result = $country_states;
    11431161            } else {
    1144                 $result[$state] = $country_states[$state];
     1162                $result[$state] = ($minimal) ? $state : $country_states[$state];
    11451163            }
    11461164        }
     
    12031221    }
    12041222}
    1205 
    1206 function seur() {
    1207     return new Seur_Global();
    12081223}
     1224if ( ! function_exists( 'seur' ) ) {
     1225    function seur() {
     1226        return Seur_Global::get_instance();
     1227    }
     1228}
  • seur/trunk/classes/class-seur-seguimiento.php

    r3283287 r3382654  
    5757        $this->reftype             = 'REFERENCE';
    5858        $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       = seur()->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 );
    6161    }
    6262
  • seur/trunk/core/functions/functions.php

    r3283287 r3382654  
    466466 */
    467467function 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 );
    473470    return $countries;
    474471}
     
    792789        $seur_contacto_apellidos_field = '';
    793790    }
    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    }
    809796    if ( $seur_pais_field ) {
    810797        if ( 'ES' === $seur_pais_field ) {
     
    836823        'contacto_nombre',
    837824        'contacto_apellidos',
    838         'ccc',
    839         'int_ccc',
    840         'franquicia',
     825        'accountNumber',
    841826    );
    842827
     
    858843        $seur_contacto_nombre_field,
    859844        $seur_contacto_apellidos_field,
    860         $seur_ccc_field,
    861         $seur_int_ccc_field,
    862         $seur_franquicia_field,
     845        $accountNumber,
    863846    );
    864847    $seur_user_settings[] = array_combine( $option, $value );
     
    874857    $seur_advanced_settings = array();
    875858
    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 = ''; }
    888859    if ( get_option( 'seur_tipo_etiqueta_field' ) ) {
    889860        $seur_tipo_etiqueta_field = get_option( 'seur_tipo_etiqueta_field' );
     
    910881    } else {
    911882        $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 = ''; }
    916883
    917884    $option = array(
    918         'preaviso_notificar',
    919         'reparto_notificar',
    920         'tipo_notificacion',
    921885        'tipo_etiqueta',
    922886        'aduana_origen',
     
    925889        'id_mercancia',
    926890        'descripcion',
    927         'geolabel',
    928891    );
    929892    $value = array(
    930         $seur_preaviso_notificar_field,
    931         $seur_reparto_notificar_field,
    932         $seur_tipo_notificacion_field,
    933893        $seur_tipo_etiqueta_field,
    934894        $seur_aduana_origen_field,
     
    937897        $seur_id_mercancia_field,
    938898        $seur_descripcion_field,
    939         $seur_activate_geolabel_field,
    940899    );
    941900
     
    13251284    $preparedData['mobile_shipping']          = cleanPhone($order->get_meta('_shipping_mobile_phone', true ));
    13261285    $preparedData['mobile_billing']           = cleanPhone($order->get_meta('_billing_mobile_phone', true ));
    1327     $preparedData['log']                      = new WC_Logger();
    13281286
    13291287    // All needed Data return Array.
     
    13561314    $preparedData['contacto_apellidos'] = $user_data[0]['contacto_apellidos'];
    13571315    $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'],'-'));
    13611318
    13621319    $paisgl  = $user_data[0]['pais'];
     
    13711328
    13721329    // Advanced User Settings.
    1373     $preparedData['geolabel']           = $advanced_data[0]['geolabel'];
    13741330    $preparedData['aduana_origen']      = $advanced_data[0]['aduana_origen'];
    13751331    $preparedData['aduana_destino']     = $advanced_data[0]['aduana_destino'];
     
    13781334    $preparedData['descripcion']        = $advanced_data[0]['descripcion'];
    13791335    $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;
    14221336
    14231337    // Customer/Order Data.
     
    14371351    $preparedData['order_pay_method']     = seur_clean_data( $order_data[0]['order_pay_method'] );
    14381352
    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 
    14451353    if ( $post_weight ) {
    14461354        $preparedData['customer_weight_kg'] = seur_always_kg( $weight );
     
    15111419    }
    15121420
    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 
    15371421    $mobile_billing = $preparedData['mobile_billing'];
    15381422    $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     }
    15501423
    15511424    if ( $order_data[0]['code_centro_2shop'] ) {
    1552         $reparto_notificar  = 'N';
    1553         $preaviso_notificar = 'N';
    15541425        $preparedData['seur_email']        = 'N';
    15551426        $preparedData['customer_phone']    = $mobile_billing;
    15561427    }
    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 
    15671428    $log->add( 'seur', 'preparedData: ' . print_r( $preparedData, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
    15681429
     
    16991560
    17001561        if (!seur()->updateShipment($shipmentData)) {
    1701             wp_redirect(wp_get_raw_referer());
    1702             exit;
     1562            return false;
    17031563        }
    17041564        return true;
     
    18101670        $order->update_meta_data('_seur_shipping_weight', $weight);
    18111671        $order->update_meta_data('_seur_cart_weight', $weight);
     1672        seur()->slog( "seur_get_order_weight() -> _seur_cart_weight: $weight - order:". $order->get_id());
    18121673        $order->save_meta_data();
    18131674        if ($label_ids) {
    18141675            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]);
    18151677        }
    18161678    }
  • seur/trunk/core/installer.php

    r3283287 r3382654  
    1111require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    1212require_once(dirname(__FILE__) . '/functions/functions.php');
     13require_once(SEUR_PLUGIN_PATH . 'classes/class-seur-global.php');
    1314
    1415function deleteTableSeurSpvr() {
     
    544545}
    545546
     547function 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
    546577function insertIntoSeurCustomRates() {
    547578    global $wpdb;
     
    795826
    796827    if ( ! $seur_table_version_saved || '' === $seur_table_version_saved ) {
    797         insertIntoSeurCustomRates();
     828        //insertIntoSeurCustomRates();
     829        insertFreeSeurCustomRates();
    798830    }
    799831    if ( $seur_table_version_saved && ($seur_table_version_saved !== '1.0.4') && ( SEUR_TABLE_VERSION === '1.0.4') ) {
     
    876908    if ( ! $seur_add ) {
    877909        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' );
    881910        update_option( 'seur_tipo_etiqueta_field', 'PDF' );
    882911        update_option( 'seur_aduana_origen_field', 'D' );
  • seur/trunk/core/labels-cpt/labels-cpt.php

    r3283287 r3382654  
    496496        foreach ($merchants as $ccc => $orders)
    497497        {
    498             $manifest['ccc'] = $ccc;
     498            $accountNumber = get_option('seur_accountNumber_field');
     499            $manifest['ccc'] = substr( $accountNumber, 0, strpos( $accountNumber, '-' ) );
    499500            $manifest['company'] = get_option( 'seur_empresa_field' );
    500501            $manifest['cif']= get_option( 'seur_nif_field' );
    501             $manifest['franchise'] = get_option( 'seur_franquicia_field' );
     502            $manifest['franchise'] = substr( $accountNumber, strpos( $accountNumber, '-' ) + 1 );
    502503            $manifest['street_type'] = get_option( 'seur_viatipo_field' );
    503504            $manifest['street_name'] = get_option( 'seur_vianombre_field' );
  • seur/trunk/core/pages/rates/seur-country-state-process.php

    r3183810 r3382654  
    4848            $placeholder = 'EX : State';
    4949            $value = '';
     50            $readonly = '';
    5051            if ( '*' === $country) {
    5152                $title = 'No needed';
    5253                $placeholder = 'No needed';
    53                 $value = 'value="*" readonly';
     54                $value = '*';
     55                $readonly = 'readonly';
    5456            }
    5557            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.'>';
    5960        }
    6061        unset( $country );
  • seur/trunk/core/pages/rates/seur-rates.php

    r3176965 r3382654  
    3636                $kilos = '';
    3737            }
    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'] ) ) );
    4040            } else {
    4141                $pais = '';
     
    7272        <label>
    7373            <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>
    7575            <?php
    7676            if ( ! empty( $pais ) && 'ES' === $pais ) {
     
    146146        </label>
    147147    </div>
     148
    148149    <?php
    149150    if ( isset( $_POST['seur_rates_seur_nonce_field'] ) ) {
     
    172173
    173174    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'];
    182175
    183176        if ( ( 'ES' === $pais ) || ( 'PT' === $pais ) || ( 'AD' === $pais ) ) {
     
    186179                'postalCode' => $postal
    187180            ];
    188             if ( false === seur()->seur_api_check_city( $datos ) ) {
     181            $result = seur()->seur_api_check_city( $datos );
     182            if ( $result === false ) {
    189183                echo "<hr><b><font color='#e53920'>";
    190184                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>';
    191185                echo "<font color='#0074a2'><br>Par no Encontrado:<br>" . esc_html( $postal ) . ' - ' . esc_html( $pais );
    192186                return;
    193             }
    194         } else {
    195             $postal    = '08023';
    196             $poblacion = 'BARCELONA';
     187            } else {
     188                //print_r($result);
     189            }
    197190        }
    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             <?php
    243             while ( -1 !== $lineas ) {
    244                 $nom_concept_imp = (string) $xml->REG[ $lineas ]->NOM_CONCEPTO_IMP; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
    245                 $valor           = $xml->REG[ $lineas ]->VALOR; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
    246                 $total           = $total + (float) $xml->REG[ $lineas ]->VALOR; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
    247                 echo '<tr>';
    248                 echo '<td>' . utf8_decode( $nom_concept_imp ) . '</td>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    249                 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             <?php
    258             return;
    259         } */
    260191    }
    261192    ?>
  • seur/trunk/core/pages/setting-options/advanced-settings.php

    r3312581 r3382654  
    1111
    1212/**
    13  * SEUR active geolabel
    14  */
    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     <?php
    19 }
    20 
    21 /**
    2213 * SEUR active local pickup
    2314 */
     
    6556        ?>
    6657        ><?php esc_html_e( 'Mark as Complete', 'seur' ); ?></option>
    67     </select>
    68     <?php
    69 }
    70 
    71 /**
    72  * SEUR preaviso notificar
    73  */
    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     <?php
    78 }
    79 
    80 /**
    81  * SEUR reparto notificar
    82  */
    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     <?php
    87 }
    88 
    89 /**
    90  * SEUR tipo notificacion
    91  */
    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         <?php
    99         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         <?php
    105         if ( 'EMAIL' === $option ) {
    106             echo ' selected';}
    107         ?>
    108         ><?php esc_html_e( 'Email', 'seur' ); ?></option>
    109         <option value="both"
    110         <?php
    111         if ( 'both' === $option ) {
    112             echo ' selected';}
    113         ?>
    114         ><?php esc_html_e( 'Both (this option has an extra cost)', 'seur' ); ?></option>
    11558    </select>
    11659    <?php
     
    237180
    238181    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' );
    240182    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' );
    241183    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' );
    242184    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' );
    243185    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' );
    247186    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' );
    248187    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' );
     
    254193
    255194    // 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 known
    257195    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 known
    259196    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
    260197    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 known
    262198
    263199    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 known
    265200    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
    266201    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  
    281281    ?>
    282282    <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     <?php
    284 }
    285 
    286 /**
    287  * SEUR CCC
    288  */
    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     <?php
    293 }
    294 
    295 /**
    296  * SEUR CCC Internacional
    297  */
    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     <?php
    302 }
    303 
    304 /**
    305  * SEUR franquicia
    306  */
    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" />
    310283    <?php
    311284}
     
    342315    add_settings_field( 'seur_client_id_field', __( 'Client id<sup>*</sup>', 'seur' ), 'seur_client_id_field', 'seur-user-settings-options', 'seur-user-settings-section' );
    343316    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' );
    347317
    348318    // register all setings.
     
    373343    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
    374344    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 known
    376     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 known
    377     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 known
    378345}
    379346add_action( 'admin_init', 'display_seur_user_sittings_panel_fields' );
  • seur/trunk/core/pages/seur-get-labels.php

    r3283287 r3382654  
    169169        update_post_meta($order_id, '_seur_shipping_packages', $label_shipping_packages);
    170170        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);
    171172    }
    172173
     
    235236                $order->update_meta_data('_seur_shipping_packages', $total_packages);
    236237                $order->update_meta_data('_seur_shipping_weight', $new_weight);
     238                seur()->slog( "seur_modify_packages() -> _seur_shipping_weight: $new_weight - order:". $order_id);
    237239                $order->update_meta_data('_seur_label_ecbs', $ecbs_serialized);
    238240                $order->update_meta_data('_seur_label_parcelNumbers', $parcelNumbers_serialized);
  • seur/trunk/core/pages/seur-nomenclator.php

    r3119152 r3382654  
    1616 */
    1717function seur_search_nomenclator( $post ) { ?>
    18 
     18    <form method="post" name="formulario" width="100%">
    1919    <div class="wrap">
    2020        <h1 class="wp-heading-inline"><?php esc_html_e( 'Nomenclator', 'seur' ); ?></h1>
     
    2727        ?>
    2828        <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
    3131        <?php
    3232        if ( isset( $_POST['codigo_postal'] ) ) {
     
    7676                        <?php
    7777                        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.UsedPropertyNotSnakeCase
     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.UsedPropertyNotSnakeCase
    8080                            echo '</td>';
    81                             echo '<td>' . esc_html( $item->cityName ) . '</td>'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     81                            echo '<td>' . esc_html( $item['cityName'] ) . '</td>'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
    8282                        }
    8383                        ?>
     
    9292                }
    9393            }
    94             ?>
    95         </form>
     94        } ?>
    9695    </div>
    97     <?php
    98     }
    99     ?>
    10096    <div class="wp-filter">
    10197        <label>
     
    112108    </div>
    113109    <?php wp_nonce_field( 'nomenclator_seur', 'nomenclator_seur_nonce_field' ); ?>
     110    </form>
    114111    <?php
    115112}
  • seur/trunk/core/pages/seur-settings.php

    r3159775 r3382654  
    6666                var switchery = new Switchery(log, { size: 'small' } );
    6767            }
    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             }
    8068            var localpickup = document.querySelector( '.js-switch-pickup' );
    8169            if ( localpickup ) {
  • seur/trunk/core/pages/status/status-check.php

    r3283287 r3382654  
    616616                <table class="seur-status-table widefat" cellspacing="0">
    617617                    <?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');
    621619                    ?>
    622620                    <thead>
     
    627625                    <tbody>
    628626                        <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>
    652630                                <?php
    653631                            } else {
     
    667645                        $seur_google_maps_api_field        = get_option( 'seur_google_maps_api_field' );
    668646                        $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' );
    672647                        $seur_tipo_etiqueta_field          = get_option( 'seur_tipo_etiqueta_field' );
    673648                        $seur_aduana_origen_field          = get_option( 'seur_aduana_origen_field' );
     
    724699                        </tr>
    725700                        <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                                 <?php
    730                             } 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                                 <?php
    740                             } 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                                 <?php
    750                             } else {
    751                                 ?>
    752                                 <td><span class="error">No.</span></td>
    753                                 <?php } ?>
    754                         </tr>
    755                         <tr>
    756701                            <td data-export-label="Type of label"><?php esc_html_e( 'Type of label:', 'seur' ); ?></td>
    757702                            <?php if ( $seur_tipo_etiqueta_field ) { ?>
  • seur/trunk/core/woocommerce/includes/class-seur_local_shipping_method.php

    r3283287 r3382654  
    3232        $this->method_title         = __( 'SEUR Local Pickup', 'seur' );
    3333        $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' );
    3435        $this->supports             = array(
    3536            'shipping-zones',
     
    179180function seur_map_checkout_load_js() {
    180181    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 ) ) {
    183184            return;
    184         }
     185        }*/
    185186        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    }
    188189}
    189190
     
    304305              && ( $method->id === $chosen_shipping ) && is_checkout() ) {
    305306            $local_pickups_array = seur_get_local_pickups( $country_seur, $city, $postcode_seur );
     307            $print_js = '';
    306308            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 ) {
    308310                    $print_js = '{';
    309311                } else {
     
    351353                        html = '',
    352354                        title,
    353                         a;
     355                        a;                   
    354356                        if (this.ln > 1) {
    355357                            html += '<select name=\"seur_pickup\" required=\"required\" class=\"seur-pickup-select2' + this.o.controls_cssclass + '\">';
     
    410412                    controls_on_map: false,
    411413                    controls_type: 'seurdropdown'
    412                 });
    413             });
     414                });";
     415            if (empty($seur_gmap_api)) {
     416                echo "$('#seur-gmap').hide();";
     417            }
     418            echo "});
    414419            </script>";
     420
    415421        }
    416422    }
  • seur/trunk/core/woocommerce/includes/class-wc-shipping-seur.php

    r3283287 r3382654  
    441441        $rate_requests = array();
    442442        $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_r
     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_r
    445445
    446446        // Only return rates if the package has a destination including country.
  • seur/trunk/core/woocommerce/includes/seur-woo-functions.php

    r3283287 r3382654  
    2222}
    2323
    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/*
     25function 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) ---
     54add_action( 'woocommerce_before_save_order_items', function( $order_id ) {
     55    seur_recalculate_order_weight( $order_id );
     56}, 20, 1 );
     57
     58add_action( 'woocommerce_order_item_added', function( $item_id, $item, $order_id ) {
     59    seur_recalculate_order_weight( $order_id );
     60}, 20, 3 );
     61
     62add_action( 'woocommerce_after_order_item_quantity_update', function( $item, $order_id ) {
     63    seur_recalculate_order_weight( $order_id );
     64}, 20, 2 );
     65*/
     66
     67function 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;
    4077            if ($custom_name == $product_name) {
    4178                $order->update_meta_data('_seur_shipping', 'seur');
    4279                $order->update_meta_data('_seur_shipping_method_service_real_name', $code);
    4380                $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}
     85function 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();
    4989        $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)
     96add_action('woocommerce_checkout_create_order', function( $order, $data ) {
     97    seur_set_cart_weight_meta($order);
     98    seur_set_shipping_metas($order);
     99}, 10, 2);
    61100
    62101// Add order new column in administration.
  • seur/trunk/loader.php

    r3312581 r3382654  
    44 * Plugin URI: http://www.seur.com/
    55 * 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.26
     6 * Version: 2.2.27
    77 * Author: SEUR Oficial
    88 * Author URI: http://www.seur.com/
     
    2020use Automattic\WooCommerce\Utilities\FeaturesUtil;
    2121
    22 define( 'SEUR_OFFICIAL_VERSION', '2.2.26' );
     22define( 'SEUR_OFFICIAL_VERSION', '2.2.27' );
    2323define( 'SEUR_DB_VERSION', '1.0.5' );
    2424define( 'SEUR_TABLE_VERSION', '1.0.5' );
     
    202202}
    203203add_action( 'admin_enqueue_scripts', 'seur_notice_style' );
     204
     205/**
     206 * Check if the shipping method is compatible with Block Checkout.
     207 */
     208const TARGET_SHIPPING_METHOD = 'seurlocal';
     209
     210/*******************************************************************************************************************
     211 * CHECKOUT BLOCKS or CLASSIC ?
     212 */
     213function 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 */
     247function 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 */
     257function 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 */
     275function 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 */
     290function 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}
     305add_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 */
     311function 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}
     322add_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 */
     327function 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}
     361add_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 */
     367function 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 */
     377function 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}
     400add_action('admin_notices', 'seur_output_error_admin_notices');
  • seur/trunk/readme.txt

    r3312581 r3382654  
    44Requires at least: 4.0
    55Tested up to: 6.8
    6 Stable tag: 2.2.26
     6Stable tag: 2.2.27
    77WC requires at least: 3.0
    88WC tested up to: 9.1.4
     
    8787== Changelog ==
    8888
     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
    8998== 2.2.26 ==
    9099
    91100* FIXED: Wrong order status after generating SEUR label
    92101* FIXED: SEUR metabox not visible with legacy order storage (HPOS inactive)
    93 * FIXED: Weight calculation
    94102
    95103== 2.2.25 ==
  • seur/trunk/uninstall.php

    r3283287 r3382654  
    2525$options = array(
    2626    'seur_after_get_label_field',
    27     'seur_preaviso_notificar_field',
    28     'seur_reparto_notificar_field',
    29     'seur_tipo_notificacion_field',
    3027    'seur_tipo_etiqueta_field',
    3128    'seur_change_service_enabled_field',
     
    5451    'seur_cit_usuario_field',
    5552    'seur_cit_contra_field',
    56     'seur_ccc_field',
    57     'seur_franquicia_field',
    5853    'seur_seurcom_usuario_field',
    5954    'seur_seurcom_contra_field',
Note: See TracChangeset for help on using the changeset viewer.