Changeset 3171290
- Timestamp:
- 10/18/2024 08:37:46 AM (18 months ago)
- Location:
- bpost-shipping/trunk
- Files:
-
- 8 edited
-
bpost-shipping.php (modified) (2 diffs)
-
classes/class-wc-bpost-shipping-data-builder.php (modified) (8 diffs)
-
classes/class-wc-bpost-shipping-logger.php (modified) (3 diffs)
-
classes/class-wc-bpost-shipping-order-details-controller.php (modified) (3 diffs)
-
classes/locale/class-wc-bpost-shipping-locale-locale.php (modified) (1 diff)
-
classes/options/class-wc-bpost-shipping-options-base.php (modified) (1 diff)
-
languages/bpost_shipping.pot (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bpost-shipping/trunk/bpost-shipping.php
r3158208 r3171290 6 6 * Author: bpost 7 7 * Author URI: https://www.bpost.be/ 8 * Version: 3.1.1 08 * Version: 3.1.11 9 9 * WC requires at least: 3.0 10 10 * WC tested up to: 8.9 … … 15 15 define( 'BPOST_PLUGIN_DIR', __DIR__ ); 16 16 define( 'BPOST_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 17 define( 'BPOST_PLUGIN_VERSION', '3.1.1 0' );17 define( 'BPOST_PLUGIN_VERSION', '3.1.11' ); 18 18 19 19 /** -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-data-builder.php
r3158208 r3171290 1 1 <?php 2 2 3 use WC_BPost_Shipping\Adapter\WC_BPost_Shipping_Adapter_Woocommerce;4 3 use WC_BPost_Shipping\Locale\WC_BPost_Shipping_Locale_Locale; 5 4 use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Base; 5 use WC_BPost_Shipping\WC_Bpost_Shipping_Container as Container; 6 6 7 7 if ( ! defined( 'ABSPATH' ) ) { … … 18 18 private WC_BPost_Shipping_Delivery_Methods $delivery_methods; 19 19 20 private array $shm_supported_languages = array( 21 WC_BPost_Shipping_Locale_Locale::LANGUAGE_EN, 22 WC_BPost_Shipping_Locale_Locale::LANGUAGE_FR, 23 WC_BPost_Shipping_Locale_Locale::LANGUAGE_NL, 24 ); 25 private WC_BPost_Shipping_Logger $logger; 26 20 27 public function __construct( 21 28 WC_BPost_Shipping_Address $shipping_address, … … 23 30 WC_BPost_Shipping_Delivery_Methods $delivery_methods 24 31 ) { 25 $this->shipping_options = $shipping_options; 26 $this->shipping_address = $shipping_address; 27 $this->delivery_methods = $delivery_methods; 32 $this->shipping_options = $shipping_options; 33 $this->shipping_address = $shipping_address; 34 $this->delivery_methods = $delivery_methods; 35 $this->logger = Container::get_logger(); 28 36 } 29 37 … … 32 40 * @return string[] 33 41 */ 34 public function get_bpost_data() {42 public function get_bpost_data(): array { 35 43 36 44 // Build data to inject … … 46 54 'callback_url' => $callback_url, 47 55 // Euro-cents 48 'sub_total' => round( WC()->cart-> subtotal* 100 ),56 'sub_total' => round( WC()->cart->get_subtotal() * 100 ), 49 57 // In grams, if 0, then we set 1kg (1000g) 50 58 'sub_weight' => ceil( WC_BPost_Shipping_Cart::get_weight_in_g() ?: 1000 ), … … 66 74 } 67 75 68 /** 69 * @return string 70 */ 71 private function get_extra_json() { 76 private function get_extra_json(): string { 72 77 if ( $this->shipping_address->get_shipping_state() ) { 73 78 return json_encode( … … 79 84 } 80 85 81 /** 82 * @return string 83 */ 84 private function get_language_for_shm() { 85 $locale = new WC_BPost_Shipping_Locale_Locale( 86 new WC_BPost_Shipping_Adapter_Woocommerce() 87 ); 86 private function get_language_for_shm(): string { 87 $locale = new WC_BPost_Shipping_Locale_Locale( Container::get_adapter() ); 88 88 89 89 $language = $locale->get_language(); 90 90 91 $shm_supported_languages = array( 92 WC_BPost_Shipping_Locale_Locale::LANGUAGE_EN, 93 WC_BPost_Shipping_Locale_Locale::LANGUAGE_FR, 94 WC_BPost_Shipping_Locale_Locale::LANGUAGE_NL, 95 ); 96 97 if ( in_array( $language, $shm_supported_languages, true ) ) { 91 if ( in_array( $language, $this->shm_supported_languages, true ) ) { 98 92 return strtoupper( $language ); 93 } else { 94 $this->logger->warning( "Unsupported language '$language', falling back to '" . WC_BPost_Shipping_Locale_Locale::LANGUAGE_DEFAULT . "'" ); 99 95 } 100 96 … … 106 102 * @return string[] 107 103 */ 108 public function get_shipping_address() {104 public function get_shipping_address(): array { 109 105 $shipping_address = array( 110 106 'first_name' => $this->shipping_address->get_first_name(), -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-logger.php
r3079657 r3171290 65 65 66 66 if ( WC_Log_Levels::get_level_severity( $wcLevel ) < WC_Log_Levels::get_level_severity( $this->loggingLevel ) ) { 67 throw new InvalidArgumentException( "Unknown log level ${$wcLevel}" ); 67 $message = sprintf( "Unknown log level %s", $wcLevel ); 68 throw new InvalidArgumentException( esc_html( $message ) ); 68 69 } 69 70 … … 87 88 */ 88 89 public function setName( string $className ) { 89 \assert( \class_exists( $className ) );90 assert( class_exists( $className ) ); 90 91 91 92 $this->className = $className; … … 104 105 * Builds replacements list (for interpolate()) from the context values. 105 106 * based on 106 * @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#12-message107 * {@link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#12-message} 107 108 * 108 109 * @param array $context -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-order-details-controller.php
r3158208 r3171290 8 8 use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Base; 9 9 use WC_BPost_Shipping\Street\WC_BPost_Shipping_Street_Formatter; 10 use WC_BPost_Shipping\WC_Bpost_Shipping_Container ;10 use WC_BPost_Shipping\WC_Bpost_Shipping_Container as Container; 11 11 12 12 /** … … 78 78 private function get_geo6_template_data() { 79 79 if ( ! $this->meta_handler->get_delivery_point_type() ) { 80 $api_factory = new WC_BPost_Shipping_Api_Factory( WC_Bpost_Shipping_Container::get_logger() );80 $api_factory = new WC_BPost_Shipping_Api_Factory( Container::get_logger() ); 81 81 $order_updater = new WC_BPost_Shipping_Order_Updater( 82 82 $this->order, … … 87 87 } 88 88 89 $locale = new WC_BPost_Shipping_Locale_Locale( $this->adapter);89 $locale = new WC_BPost_Shipping_Locale_Locale( Container::get_adapter() ); 90 90 91 91 $url = sprintf( -
bpost-shipping/trunk/classes/locale/class-wc-bpost-shipping-locale-locale.php
r2890340 r3171290 5 5 use WC_BPost_Shipping\Adapter\WC_BPost_Shipping_Adapter_Woocommerce; 6 6 7 /**8 * Class WC_BPost_Shipping_Locale_Locale9 * @package WC_BPost_Shipping\Locale10 */11 7 class WC_BPost_Shipping_Locale_Locale { 12 8 13 const LANGUAGE_EN = 'EN';14 const LANGUAGE_FR = 'FR';15 const LANGUAGE_NL = 'NL';9 const LANGUAGE_EN = 'EN'; 10 const LANGUAGE_FR = 'FR'; 11 const LANGUAGE_NL = 'NL'; 16 12 const LANGUAGE_DEFAULT = self::LANGUAGE_EN; 17 13 18 /** @var WC_BPost_Shipping_Adapter_Woocommerce */ 19 private $adapter; 14 private WC_BPost_Shipping_Adapter_Woocommerce $adapter; 20 15 21 /**22 * WC_BPost_Shipping_Locale_Locale constructor.23 *24 * @param WC_BPost_Shipping_Adapter_Woocommerce $adapter25 */26 16 public function __construct( WC_BPost_Shipping_Adapter_Woocommerce $adapter ) { 27 28 17 $this->adapter = $adapter; 29 18 } 30 19 31 /** 32 * @return string 33 */ 34 public function get_locale() { 35 return $this->adapter->get_locale(); 36 } 37 38 /** 39 * @return string 40 */ 41 public function get_language() { 42 $split_locale = explode( '_', $this->get_locale() ); 20 public function get_language(): string { 21 // hack because weglot does not use get_locale() 22 if ( function_exists( 'weglot_get_current_language' ) ) { 23 return weglot_get_current_language(); 24 } 25 $split_locale = explode( '_', $this->adapter->get_locale() ); 43 26 44 27 if ( count( $split_locale ) === 2 ) { -
bpost-shipping/trunk/classes/options/class-wc-bpost-shipping-options-base.php
r3158208 r3171290 191 191 */ 192 192 public function is_free_shipping( $country_iso_2, $amount, array $free_shipping_coupons ) { 193 return $this->is_free_country_for_amount( $country_iso_2, $amount ) 194 || $this->has_free_shipping_coupon( $free_shipping_coupons ); 193 $result = $this->is_free_country_for_amount( $country_iso_2, $amount ) 194 || $this->has_free_shipping_coupon( $free_shipping_coupons ); 195 196 // Apply a filter to determine if free shipping should be applied 197 return apply_filters( 198 'wc_bpost_is_free_shipping', 199 $result, 200 false, 201 $country_iso_2, 202 $amount, 203 $free_shipping_coupons 204 ); 195 205 } 196 206 -
bpost-shipping/trunk/languages/bpost_shipping.pot
r3158208 r3171290 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: bpost shipping 3.1.1 0\n"5 "Project-Id-Version: bpost shipping 3.1.11\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/package\n" 7 "POT-Creation-Date: 2024- 09-26 11:54:47+00:00\n"7 "POT-Creation-Date: 2024-10-18 08:36:58+00:00\n" 8 8 "MIME-Version: 1.0\n" 9 9 "Content-Type: text/plain; charset=UTF-8\n" … … 197 197 msgstr "" 198 198 199 #. #-#-#-#-# bpost_shipping.pot (bpost shipping 3.1.1 0) #-#-#-#-#199 #. #-#-#-#-# bpost_shipping.pot (bpost shipping 3.1.11) #-#-#-#-# 200 200 #. Author of the plugin/theme 201 201 #: classes/class-wc-bpost-shipping-method.php:261 -
bpost-shipping/trunk/readme.txt
r3158208 r3171290 8 8 Tested up to: 6.5 9 9 Requires PHP: 7.4 10 Stable tag: 3.1.1 010 Stable tag: 3.1.11 11 11 License: GPLv2 or later 12 12 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 120 120 5. Configure your bpost shipping settings under the Woocommerce shipping > bpost shipping tab 121 121 == Changelog == 122 123 #### 3.1.11 124 125 *Release date: 2024-10-18* 126 127 * add WordPress filter in the free shipping detection 128 * suppress a php deprecation 129 * improve compatibility with weglot 122 130 123 131 #### 3.1.10
Note: See TracChangeset
for help on using the changeset viewer.