Changeset 3333025
- Timestamp:
- 07/23/2025 02:53:44 PM (8 months ago)
- Location:
- sendcloud-connected-shipping
- Files:
-
- 131 added
- 6 edited
-
tags/1.0.14 (added)
-
tags/1.0.14/changelog.txt (added)
-
tags/1.0.14/composer.json (added)
-
tags/1.0.14/composer.lock (added)
-
tags/1.0.14/database (added)
-
tags/1.0.14/database/Exceptions (added)
-
tags/1.0.14/database/Exceptions/class-migration-exception.php (added)
-
tags/1.0.14/database/Migrations (added)
-
tags/1.0.14/database/Migrations/migration.v.1.0.0.php (added)
-
tags/1.0.14/database/Migrations/migration.v.1.0.1.php (added)
-
tags/1.0.14/database/Migrations/migration.v.1.0.11.php (added)
-
tags/1.0.14/database/Utility (added)
-
tags/1.0.14/database/Utility/class-migration-reader.php (added)
-
tags/1.0.14/database/class-abstract-migration.php (added)
-
tags/1.0.14/database/class-migrator.php (added)
-
tags/1.0.14/i18n (added)
-
tags/1.0.14/i18n/languages (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-de_DE.mo (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-de_DE.po (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-en_GB.mo (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-en_GB.po (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-en_US.mo (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-en_US.po (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-es_ES.mo (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-es_ES.po (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-fr_FR.mo (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-fr_FR.po (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-it_IT.mo (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-it_IT.po (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-nl_NL.mo (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping-nl_NL.po (added)
-
tags/1.0.14/i18n/languages/sendcloud-connected-shipping.pot (added)
-
tags/1.0.14/includes (added)
-
tags/1.0.14/includes/Controllers (added)
-
tags/1.0.14/includes/Controllers/Api (added)
-
tags/1.0.14/includes/Controllers/Api/class-authorization.php (added)
-
tags/1.0.14/includes/Controllers/Api/class-base-wc-rest-controller.php (added)
-
tags/1.0.14/includes/Controllers/Api/class-integration-controller.php (added)
-
tags/1.0.14/includes/Controllers/Api/class-service-point-controller.php (added)
-
tags/1.0.14/includes/Controllers/Api/class-status-controller.php (added)
-
tags/1.0.14/includes/Controllers/Backend (added)
-
tags/1.0.14/includes/Controllers/Backend/class-connect-controller.php (added)
-
tags/1.0.14/includes/Controllers/Backend/class-migration-controller.php (added)
-
tags/1.0.14/includes/Controllers/Backend/class-support-controller.php (added)
-
tags/1.0.14/includes/Controllers/Backend/class-view-controller.php (added)
-
tags/1.0.14/includes/Controllers/Frontend (added)
-
tags/1.0.14/includes/Controllers/Frontend/class-base-controller.php (added)
-
tags/1.0.14/includes/Controllers/Frontend/class-oauth-complete-controller.php (added)
-
tags/1.0.14/includes/Controllers/Frontend/class-oauth-connect-controller.php (added)
-
tags/1.0.14/includes/Exceptions (added)
-
tags/1.0.14/includes/Exceptions/class-http-unsuccessful-response.php (added)
-
tags/1.0.14/includes/Exceptions/class-invalid-payload-exception.php (added)
-
tags/1.0.14/includes/Exceptions/class-missing-auth-data-exception.php (added)
-
tags/1.0.14/includes/Exceptions/class-missing-consumer-key-exception.php (added)
-
tags/1.0.14/includes/Exceptions/class-request-missing-parameters-exception.php (added)
-
tags/1.0.14/includes/HookHandlers (added)
-
tags/1.0.14/includes/HookHandlers/class-api-handler.php (added)
-
tags/1.0.14/includes/HookHandlers/class-plugin-disable-handler.php (added)
-
tags/1.0.14/includes/HookHandlers/class-product-handler.php (added)
-
tags/1.0.14/includes/Models (added)
-
tags/1.0.14/includes/Models/class-api-key.php (added)
-
tags/1.0.14/includes/Models/class-auth-data.php (added)
-
tags/1.0.14/includes/Models/class-deactivation-data.php (added)
-
tags/1.0.14/includes/Models/class-service-point-instance.php (added)
-
tags/1.0.14/includes/Models/class-service-point-meta.php (added)
-
tags/1.0.14/includes/Repositories (added)
-
tags/1.0.14/includes/Repositories/class-abstract-repository.php (added)
-
tags/1.0.14/includes/Repositories/class-api-key-repository.php (added)
-
tags/1.0.14/includes/Repositories/class-config-repository.php (added)
-
tags/1.0.14/includes/Repositories/class-order-repository.php (added)
-
tags/1.0.14/includes/Repositories/class-shipping-method-options-repository.php (added)
-
tags/1.0.14/includes/ServicePoint (added)
-
tags/1.0.14/includes/ServicePoint/Checkout (added)
-
tags/1.0.14/includes/ServicePoint/Checkout/class-checkout-block-handler.php (added)
-
tags/1.0.14/includes/ServicePoint/Checkout/class-checkout-handler.php (added)
-
tags/1.0.14/includes/ServicePoint/Shipping (added)
-
tags/1.0.14/includes/ServicePoint/Shipping/class-abstract-flat-rate-free-shipping-method.php (added)
-
tags/1.0.14/includes/ServicePoint/Shipping/class-service-point-shipping-method.php (added)
-
tags/1.0.14/includes/ServicePoint/class-email-handler.php (added)
-
tags/1.0.14/includes/ServicePoint/class-order-admin-handler.php (added)
-
tags/1.0.14/includes/Services (added)
-
tags/1.0.14/includes/Services/class-auth-service.php (added)
-
tags/1.0.14/includes/Services/class-config-service.php (added)
-
tags/1.0.14/includes/Services/class-connect-service.php (added)
-
tags/1.0.14/includes/Services/class-webhook-service.php (added)
-
tags/1.0.14/includes/Utility (added)
-
tags/1.0.14/includes/Utility/class-auth-code-generator.php (added)
-
tags/1.0.14/includes/Utility/class-base64-url-encoder.php (added)
-
tags/1.0.14/includes/Utility/class-database.php (added)
-
tags/1.0.14/includes/Utility/class-http-client.php (added)
-
tags/1.0.14/includes/Utility/class-logger-factory.php (added)
-
tags/1.0.14/includes/Utility/class-logger.php (added)
-
tags/1.0.14/includes/Utility/class-response.php (added)
-
tags/1.0.14/includes/Utility/class-shop-helper.php (added)
-
tags/1.0.14/includes/Utility/class-version-utility.php (added)
-
tags/1.0.14/includes/Utility/class-view.php (added)
-
tags/1.0.14/includes/class-sendcloud.php (added)
-
tags/1.0.14/readme.txt (added)
-
tags/1.0.14/resources (added)
-
tags/1.0.14/resources/css (added)
-
tags/1.0.14/resources/css/sendcloud.css (added)
-
tags/1.0.14/resources/js (added)
-
tags/1.0.14/resources/js/sendcloud.page.js (added)
-
tags/1.0.14/resources/js/service-point-block.js (added)
-
tags/1.0.14/resources/views (added)
-
tags/1.0.14/resources/views/plugin (added)
-
tags/1.0.14/resources/views/plugin/deactivation-notice.php (added)
-
tags/1.0.14/resources/views/service-point (added)
-
tags/1.0.14/resources/views/service-point/checkout (added)
-
tags/1.0.14/resources/views/service-point/checkout/service-point-carriers.php (added)
-
tags/1.0.14/resources/views/service-point/email-template.php (added)
-
tags/1.0.14/resources/views/service-point/order-admin.php (added)
-
tags/1.0.14/resources/views/service-point/order-confirmation-page.php (added)
-
tags/1.0.14/resources/views/wc-settings (added)
-
tags/1.0.14/resources/views/wc-settings/sendcloud-page.php (added)
-
tags/1.0.14/sendcloud-connected-shipping.php (added)
-
tags/1.0.14/uninstall.php (added)
-
tags/1.0.14/vendor (added)
-
tags/1.0.14/vendor/autoload.php (added)
-
tags/1.0.14/vendor/composer (added)
-
tags/1.0.14/vendor/composer/ClassLoader.php (added)
-
tags/1.0.14/vendor/composer/InstalledVersions.php (added)
-
tags/1.0.14/vendor/composer/LICENSE (added)
-
tags/1.0.14/vendor/composer/autoload_classmap.php (added)
-
tags/1.0.14/vendor/composer/autoload_namespaces.php (added)
-
tags/1.0.14/vendor/composer/autoload_psr4.php (added)
-
tags/1.0.14/vendor/composer/autoload_real.php (added)
-
tags/1.0.14/vendor/composer/autoload_static.php (added)
-
tags/1.0.14/vendor/composer/installed.json (added)
-
tags/1.0.14/vendor/composer/installed.php (added)
-
tags/1.0.14/vendor/composer/platform_check.php (added)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/includes/ServicePoint/Checkout/class-checkout-handler.php (modified) (3 diffs)
-
trunk/includes/class-sendcloud.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/sendcloud-connected-shipping.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sendcloud-connected-shipping/trunk/changelog.txt
r3318368 r3333025 1 1 *** WooCommerce Sendcloud | The all-in-one shipping platform Changelog *** 2 3 = 2025-07-23 - version 1.0.14 = 4 * Fixed checkout translation 2 5 3 6 = 2025-06-26 - version 1.0.13 = -
sendcloud-connected-shipping/trunk/includes/ServicePoint/Checkout/class-checkout-handler.php
r3300820 r3333025 11 11 use SCCSP\SendCloud\Connected\Shipping\Utility\SCCSP_View; 12 12 13 if ( ! defined( 'ABSPATH' )) {14 exit; // Exit if accessed directly13 if (!defined('ABSPATH')) { 14 exit; // Exit if accessed directly 15 15 } 16 16 17 class SCCSP_Checkout_Handler { 18 19 const CLASS_NAME = __CLASS__; 20 21 const SERVICE_POINT_EXTRA_FIELD_NAME_V2 = 'sendcloudshipping_service_point_extra_v2'; 22 23 /** 24 * @var SCCSP_Config_Service 25 */ 26 private $config_service; 27 28 /** 29 * @var \SCCSP\SendCloud\Connected\Shipping\Repositories\SCCSP_Shipping_Method_Options_Repository 30 */ 31 private $shipping_method_repository; 32 33 /** 34 * @var \SCCSP\SendCloud\Connected\Shipping\Repositories\SCCSP_Order_Repository 35 */ 36 private $order_repository; 37 38 /** 39 * Checkout_Handler constructor 40 */ 41 public function __construct() { 42 $this->config_service = new SCCSP_Config_Service(); 43 $this->shipping_method_repository = new SCCSP_Shipping_Method_Options_Repository(); 44 $this->order_repository = new SCCSP_Order_Repository(); 45 } 46 47 /** 48 * @return void 49 */ 50 public function init() { 51 add_action( 'woocommerce_checkout_after_order_review', array( $this, 'add_script_data' ) ); 52 add_action( 'wfacp_checkout_after_order_review', array( $this, 'add_script_data' ) ); 53 add_action( 'woocommerce_after_shipping_rate', array( $this, 'add_carriers' ) ); 54 add_action( 'woocommerce_checkout_process', array( $this, 'add_notice_if_service_point_not_chosen' ) ); 55 add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'update_order_meta' ) ); 56 add_action( 'woocommerce_thankyou', array( $this, 'add_service_point_info' ), 11 ); 57 add_action( 'woocommerce_view_order', array( $this, 'add_service_point_info' ), 11 ); 58 } 59 60 /** 61 * Adds service point data necessary for script in the checkout 62 */ 63 public function add_script_data() { 64 $script = $this->config_service->get_service_point_script(); 65 66 if ( empty( $script ) ) { 67 return; 68 } 69 70 wp_register_script( 'sendcloud-v2-service-point-js', $script, array(), SCCSP_Sendcloud::VERSION, true ); 17 class SCCSP_Checkout_Handler 18 { 19 20 const CLASS_NAME = __CLASS__; 21 22 const SERVICE_POINT_EXTRA_FIELD_NAME_V2 = 'sendcloudshipping_service_point_extra_v2'; 23 24 /** 25 * @var SCCSP_Config_Service 26 */ 27 private $config_service; 28 29 /** 30 * @var \SCCSP\SendCloud\Connected\Shipping\Repositories\SCCSP_Shipping_Method_Options_Repository 31 */ 32 private $shipping_method_repository; 33 34 /** 35 * @var \SCCSP\SendCloud\Connected\Shipping\Repositories\SCCSP_Order_Repository 36 */ 37 private $order_repository; 38 39 /** 40 * Checkout_Handler constructor 41 */ 42 public function __construct() 43 { 44 $this->config_service = new SCCSP_Config_Service(); 45 $this->shipping_method_repository = new SCCSP_Shipping_Method_Options_Repository(); 46 $this->order_repository = new SCCSP_Order_Repository(); 47 } 48 49 /** 50 * @return void 51 */ 52 public function init() 53 { 54 add_action('woocommerce_checkout_after_order_review', array($this, 'add_script_data')); 55 add_action('wfacp_checkout_after_order_review', array($this, 'add_script_data')); 56 add_action('woocommerce_after_shipping_rate', array($this, 'add_carriers')); 57 add_action('woocommerce_checkout_process', array($this, 'add_notice_if_service_point_not_chosen')); 58 add_action('woocommerce_checkout_update_order_meta', array($this, 'update_order_meta')); 59 add_action('woocommerce_thankyou', array($this, 'add_service_point_info'), 11); 60 add_action('woocommerce_view_order', array($this, 'add_service_point_info'), 11); 61 } 62 63 /** 64 * Adds service point data necessary for script in the checkout 65 */ 66 public function add_script_data() 67 { 68 $script = $this->config_service->get_service_point_script(); 69 70 if (empty($script)) { 71 return; 72 } 73 74 wp_register_script('sendcloud-v2-service-point-js', $script, array(), SCCSP_Sendcloud::VERSION, true); 71 75 72 76 $service_point_data_script = $this->sc_v2_generate_service_point_data_script(); 73 77 74 wp_add_inline_script( 'sendcloud-v2-service-point-js', $service_point_data_script);75 wp_enqueue_script( 'sendcloud-v2-service-point-js');76 77 wp_enqueue_script( 'sendcloud-v2-service-point-block',78 SCCSP_Sendcloud::get_plugin_url( 'resources/js/service-point-block.js'),79 array( 'jquery'),78 wp_add_inline_script('sendcloud-v2-service-point-js', $service_point_data_script, 'before'); 79 wp_enqueue_script('sendcloud-v2-service-point-js'); 80 81 wp_enqueue_script('sendcloud-v2-service-point-block', 82 SCCSP_Sendcloud::get_plugin_url('resources/js/service-point-block.js'), 83 array('jquery'), 80 84 SCCSP_Sendcloud::VERSION, 81 85 true 82 86 ); 83 }87 } 84 88 85 89 /** … … 90 94 public function sc_v2_generate_service_point_data_script() 91 95 { 92 $parts = explode( '_', get_locale() );93 94 96 $script_data = array( 95 'language' => esc_js( $parts[0]),96 'cart_dimensions' => esc_js( base64_encode( json_encode( $this->cart_max_dimensions() ) )),97 'cart_dimensions_unit' => esc_js( json_encode( get_option( 'woocommerce_dimension_unit' ) )),98 'select_spp_label' => esc_js( __( 'Select Service Point', 'sendcloud-connected-shipping' )),97 'language' => esc_js($this->getFormattedLocale()), 98 'cart_dimensions' => esc_js(base64_encode(json_encode($this->cart_max_dimensions()))), 99 'cart_dimensions_unit' => esc_js(json_encode(get_option('woocommerce_dimension_unit'))), 100 'select_spp_label' => esc_js(__('Select Service Point', 'sendcloud-connected-shipping')), 99 101 ); 100 102 … … 111 113 } 112 114 113 /** 114 * Add carrier hidden inout fields 115 * 116 * @param $method 117 * 118 * @return void 119 */ 120 public function add_carriers( $method ) { 121 if ( Service_Point_Free_Shipping_Method::ID === $method->method_id ) { 122 $instance_id = $method->instance_id; 123 if ( ! $instance_id ) { 124 $id = explode( ':', $method->id ); 125 $instance_id = ! empty( $id[1] ) ? $id[1] : null; 126 } 127 128 $this->render_carriers( $instance_id, $method->id ); 129 } 130 } 131 132 /** 133 * Checks whether user chose service point before creating an order 134 */ 135 public function add_notice_if_service_point_not_chosen() { 136 SCCSP_Logger::info( 'Checkout_Handler::add_notice_if_service_point_not_chosen() invoked ' ); 115 /** 116 * Add carrier hidden inout fields 117 * 118 * @param $method 119 * 120 * @return void 121 */ 122 public function add_carriers($method) 123 { 124 if (Service_Point_Free_Shipping_Method::ID === $method->method_id) { 125 $instance_id = $method->instance_id; 126 if (!$instance_id) { 127 $id = explode(':', $method->id); 128 $instance_id = !empty($id[1]) ? $id[1] : null; 129 } 130 131 $this->render_carriers($instance_id, $method->id); 132 } 133 } 134 135 /** 136 * Checks whether user chose service point before creating an order 137 */ 138 public function add_notice_if_service_point_not_chosen() 139 { 140 SCCSP_Logger::info('Checkout_Handler::add_notice_if_service_point_not_chosen() invoked '); 137 141 138 142 $service_point_key = $this->get_selected_shipping_method_id_key(); 139 $nonce= $this->get_nonce();140 141 $service_point_extra_field = isset( $_POST[ self::SERVICE_POINT_EXTRA_FIELD_NAME_V2 ])142 ? sanitize_text_field( wp_unslash( $_POST[ self::SERVICE_POINT_EXTRA_FIELD_NAME_V2 ] ))143 $nonce = $this->get_nonce(); 144 145 $service_point_extra_field = isset($_POST[self::SERVICE_POINT_EXTRA_FIELD_NAME_V2]) 146 ? sanitize_text_field(wp_unslash($_POST[self::SERVICE_POINT_EXTRA_FIELD_NAME_V2])) 143 147 : ''; 144 148 145 $service_point_selected = ! empty( $service_point_extra_field)146 && ( ( $nonce && wp_verify_nonce( sanitize_text_field( $nonce),147 'woocommerce-process_checkout' ))148 || WC()->session->get( 'reload_checkout', false ));149 150 if ( Service_Point_Free_Shipping_Method::ID === $service_point_key && ! $service_point_selected) {149 $service_point_selected = !empty($service_point_extra_field) 150 && (($nonce && wp_verify_nonce(sanitize_text_field($nonce), 151 'woocommerce-process_checkout')) 152 || WC()->session->get('reload_checkout', false)); 153 154 if (Service_Point_Free_Shipping_Method::ID === $service_point_key && !$service_point_selected) { 151 155 wc_add_notice( 152 esc_html__( 'Please choose a service point.', 'sendcloud-connected-shipping'),156 esc_html__('Please choose a service point.', 'sendcloud-connected-shipping'), 153 157 'error' 154 158 ); 155 159 } 156 } 157 158 /** 159 * Updates post meta field if service point is selected 160 * 161 * @param $order_id 162 */ 163 public function update_order_meta( $order_id ) { 164 SCCSP_Logger::info( 'Checkout_Handler::update_order_meta(): ' . 'order id: ' . $order_id ); 165 166 $nonce = $this->get_nonce(); 167 $service_point_selected = isset( $_POST[ self::SERVICE_POINT_EXTRA_FIELD_NAME_V2 ] ) 168 && ( ( $nonce && wp_verify_nonce( sanitize_text_field( $nonce ), 169 'woocommerce-process_checkout' ) ) 170 || WC()->session->get( 'reload_checkout', false ) ); 171 172 SCCSP_Logger::info( 'Checkout_Handler::update_order_meta(): ' . 'service point selected: ' . $service_point_selected ); 173 174 if ( $service_point_selected ) { 175 $service_point_json = isset( $_POST[ self::SERVICE_POINT_EXTRA_FIELD_NAME_V2 ] ) 176 ? sanitize_text_field( wp_unslash( $_POST[ self::SERVICE_POINT_EXTRA_FIELD_NAME_V2 ] ) ) : ''; 177 $service_point_data = json_decode( $service_point_json, true ); 178 if ( isset( $service_point_data['id'], $service_point_data['toPostalCode'], $service_point_data['name'], 179 $service_point_data['street'], $service_point_data['city'], $service_point_data['postal_code'], $service_point_data['house_number'] ) 180 ) { 181 $this->order_repository->save_service_point_meta( $order_id, $service_point_json ); 182 183 return; 184 } 185 } 186 187 SCCSP_Logger::warning( 'Service point data not found.' ); 188 } 189 190 /** 191 * Adds service point information in the order thank you page 192 * 193 * @param $order_id 194 */ 195 public function add_service_point_info( $order_id ) { 196 SCCSP_Logger::info( 'Checkout_Handler::add_service_point_info(): ' . 'order id: ' . $order_id ); 197 $service_point = $this->order_repository->get_service_point_meta( $order_id ); 198 if ( $service_point ) { 199 SCCSP_Logger::info( 'Checkout_Handler::add_service_point_info(): ' . 'service point: ' . json_encode( $service_point->to_array() ) ); 200 echo wp_kses( SCCSP_View::file( '/service-point/order-confirmation-page.php' )->render( array( 201 'address' => $service_point->get_address_formatted(), 202 'post_number' => $service_point->get_to_post_number() 203 ) ), SCCSP_View::get_allowed_tags() ); 204 } 205 } 206 207 /** 208 * @param $instance_id 209 * @param $method 210 * 211 * @return void 212 */ 213 protected function render_carriers( $instance_id, $method ) { 214 $carriers = $this->shipping_method_repository->get_service_point_instance( $instance_id )->get_carriers(); 215 216 echo wp_kses( SCCSP_View::file( '/service-point/checkout/service-point-carriers.php' )->render( array( 217 'field_id' => $method . ':carrier_select', 218 'carrier_select' => isset( $carriers ) ? implode( ',', $carriers ) : '', 219 ) ), SCCSP_View::get_allowed_tags() ); 220 } 221 222 /** 223 * Get selected shipping method id key 224 * 225 * @return mixed|string 226 */ 227 private function get_selected_shipping_method_id_key() { 228 $nonce = $this->get_nonce(); 229 230 if ( isset( $_POST['shipping_method'][0] ) 231 && $nonce 232 && wp_verify_nonce( sanitize_text_field( $nonce ), 'woocommerce-process_checkout' ) ) { 233 $parts = explode( ':', sanitize_text_field( wp_unslash( $_POST['shipping_method'][0] ) ) ); 160 } 161 162 /** 163 * Updates post meta field if service point is selected 164 * 165 * @param $order_id 166 */ 167 public function update_order_meta($order_id) 168 { 169 SCCSP_Logger::info('Checkout_Handler::update_order_meta(): ' . 'order id: ' . $order_id); 170 171 $nonce = $this->get_nonce(); 172 $service_point_selected = isset($_POST[self::SERVICE_POINT_EXTRA_FIELD_NAME_V2]) 173 && (($nonce && wp_verify_nonce(sanitize_text_field($nonce), 174 'woocommerce-process_checkout')) 175 || WC()->session->get('reload_checkout', false)); 176 177 SCCSP_Logger::info('Checkout_Handler::update_order_meta(): ' . 'service point selected: ' . $service_point_selected); 178 179 if ($service_point_selected) { 180 $service_point_json = isset($_POST[self::SERVICE_POINT_EXTRA_FIELD_NAME_V2]) 181 ? sanitize_text_field(wp_unslash($_POST[self::SERVICE_POINT_EXTRA_FIELD_NAME_V2])) : ''; 182 $service_point_data = json_decode($service_point_json, true); 183 if (isset($service_point_data['id'], $service_point_data['toPostalCode'], $service_point_data['name'], 184 $service_point_data['street'], $service_point_data['city'], $service_point_data['postal_code'], $service_point_data['house_number']) 185 ) { 186 $this->order_repository->save_service_point_meta($order_id, $service_point_json); 187 188 return; 189 } 190 } 191 192 SCCSP_Logger::warning('Service point data not found.'); 193 } 194 195 /** 196 * Adds service point information in the order thank you page 197 * 198 * @param $order_id 199 */ 200 public function add_service_point_info($order_id) 201 { 202 SCCSP_Logger::info('Checkout_Handler::add_service_point_info(): ' . 'order id: ' . $order_id); 203 $service_point = $this->order_repository->get_service_point_meta($order_id); 204 if ($service_point) { 205 SCCSP_Logger::info('Checkout_Handler::add_service_point_info(): ' . 'service point: ' . json_encode($service_point->to_array())); 206 echo wp_kses(SCCSP_View::file('/service-point/order-confirmation-page.php')->render(array( 207 'address' => $service_point->get_address_formatted(), 208 'post_number' => $service_point->get_to_post_number() 209 )), SCCSP_View::get_allowed_tags()); 210 } 211 } 212 213 /** 214 * @param $instance_id 215 * @param $method 216 * 217 * @return void 218 */ 219 protected function render_carriers($instance_id, $method) 220 { 221 $carriers = $this->shipping_method_repository->get_service_point_instance($instance_id)->get_carriers(); 222 223 echo wp_kses(SCCSP_View::file('/service-point/checkout/service-point-carriers.php')->render(array( 224 'field_id' => $method . ':carrier_select', 225 'carrier_select' => isset($carriers) ? implode(',', $carriers) : '', 226 )), SCCSP_View::get_allowed_tags()); 227 } 228 229 /** 230 * Get selected shipping method id key 231 * 232 * @return mixed|string 233 */ 234 private function get_selected_shipping_method_id_key() 235 { 236 $nonce = $this->get_nonce(); 237 238 if (isset($_POST['shipping_method'][0]) 239 && $nonce 240 && wp_verify_nonce(sanitize_text_field($nonce), 'woocommerce-process_checkout')) { 241 $parts = explode(':', sanitize_text_field(wp_unslash($_POST['shipping_method'][0]))); 234 242 235 243 return $parts[0]; 236 }237 238 /*239 * In case where the customer account is created on checkout, nonce value is already verified by the base240 * checkout action at the start, then the customer account is created, after that nonce value is no longer valid241 * for the newly started session.242 * The reload_checkout flag is set on session by the WooCommerce system so it is safe to use as an indicator243 * of that checkout case, and since the nonce was already verified, it is safe to read request parameters.244 */245 $is_checkout_reload = WC()->session->get( 'reload_checkout', false);246 if ( isset( $_POST['shipping_method'][0] ) && $is_checkout_reload) {247 $parts = explode( ':', sanitize_text_field( wp_unslash( $_POST['shipping_method'][0] ) ));244 } 245 246 /* 247 * In case where the customer account is created on checkout, nonce value is already verified by the base 248 * checkout action at the start, then the customer account is created, after that nonce value is no longer valid 249 * for the newly started session. 250 * The reload_checkout flag is set on session by the WooCommerce system so it is safe to use as an indicator 251 * of that checkout case, and since the nonce was already verified, it is safe to read request parameters. 252 */ 253 $is_checkout_reload = WC()->session->get('reload_checkout', false); 254 if (isset($_POST['shipping_method'][0]) && $is_checkout_reload) { 255 $parts = explode(':', sanitize_text_field(wp_unslash($_POST['shipping_method'][0]))); 248 256 249 257 return $parts[0]; 250 } 251 252 return ''; 253 } 254 255 /** 256 * Fetches nonce from request. If nonce is not set in request, it will return null. 257 * 258 * @return string|null 259 */ 260 protected function get_nonce() { 261 if ( isset( $_REQUEST['woocommerce-process-checkout-nonce'] ) ) { 262 return wp_kses_post( wp_unslash( $_REQUEST['woocommerce-process-checkout-nonce'] ) ); 263 } 264 265 if ( isset( $_REQUEST['_wpnonce'] ) ) { 266 return wp_kses_post( wp_unslash( $_REQUEST['_wpnonce'] ) ); 267 } 268 269 return null; 270 } 271 272 /** 273 * Gets product dimensions 274 * 275 * @return array 276 */ 277 private function cart_max_dimensions() { 278 $dimensions = array(); 279 $cart = WC()->cart; 280 281 foreach ( $cart->get_cart() as $values ) { 282 $product = $values['data']; 283 if ( $product->has_dimensions() ) { 284 $dimensions[] = array( 285 $product->get_length(), 286 $product->get_width(), 287 $product->get_height(), 288 ); 289 } 290 } 291 292 return $dimensions; 293 } 258 } 259 260 return ''; 261 } 262 263 /** 264 * Fetches nonce from request. If nonce is not set in request, it will return null. 265 * 266 * @return string|null 267 */ 268 protected function get_nonce() 269 { 270 if (isset($_REQUEST['woocommerce-process-checkout-nonce'])) { 271 return wp_kses_post(wp_unslash($_REQUEST['woocommerce-process-checkout-nonce'])); 272 } 273 274 if (isset($_REQUEST['_wpnonce'])) { 275 return wp_kses_post(wp_unslash($_REQUEST['_wpnonce'])); 276 } 277 278 return null; 279 } 280 281 /** 282 * Gets product dimensions 283 * 284 * @return array 285 */ 286 private function cart_max_dimensions() 287 { 288 $dimensions = array(); 289 $cart = WC()->cart; 290 291 foreach ($cart->get_cart() as $values) { 292 $product = $values['data']; 293 if ($product->has_dimensions()) { 294 $dimensions[] = array( 295 $product->get_length(), 296 $product->get_width(), 297 $product->get_height(), 298 ); 299 } 300 } 301 302 return $dimensions; 303 } 304 305 /** 306 * Returns formatted locale to be used in the JS script 307 * 308 * @return string 309 */ 310 private function getFormattedLocale(): string 311 { 312 return strtolower(str_replace('_', '-', get_locale())); 313 } 294 314 } -
sendcloud-connected-shipping/trunk/includes/class-sendcloud.php
r3318368 r3333025 27 27 28 28 class SCCSP_Sendcloud { 29 const VERSION = '1.0.1 3';29 const VERSION = '1.0.14'; 30 30 31 31 const INTEGRATION_NAME = 'sendcloudshipping'; -
sendcloud-connected-shipping/trunk/readme.txt
r3318375 r3333025 1 1 === Sendcloud Shipping === 2 Version: 1.0.1 32 Version: 1.0.14 3 3 Developer: SendCloud Global B.V. 4 4 Developer URI: http://sendcloud.com … … 6 6 Requires at least: 4.9 7 7 Requires PHP: 7.0 8 Tested up to: 6.8 9 Stable tag: 1.0.1 38 Tested up to: 6.8.2 9 Stable tag: 1.0.14 10 10 License: GPLv2 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 91 91 92 92 == Changelog == 93 = 1.0.14 = 94 * Fixed checkout translation 95 93 96 = 1.0.13 = 94 97 * Fixed excessive DB queries -
sendcloud-connected-shipping/trunk/sendcloud-connected-shipping.php
r3318368 r3333025 4 4 * Plugin URI: https://wordpress.org/plugins/sendcloud-connected-shipping/ 5 5 * Description: Sendcloud plugin. 6 * Version: 1.0.1 36 * Version: 1.0.14 7 7 * Woo: 8 8 * Author: Sendcloud B.V. … … 15 15 * Domain Path: /i18n/languages/ 16 16 * WC requires at least: 3.5.0 17 * WC tested up to: 9. 8.517 * WC tested up to: 9.9.5 18 18 * 19 19 * @package sendcloud-connected-shipping -
sendcloud-connected-shipping/trunk/vendor/composer/installed.php
r3318368 r3333025 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 9d075f6b385d6314ef3d2844a924c877a6f07553',6 'reference' => '4cc742386ef767aa8d6f539ecc2e1b5f116d1333', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 9d075f6b385d6314ef3d2844a924c877a6f07553',16 'reference' => '4cc742386ef767aa8d6f539ecc2e1b5f116d1333', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.