Changeset 3158208
- Timestamp:
- 09/26/2024 11:55:42 AM (18 months ago)
- Location:
- bpost-shipping/trunk
- Files:
-
- 20 edited
-
bpost-shipping.php (modified) (2 diffs)
-
classes/api/class-wc-bpost-shipping-api-factory.php (modified) (2 diffs)
-
classes/assets/class-wc-bpost-shipping-assets-management.php (modified) (1 diff)
-
classes/assets/class-wc-bpost-shipping-assets-resources.php (modified) (5 diffs)
-
classes/checkout/class-wc-bpost-shipping-checkout-order-review.php (modified) (1 diff)
-
classes/class-wc-bpost-shipping-cart.php (modified) (2 diffs)
-
classes/class-wc-bpost-shipping-container.php (modified) (5 diffs)
-
classes/class-wc-bpost-shipping-data-builder.php (modified) (2 diffs)
-
classes/class-wc-bpost-shipping-hooks.php (modified) (3 diffs)
-
classes/class-wc-bpost-shipping-limitations.php (modified) (5 diffs)
-
classes/class-wc-bpost-shipping-method.php (modified) (4 diffs)
-
classes/class-wc-bpost-shipping-order-details-controller.php (modified) (4 diffs)
-
classes/class-wc-bpost-shipping-package.php (modified) (2 diffs)
-
classes/class-wc-bpost-shipping-posted.php (modified) (3 diffs)
-
classes/class-wc-bpost-shipping-shm-callback-controller.php (modified) (1 diff)
-
classes/options/class-wc-bpost-shipping-options-base.php (modified) (1 diff)
-
languages/bpost_shipping-fr_BE.mo (modified) (previous)
-
languages/bpost_shipping-fr_FR.mo (modified) (previous)
-
languages/bpost_shipping.pot (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bpost-shipping/trunk/bpost-shipping.php
r3152964 r3158208 6 6 * Author: bpost 7 7 * Author URI: https://www.bpost.be/ 8 * Version: 3.1. 98 * Version: 3.1.10 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. 9' );17 define( 'BPOST_PLUGIN_VERSION', '3.1.10' ); 18 18 19 19 /** -
bpost-shipping/trunk/classes/api/class-wc-bpost-shipping-api-factory.php
r2929716 r3158208 1 1 <?php 2 2 3 namespace WC_BPost_Shipping\Api; 3 4 4 use WC_BPost_Shipping\ Options\WC_BPost_Shipping_Options_Base;5 use WC_BPost_Shipping\WC_Bpost_Shipping_Container; 5 6 use WC_BPost_Shipping_Logger; 6 7 … … 10 11 class WC_BPost_Shipping_Api_Factory { 11 12 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; 16 14 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; 26 17 } 27 18 28 /**29 * @return WC_BPost_Shipping_Api_Product_Configuration30 */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 ); 33 24 } 34 25 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 ); 40 28 } 41 29 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 { 46 31 return new WC_BPost_Shipping_Api_Geo6_Search( $this->get_api_geo6_connector() ); 47 32 } 48 33 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 ); 63 36 } 64 37 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' ); 79 40 } 80 41 } -
bpost-shipping/trunk/classes/assets/class-wc-bpost-shipping-assets-management.php
r2894167 r3158208 64 64 * @param string[] $shm_data 65 65 */ 66 public function callback_page( $shm_data ) {66 public function callback_page( array $shm_data ) { 67 67 $this->resources->get_callback_page( $shm_data ); 68 68 } -
bpost-shipping/trunk/classes/assets/class-wc-bpost-shipping-assets-resources.php
r2894167 r3158208 36 36 public function get_order_receive_page( $order_received ) { 37 37 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 ); 40 46 wp_localize_script( 'bpost-order-received', 'bpost_order_received', $order_received ); 41 47 wp_enqueue_script( 'bpost-order-received' ); … … 46 52 */ 47 53 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 ); 50 62 } 51 63 … … 58 70 wp_enqueue_script( 'bpost-shm-app', BPOST_PLUGIN_URL . 'public/js/app.min.js', array(), BPOST_PLUGIN_VERSION ); 59 71 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 ); 61 76 wp_localize_script( 'bpost-admin-order-edit', 'bpost_order_data', $order_data ); 62 77 wp_enqueue_script( 'bpost-admin-order-edit' ); … … 68 83 * @param string[] $shm_data 69 84 */ 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/xml85 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 72 87 wp_enqueue_script( 'bpost-shm-app', BPOST_PLUGIN_URL . 'public/js/app.min.js', array(), BPOST_PLUGIN_VERSION ); 73 88 … … 97 112 98 113 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 ); 100 118 } 101 119 } -
bpost-shipping/trunk/classes/checkout/class-wc-bpost-shipping-checkout-order-review.php
r2890340 r3158208 4 4 5 5 6 use Exception; 6 7 use WC_BPost_Shipping\Adapter\WC_BPost_Shipping_Adapter_Woocommerce; 7 use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Factory;8 8 use WC_BPost_Shipping\Street\WC_BPost_Shipping_Street_Builder; 9 9 use WC_BPost_Shipping\Street\WC_BPost_Shipping_Street_Solver; 10 use WC_BPost_Shipping\WC_Bpost_Shipping_Container as Container; 11 use WC_BPost_Shipping_Cart; 12 use WC_BPost_Shipping_Limitations; 13 use WC_BPost_Shipping_Posted; 10 14 11 15 class WC_BPost_Shipping_Checkout_Order_Review { 12 16 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; 23 19 24 25 /**26 * WC_BPost_Shipping_Checkout_Order_Review constructor.27 *28 * @param WC_BPost_Shipping_Adapter_Woocommerce $adapter_woocommerce29 * @param WC_BPost_Shipping_Api_Factory $factory30 * @param \WC_BPost_Shipping_Limitations $limitations31 * @param \WC_BPost_Shipping_Cart $cart32 * @param \WC_BPost_Shipping_Posted $posted33 */34 20 public function __construct( 35 21 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 40 23 ) { 41 24 $this->adapter_woocommerce = $adapter_woocommerce; 42 25 $this->limitations = $limitations; 43 $this->factory = $factory;44 45 $this->cart = $cart;46 $this->posted = $posted;47 26 } 48 27 49 /** 50 * @return bool 51 */ 52 public function review_order() { 28 public function review_order( WC_BPost_Shipping_Posted $posted ): bool { 53 29 $street_builder = new WC_BPost_Shipping_Street_Builder( new WC_BPost_Shipping_Street_Solver() ); 54 30 31 $street = $street_builder 32 ->get_street_items( WC()->customer->get_shipping_address(), WC()->customer->get_shipping_address_2() ) 33 ->get_street(); 34 55 35 $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() 61 39 ); 62 40 63 41 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' ); 65 46 } 66 47 -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-cart.php
r2283055 r3158208 1 1 <?php 2 2 3 if ( ! defined( 'ABSPATH' ) ) { 3 4 exit; // Exit if accessed directly … … 9 10 */ 10 11 class 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; 20 14 } 21 15 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' ); 27 18 } 28 19 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(); 34 22 } 35 23 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(); 41 26 } 42 43 /**44 * @return array45 */46 public function get_used_coupons() {47 return $this->cart->get_applied_coupons();48 }49 50 27 } -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-container.php
r3117106 r3158208 5 5 use LogicException; 6 6 use WC_BPost_Shipping\Adapter\WC_BPost_Shipping_Adapter_Woocommerce as Adapter; 7 use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Connector; 7 8 use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Factory; 9 use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Product_Configuration; 8 10 use WC_BPost_Shipping\Assets\WC_BPost_Shipping_Assets_Detector; 9 11 use WC_BPost_Shipping\Assets\WC_BPost_Shipping_Assets_Management; 10 12 use WC_BPost_Shipping\Assets\WC_BPost_Shipping_Assets_Resources; 13 use WC_BPost_Shipping\Checkout\WC_BPost_Shipping_Checkout_Order_Review; 11 14 use WC_BPost_Shipping\Label\WC_BPost_Shipping_Label_Path_Resolver; 12 15 use WC_BPost_Shipping\Label\WC_BPost_Shipping_Label_Retriever; 13 16 use WC_BPost_Shipping\Label\WC_BPost_Shipping_Label_Url_Generator; 17 use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Base; 14 18 use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Label; 19 use WC_BPost_Shipping_Limitations; 15 20 use WC_BPost_Shipping_Logger; 16 21 use WC_BPost_Shipping_Meta_Type; … … 35 40 return new WC_BPost_Shipping_Options_Label( self::get_adapter() ); 36 41 42 case WC_BPost_Shipping_Options_Base::class: 43 return new WC_BPost_Shipping_Options_Base(); 44 37 45 case WC_BPost_Shipping_Label_Path_Resolver::class: 38 46 return new WC_BPost_Shipping_Label_Path_Resolver( self::get_options_label() ); … … 49 57 case WC_BPost_Shipping_Api_Factory::class: 50 58 return new WC_BPost_Shipping_Api_Factory( 51 self::get_options_label(),52 59 self::get_logger() 53 60 ); … … 69 76 case WC_BPost_Shipping_Meta_Type::class: 70 77 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 ); 71 101 } 72 102 … … 110 140 } 111 141 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 112 150 } -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-data-builder.php
r3117106 r3158208 17 17 private WC_BPost_Shipping_Address $shipping_address; 18 18 private WC_BPost_Shipping_Delivery_Methods $delivery_methods; 19 private WC_BPost_Shipping_Cart $cart;20 19 21 /**22 * WC_BPost_Shipping_Data_Builder constructor.23 *24 * @param WC_BPost_Shipping_Cart $cart25 * @param WC_BPost_Shipping_Address $shipping_address26 * @param WC_BPost_Shipping_Options_Base $shipping_options27 * @param WC_BPost_Shipping_Delivery_Methods $delivery_methods28 */29 20 public function __construct( 30 WC_BPost_Shipping_Cart $cart,31 21 WC_BPost_Shipping_Address $shipping_address, 32 22 WC_BPost_Shipping_Options_Base $shipping_options, 33 23 WC_BPost_Shipping_Delivery_Methods $delivery_methods 34 24 ) { 35 $this->cart = $cart;36 25 $this->shipping_options = $shipping_options; 37 26 $this->shipping_address = $shipping_address; … … 59 48 'sub_total' => round( WC()->cart->subtotal * 100 ), 60 49 // 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 ), 62 51 'language' => $this->get_language_for_shm(), 63 52 'additional_customer_ref' => 'WORDPRESS ' . get_bloginfo( 'version' ) . ' / WOOCOMMERCE ' . WC()->version, 64 53 'delivery_method_overrides' => $this->shipping_options->get_delivery_method_overrides( 65 54 $this->shipping_address, 66 $this->cart,67 55 $this->delivery_methods 68 56 ), -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-hooks.php
r3117106 r3158208 181 181 182 182 $api_factory = new WC_BPost_Shipping_Api_Factory( 183 new WC_BPost_Shipping_Options_Base(),184 183 Container::get_logger() 185 184 ); … … 364 363 */ 365 364 public function bpost_shipping_api_loader() { 366 $posted_obj = new WC_BPost_Shipping_Posted( $_POST );365 $posted_obj = WC_BPost_Shipping_Posted::create( $_POST ); 367 366 $bpost_street_builder = new WC_BPost_Shipping_Street_Builder( new WC_BPost_Shipping_Street_Solver() ); 368 367 369 $cart = new WC_BPost_Shipping_Cart( WC()->cart );370 371 368 $data_builder = new WC_BPost_Shipping_Data_Builder( 372 $cart,373 369 new WC_BPost_Shipping_Address( $bpost_street_builder, WC()->customer, $posted_obj ), 374 370 new WC_BPost_Shipping_Options_Base(), 375 371 new WC_BPost_Shipping_Delivery_Methods( 376 Container::get_api_ factory()->get_api_connector()->fetchProductConfig()372 Container::get_api_connector()->fetchProductConfig() 377 373 ) 378 374 ); … … 739 735 } 740 736 737 Container::get_order_review()->review_order( WC_BPost_Shipping_Posted::create( $posted_data ) ); 738 741 739 Container::get_logger()->notice( 742 740 'bpost_shm_already_called = ' . $posted_data['bpost_shm_already_called'], -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-limitations.php
r2890340 r3158208 1 1 <?php 2 2 3 use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Connector; 3 4 use WC_BPost_Shipping\Api\WC_BPost_Shipping_Api_Product_Configuration; … … 21 22 private $errors; 22 23 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; 25 34 } 26 35 … … 29 38 * @param string $address 30 39 * @param int $weight 31 * @param WC_BPost_Shipping_Api_Product_Configuration $product_configuration32 * @param WC_BPost_Shipping_Api_Connector $connector33 40 * 34 41 * @return bool 35 42 */ 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 ) { 43 44 $limitations_are_ok = true; 44 45 … … 56 57 } 57 58 58 if ( ! $this->is_valid_weight( $ product_configuration, $weight ) ) {59 if ( ! $this->is_valid_weight( $this->product_configuration, $weight ) ) { 59 60 $this->errors[] = sprintf( 60 61 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 ), 62 63 number_format( $weight, 2 ) 63 64 ); … … 65 66 } 66 67 67 if ( ! $this->check_webservice_status( $ connector ) ) {68 if ( ! $this->check_webservice_status( $this->connector ) ) { 68 69 $this->errors[] = 69 70 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 11 11 use WC_BPost_Shipping\JsonArray\WC_BPost_Shipping_JsonArray_Validator; 12 12 use WC_BPost_Shipping\Options\WC_BPost_Shipping_Options_Base; 13 use WC_BPost_Shipping\WC_Bpost_Shipping_Container; 13 14 14 15 /** … … 56 57 $this->init_logger(); 57 58 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 ); 62 60 63 61 $this->supports[] = 'shipping-zones'; … … 75 73 $this->init_settings(); // This is part of the settings API. Loads settings you previously init. 76 74 $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() 79 77 ); 80 78 … … 200 198 $this->product_configuration_factory->get_product_configuration(), 201 199 new WC_BPost_Shipping_Options_Base(), 202 $package, 203 WC()->cart 200 $package 204 201 ); 205 202 -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-order-details-controller.php
r2926483 r3158208 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 11 11 12 /** … … 70 71 return array_merge( $template_data, $this->get_google_template_data() ); 71 72 } 72 73 73 } 74 74 … … 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( 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() ); 84 81 $order_updater = new WC_BPost_Shipping_Order_Updater( 85 82 $this->order, … … 131 128 'map_provider' => self::MAP_PROVIDER_GOOGLE, 132 129 ); 133 134 130 } 135 131 -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-package.php
r2890340 r3158208 11 11 class WC_BPost_Shipping_Package { 12 12 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; 21 16 22 17 23 /**24 * WC_BPost_Shipping_Package constructor.25 *26 * @param WC_BPost_Shipping_Api_Product_Configuration $product_configuration27 * @param WC_BPost_Shipping_Options_Base $options28 * @param array $package29 * @param WC_Cart $cart30 */31 18 public function __construct( 32 19 WC_BPost_Shipping_Api_Product_Configuration $product_configuration, 33 20 WC_BPost_Shipping_Options_Base $options, 34 array $package, 35 WC_Cart $cart 21 array $package 36 22 ) { 37 23 $this->product_configuration = $product_configuration; 38 24 $this->options = $options; 39 25 $this->package = $package; 40 $this->cart = $cart;41 26 } 42 27 … … 59 44 } 60 45 61 $bpost_cart = new WC_BPost_Shipping_Cart( $this->cart );62 46 if ( $this->options->is_free_shipping( 63 47 $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() 66 50 ) ) { 67 51 return 0; -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-posted.php
r2890340 r3158208 1 1 <?php 2 2 3 if ( ! defined( 'ABSPATH' ) ) { 3 4 exit; // Exit if accessed directly … … 9 10 class WC_BPost_Shipping_Posted { 10 11 /** @var string[] */ 11 private $posted; 12 /** @var bool */ 13 private $ship_to_different_address; 12 private array $posted; 14 13 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 ) { 21 15 $this->posted = $posted; 16 } 22 17 18 public static function create( array $posted ): self { 23 19 // 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( 25 21 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, 35 32 ), 36 $ this->posted33 $posted 37 34 ); 38 35 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 ); 40 37 } 41 38 42 /** 43 * @return string 44 */ 45 public function get_payment_method() { 39 public function get_payment_method(): string { 46 40 return $this->posted['payment_method']; 47 41 } 48 42 49 /** 50 * @return string 51 */ 52 public function get_first_name() { 43 public function get_first_name(): string { 53 44 return $this->posted[ $this->get_address_type() . '_first_name' ]; 54 45 } 55 46 56 47 /** 57 * @return string return 'shipping' or 'billing' depending o fship_to_different_address flag48 * @return string return 'shipping' or 'billing' depending on ship_to_different_address flag 58 49 */ 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'; 61 52 } 62 53 63 /** 64 * @return string 65 */ 66 public function get_last_name() { 54 public function get_last_name(): string { 67 55 return $this->posted[ $this->get_address_type() . '_last_name' ]; 68 56 } 69 57 70 /** 71 * @return string 72 */ 73 public function get_company() { 58 public function get_company(): string { 74 59 return $this->posted[ $this->get_address_type() . '_company' ]; 75 60 } 76 61 77 /** 78 * @return string the email value from billing email every time 79 */ 80 public function get_email() { 62 public function get_email(): string { 81 63 return $this->posted['billing_email']; 82 64 } 83 65 84 /** 85 * @return string the phone value from billing phone every time 86 */ 87 public function get_phone() { 66 public function get_phone(): string { 88 67 return $this->posted['billing_phone']; 89 68 } 90 69 91 /** 92 * @return string 93 */ 94 public function get_shipping_method() { 70 public function get_shipping_method(): string { 95 71 if ( ! is_array( $this->posted['shipping_method'] ) ) { 96 72 return ''; … … 100 76 } 101 77 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']; 107 80 } 108 81 } -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-shm-callback-controller.php
r2890340 r3158208 55 55 * @return array json 56 56 */ 57 private function get_callback_data() {57 private function get_callback_data(): array { 58 58 switch ( $this->result ) { 59 59 case self::RESULT_SHM_CALLBACK_CONFIRM: -
bpost-shipping/trunk/classes/options/class-wc-bpost-shipping-options-base.php
r3122012 r3158208 161 161 * TODO why this is here? 162 162 * 163 * @param WC_BPost_Shipping_Address $shipping_address164 * @param WC_BPost_Shipping_Cart $cart165 * @param WC_BPost_Shipping_Delivery_Methods $delivery_methods166 *167 163 * @return string[] 168 164 */ 169 165 public function get_delivery_method_overrides( 170 166 WC_BPost_Shipping_Address $shipping_address, 171 WC_BPost_Shipping_Cart $cart,172 167 WC_BPost_Shipping_Delivery_Methods $delivery_methods 173 168 ) { 174 169 if ( $this->is_free_shipping( 175 170 $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() 178 173 ) 179 174 ) { -
bpost-shipping/trunk/languages/bpost_shipping.pot
r3152964 r3158208 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: bpost shipping 3.1. 9\n"5 "Project-Id-Version: bpost shipping 3.1.10\n" 6 6 "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" 8 8 "MIME-Version: 1.0\n" 9 9 "Content-Type: text/plain; charset=UTF-8\n" … … 95 95 msgstr "" 96 96 97 #: classes/class-wc-bpost-shipping-hooks.php:23 997 #: classes/class-wc-bpost-shipping-hooks.php:238 98 98 msgid "(as from)" 99 99 msgstr "" 100 100 101 #: classes/class-wc-bpost-shipping-hooks.php:24 3101 #: classes/class-wc-bpost-shipping-hooks.php:242 102 102 msgid "Free shipping available" 103 103 msgstr "" 104 104 105 #: classes/class-wc-bpost-shipping-hooks.php:43 5105 #: classes/class-wc-bpost-shipping-hooks.php:431 106 106 msgid "status: " 107 107 msgstr "" 108 108 109 #: classes/class-wc-bpost-shipping-hooks.php:53 6109 #: classes/class-wc-bpost-shipping-hooks.php:532 110 110 msgid "bpost labels" 111 111 msgstr "" 112 112 113 #: classes/class-wc-bpost-shipping-hooks.php: 701113 #: classes/class-wc-bpost-shipping-hooks.php:697 114 114 msgid "You have to specify a delivery method" 115 115 msgstr "" 116 116 117 #: classes/class-wc-bpost-shipping-hooks.php: 703117 #: classes/class-wc-bpost-shipping-hooks.php:699 118 118 msgid "Your bpost delivery method" 119 119 msgstr "" 120 120 121 #: classes/class-wc-bpost-shipping-hooks.php:704 122 msgid "bpost_method_Regular" 123 msgstr "" 124 125 #: classes/class-wc-bpost-shipping-hooks.php:705 126 msgid "bpost_method_Pugo" 127 msgstr "" 128 129 #: classes/class-wc-bpost-shipping-hooks.php:706 130 msgid "bpost_method_Parcels depot" 131 msgstr "" 132 133 #: classes/class-wc-bpost-shipping-hooks.php:707 134 msgid "bpost_method_bpack BUSINESS" 135 msgstr "" 136 121 137 #: classes/class-wc-bpost-shipping-hooks.php:708 122 msgid "bpost_method_Regular"123 msgstr ""124 125 #: classes/class-wc-bpost-shipping-hooks.php:709126 msgid "bpost_method_Pugo"127 msgstr ""128 129 #: classes/class-wc-bpost-shipping-hooks.php:710130 msgid "bpost_method_Parcels depot"131 msgstr ""132 133 #: classes/class-wc-bpost-shipping-hooks.php:711134 msgid "bpost_method_bpack BUSINESS"135 msgstr ""136 137 #: classes/class-wc-bpost-shipping-hooks.php:712138 138 msgid "bpost_method_Pugo international" 139 139 msgstr "" 140 140 141 #: classes/class-wc-bpost-shipping-hooks.php:7 21141 #: classes/class-wc-bpost-shipping-hooks.php:717 142 142 msgid "Change the delivery method" 143 143 msgstr "" 144 144 145 #: classes/class-wc-bpost-shipping-hooks.php:74 7145 #: classes/class-wc-bpost-shipping-hooks.php:745 146 146 msgid "Please, specify a bpost delivery method!" 147 147 msgstr "" 148 148 149 #: classes/class-wc-bpost-shipping-limitations.php:4 6149 #: classes/class-wc-bpost-shipping-limitations.php:47 150 150 msgid "" 151 151 "bpost doesn't allow the \"Cash on delivery\" on this website. Please use a " … … 153 153 msgstr "" 154 154 155 #: classes/class-wc-bpost-shipping-limitations.php:5 2155 #: classes/class-wc-bpost-shipping-limitations.php:53 156 156 msgid "Your address can't have a length over %s" 157 157 msgstr "" 158 158 159 #: classes/class-wc-bpost-shipping-limitations.php:6 0159 #: classes/class-wc-bpost-shipping-limitations.php:61 160 160 msgid "" 161 161 "Shipments over %s kg are not possible with bpost, the current cart weight is " … … 163 163 msgstr "" 164 164 165 #: classes/class-wc-bpost-shipping-limitations.php: 69165 #: classes/class-wc-bpost-shipping-limitations.php:70 166 166 msgid "" 167 167 "The Shipping Manager is currently unavailable, please contact the webshop's " … … 197 197 msgstr "" 198 198 199 #. #-#-#-#-# bpost_shipping.pot (bpost shipping 3.1. 9) #-#-#-#-#199 #. #-#-#-#-# bpost_shipping.pot (bpost shipping 3.1.10) #-#-#-#-# 200 200 #. Author of the plugin/theme 201 #: classes/class-wc-bpost-shipping-method.php:26 4202 #: classes/class-wc-bpost-shipping-method.php:27 3201 #: classes/class-wc-bpost-shipping-method.php:261 202 #: classes/class-wc-bpost-shipping-method.php:270 203 203 msgid "bpost" 204 204 msgstr "" 205 205 206 #: classes/class-wc-bpost-shipping-method.php:32 3206 #: classes/class-wc-bpost-shipping-method.php:320 207 207 msgid "" 208 208 "%s is set in your bpost Shipping Manager but you did not allow it in your " … … 210 210 msgstr "" 211 211 212 #: classes/class-wc-bpost-shipping-method.php:33 4212 #: classes/class-wc-bpost-shipping-method.php:331 213 213 msgid "%s is not available in your bpost Shipping Manager" 214 214 msgstr "" 215 215 216 #: classes/class-wc-bpost-shipping-method.php:3 52216 #: classes/class-wc-bpost-shipping-method.php:349 217 217 msgid "bpost logs had been clean" 218 218 msgstr "" 219 219 220 #: classes/class-wc-bpost-shipping-method.php:3 61220 #: classes/class-wc-bpost-shipping-method.php:358 221 221 msgid "" 222 222 "The plugin has been disabled because the connection to the API failed. Do " -
bpost-shipping/trunk/readme.txt
r3152964 r3158208 8 8 Tested up to: 6.5 9 9 Requires PHP: 7.4 10 Stable tag: 3.1. 910 Stable tag: 3.1.10 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.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 122 129 123 130 #### 3.1.9
Note: See TracChangeset
for help on using the changeset viewer.