=== CatCode Org Number Lookup for WooCommerce ===
Contributors: catcodestudio
Tags: organisationsnummer, bolagsverket, brreg, b2b, checkout
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Company buyers from Sweden and Norway enter their organisation number at checkout. The number is checked and the company name and address are filled in.

== Description ==

You sell to companies in Sweden or Norway. Your invoices need the buyer's organisation number, and a mistyped number or company name means a credit note later. This plugin adds an organisation number field to checkout, checks it and fills in the rest from the official register.

Bolagsverket and the Brønnøysund Register Centre are third parties. This is an independent integration, not affiliated with or endorsed by them.

= What it does =

* **One field, on both checkouts.** Works on the block checkout and on the classic shortcode checkout, and only appears when the billing country is Sweden or Norway.
* **Check digit first.** A mistyped number is refused before anything is asked of a register. 556036-0793, 5560360793 and SE556036079301 are all understood, as are 923 609 016 and NO923609016MVA.
* **Company name and address filled in.** Sweden from Bolagsverket, Norway from the Central Coordinating Register for Legal Entities. An address the buyer has already typed stays unless you choose otherwise.
* **The state of the company.** The buyer sees it at once if the register has the company as bankrupt, in liquidation or deregistered. The order screen shows it too, along with the name in the register and whether the buyer wrote a different one.
* **Required or optional.** Optional, required when a company name is filled in, or always required.
* **On the order.** The number appears on the order, in the e-mails and in the customer's order details.

= Built not to lose a sale =

* If a register does not answer, the order still goes through and the order screen says it was not checked.
* Answers are kept for a week, so a repeat customer costs no call, and each visitor can only cause a limited number of calls.

= Privacy =

A Swedish sole trader's number is a personal identity number. Such a number is checked by format only and never sent to a register, so that the checkout cannot be used to find a person's address. The Activity tab keeps only masked numbers. WooCommerce's privacy tools export and erase the number on an order.

// @pro-begin
= Pro =

Sold on [catcode.com.ua](https://catcode.com.ua/modules/org-number-lookup-woocommerce/) with a 7-day trial:

* **Search by name in Norway.** Suggestions while the buyer types the company name in the field. Sweden has no search by name, because the Bolagsverket API only answers for a complete number.
* **Refuse orders** from companies that are deregistered, bankrupt or in liquidation, or whose number is not in the register.
* **Payment methods for companies only.** Payment on invoice, for example, only for a company found in the register.
* **VAT number on the order.** SE + number + 01 for Sweden, as a form and without proof of VAT registration; number + MVA for Norway, only if the register says the company is in the VAT register. Can be copied to the order meta key of your invoice or VAT plugin.
* **Details on the order screen.** Legal form, business, VAT status and a button to check again.
* **E-mail alert** when an order comes in from a company not in good standing.

// @pro-end
== Installation ==

1. Install and activate the plugin. WooCommerce must be active.
2. Open **WooCommerce > Org Number Lookup**. Norway works right away, no key needed.
3. For Sweden, send Bolagsverket the customer registration form for the high-value datasets API (free of charge, no contract). You receive a client ID and client secret by e-mail, with the password by SMS.
4. Paste them into the settings and press **Test the keys**.

== Frequently Asked Questions ==

= Does this need a CatCode account? =

No. The plugin talks to the registers directly.

= What happens with Swedish numbers before I add the keys? =

The check digit is still verified, but nothing is filled in. The field works, the lookup does not.

= Can it search Swedish companies by name? =

No. The Bolagsverket API answers only for a complete number and has no search by name.

= Does a company the register does not know get refused? =

No. The buyer sees a message and can fill in the details by hand, because a new company can take time to appear. The order screen shows the result.

= Which address is filled in? =

Sweden: the postal address the register has. Norway: the business address, or the postal address if there is none. A postal address can be a PO box, so the buyer should check it if goods are to be delivered there.

= Does it say that a company is registered for VAT? =

Norway's register says so and the plugin uses it. Sweden's open data does not.

== External services ==

This plugin connects to two official company registers, because checking the number is its purpose. Each call is made from your server. The buyer's browser only talks to your site.

**Bolagsverket, Sweden** (gw.api.bolagsverket.se and portal.api.bolagsverket.se, or their accept2 test hosts). Used only for buyers with a Swedish billing country and only after you enter your own keys. Sent: your client ID and secret to get a token, and the organisation number the buyer entered. A number with the form of a personal identity number is never sent. [Bolagsverket](https://bolagsverket.se/), [privacy](https://bolagsverket.se/omoss/varverksamhet/sabehandlarvidinapersonuppgifter.2083.html).

**Brønnøysund Register Centre, Norway** (data.brreg.no). Used only for buyers with a Norwegian billing country. Sent: the organisation number the buyer entered. No key and no account. The data is published as open government data (NLOD). [Brønnøysund Register Centre](https://www.brreg.no/en/), [privacy](https://www.brreg.no/en/privacy-statement/).

// @pro-begin
The name search of the Pro version also sends the letters the buyer typed to data.brreg.no.

// @pro-end
== Changelog ==

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 1.0.0 =
First release.
