Support » Plugin: Booster for WooCommerce » PDF Customizing

  • Resolved jackofallspades

    (@jackofallspades)


    Hello – I am trying to figure out how to improve my PDF invoices. I use Woocommerce Bundles & Composites and I would like the items within the bundle to indent. Is there a way to do this?

    Also, I don’t want all items within bundles to show – is there a way to do this? Some of my hidden products I want listed and some I don’t. So I am hoping i can pick and choose which products are shown on the invoice.

    Thank you in advance!

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support RokasJ

    (@rokasjan)

    Hi,

    There aren’t any preset options for these, however https://booster.io/shortcodes/wcj_order_items_table/ page shows an example how to modify content for bundle products using custom PHP code. If you are familiar with it, you could modify it to indent the products and whatnot, and use Booster’s “Custom PHP” module to run the code.

    Thank you –
    Are you saying there is not a way to ignore certain IDs or skus, or even to hide all hidden products or all zero priced products?

    And I just found this:
    exclude_by_categories
    (optional) Exclude some items from the table by product category. Can be comma separated list.

    This could work! I could exclude the products in a category – please excuse my ignorance, but how could I work this in to my table?

    I added the following snippet, and it made the font smaller but I was hoping to indent everything in the bundle instead. What do I need to change in the following PHP snippet to make things indent?

    Really appreciate your time!

    Carrie

    if ( ! function_exists( ‘alg_modify_bundle_products_in_pdf_invoice’ ) ) {
    /*
    * alg_modify_bundle_products_in_pdf_invoice.
    */
    function alg_modify_bundle_products_in_pdf_invoice( $cell_data, $args ) {
    $item_total_tax_incl = $args[‘order’]->get_item_total( $args[‘item’], true, true );
    if ( 0 == $item_total_tax_incl ) {
    $cell_data = ‘<span style=”font-size:small;”>’ . $cell_data . ‘</span>’;
    switch ( $args[‘column’] ) {
    case ‘item_number’:
    return ”;
    case ‘item_name’:
    return ‘-‘ . $cell_data;
    }
    }
    return $cell_data;
    }
    add_filter( ‘wcj_pdf_invoicing_cell_data’, ‘alg_modify_bundle_products_in_pdf_invoice’, PHP_INT_MAX, 2 );
    }

    Plugin Support RokasJ

    (@rokasjan)

    Hi,

    You could use exclude_by_categories or exclude_by_tags arguments for the order items table (shown in the same page) to hide bundle products if you decide to add them all to one category or tag.

    The code above modifies the cell_data so that it would be surrounded by <span style=”font-size:small;”> and </span> (on line 8). You could instead change it so that it would add leading spaces or tab symbol so that it would be indented (there is no option to actually change the indentation of the lines of the table; the table would get crooked).
    $cell_data = ‘ ’ . $cell_data;
    I would not recommend copying this directly as these forums replace quotation marks and other symbols and this would not work.

    Hi there,

    Appreciate your patience with me, but I apologize that I do not follow. I know you said not to copy it directly, so then how do I know what to replace this line with?

    $cell_data = ‘<span style=”font-size:small;”>’ . $cell_data . ‘</span>’;

    I did try and use what you put above, but of course that did not work:

    $cell_data = ‘ ’ . $cell_data;

    ————————–

    And where do I put the exclude_by_categories? Let’s assume the category is called “shirts” that I want to exclude. Where do I put that within the template? Here is what my template table looks like:

    [wcj_order_items_table table_class=”pdf_invoice_items_table”
    columns=”item_number|item_name|item_quantity|line_total_tax_excl”
    columns_titles=”|Product|Qty|Total”
    columns_styles=”width:5%;|width:75%;|width:5%;|width:15%;text-align:right;”
    discount_as_item=”Discount”]

    Thanks again for your help 🙂

    Carrie

    Plugin Support RokasJ

    (@rokasjan)

    Hi Carrie,

    The forums replaced my 4 spaces (which is equivalent to 1 tab) in the line I’ve suggested. You should try adding more spaces. To write PHP code you would need some programming knowledge, that’s why I suggested doing that if you are familiar with PHP.

    In the website linked in the first reply, this is written for ‘exclude_by_categories’: “Exclude some items from the table by product category. Can be comma separated list.”. There are examples how to use arguments like this (not exactly this one) on the bottom of the page (that’s where you can directly copy it off, these forums here change the content of the message).

    So your table would look something like this:
    [wcj_order_items_table
    table_class=”pdf_invoice_items_table”
    exclude_by_categories=”bundled”
    columns=”item_number|item_name|item_quantity|line_total_tax_excl”
    columns_titles=”|Product|Qty|Total”
    columns_styles=”width:5%;|width:75%;|width:5%;|width:15%;text-align:right;”
    discount_as_item=”Discount”]
    where bundled (hidden) products are added to category called ‘bundled’.

    Beautiful!!! The exclude category thing worked, thank goodness!! That is going to clean up my invoices so much, so thank you!!!

    The first one.. I am not following. I really wish I understood what you meant. I am somewhat familiar with php as I built my whole site with no hired help, but I just cannot seem to grasp what I am supposed to write in this snippet, in order to indent. If you are able to, could you email me directly what the line should look like, because you said that this support page modifies it? Or you can screenshot it and send it to me somehow? I really want to understand!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PDF Customizing’ is closed to new replies.