Plugin Directory

Changeset 3171290


Ignore:
Timestamp:
10/18/2024 08:37:46 AM (18 months ago)
Author:
antidot-dev
Message:

Release 3.1.11

Location:
bpost-shipping/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • bpost-shipping/trunk/bpost-shipping.php

    r3158208 r3171290  
    66 * Author: bpost
    77 * Author URI: https://www.bpost.be/
    8  * Version: 3.1.10
     8 * Version: 3.1.11
    99 * WC requires at least: 3.0
    1010 * WC tested up to: 8.9
     
    1515define( 'BPOST_PLUGIN_DIR', __DIR__ );
    1616define( 'BPOST_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    17 define( 'BPOST_PLUGIN_VERSION', '3.1.10' );
     17define( 'BPOST_PLUGIN_VERSION', '3.1.11' );
    1818
    1919/**
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-data-builder.php

    r3158208 r3171290  
    11<?php
    22
    3 use WC_BPost_Shipping\Adapter\WC_BPost_Shipping_Adapter_Woocommerce;
    43use WC_BPost_Shipping\Locale\WC_BPost_Shipping_Locale_Locale;
    54use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Base;
     5use WC_BPost_Shipping\WC_Bpost_Shipping_Container as Container;
    66
    77if ( ! defined( 'ABSPATH' ) ) {
     
    1818    private WC_BPost_Shipping_Delivery_Methods $delivery_methods;
    1919
     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
    2027    public function __construct(
    2128        WC_BPost_Shipping_Address $shipping_address,
     
    2330        WC_BPost_Shipping_Delivery_Methods $delivery_methods
    2431    ) {
    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();
    2836    }
    2937
     
    3240     * @return string[]
    3341     */
    34     public function get_bpost_data() {
     42    public function get_bpost_data(): array {
    3543
    3644        // Build data to inject
     
    4654            'callback_url'              => $callback_url,
    4755            // Euro-cents
    48             'sub_total'                 => round( WC()->cart->subtotal * 100 ),
     56            'sub_total'                 => round( WC()->cart->get_subtotal() * 100 ),
    4957            // In grams, if 0, then we set 1kg (1000g)
    5058            'sub_weight'                => ceil( WC_BPost_Shipping_Cart::get_weight_in_g() ?: 1000 ),
     
    6674    }
    6775
    68     /**
    69      * @return string
    70      */
    71     private function get_extra_json() {
     76    private function get_extra_json(): string {
    7277        if ( $this->shipping_address->get_shipping_state() ) {
    7378            return json_encode(
     
    7984    }
    8085
    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() );
    8888
    8989        $language = $locale->get_language();
    9090
    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 ) ) {
    9892            return strtoupper( $language );
     93        } else {
     94            $this->logger->warning( "Unsupported language '$language', falling back to '" . WC_BPost_Shipping_Locale_Locale::LANGUAGE_DEFAULT . "'" );
    9995        }
    10096
     
    106102     * @return string[]
    107103     */
    108     public function get_shipping_address() {
     104    public function get_shipping_address(): array {
    109105        $shipping_address = array(
    110106            'first_name'   => $this->shipping_address->get_first_name(),
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-logger.php

    r3079657 r3171290  
    6565
    6666        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 ) );
    6869        }
    6970
     
    8788     */
    8889    public function setName( string $className ) {
    89         \assert( \class_exists( $className ) );
     90        assert( class_exists( $className ) );
    9091
    9192        $this->className = $className;
     
    104105     * Builds replacements list (for interpolate()) from the context values.
    105106     * based on
    106      * @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#12-message
     107     * {@link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#12-message}
    107108     *
    108109     * @param array $context
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-order-details-controller.php

    r3158208 r3171290  
    88use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Base;
    99use WC_BPost_Shipping\Street\WC_BPost_Shipping_Street_Formatter;
    10 use WC_BPost_Shipping\WC_Bpost_Shipping_Container;
     10use WC_BPost_Shipping\WC_Bpost_Shipping_Container as Container;
    1111
    1212/**
     
    7878    private function get_geo6_template_data() {
    7979        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() );
    8181            $order_updater = new WC_BPost_Shipping_Order_Updater(
    8282                $this->order,
     
    8787        }
    8888
    89         $locale = new WC_BPost_Shipping_Locale_Locale( $this->adapter );
     89        $locale = new WC_BPost_Shipping_Locale_Locale( Container::get_adapter() );
    9090
    9191        $url = sprintf(
  • bpost-shipping/trunk/classes/locale/class-wc-bpost-shipping-locale-locale.php

    r2890340 r3171290  
    55use WC_BPost_Shipping\Adapter\WC_BPost_Shipping_Adapter_Woocommerce;
    66
    7 /**
    8  * Class WC_BPost_Shipping_Locale_Locale
    9  * @package WC_BPost_Shipping\Locale
    10  */
    117class WC_BPost_Shipping_Locale_Locale {
    128
    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';
    1612    const LANGUAGE_DEFAULT = self::LANGUAGE_EN;
    1713
    18     /** @var WC_BPost_Shipping_Adapter_Woocommerce */
    19     private $adapter;
     14    private WC_BPost_Shipping_Adapter_Woocommerce $adapter;
    2015
    21     /**
    22      * WC_BPost_Shipping_Locale_Locale constructor.
    23      *
    24      * @param WC_BPost_Shipping_Adapter_Woocommerce $adapter
    25      */
    2616    public function __construct( WC_BPost_Shipping_Adapter_Woocommerce $adapter ) {
    27 
    2817        $this->adapter = $adapter;
    2918    }
    3019
    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() );
    4326
    4427        if ( count( $split_locale ) === 2 ) {
  • bpost-shipping/trunk/classes/options/class-wc-bpost-shipping-options-base.php

    r3158208 r3171290  
    191191     */
    192192    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        );
    195205    }
    196206
  • bpost-shipping/trunk/languages/bpost_shipping.pot

    r3158208 r3171290  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: bpost shipping 3.1.10\n"
     5"Project-Id-Version: bpost shipping 3.1.11\n"
    66"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"
    88"MIME-Version: 1.0\n"
    99"Content-Type: text/plain; charset=UTF-8\n"
     
    197197msgstr ""
    198198
    199 #. #-#-#-#-#  bpost_shipping.pot (bpost shipping 3.1.10)  #-#-#-#-#
     199#. #-#-#-#-#  bpost_shipping.pot (bpost shipping 3.1.11)  #-#-#-#-#
    200200#. Author of the plugin/theme
    201201#: classes/class-wc-bpost-shipping-method.php:261
  • bpost-shipping/trunk/readme.txt

    r3158208 r3171290  
    88Tested up to: 6.5
    99Requires PHP: 7.4
    10 Stable tag: 3.1.10
     10Stable tag: 3.1.11
    1111License: GPLv2 or later
    1212License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1201205. Configure your bpost shipping settings under the Woocommerce shipping > bpost shipping tab
    121121== 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
    122130
    123131#### 3.1.10
Note: See TracChangeset for help on using the changeset viewer.