Changeset 2981896
- Timestamp:
- 10/20/2023 09:38:47 PM (2 years ago)
- Location:
- bpost-shipping/trunk
- Files:
-
- 6 edited
-
bpost-shipping.php (modified) (2 diffs)
-
classes/class-wc-bpost-shipping-container.php (modified) (1 diff)
-
classes/class-wc-bpost-shipping-hooks.php (modified) (5 diffs)
-
composer.json (modified) (1 diff)
-
languages/bpost_shipping.pot (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bpost-shipping/trunk/bpost-shipping.php
r2980361 r2981896 6 6 * Author: bpost 7 7 * Author URI: https://www.bpost.be/ 8 * Version: 3.0. 18 * Version: 3.0.2 9 9 * WC requires at least: 3.0 10 10 * WC tested up to: 7.9 … … 15 15 define( 'BPOST_PLUGIN_DIR', __DIR__ ); 16 16 define( 'BPOST_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 17 define( 'BPOST_PLUGIN_VERSION', '3.0. 1' );17 define( 'BPOST_PLUGIN_VERSION', '3.0.2' ); 18 18 19 19 /** -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-container.php
r2890340 r2981896 52 52 $options = self::get( WC_BPost_Shipping_Options_Label::class ); 53 53 if ( ! $options->is_logs_debug_mode() ) { 54 $handler->setLevel( \Monolog\Logger:: ERROR);54 $handler->setLevel( \Monolog\Logger::NOTICE ); 55 55 } 56 56 -
bpost-shipping/trunk/classes/class-wc-bpost-shipping-hooks.php
r2980361 r2981896 441 441 } 442 442 443 /** 444 * @param array $posted 445 * 446 * @return bool 447 */ 448 private function is_bpost_shipping_from_session() { 449 if (empty(WC()->cart->get_shipping_packages()['contents'])) { 443 private function is_bpost_shipping_from_session(): bool { 444 if ( ! $this->need_shipping() ) { 445 return false; 446 } 447 448 $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' ); 449 450 foreach ( $chosen_shipping_methods as $shipping_method ) { 451 switch ( $shipping_method ) { 452 case BPOST_PLUGIN_ID: 453 case BPOST_PLUGIN_ID . '_error': 454 Container::get_logger()->notice( 'It is a bpost shipping', $chosen_shipping_methods ); 455 456 return true; 457 } 458 } 459 460 Container::get_logger()->notice( 'It is not a bpost shipping', $chosen_shipping_methods ); 461 462 return false; 463 } 464 465 private function need_shipping(): bool { 466 $shipping_packages = WC()->cart->get_shipping_packages(); 467 $shipping_packages_count = count( $shipping_packages ); 468 469 Container::get_logger()->notice( 470 'bpost_shipping_options_validation: bpost order ?', 471 [ 472 'shipping_packages' => $shipping_packages, 473 'chosen_shipping_methods' => WC()->session->get( 'chosen_shipping_methods' ), 474 ] 475 ); 476 477 if ( $shipping_packages_count !== 1 ) { 478 Container::get_logger()->notice( 479 "There is $shipping_packages_count shipping package(s)!", 480 $shipping_packages 481 ); 482 483 return false; 484 } 485 486 $contents = $shipping_packages[0]['contents']; 487 488 if ( empty( $contents ) ) { 450 489 // all cart products are virtual (or the cart is empty...) 490 Container::get_logger()->notice( 'All products seem virtual (no shipping needed)' ); 491 451 492 return false; 452 493 } 453 494 454 $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' ); 455 456 return 457 in_array( BPOST_PLUGIN_ID, $chosen_shipping_methods, true ) 458 || in_array( BPOST_PLUGIN_ID . '_error', $chosen_shipping_methods, true ); 495 return true; 459 496 } 460 497 … … 655 692 $parcel_shop_info_color = 'red'; 656 693 $button_label = bpost__( 'Your bpost delivery method' ); 694 $button_class = 'alt'; 657 695 } else { 658 696 // Here to help the generation of the pot file: … … 672 710 $parcel_shop_info_color = 'green'; 673 711 $button_label = bpost__( 'Change the delivery method' ); 712 $button_class = ''; 674 713 } 675 714 676 715 echo <<<HTML 677 716 <p style="font-weight: 400"> 678 <button class="js-bpost-shipping-options-modal ">$button_label</button>717 <button class="js-bpost-shipping-options-modal button $button_class">$button_label</button> 679 718 <br> 680 719 <span id="bpost_shipping_info" style="color: $parcel_shop_info_color">$parcel_shop_info</span> … … 690 729 } 691 730 692 Container::get_logger()-> debug(731 Container::get_logger()->notice( 693 732 'bpost_shm_already_called = ' . $posted_data['bpost_shm_already_called'], 694 733 array_keys( WC()->payment_gateways->get_available_payment_gateways() ) … … 698 737 $error_message = bpost__( 'Please, specify a bpost delivery method!' ); 699 738 700 Container::get_logger()->warning( $error_message, [ 'payment_method' => $posted_data['payment_method'] ] ); 701 702 // If PayPal CheckOut from WooCommerce is enabled, we don't use wc_add_notice because it doesn't block the payment 703 switch ( $posted_data['payment_method'] ) { 704 case 'ppec_paypal': 705 throw new Exception( $error_message ); 706 default: 707 wc_add_notice( $error_message, 'error' ); 708 } 739 Container::get_logger()->warning( $error_message ); 740 741 throw new Exception( $error_message ); // throw an exception will provide a wp_notice(..., 'error') 709 742 } 710 743 } -
bpost-shipping/trunk/composer.json
r2980361 r2981896 3 3 "description": "WooCommerce plugin for bpost shipping", 4 4 "type": "wordpress-plugin", 5 "version": "3.0. 1",5 "version": "3.0.2", 6 6 7 7 "require": { -
bpost-shipping/trunk/languages/bpost_shipping.pot
r2980361 r2981896 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: bpost shipping 3.0. 1\n"5 "Project-Id-Version: bpost shipping 3.0.2\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/package\n" 7 "POT-Creation-Date: 2023-10- 17 22:25:00+00:00\n"7 "POT-Creation-Date: 2023-10-20 21:38:08+00:00\n" 8 8 "MIME-Version: 1.0\n" 9 9 "Content-Type: text/plain; charset=UTF-8\n" … … 107 107 msgstr "" 108 108 109 #: classes/class-wc-bpost-shipping-hooks.php: 486109 #: classes/class-wc-bpost-shipping-hooks.php:523 110 110 msgid "bpost labels" 111 111 msgstr "" 112 112 113 #: classes/class-wc-bpost-shipping-hooks.php:6 54113 #: classes/class-wc-bpost-shipping-hooks.php:691 114 114 msgid "You have to specify a delivery method" 115 115 msgstr "" 116 116 117 #: classes/class-wc-bpost-shipping-hooks.php:6 56117 #: classes/class-wc-bpost-shipping-hooks.php:693 118 118 msgid "Your bpost delivery method" 119 119 msgstr "" 120 120 121 #: classes/class-wc-bpost-shipping-hooks.php:6 60121 #: classes/class-wc-bpost-shipping-hooks.php:698 122 122 msgid "bpost_method_Regular" 123 123 msgstr "" 124 124 125 #: classes/class-wc-bpost-shipping-hooks.php:6 61125 #: classes/class-wc-bpost-shipping-hooks.php:699 126 126 msgid "bpost_method_Pugo" 127 127 msgstr "" 128 128 129 #: classes/class-wc-bpost-shipping-hooks.php: 662129 #: classes/class-wc-bpost-shipping-hooks.php:700 130 130 msgid "bpost_method_Parcels depot" 131 131 msgstr "" 132 132 133 #: classes/class-wc-bpost-shipping-hooks.php: 663133 #: classes/class-wc-bpost-shipping-hooks.php:701 134 134 msgid "bpost_method_bpack BUSINESS" 135 135 msgstr "" 136 136 137 #: classes/class-wc-bpost-shipping-hooks.php: 664137 #: classes/class-wc-bpost-shipping-hooks.php:702 138 138 msgid "bpost_method_Pugo international" 139 139 msgstr "" 140 140 141 #: classes/class-wc-bpost-shipping-hooks.php: 673141 #: classes/class-wc-bpost-shipping-hooks.php:711 142 142 msgid "Change the delivery method" 143 143 msgstr "" 144 144 145 #: classes/class-wc-bpost-shipping-hooks.php: 698145 #: classes/class-wc-bpost-shipping-hooks.php:737 146 146 msgid "Please, specify a bpost delivery method!" 147 147 msgstr "" … … 197 197 msgstr "" 198 198 199 #. #-#-#-#-# bpost_shipping.pot (bpost shipping 3.0. 1) #-#-#-#-#199 #. #-#-#-#-# bpost_shipping.pot (bpost shipping 3.0.2) #-#-#-#-# 200 200 #. Author of the plugin/theme 201 201 #: classes/class-wc-bpost-shipping-method.php:264 -
bpost-shipping/trunk/readme.txt
r2980361 r2981896 6 6 Author URI: https://www.bpost.be/ 7 7 Requires at least: 4.9 8 Tested up to: 6. 28 Tested up to: 6.3 9 9 Requires PHP: 7.4 10 Stable tag: 3.0. 110 Stable tag: 3.0.2 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.0.2 124 125 *Release date: 2023-10-20* 126 127 * Improve visibility of the button 128 * Improve validation of bpost delivery method 129 * Confirm tested up to WP 6.3 122 130 123 131 #### 3.0.1
Note: See TracChangeset
for help on using the changeset viewer.