Viewing 13 replies - 16 through 28 (of 28 total)
  • How can month be added in above snippet? for example order for January 2013, your snippet will print:

    ABC2013100xx

    How to make it display along with month before year:

    ABC012013100xx

    How can we display all four namely order number, order date, invoice number and invoice date.
    Any snippet for “Simple” templete?

    Plugin Contributor Ewout

    (@pomegranate)

    you can get the order month with the following code:

    $order_month = date_i18n( 'n', strtotime( $order_date ) );

    Or the complete year+month directly:

    $order_yearmonth = date_i18n( 'Yn', strtotime( $order_date ) );

    The example in the FAQ is more up to date that the above and includes padding and your xx suffix too:

    add_filter( 'wpo_wcpdf_invoice_number', 'wpo_wcpdf_invoice_number', 10, 4 );
    function wpo_wcpdf_invoice_number( $invoice_number, $order_number, $order_id, $order_date ) {
        $prefix = 'ABC';
        $order_year = date_i18n( 'Y', strtotime( $order_date ) );
        $order_month = date_i18n( 'n', strtotime( $order_date ) );
        $padding = 6; // number of digits - so 42 becomes 000042
        $suffix = 'xx';
        $invoice_number = $prefix . $order_year . $order_month . sprintf('%0'.$padding.'d', $invoice_number) . $suffix ;
        return $invoice_number;
    }

    $order_month = date_i18n( 'n', strtotime( $order_date ) );
    or
    $order_yearmonth = date_i18n( 'Yn', strtotime( $order_date ) );

    both are not displaying month in my case.

    Plugin Contributor Ewout

    (@pomegranate)

    Have you tried the full filter as given? You will need to include these strings in the filename too ??

    hmm, I got it but it may become difficult to fins the invoice because February is printed as 2 and not 02
    When using offset may lead to confusion for November and December might look like January.

    Plugin Contributor Ewout

    (@pomegranate)

    Ah yes, but you gave 20131 as an example :o)
    you need ‘m’ instead of ‘n’ if you want a leading zero.
    more info: PHP date

    Ah my bad. Thank you again.

    sorry to ask again, but I’m not sure I understand.

    My invoice says:

    Order Date:
    Invoice Number:
    Payment Method:

    I would like to add “Order number” in the invoice as well so it looks like:

    Order Date:
    Invoice Number:
    Order number:
    Payment Method:

    Would have been nice to have that as an option in the settings so you have to tick what fields you want to include in the invoice.

    So, it seems like I need to add “<?php $wpo_wcpdf->order_number(); ?>”, but I’m not sure where….

    Would it be in any of the “Extra template fields”. If so, would that make it appear below “Invoice number?”

    Thanks for your help Ewout! ??

    Plugin Contributor Ewout

    (@pomegranate)

    Hi Nano,
    To make these kind of changes, you need to edit the template files (invoice.php).
    Make a copy of the Simple template (see FAQ for instructions), then open up invoice.php in the new location

    over there you can insert the following after line 55 (the line that starts with <span class="order-number">):

    <span class="order-number-label"><?php _e( 'Order Number:', 'wpo_wcpdf' ); ?></span>
    <span class="order-number"><?php $wpo_wcpdf->order_number(); ?></span><br />

    Unfortunately it’s not possible right now to change this is the settings, but I will consider adding this to a future version.

    Have a great day!
    Ewout

    Thank you Ewout! Now I get it. I was able to do it following your instructions. ??

    I consider it useful to display the order date aswel as the invoice date.

    Is it possible to do the same thing as you did with the order number and invoice number Ewout?

    Plugin Contributor Ewout

    (@pomegranate)

    Hi RJWJ,
    You can find the answer to your question a few posts up:

    <?php $wpo_wcpdf->invoice_number(); ?>
    <?php $wpo_wcpdf->invoice_date(); ?>
    <?php $wpo_wcpdf->order_number(); ?>
    <?php $wpo_wcpdf->order_date(); ?>
Viewing 13 replies - 16 through 28 (of 28 total)
  • The topic ‘invoice number vs invoice order’ is closed to new replies.