1

With WooCommerce and WooCommerce PDF Invoices & Packing Slips plugins, I have an issue. When PDF Invoices are generated, they shows the TAX two times:
Previous

I need to remove this duplication to make it looks like this:

After

I Know there are a few Premium Plugins with a mass of functions but I can not buy Premium Plugins anymore, as invested too much in other Plugins.

So I will need to make that little change. I can't find any solution for this.

Can anyone help me with that?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Marek
  • 41
  • 1
  • 7

2 Answers2

5

@update — Working and fully functional

Yes, you can edit the default templates to fit your needs, without buying the premium one, but you need inside your active child theme or theme (if it doesn't exist yet):

  1. To create a folder named woocommerce
  2. Copy folder from plugins > woocommerce-pdf-invoices-packing-slips > templates > pdf to this newly fresh created woocommerce folder.
  3. Inside this pdf folder, rename simple subfolder with something like custom1 (or whatever you want).
  4. Activate your custom1 pdf template, going in admin backend at:
    WooCommerce > PDF Invoices > Template (tab), select custom1* in and **save.

Now in your active theme > woocommerce > pdf > custom1 you can customize the templates files included to feet your needs.


Get reed of the double tax display: the problem is in the foreach loop.

1. Retrieving the slug (key name) for VAT duplicate value:
As you say, adding something inside this loop make it reproduce in each displayed element.
Here we are going to display the key names or slugs just after the corresponding values:

<?php foreach( $wpo_wcpdf->get_woocommerce_totals() as $key => $total ) : ?>
    <tr class="<?php echo $key; ?>">
        <td class="no-borders"></td>
        <!-- we display the index value in here, below. -->
        <th class="description"><?php echo $total['label'] . " (The key is '" . $key . "') " ;?></th> 
        <td class="price"><span class="totals-price"><?php echo $total['value']; ?></span></td>
    </tr>
<?php endforeach; ?>

Now if you generate the pdf invoice you will get at each line a different $key name or slug (just after the corresponding values).

2. Adding a conditional in the loop to avoid displayed repetition:

Now that you know the key name of the duplicated element you can act on the loop with an if() statement inside it. You will have to replace 'the_key_name' by the real key name of the duplicated item:

<?php foreach( $wpo_wcpdf->get_woocommerce_totals() as $key => $total ) :
    // As long as $key is NOT 'the_key_name' the item line is displayed
    if ($key != 'the_key_name'){ ?>
        <tr class="<?php echo $key; ?>">
            <td class="no-borders"></td>
            <th class="description"><?php echo $total['label']</th> 
            <td class="price"><span class="totals-price"><?php echo $total['value']; ?></span></td>
        </tr>
    <?php }
endforeach; ?>

Now if you generate the pdf invoice, the duplicated item has disappeared completely from it.

Et voilà… Bon appétit :)

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • Thanks but that are the Steps i made before. Need the next steps. because changing the Template wont fix the Problem, when i remove or add something to that part i want to change, it will change the whole block, so when i add a char "1" to the first line, it appears to the whole block, in every of the 4 lines there will appear an "1" then. in need to switch the positions of the 4 lines but doesnt matter what i do i takes changes for all lines – Marek Apr 18 '16 at 07:35
  • Hey, @LoicTheAstec sorry to bump, but I can't make this plugin display VAT on the invoice, is that possible ? thanks – Louis Jun 07 '17 at 11:43
0

If you are looking for a free alternative, the plugin WooCommerce PDF Invoices and Packing Slips might help. The plugin does allow you to add tax in your invoice and you can check if this helps for your specific situation.

Safwana
  • 86
  • 3