Cartnorm B2B is not on WordPress.org yet. These pages describe version 0.3.0, the version that will be published. Pro features are marked as planned.
All hooks below are in Cartnorm B2B 0.3.0. Namespace of the PHP classes: Cartnorm\B2B.
Read with $order->get_meta( '…' ). Invoice and ERP plugins can print or export these.
| Meta key | Content |
|---|
_cartnorm_b2b_vat_id | VAT ID with country prefix, e.g. DE123456789 |
_cartnorm_b2b_vat_country | Country of the VAT ID |
_cartnorm_b2b_vat_destination | Country that decided about VAT (billing or shipping) |
_cartnorm_b2b_vies_status | valid, invalid, unavailable or format_invalid |
_cartnorm_b2b_vies_consultation | VIES consultation number |
_cartnorm_b2b_vies_checked_at | Time of the VIES check (UTC, ISO 8601) |
_cartnorm_b2b_vies_name, _cartnorm_b2b_vies_address | Trader data returned by VIES (empty for some countries) |
_cartnorm_b2b_vat_treatment | standard, intra_community_supply, reverse_charge, mixed or pending_verification |
_cartnorm_b2b_vat_reason | cross_border, same_country, outside_eu, country_mismatch, invalid, unavailable, verified_after_order … |
_cartnorm_b2b_vat_notes | Array of legal notes to print on the invoice |
_cartnorm_b2b_customer_group | Customer group at the time of the order |
_cartnorm_b2b_locale | Language of the legal notes |
_cartnorm_b2b_quote_id | Quote the order was created from |
Order item meta _cartnorm_b2b_group_price marks lines that were priced for a group in the admin order editor.
Filters
Groups and prices
| Filter | Arguments | Use |
|---|
cartnorm_b2b_max_groups | int $max | Maximum number of B2B groups (free: 2) |
cartnorm_b2b_user_group | string $slug, int $user_id | Group of a user; must return an existing slug or retail |
cartnorm_b2b_can_assign_group | bool $allowed, int $user_id | Whether the current user may change a customer’s group |
cartnorm_b2b_group_price | $price, WC_Product $product, string $group, string $source | Group price before quantity prices; return null for the normal price |
cartnorm_b2b_never_above_retail | bool $never, WC_Product $product | Default true: a group price is never higher than the current price |
cartnorm_b2b_tier_quantity | float $quantity, array $item, string $cart_key | Quantity used to pick a quantity price (default: total of the same product or variation in the cart) |
cartnorm_b2b_convert_price | $converted, $amount | Convert fixed group and quantity prices for currency switchers other than WCML |
cartnorm_b2b_show_excl_suffix | bool $show | Show the “excl. VAT” suffix (default: on unless Germanized is active) |
cartnorm_b2b_units | array $units | Units of the simple unit price (key => label) |
VAT and VIES
| Filter | Arguments | Use |
|---|
cartnorm_b2b_vat_field_mode | string $mode, string $group | required, optional or hidden for the current visitor |
cartnorm_b2b_vat_decision | array $decision, string $raw, string $country | The full VAT decision for a VAT ID and destination country |
cartnorm_b2b_require_matching_country | bool $require | Default true: the VAT ID country must match the address country |
cartnorm_b2b_is_service | bool $service, WC_Order_Item_Product $item | Goods or service (default: virtual products are services) |
cartnorm_b2b_legal_phrases | array $table | Built-in phrase table (keys: language codes such as de or locales) |
cartnorm_b2b_legal_note_goods | string $note, string $locale | Note for goods (Art. 138) |
cartnorm_b2b_legal_note_services | string $note, string $locale | Note for services (Art. 196) |
cartnorm_b2b_legal_notes | array $notes, string $treatment, WC_Order $order, array $decision | All notes stored on an order |
cartnorm_b2b_order_language | string $locale, WC_Order $order | Language of the notes |
cartnorm_b2b_vies_timeout | int $seconds | VIES request timeout (default 10) |
cartnorm_b2b_vies_cache_ttl | int $ttl, array $result | Cache time of a VIES result in seconds |
Order rules
| Filter | Arguments | Use |
|---|
cartnorm_b2b_group_order_rules | array $rules, string $slug | Minimum order value and number of items of a group |
cartnorm_b2b_product_quantity_rule | array|null $rule, WC_Product $product, string $slug | Minimum, maximum and pack size of a product for a group |
cartnorm_b2b_min_order_cart_amount | float $amount, WC_Cart $cart, bool $incl | Amount compared with the minimum order value |
cartnorm_b2b_cart_rule_messages | array $messages, WC_Cart $cart, string $slug | Messages shown in the cart |
cartnorm_b2b_classic_notice_type | string $type | error (default) or notice in the classic cart |
cartnorm_b2b_is_store_api_checkout | bool $checkout, string $route | Whether a Store API request is a checkout (blocked by the rules) |
Quotes, registration, store mode, caching
| Filter | Arguments | Use |
|---|
cartnorm_b2b_quote_mode | string $mode, string $audience | off, both or only for guest, retail or a group slug |
cartnorm_b2b_hide_prices | bool $hidden, string $audience | Hide prices for the current visitor |
cartnorm_b2b_add_to_quote_label | string $label | Button text |
cartnorm_b2b_registration_errors | WP_Error $errors, array $fields, int $user_id | Your own validation of applications |
cartnorm_b2b_auto_approve | bool $auto, int $user_id, array $application | Decide about automatic approval |
cartnorm_b2b_rate_limit | int $max, string $action | Requests per IP address (default 5) |
cartnorm_b2b_store_locked | bool $locked, int $user_id | Whether the visitor is kept out of a “B2B only” shop |
cartnorm_b2b_store_notice | string $html | Notice for visitors of a “B2B only” shop |
cartnorm_b2b_is_catalog_request | bool $catalog | Whether the request is a catalog page (catalog restriction) |
cartnorm_b2b_private_page | bool $private | Whether the current page must not be cached |
cartnorm_b2b_cache_plugins | array $plugins | Detected cache plugins (id => [ name, detected ]) |
Other
| Filter | Arguments | Use |
|---|
cartnorm_b2b_settings | array $settings | Effective settings |
cartnorm_b2b_show_pro_hints | bool $enabled | Turn off the one-line Pro hints |
cartnorm_b2b_keep_data_on_uninstall | bool $keep | Keep all data when the plugin is deleted |
Actions
| Action | Arguments | When |
|---|
cartnorm_b2b_loaded | — | The plugin has loaded |
cartnorm_b2b_vies_checked | array $result, string $prefix, string $number | After a live VIES request (not for cached results) |
cartnorm_b2b_vat_recorded | WC_Order $order, array $decision | VAT evidence was stored on an order |
cartnorm_b2b_vat_rechecked | WC_Order $order, array $result | A pending VAT ID was checked again |
cartnorm_b2b_quote_created | int $quote_id | A quote request was sent |
cartnorm_b2b_quote_after_answer | int $quote_id, bool $sent | You saved (and maybe sent) an answer |
cartnorm_b2b_quote_status_changed | int $quote_id, string $status | A quote changed status |
cartnorm_b2b_quote_converted | int $quote_id, WC_Order $order | An order was created from a quote |
cartnorm_b2b_application_submitted | int $user_id, array $application, bool $created | A wholesale application was sent |
cartnorm_b2b_application_approved | int $user_id, string $group | An application was approved |
cartnorm_b2b_application_rejected | int $user_id | An application was rejected |
Quotes as posts
Quotes are posts of the private post type cartnorm_b2b_quote with the post statuses cnb2b-new, cnb2b-answered, cnb2b-accepted, cnb2b-expired and cnb2b-converted.
Shortcodes
[cartnorm_b2b_quote]: quote request and accept page
[cartnorm_b2b_registration]: wholesale registration form
PHP
// Put a user into a group; 'retail' removes them from their group.
// Returns false if the group does not exist.
\Cartnorm\B2B\Groups::assign( $user_id, 'wholesale' );
// Name and value of the cache cookie.
\Cartnorm\B2B\Cache::COOKIE; // 'cartnorm_b2b_group'
\Cartnorm\B2B\Cache::cookie_value( 'wholesale' );
Example: treat a product category as services
add_filter( 'cartnorm_b2b_is_service', function ( $service, $item ) {
$product = $item->get_product();
if ( $product && has_term( 'installation', 'product_cat', $product->get_parent_id() ?: $product->get_id() ) ) {
return true;
}
return $service;
}, 10, 2 );
Something unclear or missing? Write to [email protected].