• [01-Apr-2026 09:11:34 UTC] PHP 16. WooCommerce_Italian_add_on_plus->piva_checkout_field_process(”) /home//public_html/wp-includes/class-wp-hook.php:341 [01-Apr-2026 09:11:34 UTC] PHP 15. WP_Hook->apply_filters($value = ”, $args = [0 => ”]) /home//public_html/wp-includes/class-wp-hook.php:365
    [01-Apr-2026 09:11:34 UTC] PHP 14. WP_Hook->do_action($args = [0 => ”]) /home//public_html/wp-includes/plugin.php:522 [01-Apr-2026 09:11:34 UTC] PHP 13. do_action($hook_name = ‘woocommerce_checkout_process’) /home//public_html/wp-content/plugins/woocommerce/includes/class-wc-checkout.php:1303
    [01-Apr-2026 09:11:34 UTC] PHP 12. WC_Checkout->process_checkout() /home//public_html/wp-content/plugins/woocommerce/includes/class-wc-ajax.php:596 [01-Apr-2026 09:11:34 UTC] PHP 11. WC_AJAX::checkout(”) /home//public_html/wp-includes/class-wp-hook.php:341
    [01-Apr-2026 09:11:34 UTC] PHP 10. WP_Hook->apply_filters($value = ”, $args = [0 => ”]) /home//public_html/wp-includes/class-wp-hook.php:365 [01-Apr-2026 09:11:34 UTC] PHP 9. WP_Hook->do_action($args = [0 => ”]) /home//public_html/wp-includes/plugin.php:522
    [01-Apr-2026 09:11:34 UTC] PHP 8. do_action($hook_name = ‘wc_ajax_checkout’) /home//public_html/wp-content/plugins/woocommerce/includes/class-wc-ajax.php:127 [01-Apr-2026 09:11:34 UTC] PHP 7. WC_AJAX::do_wc_ajax(”) /home//public_html/wp-includes/class-wp-hook.php:341
    [01-Apr-2026 09:11:34 UTC] PHP 6. WP_Hook->apply_filters($value = ”, $args = [0 => ”]) /home//public_html/wp-includes/class-wp-hook.php:365 [01-Apr-2026 09:11:34 UTC] PHP 5. WP_Hook->do_action($args = [0 => ”]) /home//public_html/wp-includes/plugin.php:522
    [01-Apr-2026 09:11:34 UTC] PHP 4. do_action($hook_name = ‘template_redirect’) /home//public_html/wp-includes/template-loader.php:23 [01-Apr-2026 09:11:34 UTC] PHP 3. require_once() /home//public_html/wp-blog-header.php:19
    [01-Apr-2026 09:11:34 UTC] PHP 2. require() /home//public_html/index.php:17 [01-Apr-2026 09:11:34 UTC] PHP 1. {main}() /home//public_html/index.php:0
    [01-Apr-2026 09:11:34 UTC] PHP Stack trace:
    [01-Apr-2026 09:11:34 UTC] PHP Warning: Undefined array key “base_country” in /home/*/public_html/wp-content/plugins/woocommerce-italian-add-on/woocommerce-italian-add-on.php on line 856

Viewing 1 replies (of 1 total)
  • Thread Starter appteam

    (@appteam)

    Correzioni applicate a “WooCommerce Italian Add-on Plus” (per passaggio allo sviluppatore)

    Obiettivo

    • Eliminare il fatal in export XML: “Cannot access offset of type string on string” (accesso a $document_data[“fn”])
    • Eliminare warning in checkout: “Undefined array key “base_country”” (in realtà manca billing/shipping country in $_POST)

    1) Fix fatal export XML (document_data coerente)
    File:

    • wp-content/plugins/woocommerce-italian-add-on/includes/class-wc-settings-export.php

    1A. Validazione meta _wcpdf_IT_document_data
    Motivo:

    • $order->get_meta(‘_wcpdf_IT_document_data’, true) può ritornare una stringa/bool; il codice lo trattava come array.

    Modifica (nel ramo “else”, vicino alla lettura del meta):
    PRIMA:
    $document_data = $order->get_meta( ‘_wcpdf_IT_document_data’, true );
    if ( $document_data ) {
    $number_formatted = $document_data[“number_formatted”];
    $number = $document_data[“number”];
    $date = $document_data[“date”];

    }

    DOPO:
    $document_data = $order->get_meta( ‘_wcpdf_IT_document_data’, true );
    if ( is_array( $document_data ) && $document_data ) {
    $number_formatted = empty( $document_data[“number_formatted”] ) ? “” : $document_data[“number_formatted”];
    $number = empty( $document_data[“number”] ) ? “” : $document_data[“number”];
    $date = empty( $document_data[“date”] ) ? “” : $document_data[“date”];

    }

    1B. get_document_data() restituisce sempre un array
    Motivo:

    • get_document_data() ritornava “” quando non trovava dati; crea_xml() poi faceva $document_data[“fn”] causando fatal.

    Modifica (a fine get_document_data()):
    PRIMA:
    $res = “”;
    if ( $number_formatted ) {
    $date_formatted = empty( $date ) ? “” : date( “Y-m-d”, strtotime( $date ) );
    $res = array( “num” => $number_formatted, “data” => $date_formatted, “fn” => $fname, “type” => $document_type );
    }
    return $res;

    DOPO:
    $res = array( “num” => “”, “data” => “”, “fn” => $fname, “type” => $document_type );
    if ( $number_formatted ) {
    $date_formatted = empty( $date ) ? “” : date( “Y-m-d”, strtotime( $date ) );
    $res[“num”] = $number_formatted;
    $res[“data”] = $date_formatted;
    }
    return $res;

    Impatto:

    • crea_xml() può sempre fare $document_data[“fn”] senza rischiare accesso a offset su stringa.

    2) Fix warning “base_country” in checkout (fallback country in $_POST)
    File:

    • wp-content/plugins/woocommerce-italian-add-on/woocommerce-italian-add-on.php

    Punto:

    • Funzione piva_checkout_field_process()

    Motivo:

    • $_POST[$tax_based_on_country] (billing_country o shipping_country) può non arrivare in alcuni flussi; il codice lo usa senza check.

    Modifica (subito dopo la definizione di $tax_based_on_country):
    AGGIUNTA:
    $tax_based_on_country = $tax_based_on . “_country”;
    if ( empty( $_POST[ $tax_based_on_country ] ) ) {
    $_POST[ $tax_based_on_country ] = $this->default_country;
    }

    Impatto:

    • Evita accessi a chiavi inesistenti in $_POST e quindi elimina i warning relativi.
    • This reply was modified 2 months, 1 week ago by appteam.
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.