=== Umbrella Web B2B Pricing for WooCommerce ===
Contributors: blairwebproject
Tags: wholesale, b2b, woocommerce, quantity discounts, wholesale pricing
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 0.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Wholesale pricing, quantity tiers and order minimums for WooCommerce, with an application form that creates accounts only after you approve.

== Description ==

Umbrella Web B2B Pricing adds a Wholesale Customer role to WooCommerce and gives those customers their own prices. Visitors apply through a form; nothing is created until you approve the application.

= Features =

* Wholesale Customer role
* Default wholesale discount (%) and fixed wholesale price per simple product or per variation
* Quantity discount tiers per product or per variation ("10:5, 50:10"); tiers stack on top of the base price and are counted per cart line (per variation)
* Variable products: wholesale prices, price ranges, cart, mini-cart, block cart and checkout all use the variation's own regular price
* Minimum items / minimum subtotal for wholesale orders
* Hide prices and purchasing from logged-out visitors
* [uwbp_application_form] shortcode: applications are held for review (Users > Wholesale Applications) and no account is created until a shop manager or admin approves

= Wholesale applications =

* Visitors apply with the [uwbp_application_form] shortcode. The application is stored as a private record; no WordPress user is created and the applicant receives no email yet.
* The shop owner (Settings > B2B Pricing > notification email, or the site admin email) is emailed. Review under Users > Wholesale Applications as an administrator or shop manager.
* Approve creates the customer account (or adds the Wholesale Customer role to the applicant's existing account if they applied while logged in) and emails a link to set a password. Reject marks the application rejected and sends nothing.
* A second application from the same email while one is pending is ignored. An email that already belongs to an account is not attached to a record; the shop owner gets a "review manually" email instead.
* Each IP address may submit at most 5 applications per hour.

= Variable products =

* A variation's fixed wholesale price applies only to that variation. A fixed price is never inherited from the parent product, because variations can have different regular prices.
* Quantity tiers: a variation's own tiers are used if set, otherwise the tiers set on the variable product apply.
* Without a fixed price, the default wholesale discount is applied to the variation's regular price.
* Sale prices are not used for wholesale pricing; the wholesale price is always based on the regular price.


== Installation ==

1. Make sure WooCommerce is installed and active.
2. Upload the plugin folder to `/wp-content/plugins/`, or install it from the Plugins screen, and activate it.
3. Go to Settings > B2B Pricing to set the default discount, order minimums and the notification email.
4. Add the `[uwbp_application_form]` shortcode to a page so customers can apply.
5. Optionally set a wholesale price and quantity discounts on each product.

== Frequently Asked Questions ==

= Where do I review applications? =

Users > Wholesale Applications. Administrators and shop managers can approve or reject each one.

= Does an applicant get an account straight away? =

No. An account is created only when you click Approve. The applicant is then emailed a link to set a password.

= Can I give an existing customer wholesale access without an application? =

Yes. Give the user the Wholesale Customer role from the Users screen.

= Does it work with variable products? =

Yes. See the Variable products section above.

= What happens to my data if I delete the plugin? =

The plugin's settings are removed. Wholesale customer accounts, the Wholesale Customer role and the stored applications are kept.

== Privacy ==

When someone submits the application form the plugin stores their contact name, email address, company, tax or VAT ID and note as a private record in your site's database (Users > Wholesale Applications). It is visible only to administrators and shop managers, and it is emailed to the notification address you set. The visitor's IP address is not stored; it is used only to rate limit submissions, as a hashed temporary counter that expires after an hour. No data is sent to any third-party service. Applications are included in WordPress's Tools > Export Personal Data and are deleted by Tools > Erase Personal Data (matched by the email address on the application, including trashed ones), and suggested wording is added to Settings > Privacy > Policy Guide.

== Screenshots ==

1. The application form on the storefront ([uwbp_application_form] shortcode).
2. Users > Wholesale Applications: review pending applications and Approve or Reject them.
3. Settings > B2B Pricing: default discount, order minimums, hide prices from guests, notification email.
4. Wholesale price and quantity-discount fields on each product.
5. The Wholesale column on the Users screen shows who is approved.
6. The shop as a wholesale customer sees it, with wholesale prices.
7. Order minimums are enforced in the cart and at checkout.

== Changelog ==

= 0.2.0 =

* Applications no longer create a WordPress account on submit. They are held as private records under Users > Wholesale Applications, and the account is created only on approval.
* Approval email now contains a one-click set-password link, and WooCommerce's own "new account" email is not sent in addition.
* Applications are rate limited (5 per hour per IP address) and de-duplicated by email.
* Shop managers can review applications and save the B2B Pricing settings (saving previously returned a 403 for them).
* The application list shows the applicant's note, and its Approve link is visible (WordPress core CSS was hiding it).
* The application form is styled.
* The Wholesale column on the Users screen follows the Wholesale Customer role.
* Prices are hidden from guests in the Store API, block hydration and JSON-LD when "Hide prices from guests" is on.
* Works with WordPress's personal data export and erasure tools, and adds suggested privacy policy text.
* Declares compatibility with WooCommerce High-Performance Order Storage.
* Deleting the plugin removes its settings and counters (accounts, role and applications are kept).
* Added a Docker playground (see playground/README.md).

= 0.1.0 =

* Initial version.

== Upgrade Notice ==

= 0.2.0 =

Applications no longer create a user account when submitted. Applicants who applied under 0.1.0 already have an account and are not shown under Wholesale Applications.
