Plugin Directory

Changeset 3432374


Ignore:
Timestamp:
01/05/2026 04:28:40 AM (3 months ago)
Author:
headplus
Message:

2.0.1

Location:
smartpoints-lockers-acs/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • smartpoints-lockers-acs/trunk/README.txt

    r3431904 r3432374  
    44Requires at least: 6.0
    55Tested up to: 6.8.4
    6 Stable tag: 2.0.0
     6Stable tag: 2.0.1
    77Requires PHP: 7.4
    88License: GPL v3
     
    101101== Changelog ==
    102102
     103= 2.0.1 =
     104* HPOS Support
     105* Solved Problems with wc messages with Ajax
     106* Solved Cronjob problems
     107
     108
     109
     110
    103111= 2.0.0 =
    104112* Major Changes
  • smartpoints-lockers-acs/trunk/smartpoints-lockers-acs-main.php

    r3432319 r3432374  
    88        static $labels = [
    99            'checkout_option_title' => 'Παραλαβή από ACS SmartPoint',
    10             'checkout_button_label' => 'Επιλέξτε Smart Point',
     10            'checkout_button_label' => 'Επιλέξτε SmartPoint',
    1111            'checkout_validation_error' => 'Έχετε επιλέξει να παραλάβετε από ACS Points όμως ΔΕΝ έχετε επιλέξει ACS Smart Point!',
    1212            'checkout_validation_error_weight' => 'Λυπούμαστε αλλά η %1$s δεν υποστηρίζεται για παραγγελίες με ογκομετρικό βάρος μεγαλύτερο από %2$d kg.',
    1313            'checkout_selected_point_title' => 'Έχετε επιλέξει να παραλάβετε την παραγγελία σας από',
    14             'email_selected_point_title' => 'ΕΠΙΛΕΓΜΕΝΟ ACS SmartPoint',
     14            'email_selected_point_title' => 'Επιλεγμένο ACS SmartPoint',
    1515        ];
    1616
     
    3535            add_action('woocommerce_after_shipping_rate', array($this, 'add_map_trigger_to_shipping_option'), 10, 2);
    3636            add_action('woocommerce_after_order_notes', array($this, 'add_checkout_point_input'));
    37             add_action('woocommerce_checkout_update_order_meta', array($this, 'save_checkout_point_input'));
     37            add_action('woocommerce_checkout_update_order_meta', array($this, 'save_checkout_point_input'), 20);
    3838            add_action('woocommerce_order_details_after_customer_details', array($this, 'show_point_details_in_customer'), 10);
    3939            add_action('woocommerce_admin_order_data_after_order_details', array($this, 'show_point_details_in_admin'), 10, 1);
     
    151151        }
    152152       
    153         public function save_checkout_point_input($order_id)
    154         {
    155             // Έλεγχος nonce
    156             if (!isset($_POST['acs_pp_nonce_field']) || !wp_verify_nonce($_POST['acs_pp_nonce_field'], 'acs_pp_nonce_action')) {
    157                 return;
    158             }
    159 
    160             $value = (int)($_POST[self::$configuration['checkout_input_name']] ?? 0);
    161             if (!$value || ($_POST['shipping_method'][0] ?? '') != SMARTPOINTS_LOCKERS_ACS_PLUGIN_ID) return;
    162 
    163             global $wp_filesystem;
    164             if (empty($wp_filesystem)) {
    165                 require_once(ABSPATH . '/wp-admin/includes/file.php');
    166                 WP_Filesystem();
    167             }
    168 
    169             $pointsFile = $wp_filesystem->get_contents(__DIR__ . '/data.json');
    170             $points = json_decode($pointsFile, true);
    171 
    172             $selectedPoint = [$value];
    173             foreach ($points['points'] ?? [] as $point) {
    174                 if (($point['id'] ?? 0) == $value) {
    175                     $selectedPoint = $point;
    176                     break;
    177                 }
    178             }
    179 
    180             update_post_meta($order_id, self::$configuration['post_meta_field_name'], wp_json_encode($selectedPoint, JSON_UNESCAPED_UNICODE));
    181             update_post_meta(
    182                 $order_id,
    183                 self::$configuration['post_meta_field_name'].'_slug',
    184                 esc_attr($selectedPoint['Acs_Station_Destination'] ?? '') . esc_attr($selectedPoint['Acs_Station_Branch_Destination'] ?? '')
    185             );
    186 
    187             // Ενημέρωση shipping address
    188             $order = wc_get_order($order_id);
    189             if ($order && isset($selectedPoint['street'], $selectedPoint['city'], $selectedPoint['sa_zipcode'])) {
    190                 $shipping_company = '***SmartPoint ACS Locker (' . esc_attr($selectedPoint['Acs_Station_Destination'] ?? '') . esc_attr($selectedPoint['Acs_Station_Branch_Destination'] ?? '') . ')***';
    191                 $order->set_shipping_company($shipping_company);
    192                 $order->set_shipping_address_1(esc_attr($selectedPoint['street']));
    193                 $order->set_shipping_city(esc_attr($selectedPoint['city']));
    194                 $order->set_shipping_postcode(esc_attr($selectedPoint['sa_zipcode']));
    195                 $order->save();
    196             }
    197         }
     153public function save_checkout_point_input($order_id)
     154{
     155    // Έλεγχος nonce για ασφάλεια
     156    if (!isset($_POST['acs_pp_nonce_field']) || !wp_verify_nonce($_POST['acs_pp_nonce_field'], 'acs_pp_nonce_action')) {
     157        return;
     158    }
     159
     160    $value = (int)($_POST[self::$configuration['checkout_input_name']] ?? 0);
     161
     162    // Αν δεν υπάρχει τιμή ή δεν είναι ACS shipping method, δεν κάνουμε τίποτα
     163    if (!$value || ($_POST['shipping_method'][0] ?? '') != SMARTPOINTS_LOCKERS_ACS_PLUGIN_ID) {
     164        return;
     165    }
     166
     167    global $wp_filesystem;
     168    if (empty($wp_filesystem)) {
     169        require_once(ABSPATH . '/wp-admin/includes/file.php');
     170        WP_Filesystem();
     171    }
     172
     173    // Φορτώνουμε τα σημεία από το JSON
     174    $pointsFile = $wp_filesystem->get_contents(__DIR__ . '/data.json');
     175    $points = json_decode($pointsFile, true);
     176    $selectedPoint = [$value];
     177
     178    foreach ($points['points'] ?? [] as $point) {
     179        if (($point['id'] ?? 0) == $value) {
     180            $selectedPoint = $point;
     181            break;
     182        }
     183    }
     184
     185    // Παίρνουμε το αντικείμενο παραγγελίας
     186    $order = wc_get_order($order_id);
     187    if (!$order) return;
     188
     189    // --- Αποθήκευση στο HPOS / WC_Order meta ---
     190    $order->update_meta_data(self::$configuration['post_meta_field_name'], wp_json_encode($selectedPoint, JSON_UNESCAPED_UNICODE));
     191    $order->update_meta_data(
     192        self::$configuration['post_meta_field_name'] . '_slug',
     193        esc_attr($selectedPoint['Acs_Station_Destination'] ?? '') . esc_attr($selectedPoint['Acs_Station_Branch_Destination'] ?? '')
     194    );
     195
     196    // --- Ενημέρωση shipping address ---
     197    if (isset($selectedPoint['street'], $selectedPoint['city'], $selectedPoint['sa_zipcode'])) {
     198        $shipping_company = '***SmartPoint ACS Locker (' . esc_attr($selectedPoint['Acs_Station_Destination'] ?? '') . esc_attr($selectedPoint['Acs_Station_Branch_Destination'] ?? '') . ')***';
     199        $order->set_shipping_company($shipping_company);
     200        $order->set_shipping_address_1(esc_attr($selectedPoint['street']));
     201        $order->set_shipping_city(esc_attr($selectedPoint['city']));
     202        $order->set_shipping_postcode(esc_attr($selectedPoint['sa_zipcode']));
     203    }
     204
     205    // Αποθήκευση όλων των αλλαγών
     206    $order->save();
     207}
    198208
    199209        public function show_point_details_in_customer($order)
  • smartpoints-lockers-acs/trunk/smartpoints-lockers-acs-plugin.php

    r3431896 r3432374  
    33 * Plugin Name: Smartpoints Lockers for ACS
    44 * Description: The Smartpoints Lockers for ACS Plugin on your e-shop, offers at your customers the option to easily and quickly pick up their online orders from an ACS Smartpoint Locker or ACS store.
    5  * Version: 2.0.0
     5 * Version: 2.0.1
    66 * Author: HEADPLUS
    77 * Author URI: https://headplus.gr
     
    2020}
    2121
    22 define('SMARTPOINTS_LOCKERS_ACS_PLUGIN_VERSION', '2.0.0');
     22define('SMARTPOINTS_LOCKERS_ACS_PLUGIN_VERSION', '2.0.1');
    2323define('SMARTPOINTS_LOCKERS_ACS_PLUGIN_ID', 'smartpoints-lockers-acs');
    2424
Note: See TracChangeset for help on using the changeset viewer.