Changeset 3239423
- Timestamp:
- 02/12/2025 01:37:20 PM (14 months ago)
- Location:
- posti-warehouse
- Files:
-
- 12 edited
- 1 copied
-
tags/3.3.0 (copied) (copied from posti-warehouse/trunk)
-
tags/3.3.0/README.md (modified) (1 diff)
-
tags/3.3.0/classes/class-api.php (modified) (1 diff)
-
tags/3.3.0/classes/class-frontend.php (modified) (4 diffs)
-
tags/3.3.0/classes/class-order.php (modified) (6 diffs)
-
tags/3.3.0/posti-warehouse.php (modified) (1 diff)
-
tags/3.3.0/readme.txt (modified) (1 diff)
-
trunk/README.md (modified) (1 diff)
-
trunk/classes/class-api.php (modified) (1 diff)
-
trunk/classes/class-frontend.php (modified) (4 diffs)
-
trunk/classes/class-order.php (modified) (6 diffs)
-
trunk/posti-warehouse.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
posti-warehouse/tags/3.3.0/README.md
r3198079 r3239423 98 98 99 99 ## Version history 100 - 3.3.0: 101 - Added GLS, UPS tracking links. 100 102 - 3.2.0: 101 103 - Added clickable tracking link to order table and email. -
posti-warehouse/tags/3.3.0/classes/class-api.php
r3198079 r3239423 14 14 private $last_status = false; 15 15 private $token_option = 'posti_wh_api_auth'; 16 private $user_agent = 'woo-wh-client/3. 2.0';16 private $user_agent = 'woo-wh-client/3.3.0'; 17 17 18 18 public function __construct(Posti_Warehouse_Logger $logger, array &$options) { -
posti-warehouse/tags/3.3.0/classes/class-frontend.php
r3139663 r3239423 179 179 180 180 $key_id = $this->add_prefix('_pickup_point_id'); 181 182 181 if (empty($pickup_point)) { 183 182 $pickup_point = WC()->session->get($key_id); … … 188 187 $order = wc_get_order($order_id); 189 188 $order->update_meta_data('_' . $key, sanitize_text_field($pickup_point)); 190 // Find string like '(#6681)' 191 preg_match('/\(#[A-Za-z0-9\-]+\)/', $pickup_point, $matches); 192 // Cut the number out from a string of the form '(#6681)' 193 $pickup_point_id = ( !empty($matches) ) ? substr($matches[0], 2, -1) : ''; 194 $order->update_meta_data('_' . $key_id, sanitize_text_field($pickup_point_id)); 195 $order->save(); 196 } 189 190 $pickup_point_ref = $this->extract_pickup_point_ref($pickup_point); 191 if (!empty($pickup_point_ref)) { 192 $order->update_meta_data('_' . $key_id, sanitize_text_field($pickup_point_ref)); 193 $order->save(); 194 } 195 } 196 } 197 198 private function extract_pickup_point_ref($pickup_point) { 199 $preamble = ' (#'; 200 $preamble_start = strpos($pickup_point, $preamble); 201 if ($preamble_start && $preamble_start > 0) { 202 return substr($pickup_point, $preamble_start + strlen($preamble), -1); 203 } 204 205 return null; 197 206 } 198 207 … … 539 548 } 540 549 550 $pickup_point_ref = base64_encode(json_encode($pickup_point)); 541 551 $key_part = empty($serviceProvider) ? $type : $serviceProvider; 542 552 $pickup_point_key = $key_part 543 553 . ': ' . $pickup_point['name'] 544 . ' (#' . $pickup_point ['externalId']. ')';554 . ' (#' . $pickup_point_ref . ')'; 545 555 $pickup_point_value = $pickup_point['name'] 546 556 . ' (' . $pickup_point['streetAddress'] . ')'; … … 574 584 575 585 if (!empty($pickup_point)) { 586 $pickup_point_preamble_start = strpos($pickup_point, ' (#'); 587 $pickup_point_text = strlen($pickup_point) - $pickup_point_preamble_start > 36 ? substr($pickup_point, 0, $pickup_point_preamble_start) : $pickup_point; 576 588 wc_get_template( 577 589 $this->core->templates['account_order'], 578 590 array( 579 'pickup_point' => esc_attr($pickup_point ),591 'pickup_point' => esc_attr($pickup_point_text), 580 592 'texts' => array( 581 593 'title' => Posti_Warehouse_Text::pickup_point_title() -
posti-warehouse/tags/3.3.0/classes/class-order.php
r3198079 r3239423 545 545 $item_counter = 1; 546 546 $service_code = $order_services['service']; 547 $pickup_point = $_order->get_meta('_warehouse_pickup_point_id', true); //_woo_posti_shipping_pickup_point_id 547 $pickup_point_ref = $_order->get_meta('_warehouse_pickup_point_id', true); //_woo_posti_shipping_pickup_point_id 548 $pickup_point = empty($pickup_point_ref) ? null : json_decode(base64_decode($pickup_point_ref), true); 548 549 549 550 foreach ($_order->get_items('shipping') as $item_id => $shipping_item_obj) { … … 623 624 'email' => $_order->get_billing_email() 624 625 ], 625 'deliveryAddress' => [ 626 'name' => $_order->get_shipping_first_name() . ' ' . $_order->get_shipping_last_name(), 627 'streetAddress' => $_order->get_shipping_address_1(), 628 'postalCode' => $_order->get_shipping_postcode(), 629 'postOffice' => $_order->get_shipping_city(), 630 'country' => $_order->get_shipping_country(), 631 'telephone' => $phone, 632 'email' => $email 633 ], 634 'pickupPointId' => $pickup_point, 626 'deliveryAddress' => $this->getDeliveryAddress($_order, $phone, $email), 635 627 'currency' => $_order->get_currency(), 636 628 'serviceCode' => (string) $service_code, … … 640 632 'rows' => $order_items 641 633 ); 634 635 if (isset($pickup_point) && $pickup_point) { 636 $order['pickupPoint'] = $this->getPickupPoint($pickup_point); 637 } 642 638 643 639 $note = $_order->get_customer_note(); … … 714 710 $tracking_link = Posti_Warehouse_Order::get_tracking_link($order); 715 711 if (!empty($tracking_link)) { 716 echo '<p>' . Posti_Warehouse_Text::tracking_number($tracking_link) . '</p>'; 717 } 712 echo '<p>' . Posti_Warehouse_Text::tracking_number($tracking_link) . '</p>'; 713 } 714 } 715 716 private static function getDeliveryAddress($order, $phone, $email) { 717 return array( 718 'name' => $order->get_shipping_first_name() . ' ' . $order->get_shipping_last_name(), 719 'streetAddress' => $order->get_shipping_address_1(), 720 'postalCode' => $order->get_shipping_postcode(), 721 'postOffice' => $order->get_shipping_city(), 722 'country' => $order->get_shipping_country(), 723 'telephone' => $phone, 724 'email' => $email 725 ); 726 } 727 728 private static function getPickupPoint($pickup_point) { 729 return array( 730 'externalId' => isset($pickup_point['externalId']) ? $pickup_point['externalId'] : null, 731 'name' => isset($pickup_point['name']) ? $pickup_point['name'] : null, 732 'streetAddress' => isset($pickup_point['streetAddress']) ? $pickup_point['streetAddress'] : null, 733 'postalCode' => isset($pickup_point['postalCode']) ? $pickup_point['postalCode'] : null, 734 'postOffice' => isset($pickup_point['postOffice']) ? $pickup_point['postOffice'] : null, 735 'country' => isset($pickup_point['country']) ? $pickup_point['country'] : null 736 ); 718 737 } 719 738 … … 725 744 $tracking_code = $order->get_meta('_posti_api_tracking', true); 726 745 if (empty($tracking_code)) { 727 return $tracking_code;746 return $tracking_code; 728 747 } 729 748 730 749 $operator = $order->get_meta('_posti_api_operator', true); 731 750 if (empty($operator)) { 732 return $tracking_code;751 return $tracking_code; 733 752 } 734 753 735 754 $delivery_operator_link = Posti_Warehouse_Order::get_delivery_operator_url($operator); 736 755 if (empty($delivery_operator_link)) { 737 return $tracking_code;756 return $tracking_code; 738 757 } 739 758 … … 755 774 return "https://www.dbschenker.com/app/tracking-public/?refType=WaybillNo&refNumber="; 756 775 } 776 else if ('gls' === $op) { 777 return "https://gls-group.eu/GROUP/en/parcel-tracking?match="; 778 } 779 else if ('ups' === $op) { 780 return "https://www.ups.com/track?loc=en_US&requester=ST/&tracknum="; 781 } 757 782 758 783 return null; -
posti-warehouse/tags/3.3.0/posti-warehouse.php
r3198079 r3239423 3 3 /** 4 4 * Plugin Name: Posti Warehouse 5 * Version: 3. 2.05 * Version: 3.3.0 6 6 * Description: Provides integration to Posti warehouse and dropshipping services. 7 7 * Author: Posti -
posti-warehouse/tags/3.3.0/readme.txt
r3198079 r3239423 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.1 7 Stable tag: 3. 2.07 Stable tag: 3.3.0 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html -
posti-warehouse/trunk/README.md
r3198079 r3239423 98 98 99 99 ## Version history 100 - 3.3.0: 101 - Added GLS, UPS tracking links. 100 102 - 3.2.0: 101 103 - Added clickable tracking link to order table and email. -
posti-warehouse/trunk/classes/class-api.php
r3198079 r3239423 14 14 private $last_status = false; 15 15 private $token_option = 'posti_wh_api_auth'; 16 private $user_agent = 'woo-wh-client/3. 2.0';16 private $user_agent = 'woo-wh-client/3.3.0'; 17 17 18 18 public function __construct(Posti_Warehouse_Logger $logger, array &$options) { -
posti-warehouse/trunk/classes/class-frontend.php
r3139663 r3239423 179 179 180 180 $key_id = $this->add_prefix('_pickup_point_id'); 181 182 181 if (empty($pickup_point)) { 183 182 $pickup_point = WC()->session->get($key_id); … … 188 187 $order = wc_get_order($order_id); 189 188 $order->update_meta_data('_' . $key, sanitize_text_field($pickup_point)); 190 // Find string like '(#6681)' 191 preg_match('/\(#[A-Za-z0-9\-]+\)/', $pickup_point, $matches); 192 // Cut the number out from a string of the form '(#6681)' 193 $pickup_point_id = ( !empty($matches) ) ? substr($matches[0], 2, -1) : ''; 194 $order->update_meta_data('_' . $key_id, sanitize_text_field($pickup_point_id)); 195 $order->save(); 196 } 189 190 $pickup_point_ref = $this->extract_pickup_point_ref($pickup_point); 191 if (!empty($pickup_point_ref)) { 192 $order->update_meta_data('_' . $key_id, sanitize_text_field($pickup_point_ref)); 193 $order->save(); 194 } 195 } 196 } 197 198 private function extract_pickup_point_ref($pickup_point) { 199 $preamble = ' (#'; 200 $preamble_start = strpos($pickup_point, $preamble); 201 if ($preamble_start && $preamble_start > 0) { 202 return substr($pickup_point, $preamble_start + strlen($preamble), -1); 203 } 204 205 return null; 197 206 } 198 207 … … 539 548 } 540 549 550 $pickup_point_ref = base64_encode(json_encode($pickup_point)); 541 551 $key_part = empty($serviceProvider) ? $type : $serviceProvider; 542 552 $pickup_point_key = $key_part 543 553 . ': ' . $pickup_point['name'] 544 . ' (#' . $pickup_point ['externalId']. ')';554 . ' (#' . $pickup_point_ref . ')'; 545 555 $pickup_point_value = $pickup_point['name'] 546 556 . ' (' . $pickup_point['streetAddress'] . ')'; … … 574 584 575 585 if (!empty($pickup_point)) { 586 $pickup_point_preamble_start = strpos($pickup_point, ' (#'); 587 $pickup_point_text = strlen($pickup_point) - $pickup_point_preamble_start > 36 ? substr($pickup_point, 0, $pickup_point_preamble_start) : $pickup_point; 576 588 wc_get_template( 577 589 $this->core->templates['account_order'], 578 590 array( 579 'pickup_point' => esc_attr($pickup_point ),591 'pickup_point' => esc_attr($pickup_point_text), 580 592 'texts' => array( 581 593 'title' => Posti_Warehouse_Text::pickup_point_title() -
posti-warehouse/trunk/classes/class-order.php
r3198079 r3239423 545 545 $item_counter = 1; 546 546 $service_code = $order_services['service']; 547 $pickup_point = $_order->get_meta('_warehouse_pickup_point_id', true); //_woo_posti_shipping_pickup_point_id 547 $pickup_point_ref = $_order->get_meta('_warehouse_pickup_point_id', true); //_woo_posti_shipping_pickup_point_id 548 $pickup_point = empty($pickup_point_ref) ? null : json_decode(base64_decode($pickup_point_ref), true); 548 549 549 550 foreach ($_order->get_items('shipping') as $item_id => $shipping_item_obj) { … … 623 624 'email' => $_order->get_billing_email() 624 625 ], 625 'deliveryAddress' => [ 626 'name' => $_order->get_shipping_first_name() . ' ' . $_order->get_shipping_last_name(), 627 'streetAddress' => $_order->get_shipping_address_1(), 628 'postalCode' => $_order->get_shipping_postcode(), 629 'postOffice' => $_order->get_shipping_city(), 630 'country' => $_order->get_shipping_country(), 631 'telephone' => $phone, 632 'email' => $email 633 ], 634 'pickupPointId' => $pickup_point, 626 'deliveryAddress' => $this->getDeliveryAddress($_order, $phone, $email), 635 627 'currency' => $_order->get_currency(), 636 628 'serviceCode' => (string) $service_code, … … 640 632 'rows' => $order_items 641 633 ); 634 635 if (isset($pickup_point) && $pickup_point) { 636 $order['pickupPoint'] = $this->getPickupPoint($pickup_point); 637 } 642 638 643 639 $note = $_order->get_customer_note(); … … 714 710 $tracking_link = Posti_Warehouse_Order::get_tracking_link($order); 715 711 if (!empty($tracking_link)) { 716 echo '<p>' . Posti_Warehouse_Text::tracking_number($tracking_link) . '</p>'; 717 } 712 echo '<p>' . Posti_Warehouse_Text::tracking_number($tracking_link) . '</p>'; 713 } 714 } 715 716 private static function getDeliveryAddress($order, $phone, $email) { 717 return array( 718 'name' => $order->get_shipping_first_name() . ' ' . $order->get_shipping_last_name(), 719 'streetAddress' => $order->get_shipping_address_1(), 720 'postalCode' => $order->get_shipping_postcode(), 721 'postOffice' => $order->get_shipping_city(), 722 'country' => $order->get_shipping_country(), 723 'telephone' => $phone, 724 'email' => $email 725 ); 726 } 727 728 private static function getPickupPoint($pickup_point) { 729 return array( 730 'externalId' => isset($pickup_point['externalId']) ? $pickup_point['externalId'] : null, 731 'name' => isset($pickup_point['name']) ? $pickup_point['name'] : null, 732 'streetAddress' => isset($pickup_point['streetAddress']) ? $pickup_point['streetAddress'] : null, 733 'postalCode' => isset($pickup_point['postalCode']) ? $pickup_point['postalCode'] : null, 734 'postOffice' => isset($pickup_point['postOffice']) ? $pickup_point['postOffice'] : null, 735 'country' => isset($pickup_point['country']) ? $pickup_point['country'] : null 736 ); 718 737 } 719 738 … … 725 744 $tracking_code = $order->get_meta('_posti_api_tracking', true); 726 745 if (empty($tracking_code)) { 727 return $tracking_code;746 return $tracking_code; 728 747 } 729 748 730 749 $operator = $order->get_meta('_posti_api_operator', true); 731 750 if (empty($operator)) { 732 return $tracking_code;751 return $tracking_code; 733 752 } 734 753 735 754 $delivery_operator_link = Posti_Warehouse_Order::get_delivery_operator_url($operator); 736 755 if (empty($delivery_operator_link)) { 737 return $tracking_code;756 return $tracking_code; 738 757 } 739 758 … … 755 774 return "https://www.dbschenker.com/app/tracking-public/?refType=WaybillNo&refNumber="; 756 775 } 776 else if ('gls' === $op) { 777 return "https://gls-group.eu/GROUP/en/parcel-tracking?match="; 778 } 779 else if ('ups' === $op) { 780 return "https://www.ups.com/track?loc=en_US&requester=ST/&tracknum="; 781 } 757 782 758 783 return null; -
posti-warehouse/trunk/posti-warehouse.php
r3198079 r3239423 3 3 /** 4 4 * Plugin Name: Posti Warehouse 5 * Version: 3. 2.05 * Version: 3.3.0 6 6 * Description: Provides integration to Posti warehouse and dropshipping services. 7 7 * Author: Posti -
posti-warehouse/trunk/readme.txt
r3198079 r3239423 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.1 7 Stable tag: 3. 2.07 Stable tag: 3.3.0 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset
for help on using the changeset viewer.