Changeset 3432374
- Timestamp:
- 01/05/2026 04:28:40 AM (3 months ago)
- Location:
- smartpoints-lockers-acs/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (2 diffs)
-
smartpoints-lockers-acs-main.php (modified) (3 diffs)
-
smartpoints-lockers-acs-plugin.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
smartpoints-lockers-acs/trunk/README.txt
r3431904 r3432374 4 4 Requires at least: 6.0 5 5 Tested up to: 6.8.4 6 Stable tag: 2.0. 06 Stable tag: 2.0.1 7 7 Requires PHP: 7.4 8 8 License: GPL v3 … … 101 101 == Changelog == 102 102 103 = 2.0.1 = 104 * HPOS Support 105 * Solved Problems with wc messages with Ajax 106 * Solved Cronjob problems 107 108 109 110 103 111 = 2.0.0 = 104 112 * Major Changes -
smartpoints-lockers-acs/trunk/smartpoints-lockers-acs-main.php
r3432319 r3432374 8 8 static $labels = [ 9 9 'checkout_option_title' => 'Παραλαβή από ACS SmartPoint', 10 'checkout_button_label' => 'Επιλέξτε Smart Point',10 'checkout_button_label' => 'Επιλέξτε SmartPoint', 11 11 'checkout_validation_error' => 'Έχετε επιλέξει να παραλάβετε από ACS Points όμως ΔΕΝ έχετε επιλέξει ACS Smart Point!', 12 12 'checkout_validation_error_weight' => 'Λυπούμαστε αλλά η %1$s δεν υποστηρίζεται για παραγγελίες με ογκομετρικό βάρος μεγαλύτερο από %2$d kg.', 13 13 'checkout_selected_point_title' => 'Έχετε επιλέξει να παραλάβετε την παραγγελία σας από', 14 'email_selected_point_title' => 'Ε ΠΙΛΕΓΜΕΝΟACS SmartPoint',14 'email_selected_point_title' => 'Επιλεγμένο ACS SmartPoint', 15 15 ]; 16 16 … … 35 35 add_action('woocommerce_after_shipping_rate', array($this, 'add_map_trigger_to_shipping_option'), 10, 2); 36 36 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); 38 38 add_action('woocommerce_order_details_after_customer_details', array($this, 'show_point_details_in_customer'), 10); 39 39 add_action('woocommerce_admin_order_data_after_order_details', array($this, 'show_point_details_in_admin'), 10, 1); … … 151 151 } 152 152 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 } 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 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 } 198 208 199 209 public function show_point_details_in_customer($order) -
smartpoints-lockers-acs/trunk/smartpoints-lockers-acs-plugin.php
r3431896 r3432374 3 3 * Plugin Name: Smartpoints Lockers for ACS 4 4 * 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. 05 * Version: 2.0.1 6 6 * Author: HEADPLUS 7 7 * Author URI: https://headplus.gr … … 20 20 } 21 21 22 define('SMARTPOINTS_LOCKERS_ACS_PLUGIN_VERSION', '2.0. 0');22 define('SMARTPOINTS_LOCKERS_ACS_PLUGIN_VERSION', '2.0.1'); 23 23 define('SMARTPOINTS_LOCKERS_ACS_PLUGIN_ID', 'smartpoints-lockers-acs'); 24 24
Note: See TracChangeset
for help on using the changeset viewer.