• Resolved josede

    (@josede)


    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

    (@yordansoares)

    Hola, @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

    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

    (@josede)

    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.
    • This reply was modified 5 years, 3 months ago by josede.
    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hello @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

    (@josede)

    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

    (@yordansoares)

    Hello @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 [email protected]

    Thread Starter josede

    (@josede)

    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.
    Plugin Contributor Yordan Soares

    (@yordansoares)

    Based on this message, 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.