EAN and WPOvernight PDF Invoices

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #85071
    Tobias Bindemo
    Participant

    Hi,

    We use WPOvernight PDF Invoices for our packaging slips Premium. Currently the EAN is displayed below the product name.

    Instead we would like to place the EAN in a column next to the product name. How can we do that?

    In the PDF Invoices plugin we can create a new column, but I don’t understand what type of column i should select and what code i should enter 🙂

    #85072
    Tom Anbinder
    Moderator
    Plugin Support

    Hi Tobias,

    By “we can create a new column”, you mean you are customizing their template, correct? If that’s the case, try using this:

    <td class="ean"><?php
        if (
            ! empty( $item['item_id'] ) &&
            ( $item = new WC_Order_Item_Product( $item['item_id'] ) ) &&
            false !== ( $ean = alg_wc_ean()->core->get_ean_from_order_item( $item ) )
        ) {
            echo $ean;
        }
    ?></td>

    Please give it a try and let me know if that is working as expected.

    #85073
    Tobias Bindemo
    Participant

    Instead of hardcoding it into the PDF template, i would like to use the Customizer to achieve this.

    https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/using-the-customizer/

    Is it doable?

    #85074
    Tom Anbinder
    Moderator
    Plugin Support

    Customizer is a premium feature, correct? If that’s the case, could you please send it to me (via [email protected]), or share access to your site, so I could log in and check it out there?

    #85075
    Tobias Bindemo
    Participant

    Yes it is.

    Email sent!

    #85076
    Tom Anbinder
    Moderator
    Plugin Support

    If anyone else is interested, we’ve solved it by adding “Custom function” item column (in “WooCommerce > PDF Invoices > Customizer > Invoices”). There we’ve set “Function name” to my_alg_wc_ean_wpo_wcpdf. And finally, we’ve added this snippet to the site – it will display EAN and 1D barcode:

    if ( ! function_exists( 'my_alg_wc_ean_wpo_wcpdf' ) ) {
        function my_alg_wc_ean_wpo_wcpdf( $item ) {
            if (
                ! empty( $item['item_id'] ) &&
                ( $item = new WC_Order_Item_Product( $item['item_id'] ) ) &&
                false !== ( $ean = alg_wc_ean()->core->get_ean_from_order_item( $item ) )
            ) {
                $barcode = '<div class="ean_wrapper">' .
                    alg_wc_ean()->pro->barcode->get_barcode_img( $ean, array(
                        'dim'        => '1d',
                        'id'         => alg_wc_ean()->core->ean_key . '_barcode_img',
                        'class'      => 'ean-barcode',
                        'w'          => 1,
                        'h'          => 20,
                        'product_id' => alg_wc_ean()->core->get_order_item_product_id( $item ),
                    ) ) .
                '</div>';
                return $ean . $barcode;
            }
        }
    }
    
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.