=== B2BKit - Complete WooCommerce Wholesale, B2B, RFQ & Dynamic Pricing Suite ===
Contributors: dominopress, jrmark
Tags: woocommerce, b2b, wholesale, quotes, rfq
Requires at least: 5.0
Tested up to: 7.1
Stable tag: 1.1.3
Requires PHP: 7.2
License: GPL-2.0+
License URI: https://www.gnu.org/licenses/gpl-2.0.html

B2BKit is a complete Enterprise B2B Commerce Operating System for WooCommerce. Transform your store into a powerful B2B wholesale platform.

== Description ==

B2BKit by DominoPress is not just another simple wholesale pricing plugin. It is a **complete Enterprise B2B Commerce Operating System** built natively for WooCommerce. 

Whether you are building a wholesale store, distributor portal, manufacturer store, dealer/reseller portal, B2B + B2C hybrid store, corporate procurement portal, RFQ/quotation platform, or an enterprise customer portal, B2BKit provides the deeply integrated tools you need.

Designed with a modular, highly performant PHP architecture, B2BKit seamlessly overlays onto your existing WooCommerce store, allowing you to run complex B2B operations alongside your standard retail (B2C) operations.

### 🚀 Core Features & Modules

#### 1. The Turing-Complete Rule Engine
At the heart of B2BKit is a deeply powerful, custom-built Rule Engine. Instead of rigid toggles, you can build dynamic, conditional rules to control every aspect of your store.
*   **Conditions:** Build rules based on Company ID, User Role, Department, Cart Subtotal, Specific Products/Categories, and more.
*   **Actions:** Apply percentage discounts, fixed price overrides, hide products, enforce minimum order quantities (MOQ), or trigger approval workflows.

#### 2. Advanced B2B Pricing & Catalog Visibility
Take absolute control over what your customers see and what they pay.
*   **Tiered Pricing:** Set bulk discounts (e.g., Buy 10-49 for $5, Buy 50+ for $4).
*   **Company-Specific Contracts:** Assign highly specific, negotiated pricing contracts to individual companies.
*   **Catalog Hiding:** Hide entire categories or specific products from guest users, retail users, or specific B2B companies.
*   **MOQ & MOV:** Enforce Minimum Order Quantities per product and Minimum Order Values per cart before checkout is permitted.

#### 3. B2B Companies & Departments
B2B commerce involves organizations, not just individual users.
*   **Company Accounts:** Group multiple WordPress users under a single master Company Account.
*   **Department Hierarchies:** Assign employees to specific departments within a company (e.g., Marketing, IT, Purchasing).
*   **Budgets:** Set rolling monthly spending budgets for specific employees or departments.

#### 4. RFQ, Quote Cart & Negotiation
Allow enterprise clients to negotiate prices instead of forcing them through a standard cart.
*   **Add to Quote:** Dynamically replace "Add to Cart" buttons with "Add to Quote" buttons based on your Rule Engine logic.
*   **Quote Cart:** A dedicated frontend interface where buyers can stage products and submit a Request for Quote (RFQ).
*   **Quote Manager Dashboard:** A robust admin UI to review incoming quotes, adjust unit prices, and send counter-offers.
*   **B2B Messaging Center:** A threaded, real-time AJAX messaging system attached directly to quotes for seamless buyer-seller negotiation.

#### 5. Procurement & Approval Workflows
Mirror corporate purchasing hierarchies directly inside WooCommerce.
*   **Purchase Order (PO) Gateway:** A native WooCommerce payment gateway that forces buyers to enter a PO Number at checkout.
*   **Manager Approvals:** If an employee exceeds their assigned budget, or if a strict rule applies, the checkout is intercepted. The order is placed "On Hold" (`wc-pending-approval`) until the Company Manager approves it via their frontend dashboard.

#### 6. B2B Financial Ledger (Credit Limits & Terms)
Manage complex B2B payment terms without needing external software.
*   **Pay on Credit Gateway:** Allow trusted companies to check out using an assigned credit line. The system automatically hard-blocks transactions that exceed their available balance.
*   **Automated Ledgers:** All credit purchases automatically debit the company account and log a transaction in the B2BKit ledger.
*   **Payment Terms:** Assign Net-15, Net-30, Net-60 terms to companies.
*   **Automated Invoicing:** Orders placed on Credit or PO automatically generate a formal B2B invoice with a perfectly calculated Due Date.

#### 7. Sales Representatives & CRM
Bridge the gap between your sales team and your buyers.
*   **Sales Rep Role:** A custom WordPress user role (`b2bkit_sales_rep`) with restricted permissions.
*   **Company Assignment:** Assign Sales Reps to specific companies.
*   **CRM Data Isolation:** Sales Reps get a dedicated backend CRM dashboard. Strict database isolation ensures they can *only* see orders and quotes from the companies assigned to them.
*   **Commission Attribution:** Orders placed by a company are automatically tagged with their assigned Sales Rep's ID.

#### 8. Analytics & PDF Document Generation
Keep your finger on the pulse of your B2B operations.
*   **B2B Dashboard:** A custom analytics screen that filters out retail sales, showing you pure B2B gross volume, outstanding credit debt, and pending quote pipelines.
*   **1-Click PDF Generation:** High-performance, unstyled HTML-to-Print endpoints allow users to instantly generate beautiful, printable PDFs of their Quotes, Invoices, and Price Lists without bloating your server.

#### 9. Developer-Friendly REST API
Integrate B2BKit with your existing enterprise software (SAP, NetSuite, Salesforce).
*   **Native WordPress REST API:** Inherits WordPress's robust authentication (Cookie, Application Passwords).
*   **Company Endpoints:** Read company profiles and real-time credit balances via `/wp-json/b2bkit/v1/companies`.
*   **Credit Management:** Programmatically replenish credit limits via external ERPs when off-platform wire transfers clear.

== Installation ==

1. Upload the `b2bkit-advanced-wholesale-suite-by-dominopress` folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. Ensure WooCommerce is active.
4. Navigate to **B2BKit -> Settings** to begin configuring your Rule Engine and Company accounts.

== Frequently Asked Questions ==

= Do I need WooCommerce to run B2BKit? =
Yes, B2BKit is built as a highly advanced extension of the WooCommerce core e-commerce engine.

= Can I run a retail (B2C) store alongside my B2B store? =
Absolutely. B2BKit's Rule Engine allows you to create rules that only apply to logged-in B2B companies, leaving your retail prices and "Add to Cart" buttons perfectly intact for standard guests.

= How do I assign a Sales Rep to a Company? =
Create a WordPress user and assign them the "B2B Sales Representative" role. Then, edit a Company profile in the B2BKit backend and select the user from the Sales Rep dropdown.

= Does this plugin generate heavy PDF files on my server? =
No! To keep your site lightning-fast, we built a modern HTML-to-Print engine. Clicking "Download PDF" loads a clean, brandable HTML page that automatically triggers the browser's native, highly-optimized "Save as PDF" engine.

== Screenshots ==

1. **Rule Builder:** The Turing-complete Rule Engine where you can define complex pricing and visibility logic.
2. **Quote Manager:** The admin interface for reviewing RFQs and negotiating counter-offers.
3. **CRM Dashboard:** The isolated backend view for Sales Representatives to monitor their accounts.
4. **Approval Workflow:** The frontend My Account view where Company Managers approve employee orders.
