Plugin Directory

Changeset 3158208


Ignore:
Timestamp:
09/26/2024 11:55:42 AM (18 months ago)
Author:
antidot-dev
Message:

Release 3.1.10

Location:
bpost-shipping/trunk
Files:
20 edited

Legend:

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

    r3152964 r3158208  
    66 * Author: bpost
    77 * Author URI: https://www.bpost.be/
    8  * Version: 3.1.9
     8 * Version: 3.1.10
    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.9' );
     17define( 'BPOST_PLUGIN_VERSION', '3.1.10' );
    1818
    1919/**
  • bpost-shipping/trunk/classes/api/class-wc-bpost-shipping-api-factory.php

    r2929716 r3158208  
    11<?php
     2
    23namespace WC_BPost_Shipping\Api;
    34
    4 use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Base;
     5use WC_BPost_Shipping\WC_Bpost_Shipping_Container;
    56use WC_BPost_Shipping_Logger;
    67
     
    1011class WC_BPost_Shipping_Api_Factory {
    1112
    12     /** @var WC_BPost_Shipping_Options_Base */
    13     private $bpost_options;
    14     /** @var WC_BPost_Shipping_Logger */
    15     private $logger;
     13    private WC_BPost_Shipping_Logger $logger;
    1614
    17     /**
    18      * WC_BPost_Shipping_Product_Configuration_Factory constructor.
    19      *
    20      * @param WC_BPost_Shipping_Options_Base $options
    21      * @param WC_BPost_Shipping_Logger $logger
    22      */
    23     public function __construct( WC_BPost_Shipping_Options_Base $options, WC_BPost_Shipping_Logger $logger ) {
    24         $this->bpost_options = $options;
    25         $this->logger        = $logger;
     15    public function __construct( WC_BPost_Shipping_Logger $logger ) {
     16        $this->logger = $logger;
    2617    }
    2718
    28     /**
    29      * @return WC_BPost_Shipping_Api_Product_Configuration
    30      */
    31     public function get_product_configuration() {
    32         return new WC_BPost_Shipping_Api_Product_Configuration( $this->get_api_connector(), $this->logger );
     19    public function get_product_configuration(): WC_BPost_Shipping_Api_Product_Configuration {
     20        return new WC_BPost_Shipping_Api_Product_Configuration(
     21            WC_Bpost_Shipping_Container::get_api_connector(),
     22            $this->logger
     23        );
    3324    }
    3425
    35     /**
    36      * @return WC_BPost_Shipping_Api_Label
    37      */
    38     public function get_label() {
    39         return new WC_BPost_Shipping_Api_Label( $this->get_api_connector(), $this->logger );
     26    public function get_label(): WC_BPost_Shipping_Api_Label {
     27        return new WC_BPost_Shipping_Api_Label( WC_Bpost_Shipping_Container::get_api_connector(), $this->logger );
    4028    }
    4129
    42     /**
    43      * @return WC_BPost_Shipping_Api_Geo6_Search
    44      */
    45     public function get_geo6_search() {
     30    public function get_geo6_search(): WC_BPost_Shipping_Api_Geo6_Search {
    4631        return new WC_BPost_Shipping_Api_Geo6_Search( $this->get_api_geo6_connector() );
    4732    }
    4833
    49 
    50     /**
    51      * @return WC_BPost_Shipping_Api_Connector
    52      */
    53     public function get_api_connector() {
    54         $connector = new WC_BPost_Shipping_Api_Connector(
    55             $this->bpost_options->get_account_id(),
    56             $this->bpost_options->get_passphrase(),
    57             $this->bpost_options->get_api_url()
    58         );
    59 
    60         $connector->setLogger( $this->logger );
    61 
    62         return $connector;
     34    public function get_api_status(): WC_BPost_Shipping_Api_Status {
     35        return new WC_BPost_Shipping_Api_Status( WC_Bpost_Shipping_Container::get_api_connector(), $this->logger );
    6336    }
    6437
    65     /**
    66      * @return WC_BPost_Shipping_Api_Status
    67      */
    68     public function get_api_status() {
    69         return new WC_BPost_Shipping_Api_Status( $this->get_api_connector(), $this->logger );
    70     }
    71 
    72     /**
    73      * @return WC_BPost_Shipping_Api_Geo6_Connector
    74      */
    75     public function get_api_geo6_connector() {
    76         $connector = new WC_BPost_Shipping_Api_Geo6_Connector( '999999', 'A001' );
    77 
    78         return $connector;
     38    public function get_api_geo6_connector(): WC_BPost_Shipping_Api_Geo6_Connector {
     39        return new WC_BPost_Shipping_Api_Geo6_Connector( '999999', 'A001' );
    7940    }
    8041}
  • bpost-shipping/trunk/classes/assets/class-wc-bpost-shipping-assets-management.php

    r2894167 r3158208  
    6464     * @param string[] $shm_data
    6565     */
    66     public function callback_page( $shm_data ) {
     66    public function callback_page( array $shm_data ) {
    6767        $this->resources->get_callback_page( $shm_data );
    6868    }
  • bpost-shipping/trunk/classes/assets/class-wc-bpost-shipping-assets-resources.php

    r2894167 r3158208  
    3636    public function get_order_receive_page( $order_received ) {
    3737        wp_enqueue_script( 'bpost-shm-app', BPOST_PLUGIN_URL . 'public/js/app.min.js', array(), BPOST_PLUGIN_VERSION );
    38         wp_enqueue_style( 'checkout_css_file', BPOST_PLUGIN_URL . 'public/css/checkout.min.css', array(), BPOST_PLUGIN_VERSION );
    39         wp_register_script( 'bpost-order-received', BPOST_PLUGIN_URL . 'public/js/order-received.min.js', array(), BPOST_PLUGIN_VERSION );
     38        wp_enqueue_style( 'checkout_css_file',
     39            BPOST_PLUGIN_URL . 'public/css/checkout.min.css',
     40            array(),
     41            BPOST_PLUGIN_VERSION );
     42        wp_register_script( 'bpost-order-received',
     43            BPOST_PLUGIN_URL . 'public/js/order-received.min.js',
     44            array(),
     45            BPOST_PLUGIN_VERSION );
    4046        wp_localize_script( 'bpost-order-received', 'bpost_order_received', $order_received );
    4147        wp_enqueue_script( 'bpost-order-received' );
     
    4652     */
    4753    public function get_admin_bpost_page() {
    48         wp_enqueue_style( 'font_awesome', BPOST_PLUGIN_URL . 'public/css/font-awesome.min.css', array(), BPOST_PLUGIN_VERSION );
    49         wp_enqueue_style( 'admin_css_file', BPOST_PLUGIN_URL . 'public/css/admin.min.css', array( 'font_awesome' ), BPOST_PLUGIN_VERSION );
     54        wp_enqueue_style( 'font_awesome',
     55            BPOST_PLUGIN_URL . 'public/css/font-awesome.min.css',
     56            array(),
     57            BPOST_PLUGIN_VERSION );
     58        wp_enqueue_style( 'admin_css_file',
     59            BPOST_PLUGIN_URL . 'public/css/admin.min.css',
     60            array( 'font_awesome' ),
     61            BPOST_PLUGIN_VERSION );
    5062    }
    5163
     
    5870        wp_enqueue_script( 'bpost-shm-app', BPOST_PLUGIN_URL . 'public/js/app.min.js', array(), BPOST_PLUGIN_VERSION );
    5971
    60         wp_register_script( 'bpost-admin-order-edit', BPOST_PLUGIN_URL . 'public/js/admin.min.js', array(), BPOST_PLUGIN_VERSION );
     72        wp_register_script( 'bpost-admin-order-edit',
     73            BPOST_PLUGIN_URL . 'public/js/admin.min.js',
     74            array(),
     75            BPOST_PLUGIN_VERSION );
    6176        wp_localize_script( 'bpost-admin-order-edit', 'bpost_order_data', $order_data );
    6277        wp_enqueue_script( 'bpost-admin-order-edit' );
     
    6883     * @param string[] $shm_data
    6984     */
    70     public function get_callback_page( $shm_data ) {
    71         header( 'Content-Type: text/html', true ); // force the content-type. On some cases, the content-type was text/xml
     85    public function get_callback_page( array $shm_data ) {
     86        header( 'Content-Type: text/html' ); // force the content-type. On some cases, the content-type was text/xml
    7287        wp_enqueue_script( 'bpost-shm-app', BPOST_PLUGIN_URL . 'public/js/app.min.js', array(), BPOST_PLUGIN_VERSION );
    7388
     
    97112
    98113    private function enqueue_bpost_shm_js() {
    99         wp_enqueue_script( 'bpost-shm', 'https://shippingmanager.bpost.be/ShmFrontEnd/shm.js', array( 'jquery' ), BPOST_PLUGIN_VERSION );
     114        wp_enqueue_script( 'bpost-shm',
     115            'https://shippingmanager.bpost.be/ShmFrontEnd/shm.js',
     116            array( 'jquery' ),
     117            BPOST_PLUGIN_VERSION );
    100118    }
    101119}
  • bpost-shipping/trunk/classes/checkout/class-wc-bpost-shipping-checkout-order-review.php

    r2890340 r3158208  
    44
    55
     6use Exception;
    67use WC_BPost_Shipping\Adapter\WC_BPost_Shipping_Adapter_Woocommerce;
    7 use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Factory;
    88use WC_BPost_Shipping\Street\WC_BPost_Shipping_Street_Builder;
    99use WC_BPost_Shipping\Street\WC_BPost_Shipping_Street_Solver;
     10use WC_BPost_Shipping\WC_Bpost_Shipping_Container as Container;
     11use WC_BPost_Shipping_Cart;
     12use WC_BPost_Shipping_Limitations;
     13use WC_BPost_Shipping_Posted;
    1014
    1115class WC_BPost_Shipping_Checkout_Order_Review {
    1216
    13     /** @var \WC_BPost_Shipping_Limitations */
    14     private $limitations;
    15     /** @var \WC_BPost_Shipping_Cart */
    16     private $cart;
    17     /** @var WC_BPost_Shipping_Api_Factory */
    18     private $factory;
    19     /** @var WC_BPost_Shipping_Adapter_Woocommerce */
    20     private $adapter_woocommerce;
    21     /** @var \WC_BPost_Shipping_Posted */
    22     private $posted;
     17    private WC_BPost_Shipping_Adapter_Woocommerce $adapter_woocommerce;
     18    private WC_BPost_Shipping_Limitations $limitations;
    2319
    24 
    25     /**
    26      * WC_BPost_Shipping_Checkout_Order_Review constructor.
    27      *
    28      * @param WC_BPost_Shipping_Adapter_Woocommerce $adapter_woocommerce
    29      * @param WC_BPost_Shipping_Api_Factory $factory
    30      * @param \WC_BPost_Shipping_Limitations $limitations
    31      * @param \WC_BPost_Shipping_Cart $cart
    32      * @param \WC_BPost_Shipping_Posted $posted
    33      */
    3420    public function __construct(
    3521        WC_BPost_Shipping_Adapter_Woocommerce $adapter_woocommerce,
    36         WC_BPost_Shipping_Api_Factory $factory,
    37         \WC_BPost_Shipping_Limitations $limitations,
    38         \WC_BPost_Shipping_Cart $cart,
    39         \WC_BPost_Shipping_Posted $posted
     22        WC_BPost_Shipping_Limitations $limitations
    4023    ) {
    4124        $this->adapter_woocommerce = $adapter_woocommerce;
    4225        $this->limitations         = $limitations;
    43         $this->factory             = $factory;
    44 
    45         $this->cart   = $cart;
    46         $this->posted = $posted;
    4726    }
    4827
    49     /**
    50      * @return bool
    51      */
    52     public function review_order() {
     28    public function review_order( WC_BPost_Shipping_Posted $posted ): bool {
    5329        $street_builder = new WC_BPost_Shipping_Street_Builder( new WC_BPost_Shipping_Street_Solver() );
    5430
     31        $street = $street_builder
     32            ->get_street_items( WC()->customer->get_shipping_address(), WC()->customer->get_shipping_address_2() )
     33            ->get_street();
     34
    5535        $limitation_are_ok = $this->limitations->validate_limitations(
    56             $this->posted->get_payment_method(),
    57             $street_builder->get_street_items( WC()->customer->get_shipping_address(), WC()->customer->get_shipping_address_2() )->get_street(),
    58             $this->cart->get_weight_in_kg(),
    59             $this->factory->get_product_configuration(),
    60             $this->factory->get_api_connector()
     36            $posted->get_payment_method(),
     37            $street,
     38            WC_BPost_Shipping_Cart::get_weight_in_kg()
    6139        );
    6240
    6341        foreach ( $this->limitations->get_errors() as $error ) {
    64             $this->adapter_woocommerce->add_notice( $error, 'error' );
     42            Container::get_logger()->warning( $error );
     43            throw new Exception( $error ); // throw an exception will provide a wp_notice(..., 'error')
     44
     45//          $this->adapter_woocommerce->add_notice( $error, 'error' );
    6546        }
    6647
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-cart.php

    r2283055 r3158208  
    11<?php
     2
    23if ( ! defined( 'ABSPATH' ) ) {
    34    exit; // Exit if accessed directly
     
    910 */
    1011class WC_BPost_Shipping_Cart {
    11 
    12     /** @var  WC_Cart */
    13     private $cart;
    14 
    15     /**
    16      * @param WC_Cart $cart
    17      */
    18     public function __construct( WC_Cart $cart ) {
    19         $this->cart = $cart;
     12    public static function get_weight_in_g(): float {
     13        return self::get_weight_in_kg() * 1000;
    2014    }
    2115
    22     /**
    23      * @return float
    24      */
    25     public function get_weight_in_g() {
    26         return $this->get_weight_in_kg() * 1000;
     16    public static function get_weight_in_kg(): float {
     17        return (float) wc_get_weight( WC()->cart->get_cart_contents_weight(), 'kg' );
    2718    }
    2819
    29     /**
    30      * @return float
    31      */
    32     public function get_weight_in_kg() {
    33         return wc_get_weight( $this->cart->get_cart_contents_weight(), 'kg' );
     20    public static function get_discounted_subtotal(): float {
     21        return WC()->cart->get_displayed_subtotal() - WC()->cart->get_discount_total();
    3422    }
    3523
    36     /**
    37      * @return float
    38      */
    39     public function get_discounted_subtotal() {
    40         return $this->cart->get_displayed_subtotal() - $this->cart->get_discount_total();
     24    public static function get_used_coupons(): array {
     25        return WC()->cart->get_applied_coupons();
    4126    }
    42 
    43     /**
    44      * @return array
    45      */
    46     public function get_used_coupons() {
    47         return $this->cart->get_applied_coupons();
    48     }
    49 
    5027}
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-container.php

    r3117106 r3158208  
    55use LogicException;
    66use WC_BPost_Shipping\Adapter\WC_BPost_Shipping_Adapter_Woocommerce as Adapter;
     7use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Connector;
    78use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Factory;
     9use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Product_Configuration;
    810use WC_BPost_Shipping\Assets\WC_BPost_Shipping_Assets_Detector;
    911use WC_BPost_Shipping\Assets\WC_BPost_Shipping_Assets_Management;
    1012use WC_BPost_Shipping\Assets\WC_BPost_Shipping_Assets_Resources;
     13use WC_BPost_Shipping\Checkout\WC_BPost_Shipping_Checkout_Order_Review;
    1114use WC_BPost_Shipping\Label\WC_BPost_Shipping_Label_Path_Resolver;
    1215use WC_BPost_Shipping\Label\WC_BPost_Shipping_Label_Retriever;
    1316use WC_BPost_Shipping\Label\WC_BPost_Shipping_Label_Url_Generator;
     17use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Base;
    1418use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Label;
     19use WC_BPost_Shipping_Limitations;
    1520use WC_BPost_Shipping_Logger;
    1621use WC_BPost_Shipping_Meta_Type;
     
    3540                return new WC_BPost_Shipping_Options_Label( self::get_adapter() );
    3641
     42            case WC_BPost_Shipping_Options_Base::class:
     43                return new WC_BPost_Shipping_Options_Base();
     44
    3745            case WC_BPost_Shipping_Label_Path_Resolver::class:
    3846                return new WC_BPost_Shipping_Label_Path_Resolver( self::get_options_label() );
     
    4957            case WC_BPost_Shipping_Api_Factory::class:
    5058                return new WC_BPost_Shipping_Api_Factory(
    51                     self::get_options_label(),
    5259                    self::get_logger()
    5360                );
     
    6976            case WC_BPost_Shipping_Meta_Type::class:
    7077                return new WC_BPost_Shipping_Meta_Type( self::get_adapter() );
     78
     79            case WC_BPost_Shipping_Api_Connector::class:
     80                $options   = self::get( WC_BPost_Shipping_Options_Base::class );
     81                $connector = new WC_BPost_Shipping_Api_Connector(
     82                    $options->get_account_id(), $options->get_passphrase(), $options->get_api_url()
     83                );
     84                $connector->setLogger( self::get_logger() );
     85
     86                return $connector;
     87
     88            case WC_BPost_Shipping_Limitations::class:
     89                return new WC_BPost_Shipping_Limitations(
     90                    new WC_BPost_Shipping_Api_Product_Configuration(
     91                        self::get( WC_BPost_Shipping_Api_Connector::class ), self::get_logger()
     92                    ),
     93                    self::get( WC_BPost_Shipping_Api_Connector::class )
     94                );
     95
     96            case WC_BPost_Shipping_Checkout_Order_Review::class:
     97                return new WC_BPost_Shipping_Checkout_Order_Review(
     98                    self::get_adapter(),
     99                    self::get( WC_BPost_Shipping_Limitations::class ),
     100                );
    71101        }
    72102
     
    110140    }
    111141
     142    public static function get_api_connector(): WC_BPost_Shipping_Api_Connector {
     143        return self::get( WC_BPost_Shipping_Api_Connector::class );
     144    }
     145
     146    public static function get_order_review(): WC_BPost_Shipping_Checkout_Order_Review {
     147        return self::get( WC_BPost_Shipping_Checkout_Order_Review::class );
     148    }
     149
    112150}
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-data-builder.php

    r3117106 r3158208  
    1717    private WC_BPost_Shipping_Address $shipping_address;
    1818    private WC_BPost_Shipping_Delivery_Methods $delivery_methods;
    19     private WC_BPost_Shipping_Cart $cart;
    2019
    21     /**
    22      * WC_BPost_Shipping_Data_Builder constructor.
    23      *
    24      * @param WC_BPost_Shipping_Cart $cart
    25      * @param WC_BPost_Shipping_Address $shipping_address
    26      * @param WC_BPost_Shipping_Options_Base $shipping_options
    27      * @param WC_BPost_Shipping_Delivery_Methods $delivery_methods
    28      */
    2920    public function __construct(
    30         WC_BPost_Shipping_Cart $cart,
    3121        WC_BPost_Shipping_Address $shipping_address,
    3222        WC_BPost_Shipping_Options_Base $shipping_options,
    3323        WC_BPost_Shipping_Delivery_Methods $delivery_methods
    3424    ) {
    35         $this->cart                 = $cart;
    3625        $this->shipping_options     = $shipping_options;
    3726        $this->shipping_address     = $shipping_address;
     
    5948            'sub_total'                 => round( WC()->cart->subtotal * 100 ),
    6049            // In grams, if 0, then we set 1kg (1000g)
    61             'sub_weight'                => ceil( $this->cart->get_weight_in_g() ?: 1000 ),
     50            'sub_weight'                => ceil( WC_BPost_Shipping_Cart::get_weight_in_g() ?: 1000 ),
    6251            'language'                  => $this->get_language_for_shm(),
    6352            'additional_customer_ref'   => 'WORDPRESS ' . get_bloginfo( 'version' ) . ' / WOOCOMMERCE ' . WC()->version,
    6453            'delivery_method_overrides' => $this->shipping_options->get_delivery_method_overrides(
    6554                $this->shipping_address,
    66                 $this->cart,
    6755                $this->delivery_methods
    6856            ),
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-hooks.php

    r3117106 r3158208  
    181181
    182182        $api_factory = new WC_BPost_Shipping_Api_Factory(
    183             new WC_BPost_Shipping_Options_Base(),
    184183            Container::get_logger()
    185184        );
     
    364363     */
    365364    public function bpost_shipping_api_loader() {
    366         $posted_obj           = new WC_BPost_Shipping_Posted( $_POST );
     365        $posted_obj           = WC_BPost_Shipping_Posted::create( $_POST );
    367366        $bpost_street_builder = new WC_BPost_Shipping_Street_Builder( new WC_BPost_Shipping_Street_Solver() );
    368367
    369         $cart = new WC_BPost_Shipping_Cart( WC()->cart );
    370 
    371368        $data_builder = new WC_BPost_Shipping_Data_Builder(
    372             $cart,
    373369            new WC_BPost_Shipping_Address( $bpost_street_builder, WC()->customer, $posted_obj ),
    374370            new WC_BPost_Shipping_Options_Base(),
    375371            new WC_BPost_Shipping_Delivery_Methods(
    376                 Container::get_api_factory()->get_api_connector()->fetchProductConfig()
     372                Container::get_api_connector()->fetchProductConfig()
    377373            )
    378374        );
     
    739735        }
    740736
     737        Container::get_order_review()->review_order( WC_BPost_Shipping_Posted::create( $posted_data ) );
     738
    741739        Container::get_logger()->notice(
    742740            'bpost_shm_already_called = ' . $posted_data['bpost_shm_already_called'],
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-limitations.php

    r2890340 r3158208  
    11<?php
     2
    23use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Connector;
    34use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Product_Configuration;
     
    2122    private $errors;
    2223
    23     public function __construct() {
    24         $this->errors = array();
     24    private WC_BPost_Shipping_Api_Product_Configuration $product_configuration;
     25    private WC_BPost_Shipping_Api_Connector $connector;
     26
     27    public function __construct(
     28        WC_BPost_Shipping_Api_Product_Configuration $product_configuration,
     29        WC_BPost_Shipping_Api_Connector $connector
     30    ) {
     31        $this->errors                = array();
     32        $this->product_configuration = $product_configuration;
     33        $this->connector             = $connector;
    2534    }
    2635
     
    2938     * @param string $address
    3039     * @param int $weight
    31      * @param WC_BPost_Shipping_Api_Product_Configuration $product_configuration
    32      * @param WC_BPost_Shipping_Api_Connector $connector
    3340     *
    3441     * @return bool
    3542     */
    36     public function validate_limitations(
    37         $payment_method,
    38         $address,
    39         $weight,
    40         WC_BPost_Shipping_Api_Product_Configuration $product_configuration,
    41         WC_BPost_Shipping_Api_Connector $connector
    42     ) {
     43    public function validate_limitations( $payment_method, $address, $weight ) {
    4344        $limitations_are_ok = true;
    4445
     
    5657        }
    5758
    58         if ( ! $this->is_valid_weight( $product_configuration, $weight ) ) {
     59        if ( ! $this->is_valid_weight( $this->product_configuration, $weight ) ) {
    5960            $this->errors[]     = sprintf(
    6061                bpost__( 'Shipments over %s kg are not possible with bpost, the current cart weight is %s kg' ),
    61                 number_format( $product_configuration->get_maximal_allowed_weight() / 1000, 2 ),
     62                number_format( $this->product_configuration->get_maximal_allowed_weight() / 1000, 2 ),
    6263                number_format( $weight, 2 )
    6364            );
     
    6566        }
    6667
    67         if ( ! $this->check_webservice_status( $connector ) ) {
     68        if ( ! $this->check_webservice_status( $this->connector ) ) {
    6869            $this->errors[]     =
    6970                bpost__( 'The Shipping Manager is currently unavailable, please contact the webshop\'s manager' );
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-method.php

    r2977804 r3158208  
    1111use WC_BPost_Shipping\JsonArray\WC_BPost_Shipping_JsonArray_Validator;
    1212use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Base;
     13use WC_BPost_Shipping\WC_Bpost_Shipping_Container;
    1314
    1415/**
     
    5657        $this->init_logger();
    5758
    58         $this->product_configuration_factory = new WC_BPost_Shipping_Api_Factory(
    59             new WC_BPost_Shipping_Options_Base(),
    60             $this->logger
    61         );
     59        $this->product_configuration_factory = new WC_BPost_Shipping_Api_Factory( $this->logger );
    6260
    6361        $this->supports[] = 'shipping-zones';
     
    7573        $this->init_settings(); // This is part of the settings API. Loads settings you previously init.
    7674        $this->config_checker = new WC_BPost_Shipping_Configuration_Checker(
    77             $this->product_configuration_factory->get_product_configuration(),
    78             $this->product_configuration_factory->get_api_connector()
     75            WC_Bpost_Shipping_Container::get_api_factory()->get_product_configuration(),
     76            WC_Bpost_Shipping_Container::get_api_connector()
    7977        );
    8078
     
    200198            $this->product_configuration_factory->get_product_configuration(),
    201199            new WC_BPost_Shipping_Options_Base(),
    202             $package,
    203             WC()->cart
     200            $package
    204201        );
    205202
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-order-details-controller.php

    r2926483 r3158208  
    88use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Base;
    99use WC_BPost_Shipping\Street\WC_BPost_Shipping_Street_Formatter;
     10use WC_BPost_Shipping\WC_Bpost_Shipping_Container;
    1011
    1112/**
     
    7071            return array_merge( $template_data, $this->get_google_template_data() );
    7172        }
    72 
    7373    }
    7474
     
    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(
    81                 $this->options,
    82                 \WC_BPost_Shipping\WC_Bpost_Shipping_Container::get_logger()
    83             );
     80            $api_factory   = new WC_BPost_Shipping_Api_Factory( WC_Bpost_Shipping_Container::get_logger() );
    8481            $order_updater = new WC_BPost_Shipping_Order_Updater(
    8582                $this->order,
     
    131128            'map_provider'     => self::MAP_PROVIDER_GOOGLE,
    132129        );
    133 
    134130    }
    135131
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-package.php

    r2890340 r3158208  
    1111class WC_BPost_Shipping_Package {
    1212
    13     /** @var WC_BPost_Shipping_Api_Product_Configuration */
    14     private $product_configuration;
    15     /** @var WC_BPost_Shipping_Options_Base */
    16     private $options;
    17     /** @var array */
    18     private $package;
    19     /** @var WC_Cart */
    20     private $cart;
     13    private WC_BPost_Shipping_Api_Product_Configuration $product_configuration;
     14    private WC_BPost_Shipping_Options_Base $options;
     15    private array $package;
    2116
    2217
    23     /**
    24      * WC_BPost_Shipping_Package constructor.
    25      *
    26      * @param WC_BPost_Shipping_Api_Product_Configuration $product_configuration
    27      * @param WC_BPost_Shipping_Options_Base $options
    28      * @param array $package
    29      * @param WC_Cart $cart
    30      */
    3118    public function __construct(
    3219        WC_BPost_Shipping_Api_Product_Configuration $product_configuration,
    3320        WC_BPost_Shipping_Options_Base $options,
    34         array $package,
    35         WC_Cart $cart
     21        array $package
    3622    ) {
    3723        $this->product_configuration = $product_configuration;
    3824        $this->options               = $options;
    3925        $this->package               = $package;
    40         $this->cart                  = $cart;
    4126    }
    4227
     
    5944        }
    6045
    61         $bpost_cart = new WC_BPost_Shipping_Cart( $this->cart );
    6246        if ( $this->options->is_free_shipping(
    6347            $country_iso_2,
    64             $bpost_cart->get_discounted_subtotal(),
    65             $bpost_cart->get_used_coupons()
     48            WC_BPost_Shipping_Cart::get_discounted_subtotal(),
     49            WC_BPost_Shipping_Cart::get_used_coupons()
    6650        ) ) {
    6751            return 0;
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-posted.php

    r2890340 r3158208  
    11<?php
     2
    23if ( ! defined( 'ABSPATH' ) ) {
    34    exit; // Exit if accessed directly
     
    910class WC_BPost_Shipping_Posted {
    1011    /** @var string[] */
    11     private $posted;
    12     /** @var bool */
    13     private $ship_to_different_address;
     12    private array $posted;
    1413
    15     /**
    16      * WC_BPost_Shipping_Posted constructor.
    17      *
    18      * @param string[] $posted
    19      */
    20     public function __construct( array $posted ) {
     14    private function __construct( array $posted ) {
    2115        $this->posted = $posted;
     16    }
    2217
     18    public static function create( array $posted ): self {
    2319        // Merge with an empty (about values) array to avoid a notice if the key is not in $posted
    24         $this->posted = array_merge(
     20        $posted = array_merge(
    2521            array(
    26                 'billing_first_name'  => '',
    27                 'billing_last_name'   => '',
    28                 'billing_company'     => '',
    29                 'shipping_first_name' => '',
    30                 'shipping_last_name'  => '',
    31                 'shipping_company'    => '',
    32                 'billing_email'       => '',
    33                 'billing_phone'       => '',
    34                 'payment_method'      => '',
     22                'billing_first_name'        => '',
     23                'billing_last_name'         => '',
     24                'billing_company'           => '',
     25                'shipping_first_name'       => '',
     26                'shipping_last_name'        => '',
     27                'shipping_company'          => '',
     28                'billing_email'             => '',
     29                'billing_phone'             => '',
     30                'payment_method'            => '',
     31                'ship_to_different_address' => false,
    3532            ),
    36             $this->posted
     33            $posted
    3734        );
    3835
    39         $this->ship_to_different_address = isset( $this->posted['ship_to_different_address'] ) && (bool) $this->posted['ship_to_different_address'];
     36        return new self( $posted );
    4037    }
    4138
    42     /**
    43      * @return string
    44      */
    45     public function get_payment_method() {
     39    public function get_payment_method(): string {
    4640        return $this->posted['payment_method'];
    4741    }
    4842
    49     /**
    50      * @return string
    51      */
    52     public function get_first_name() {
     43    public function get_first_name(): string {
    5344        return $this->posted[ $this->get_address_type() . '_first_name' ];
    5445    }
    5546
    5647    /**
    57      * @return string return 'shipping' or 'billing' depending of ship_to_different_address flag
     48     * @return string return 'shipping' or 'billing' depending on ship_to_different_address flag
    5849     */
    59     private function get_address_type() {
    60         return $this->ship_to_different_address ? 'shipping' : 'billing';
     50    private function get_address_type(): string {
     51        return $this->is_ship_to_different_address() ? 'shipping' : 'billing';
    6152    }
    6253
    63     /**
    64      * @return string
    65      */
    66     public function get_last_name() {
     54    public function get_last_name(): string {
    6755        return $this->posted[ $this->get_address_type() . '_last_name' ];
    6856    }
    6957
    70     /**
    71      * @return string
    72      */
    73     public function get_company() {
     58    public function get_company(): string {
    7459        return $this->posted[ $this->get_address_type() . '_company' ];
    7560    }
    7661
    77     /**
    78      * @return string the email value from billing email every time
    79      */
    80     public function get_email() {
     62    public function get_email(): string {
    8163        return $this->posted['billing_email'];
    8264    }
    8365
    84     /**
    85      * @return string the phone value from billing phone every time
    86      */
    87     public function get_phone() {
     66    public function get_phone(): string {
    8867        return $this->posted['billing_phone'];
    8968    }
    9069
    91     /**
    92      * @return string
    93      */
    94     public function get_shipping_method() {
     70    public function get_shipping_method(): string {
    9571        if ( ! is_array( $this->posted['shipping_method'] ) ) {
    9672            return '';
     
    10076    }
    10177
    102     /**
    103      * @return boolean
    104      */
    105     public function is_ship_to_different_address() {
    106         return $this->ship_to_different_address;
     78    public function is_ship_to_different_address(): bool {
     79        return (bool) $this->posted['ship_to_different_address'];
    10780    }
    10881}
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-shm-callback-controller.php

    r2890340 r3158208  
    5555     * @return array json
    5656     */
    57     private function get_callback_data() {
     57    private function get_callback_data(): array {
    5858        switch ( $this->result ) {
    5959            case self::RESULT_SHM_CALLBACK_CONFIRM:
  • bpost-shipping/trunk/classes/options/class-wc-bpost-shipping-options-base.php

    r3122012 r3158208  
    161161     * TODO why this is here?
    162162     *
    163      * @param WC_BPost_Shipping_Address $shipping_address
    164      * @param WC_BPost_Shipping_Cart $cart
    165      * @param WC_BPost_Shipping_Delivery_Methods $delivery_methods
    166      *
    167163     * @return string[]
    168164     */
    169165    public function get_delivery_method_overrides(
    170166        WC_BPost_Shipping_Address $shipping_address,
    171         WC_BPost_Shipping_Cart $cart,
    172167        WC_BPost_Shipping_Delivery_Methods $delivery_methods
    173168    ) {
    174169        if ( $this->is_free_shipping(
    175170            $shipping_address->get_shipping_country(),
    176             $cart->get_discounted_subtotal(),
    177             $cart->get_used_coupons()
     171            WC_BPost_Shipping_Cart::get_discounted_subtotal(),
     172            WC_BPost_Shipping_Cart::get_used_coupons()
    178173        )
    179174        ) {
  • bpost-shipping/trunk/languages/bpost_shipping.pot

    r3152964 r3158208  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: bpost shipping 3.1.9\n"
     5"Project-Id-Version: bpost shipping 3.1.10\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/package\n"
    7 "POT-Creation-Date: 2024-09-16 21:48:25+00:00\n"
     7"POT-Creation-Date: 2024-09-26 11:54:47+00:00\n"
    88"MIME-Version: 1.0\n"
    99"Content-Type: text/plain; charset=UTF-8\n"
     
    9595msgstr ""
    9696
    97 #: classes/class-wc-bpost-shipping-hooks.php:239
     97#: classes/class-wc-bpost-shipping-hooks.php:238
    9898msgid "(as from)"
    9999msgstr ""
    100100
    101 #: classes/class-wc-bpost-shipping-hooks.php:243
     101#: classes/class-wc-bpost-shipping-hooks.php:242
    102102msgid "Free shipping available"
    103103msgstr ""
    104104
    105 #: classes/class-wc-bpost-shipping-hooks.php:435
     105#: classes/class-wc-bpost-shipping-hooks.php:431
    106106msgid "status: "
    107107msgstr ""
    108108
    109 #: classes/class-wc-bpost-shipping-hooks.php:536
     109#: classes/class-wc-bpost-shipping-hooks.php:532
    110110msgid "bpost labels"
    111111msgstr ""
    112112
    113 #: classes/class-wc-bpost-shipping-hooks.php:701
     113#: classes/class-wc-bpost-shipping-hooks.php:697
    114114msgid "You have to specify a delivery method"
    115115msgstr ""
    116116
    117 #: classes/class-wc-bpost-shipping-hooks.php:703
     117#: classes/class-wc-bpost-shipping-hooks.php:699
    118118msgid "Your bpost delivery method"
    119119msgstr ""
    120120
     121#: classes/class-wc-bpost-shipping-hooks.php:704
     122msgid "bpost_method_Regular"
     123msgstr ""
     124
     125#: classes/class-wc-bpost-shipping-hooks.php:705
     126msgid "bpost_method_Pugo"
     127msgstr ""
     128
     129#: classes/class-wc-bpost-shipping-hooks.php:706
     130msgid "bpost_method_Parcels depot"
     131msgstr ""
     132
     133#: classes/class-wc-bpost-shipping-hooks.php:707
     134msgid "bpost_method_bpack BUSINESS"
     135msgstr ""
     136
    121137#: classes/class-wc-bpost-shipping-hooks.php:708
    122 msgid "bpost_method_Regular"
    123 msgstr ""
    124 
    125 #: classes/class-wc-bpost-shipping-hooks.php:709
    126 msgid "bpost_method_Pugo"
    127 msgstr ""
    128 
    129 #: classes/class-wc-bpost-shipping-hooks.php:710
    130 msgid "bpost_method_Parcels depot"
    131 msgstr ""
    132 
    133 #: classes/class-wc-bpost-shipping-hooks.php:711
    134 msgid "bpost_method_bpack BUSINESS"
    135 msgstr ""
    136 
    137 #: classes/class-wc-bpost-shipping-hooks.php:712
    138138msgid "bpost_method_Pugo international"
    139139msgstr ""
    140140
    141 #: classes/class-wc-bpost-shipping-hooks.php:721
     141#: classes/class-wc-bpost-shipping-hooks.php:717
    142142msgid "Change the delivery method"
    143143msgstr ""
    144144
    145 #: classes/class-wc-bpost-shipping-hooks.php:747
     145#: classes/class-wc-bpost-shipping-hooks.php:745
    146146msgid "Please, specify a bpost delivery method!"
    147147msgstr ""
    148148
    149 #: classes/class-wc-bpost-shipping-limitations.php:46
     149#: classes/class-wc-bpost-shipping-limitations.php:47
    150150msgid ""
    151151"bpost doesn't allow the \"Cash on delivery\" on this website. Please use a "
     
    153153msgstr ""
    154154
    155 #: classes/class-wc-bpost-shipping-limitations.php:52
     155#: classes/class-wc-bpost-shipping-limitations.php:53
    156156msgid "Your address can't have a length over %s"
    157157msgstr ""
    158158
    159 #: classes/class-wc-bpost-shipping-limitations.php:60
     159#: classes/class-wc-bpost-shipping-limitations.php:61
    160160msgid ""
    161161"Shipments over %s kg are not possible with bpost, the current cart weight is "
     
    163163msgstr ""
    164164
    165 #: classes/class-wc-bpost-shipping-limitations.php:69
     165#: classes/class-wc-bpost-shipping-limitations.php:70
    166166msgid ""
    167167"The Shipping Manager is currently unavailable, please contact the webshop's "
     
    197197msgstr ""
    198198
    199 #. #-#-#-#-#  bpost_shipping.pot (bpost shipping 3.1.9)  #-#-#-#-#
     199#. #-#-#-#-#  bpost_shipping.pot (bpost shipping 3.1.10)  #-#-#-#-#
    200200#. Author of the plugin/theme
    201 #: classes/class-wc-bpost-shipping-method.php:264
    202 #: classes/class-wc-bpost-shipping-method.php:273
     201#: classes/class-wc-bpost-shipping-method.php:261
     202#: classes/class-wc-bpost-shipping-method.php:270
    203203msgid "bpost"
    204204msgstr ""
    205205
    206 #: classes/class-wc-bpost-shipping-method.php:323
     206#: classes/class-wc-bpost-shipping-method.php:320
    207207msgid ""
    208208"%s is set in your bpost Shipping Manager but you did not allow it in your "
     
    210210msgstr ""
    211211
    212 #: classes/class-wc-bpost-shipping-method.php:334
     212#: classes/class-wc-bpost-shipping-method.php:331
    213213msgid "%s is not available in your bpost Shipping Manager"
    214214msgstr ""
    215215
    216 #: classes/class-wc-bpost-shipping-method.php:352
     216#: classes/class-wc-bpost-shipping-method.php:349
    217217msgid "bpost logs had been clean"
    218218msgstr ""
    219219
    220 #: classes/class-wc-bpost-shipping-method.php:361
     220#: classes/class-wc-bpost-shipping-method.php:358
    221221msgid ""
    222222"The plugin has been disabled because the connection to the API failed. Do "
  • bpost-shipping/trunk/readme.txt

    r3152964 r3158208  
    88Tested up to: 6.5
    99Requires PHP: 7.4
    10 Stable tag: 3.1.9
     10Stable tag: 3.1.10
    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.10
     124
     125*Release date: 2024-09-26*
     126
     127* avoid multiple calls to retrieve SHM product configuration
     128* restore cart limit at 30 kg
    122129
    123130#### 3.1.9
Note: See TracChangeset for help on using the changeset viewer.