Plugin Directory

Changeset 2981896


Ignore:
Timestamp:
10/20/2023 09:38:47 PM (2 years ago)
Author:
antidot-dev
Message:

Release 3.0.2

Location:
bpost-shipping/trunk
Files:
6 edited

Legend:

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

    r2980361 r2981896  
    66 * Author: bpost
    77 * Author URI: https://www.bpost.be/
    8  * Version: 3.0.1
     8 * Version: 3.0.2
    99 * WC requires at least: 3.0
    1010 * WC tested up to: 7.9
     
    1515define( 'BPOST_PLUGIN_DIR', __DIR__ );
    1616define( 'BPOST_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    17 define( 'BPOST_PLUGIN_VERSION', '3.0.1' );
     17define( 'BPOST_PLUGIN_VERSION', '3.0.2' );
    1818
    1919/**
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-container.php

    r2890340 r2981896  
    5252                $options = self::get( WC_BPost_Shipping_Options_Label::class );
    5353                if ( ! $options->is_logs_debug_mode() ) {
    54                     $handler->setLevel( \Monolog\Logger::ERROR );
     54                    $handler->setLevel( \Monolog\Logger::NOTICE );
    5555                }
    5656
  • bpost-shipping/trunk/classes/class-wc-bpost-shipping-hooks.php

    r2980361 r2981896  
    441441    }
    442442
    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 ) ) {
    450489            // all cart products are virtual (or the cart is empty...)
     490            Container::get_logger()->notice( 'All products seem virtual (no shipping needed)' );
     491
    451492            return false;
    452493        }
    453494
    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;
    459496    }
    460497
     
    655692            $parcel_shop_info_color = 'red';
    656693            $button_label           = bpost__( 'Your bpost delivery method' );
     694            $button_class           = 'alt';
    657695        } else {
    658696            // Here to help the generation of the pot file:
     
    672710            $parcel_shop_info_color = 'green';
    673711            $button_label           = bpost__( 'Change the delivery method' );
     712            $button_class           = '';
    674713        }
    675714
    676715        echo <<<HTML
    677716<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>
    679718    <br>
    680719    <span id="bpost_shipping_info" style="color: $parcel_shop_info_color">$parcel_shop_info</span>
     
    690729        }
    691730
    692         Container::get_logger()->debug(
     731        Container::get_logger()->notice(
    693732            'bpost_shm_already_called = ' . $posted_data['bpost_shm_already_called'],
    694733            array_keys( WC()->payment_gateways->get_available_payment_gateways() )
     
    698737            $error_message = bpost__( 'Please, specify a bpost delivery method!' );
    699738
    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')
    709742        }
    710743    }
  • bpost-shipping/trunk/composer.json

    r2980361 r2981896  
    33  "description": "WooCommerce plugin for bpost shipping",
    44  "type": "wordpress-plugin",
    5   "version": "3.0.1",
     5  "version": "3.0.2",
    66
    77  "require": {
  • bpost-shipping/trunk/languages/bpost_shipping.pot

    r2980361 r2981896  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: bpost shipping 3.0.1\n"
     5"Project-Id-Version: bpost shipping 3.0.2\n"
    66"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"
    88"MIME-Version: 1.0\n"
    99"Content-Type: text/plain; charset=UTF-8\n"
     
    107107msgstr ""
    108108
    109 #: classes/class-wc-bpost-shipping-hooks.php:486
     109#: classes/class-wc-bpost-shipping-hooks.php:523
    110110msgid "bpost labels"
    111111msgstr ""
    112112
    113 #: classes/class-wc-bpost-shipping-hooks.php:654
     113#: classes/class-wc-bpost-shipping-hooks.php:691
    114114msgid "You have to specify a delivery method"
    115115msgstr ""
    116116
    117 #: classes/class-wc-bpost-shipping-hooks.php:656
     117#: classes/class-wc-bpost-shipping-hooks.php:693
    118118msgid "Your bpost delivery method"
    119119msgstr ""
    120120
    121 #: classes/class-wc-bpost-shipping-hooks.php:660
     121#: classes/class-wc-bpost-shipping-hooks.php:698
    122122msgid "bpost_method_Regular"
    123123msgstr ""
    124124
    125 #: classes/class-wc-bpost-shipping-hooks.php:661
     125#: classes/class-wc-bpost-shipping-hooks.php:699
    126126msgid "bpost_method_Pugo"
    127127msgstr ""
    128128
    129 #: classes/class-wc-bpost-shipping-hooks.php:662
     129#: classes/class-wc-bpost-shipping-hooks.php:700
    130130msgid "bpost_method_Parcels depot"
    131131msgstr ""
    132132
    133 #: classes/class-wc-bpost-shipping-hooks.php:663
     133#: classes/class-wc-bpost-shipping-hooks.php:701
    134134msgid "bpost_method_bpack BUSINESS"
    135135msgstr ""
    136136
    137 #: classes/class-wc-bpost-shipping-hooks.php:664
     137#: classes/class-wc-bpost-shipping-hooks.php:702
    138138msgid "bpost_method_Pugo international"
    139139msgstr ""
    140140
    141 #: classes/class-wc-bpost-shipping-hooks.php:673
     141#: classes/class-wc-bpost-shipping-hooks.php:711
    142142msgid "Change the delivery method"
    143143msgstr ""
    144144
    145 #: classes/class-wc-bpost-shipping-hooks.php:698
     145#: classes/class-wc-bpost-shipping-hooks.php:737
    146146msgid "Please, specify a bpost delivery method!"
    147147msgstr ""
     
    197197msgstr ""
    198198
    199 #. #-#-#-#-#  bpost_shipping.pot (bpost shipping 3.0.1)  #-#-#-#-#
     199#. #-#-#-#-#  bpost_shipping.pot (bpost shipping 3.0.2)  #-#-#-#-#
    200200#. Author of the plugin/theme
    201201#: classes/class-wc-bpost-shipping-method.php:264
  • bpost-shipping/trunk/readme.txt

    r2980361 r2981896  
    66Author URI: https://www.bpost.be/
    77Requires at least: 4.9
    8 Tested up to: 6.2
     8Tested up to: 6.3
    99Requires PHP: 7.4
    10 Stable tag: 3.0.1
     10Stable tag: 3.0.2
    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.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
    122130
    123131#### 3.0.1
Note: See TracChangeset for help on using the changeset viewer.