Title: Custom shortcode in prefix
Last modified: February 17, 2021

---

# Custom shortcode in prefix

 *  Resolved [josede](https://wordpress.org/support/users/josede/)
 * (@josede)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/custom-shortcode-in-prefix/)
 * Hi, its possible put a shortcode in prefix field based on the EU/ES customer.
   Example:
    Shortcodes [invoice_es] = ES (If the customer is from Spain) [invoice_eu]
   = EU (If the customer is not from Spain and he is from Europe)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Contributor [Yordan Soares](https://wordpress.org/support/users/yordansoares/)
 * (@yordansoares)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/custom-shortcode-in-prefix/#post-14065931)
 * Hola, [@josede](https://wordpress.org/support/users/josede/):
 * El siguiente fragmento de código debería solucionar lo que estás necesitando:
 *     ```
       add_filter('wpo_wcpdf_document_number_settings','wpo_wcpdf_document_number_variable_prefix',10,2);
       function wpo_wcpdf_document_number_variable_prefix( $number_settings, $document ) {
         if (!empty($document->order) && $document->get_type() == 'invoice') {
           $billing_country = $document->order->get_billing_country();
           $eu_countries = WC()->countries->get_european_union_countries('eu_vat');
           $is_eu_country = in_array($billing_country, $eu_countries);
           if ($billing_country == 'ES') { // Customer from Spain
             $number_settings['prefix'] = "ES/";
           } elseif($is_eu_country) { // Customer from another EU country
             $number_settings['prefix'] = "EU/";
           }
         }
         return $number_settings;
       }
       ```
   
 * Asegúrate de haber configurado solo países de la Unión Europea en tus **Ubicación(
   es) de venta** (**WooCommerce > Generales**), ya que si un usuario fuera de la
   región compra en tu tienda, la factura no tendrá prefijo, tal como se muestra
   en la siguiente imagen:
 * ![Muestra una lista con tres pedidos de WooCommerce en la pantalla de lista de
   pedidos](https://i0.wp.com/i.imgur.com/Gp7w0SH.png?ssl=1)
 * De abajo hacia arriba, el primer comprador es de España, el segundo de los Países
   Bajos y el tercero de Venezuela.
 * ¡Déjame saber si funciona!
 *  Thread Starter [josede](https://wordpress.org/support/users/josede/)
 * (@josede)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/custom-shortcode-in-prefix/#post-14067166)
 * Thx so much for this. Thx.
    Three questions:
 * – If VAT its empty, Will we have an issue? I ask for this “get_european_union_countries(‘
   eu_vat’)”.
 * – With another ‘else’, Can I target non eu and non es countries, truth? (with
   a prefix like ‘world’.
 * – Whats the code to target a city inside Spain, example: Canary Island ‘TF'(woocommerce
   code). To add a prefix just to ‘TF'(woocommerce code), Its a city inside Spain.
 * Thx!
    -  This reply was modified 5 years, 3 months ago by [josede](https://wordpress.org/support/users/josede/).
    -  This reply was modified 5 years, 3 months ago by [josede](https://wordpress.org/support/users/josede/).
 *  Plugin Contributor [Yordan Soares](https://wordpress.org/support/users/yordansoares/)
 * (@yordansoares)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/custom-shortcode-in-prefix/#post-14070648)
 * Hello [@josede](https://wordpress.org/support/users/josede/),
 * > If VAT its empty, Will we have an issue? I ask for this “get_european_union_countries(‘
   > eu_vat’)”.
 * This method is used to get the countries that are part of the EU VAT zone, doesn’t
   affect whether or not you complete any VAT field you have in your site.
 * > With another ‘else’, Can I target non eu and non es countries, truth? (with
   > a prefix like ‘world’.
 * Sure, you can do it 😉
 * > Whats the code to target a city inside Spain, example: Canary Island ‘TF'(woocommerce
   > code). To add a prefix just to ‘TF'(woocommerce code), Its a city inside Spain.
 * That would be possible, but I’m afraid, that’s beyond the scope of this forum
   support, but I’m confident that you will manage to do it following the same logic
   of the other conditions.
 *  Thread Starter [josede](https://wordpress.org/support/users/josede/)
 * (@josede)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/custom-shortcode-in-prefix/#post-14282373)
 * Hi yordan. Its possible Reset the number when Its from EU.
    Its possible have
   multiple lines of invoice numbers. I dont know if its possible with premium or
   something like this or just by code. Thx
 * Europe:
    - EU/0001
    - EU/0002
    - EU/0003
    - EU/0004
    - Spain:
    - ES/0001
    - ES/0002
    - ES/0003
    - ES/0004
    - If the checkout has a specific product:
    - PRO/0001
    - PRO/0002
    - PRO/0003
    - PRO/0004
 *  Plugin Contributor [Yordan Soares](https://wordpress.org/support/users/yordansoares/)
 * (@yordansoares)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/custom-shortcode-in-prefix/#post-14282446)
 * Hello [@josede](https://wordpress.org/support/users/josede/),
 * Every document only have 1 numbering system by default.
 * However, this certainly can be done, although it would be a custom job. My colleague
   Michael does this type of work and if he has room in his agenda he could estimate
   this job for you.
 * If you are interested, please write to [support@wpovernight.com](https://wordpress.org/support/topic/custom-shortcode-in-prefix/support@wpovernight.com?output_format=md)
 *  Thread Starter [josede](https://wordpress.org/support/users/josede/)
 * (@josede)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/custom-shortcode-in-prefix/#post-14282475)
 * MMM every document have have 1 numbering system by default. Yes its correct.
   
   I want 1 numbering system. But depending If the invoice is for EU or ES or it
   has a speficic product, I want other invoice number. Not the default number. 
   But this new number should have his custom order from 0.
    -  This reply was modified 5 years, 2 months ago by [josede](https://wordpress.org/support/users/josede/).
 *  Plugin Contributor [Yordan Soares](https://wordpress.org/support/users/yordansoares/)
 * (@yordansoares)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/custom-shortcode-in-prefix/#post-14282506)
 * Based on [this message](https://wordpress.org/support/topic/custom-shortcode-in-prefix/#post-14282373),
   it seems to me that you actually need three separate sequences (in three different
   number systems)
 * As I mentioned before, this requires custom work, since our documents only handle
   a unique sequence by default.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Custom shortcode in prefix’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-pdf-invoices-packing-slips/assets/icon-256x256.
   png?rev=2189942)
 * [PDF Invoices & Packing Slips for WooCommerce](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Yordan Soares](https://wordpress.org/support/users/yordansoares/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/custom-shortcode-in-prefix/#post-14282506)
 * Status: resolved