• Resolved Sarispi

    (@sarispi)


    I am having problems with the pdfs of the invoices.

    I have an online store where customers can purchase unique items or sign up for a subscription.

    Until recently, in invoices for single orders, it always added the DNI field to the invoice pdf, but in those that were subscription orders, it added the DNI field in the first invoce order, but not in consecutive ones.
    Since October 31, no ID has been added to any invoice, not even the first order.

    In this first screenshot https://ibb.co/86jXWqx you see the invoice to a client and it has the ID, but in this second screenshot https://ibb.co/GFBvr5K, you see the next month invoice to the same client and without ID.

    Hope you can help.

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hi @sarispi

    Where is this DNI data being collected from? Is it coming from a third-party plugin or custom code?

    Thread Starter Sarispi

    (@sarispi)

    Hello Alex!
    Thank you very much for your response.
    I add the DNI field with the Checkout Manager that comes with kadence shop kit plugin https://ibb.co/HPHTMwV

    Plugin Contributor alexmigf

    (@alexmigf)

    Could you please try adding the code snippet below to your theme functions.php file or using a third-party plugin?

    add_filter( 'wpo_wcpdf_billing_address', function( $billing_address, $document ) {
    if ( 'invoice' === $document->get_type() && $document->order ) {
    $dni = $document->order->get_meta( '_dni', true );
    if ( ! empty( $dni ) ) {
    $billing_address .= "<br>DNI: " . $dni;
    }
    }
    return $billing_address;
    }, 10, 2 );

    From your screenshot, I’m guessing the meta key could be _dni.

    Let me know if that works.

    Thread Starter Sarispi

    (@sarispi)

    I have added the code but I don’t think it works.
    To check it, after adding it I went to PDF Invoice > general settings > and in the preview the DNI still does not appear.
    I also looked for an order in which there was a DNI, I accessed it and downloaded the invoice and the DNI still did not appear

    Plugin Contributor alexmigf

    (@alexmigf)

    Could you please install this plugin and let me know how the value is being stored in the order?

    Thread Starter Sarispi

    (@sarispi)

    I’ve installed the plugin, but I don’t know how to search how the value is being stored

    Plugin Contributor alexmigf

    (@alexmigf)

    Simply scroll down the order page and look for “dni” You should find it listed somewhere within a table.

    Thread Starter Sarispi

    (@sarispi)

    Ok!! Thanks!!

    this is how it is stored: meta_data[_billing_dni]

    Plugin Contributor alexmigf

    (@alexmigf)

    Update the meta key in the code snippet from _dni to _billing_dni and try it again.

    Thread Starter Sarispi

    (@sarispi)

    Now it appears on the invoices of the first orders!! Thanks a lot!!


    But I still have the problem with orders that are automatically generated when there is a subscription. The problem is that, in the first order, it saves the DNI number in the order and it place it correctly on the invoice https://ibb.co/f9ZQp3M, but in those that are generated as a suscription after the first one, it does not https://ibb.co/PGk79BN

    Thanks again

    Plugin Contributor alexmigf

    (@alexmigf)

    Which subscription plugin are you running?

    Thread Starter Sarispi

    (@sarispi)

    Yith suscriptions

    Plugin Contributor alexmigf

    (@alexmigf)

    Please give this updated snippet a try as a replacement for the previous one (note: untested).

    add_filter( 'wpo_wcpdf_billing_address', function( $billing_address, $document ) {
    if ( 'invoice' === $document->get_type() && $document->order ) {
    $order = $document->order;
    $is_a_renew = $order->get_meta( 'is_a_renew' );

    if ( wc_string_to_bool( $is_a_renew ) && function_exists( 'ywsbs_get_subscription' ) ) {
    $subscriptions = $order->get_meta( 'subscriptions' );
    $subscription = ( is_array( $subscriptions ) && ! empty( $subscriptions ) ) ? ywsbs_get_subscription( array_shift( $subscriptions ) ) : false;

    if ( $subscription && is_callable( array( $subscription, 'get_order' ) ) ) {
    $order = $subscription->get_order();
    }
    }

    $dni = $order->get_meta( '_billing_dni', true );

    if ( ! empty( $dni ) ) {
    $billing_address .= "<br>DNI: " . $dni;
    }
    }
    return $billing_address;
    }, 10, 2 );
    Thread Starter Sarispi

    (@sarispi)

    Hi again!

    I just replaced the old snippet with this new one but same thing happens. One the first order and invoice it puts the DNI but not on the suscription renovations

    Plugin Contributor alexmigf

    (@alexmigf)

    I’m unsure of the reason, so I’ll need to look into it further. Could you please reach out to us?

Viewing 15 replies - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.