• Resolved b3rgaxx

    (@b3rgaxx)


    Hello, I’ve to create a function where I’ve to input a custom field with the name (NumDdt and DateDdt), but this function doesn’t work:
    function modifica_fattura_elettronica($result_array, $order ) {
    $importo = (float)$order->get_total();
    $data = $order->get_date_created();
    $NumDdt = $order->custom_field(‘NumDdt’);
    $DateDdt = $order->custom_field(‘DateDdt’);

    $doc = new DOMDocument();
    $doc->preserveWhiteSpace = false;
    $doc->formatOutput = true;
    $doc->loadXML($result_array[“xml”]);
    $FatturaElettronicaBody = $doc->getElementsByTagName(“FatturaElettronicaBody”)->item(0);

    $DatiDDT = $doc->createElement(“DatiDDT”);
    $DatiTrasporto = $doc->createElement($NumDdt); //TP02 = pagamento completo
    $DatiDDT->appendChild($DatiTrasporto);

    $FatturaElettronicaBody->appendChild($DatiDDT);

    $xml = $doc->saveXML();
    $result_array[“xml”] = $xml;
    return $result_array;
    }
    add_action( ‘wcpdf_IT_after_creaFatturaElettronica’, ‘modifica_fattura_elettronica’, 20, 2 );

    Anyone can help me? thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @b3rgaxx!

    You mentioned getting a syntax error. Can you tell us more about this error and please provide us with the exact error message? Additionally, what exactly are you trying to achieve? Please share your details with us.

    Cheers!

    You can use this service to check for syntax errors:
    http://phpcodechecker.com/
    It finds none and I can’t either.

    Please note that add_action() always returns ‘true’. See:
    https://developer.ww.wp.xz.cn/reference/functions/add_action/

    add_filter() will return a value, but I don’t know if ‘wcpdf_IT_after_creaFatturaElettronica’ is an action or a filter. You should search for it in the plugin code.

    Just try add_filter() instead of add_action() and see if it works.

    Plugin Support Stuart Duff – a11n

    (@stuartduff)

    Automattic Happiness Engineer

    Hey @b3rgaxx,

    Searching Google for the action of wcpdf_IT_after_creaFatturaElettronica it seems the custom code which you’re writing which uses that action is related to this plugin below.

    https://ldav.it/shop/plugin/woocommerce-italian-add-on/

    I’d suggest reaching out to the developer of that plugin directly for assistance. This particular forum is only for queries relating to the default features and functionality of the free WooCommerce plugin.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Can You find the syntax error?’ is closed to new replies.