• Resolved Peter Leenders

    (@peterleenders)


    I’m getting errors on my website. And they can be traced back to Booster Plus’s “order numbering.”

    The error I found in my log files is as follows:

    Uncaught TypeError: gmdate(): Argument #2 ($timestamp) must be of type ?int, string given in /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/booster-plus-for-woocommerce/includes/class-wcj-order-numbers.php:470

    { “error”: { “type”: 1, “file”: “/var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/booster-plus-for-woocommerce/includes/class-wcj-order-numbers.php”, “line”: 470 }, “remote-logging”: true, “backtrace”: [ “”, “#0 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/booster-plus-for-woocommerce/includes/class-wcj-order-numbers.php(470): gmdate(‘Y’, ”)”, “#1 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/booster-plus-for-woocommerce/includes/class-wcj-order-numbers.php(506): WCJ_Order_Numbers->maybe_reset_sequential_counter(‘2’, 27852)”, “#2 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/booster-plus-for-woocommerce/includes/class-wcj-order-numbers.php(433): WCJ_Order_Numbers->add_order_number_meta(27852, false)”, “#3 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-includes/class-wp-hook.php(343): WCJ_Order_Numbers->add_new_order_number(27852)”, “#4 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters(NULL, Array)”, “#5 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-includes/plugin.php(522): WP_Hook->do_action(Array)”, “#6 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-includes/post.php(5205): do_action(‘wp_insert_post’, 27852, Object(WP_Post), false)”, “#7 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-data-store-cpt.php(86): wp_insert_post(Array, true)”, “#8 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php(110): Abstract_WC_Order_Data_Store_CPT->create(Object(WC_Order))”, “#9 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-data-store.php(186): WC_Order_Data_Store_CPT->create(Object(WC_Order))”, “#10 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-order.php(225): WC_Data_Store->create(Object(WC_Order))”, “#11 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-order.php(284): WC_Abstract_Order->save()”, “#12 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(471): WC_Order->save()”, “#13 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1336): WC_Checkout->create_order(Array)”, “#14 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(597): WC_Checkout->process_checkout()”, “#15 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-includes/class-wp-hook.php(341): WC_AJAX::checkout(”)”, “#16 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters(”, Array)”, “#17 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-includes/plugin.php(522): WP_Hook->do_action(Array)”, “#18 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(127): do_action(‘wc_ajax_checkou…’)”, “#19 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-includes/class-wp-hook.php(341): WC_AJAX::do_wc_ajax(”)”, “#20 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters(false, Array)”, “#21 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-includes/plugin.php(522): WP_Hook->do_action(Array)”, “#22 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-includes/template-loader.php(23): do_action(‘template_redire…’)”, “#23 /var/www/vhosts/hetjachtveld.nl/httpdocs/wp-blog-header.php(19): require_once(‘/var/www/vhosts…’)”, “#24 /var/www/vhosts/hetjachtveld.nl/httpdocs/index.php(17): require(‘/var/www/vhosts…’)”, “#25 {main}”, “thrown” ] }

    In the file class-wcj-order-numbers.php, starting at line 437, I replaced the code with

    /**
    * Maybe_reset_sequential_counter.
    *
    * @version 6.0.0
    * @since 1.0.0
    * @todo use transactions on
    wcj_order_number_use_mysql_transaction_enabled
    * @param int $current_order_number defines the current_order_number.
    * @param int $order_id defines the order_id.
    */
    public function maybe_reset_sequential_counter( $current_order_number, $order_id ) {
    $reset_period = wcj_get_option( 'wcj_order_number_counter_reset_enabled', 'no' );
    if ( 'no' !== ( $reset_period ) ) {
    $previous_order_date = wcj_get_option( 'wcj_order_number_counter_previous_order_date', 0 );
    $current_order_date = strtotime( wcj_get_order_date( wc_get_order( $order_id ) ) );

    // Zorg dat de timestamps integers zijn voor PHP 8 compatibility
    $current_timestamp = is_numeric( $current_order_date ) ? (int) $current_order_date : time();
    $previous_timestamp = is_numeric( $previous_order_date ) ? (int) $previous_order_date : 0;

    update_option( 'wcj_order_number_counter_previous_order_date', $current_timestamp );

    if ( 0 !== $previous_timestamp ) {
    $do_reset = false;
    switch ( $reset_period ) {
    case 'daily':
    $do_reset = (
    gmdate( 'Y', $current_timestamp ) !== gmdate( 'Y', $previous_timestamp ) ||
    gmdate( 'm', $current_timestamp ) !== gmdate( 'm', $previous_timestamp ) ||
    gmdate( 'd', $current_timestamp ) !== gmdate( 'd', $previous_timestamp )
    );
    break;
    case 'monthly':
    $do_reset = (
    gmdate( 'Y', $current_timestamp ) !== gmdate( 'Y', $previous_timestamp ) ||
    gmdate( 'm', $current_timestamp ) !== gmdate( 'm', $previous_timestamp )
    );
    break;
    case 'yearly':
    $do_reset = (
    gmdate( 'Y', $current_timestamp ) !== gmdate( 'Y', $previous_timestamp )
    );
    break;
    }
    if ( $do_reset ) {
    return 1;
    }
    }
    }
    return $current_order_number;
    }

    After this i didn’t get any error.

    I use php 8.3
    WordPress 6.9.4
    Woocommerce 10.7.0
    Booster plus 8.0.0

Viewing 1 replies (of 1 total)
  • Plugin Contributor David G

    (@gravid7)

    Hi,

    Thanks for sharing the detailed error and your findings.

    We’ve identified the issue with the Order Numbering module, where gmdate() receives a non-integer value under PHP 8.3. Your workaround is valid and confirms the root cause.

    We will include an official fix for this in an upcoming update so it’s handled properly without requiring manual changes.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.