Some time ago a customer asked us for a piece of custom code in order to be able to invoice in the name of two companies simultaneously in the same WooCommerce.

In his particular case he provides services exclusively and, depending on the type of service purchased, he needed the invoice to be issued in the name of one company or the other. To issue the invoices he uses the free version of the fantastic plugin for WooCommerce PDF Invoices & Packing Slips for WooCommerce.

But is it possible to do it?

If the installation were of the multi-shop (marketplace) type and used some specific plugin such as WCFM Marketplace – Best Multivendor Marketplace for WooCommerce, Dokan – Best WooCommerce Multivendor Marketplace Solution – Build Your Own Amazon, eBay, Etsy or WC Vendors – WooCommerce Multivendor, WooCommerce Marketplace, Product Vendors, Commissions, Multi Seller, to mention only a few of the many plugins that populate the WordPress ecosystem, it would be as simple as creating two or more vendors and associating each product with them, and the plugin in question would already take care of telling the invoicing plugin the corresponding data of each vendor, but this was not the case.

But yes, it is possible to invoice in a single WooCommerce in the name of two or more different companies, as long as products from different companies are not mixed in the purchase, for example by limiting the purchase to a single product or by limiting the purchase to a single category, which is what we did in this particular case.

For this you have to organise the products correctly by categories, in this case two, one for each company, and add some custom code to work the miracle.

Let us get to work

As we have already indicated, the first thing is to organise the whole catalogue into a couple of categories, if you are going to invoice in the name of two different companies; if you need more you will have to create as many categories as companies you are going to need.

Once your catalogue is organised you have to add some custom code. Let us start with the simple part, limiting the purchase to a single category.

For this we are going to use the functions.php file of the child theme, or you can create a small custom plugin to carry out these tasks. In either case we are going to use PHP code similar to this:

Copy to clipboard

With this function we have already limited the purchase to a single category at a time, so we already have the first step solved. Now it remains for us to tell PDF Invoices & Packing Slips for WooCommerce the name and the billing address according to the category that has been added to the order.

For this we are again going to use the functions.php file of the child theme or the small custom plugin that you have created, and you are going to use PHP code similar to this:

Copy to clipboard

With these two functions you can specify as many company names and addresses different from the one configured in the options of PDF Invoices & Packing Slips for WooCommerce as you need. As you can see, in the event that the product category added to the cart is called Categoría X, the name and the address set by default in the plugin options will be changed for the name and the address indicated in the code.

Just as it has been done for a single additional company, you can add as many as you need, there is no limit, although in that case the use of the PHP switch function might be more useful to you.

As always we hope you find this tutorial useful and that you can apply it to your specific needs, and we look forward to your comments.

Related posts

Comments

Suscríbete
Notificar de
2 Comments
Más antiguos
Más recientes Más votados
Alejandro Lamas
13 de marzo de 2024 15:30

Hola, cómo gestionarías con ese método el número de facturas? ya que según el plugin, el número es correlativo a la factura anterior, pero con ese método, no se seguirían números de factura correlativos para cada empresa.
Es decir, si tengo el número de factura 1 para la empresa X, pero el siguiente pedido es de la empresa Y, su factura sería la 2, no la 1 de la empresa Y
Gracias!

In this post

Products and services

Latest posts

Latest comments

Subscribe!

Lista de correos de APG

DATA PROTECTION: In accordance with data protection regulations, we provide you with the following processing information: (+)

  • Responsible: Art Project Group.
  • Treatment purposes: to respond to queries or any type of request made by the user through any of the forms of contact that are made available on the website. Sending communications about products or services (with your consent).
  • Your rights: access, rectification, portability, deletion, limitation and opposition. More information about the treatment in the Privacy Policy.

What we post on !

Se ha publicado #WooCommerce 11.2.2: actualización de seguridad que refuerza las API REST y Store, mejora la validación de CSV y corrige problemas en pagos y pedidos. Incluye cambios en la base de datos.

¡Actualiza cuanto antes!

November 5, 2026