Developer reference
Integrate VAT pairs, catalogue prices and public offers
Use the current PressFlow VAT preference, formatter, events and optional theme adapters.
Guide source reviewed for PressFlow 2.0.5.
This contract changes price presentation only. WooCommerce remains responsible for stored price basis, product tax class/status, customer tax treatment, basket prices and checkout totals.
Browser preference and toggle
Use the localStorage key pressflow-vat. Its only valid values are excl and incl. This is a browser preference, not a cookie, and does not need to vary cached server HTML.
For a theme's toggle, the plugin exposes a setter after assets/vat.js has loaded:
window.PFWVat.setMode('incl');
window.PFWVat.setMode('excl');
It validates the mode, saves the preference when localStorage is available, changes the visible paired amounts and emits pressflow:vat-change. The return value is false for an invalid mode. Use the setter inside the existing toggle's click handler; do not build a second competing toggle.
A theme can also manage its own toggle and emit the shared event:
const mode = 'incl'; // Or 'excl', selected by the customer.
try { localStorage.setItem('pressflow-vat', mode); } catch (_) {}
document.dispatchEvent(new CustomEvent('pressflow:vat-change', {
detail: { mode }
}));
PressFlow listens to valid events and storage changes from other tabs. It never sends a price request in response to a display-mode change. A saved preference takes precedence over an optional theme-provided window.pressflowVat.mode, followed by the server's WooCommerce default. PressFlow reads that optional theme state; it does not overwrite it.
Themes should use the same event and preference for their native product prices, initialise their button state from the preference, and reflect changes in aria-pressed or equivalent accessible state. The plugin updates the accessible labels of its own price matrix buttons.
Paired markup and PHP formatter
PressFlow always calculates both amounts server-side for the same job/specification. It calls wc_get_price_excluding_tax() and wc_get_price_including_tax() with the product, explicit engine amount and quantity of one complete job. Per-copy prices divide those paired job totals. Do not multiply one display amount by a fixed tax rate.
If the theme defines pressflow_vat_price_markup($excl_html, $incl_html, $from = false), PressFlow passes formatted WooCommerce prices and false for the final argument. The surrounding starting-price block owns the single “From”. The formatter must return branches using the following attributes and hide the inactive one according to the configured WooCommerce display:
<span data-pressflow-vat="excl">...</span>
<span data-pressflow-vat="incl" hidden>...</span>
The theme formatter owns its visible tax suffix. Without it, PressFlow supplies its portable paired fallback with one suffix in the visible branch. Keep hidden branches hidden in the theme's CSS; do not override the hidden attribute.
Starting prices and catalogue adapters
Use pressflow_from_price() or [pressflow_from_price product_id="123"] for the complete starting block, including starting-specification tooltip, quantity and “per print job” description.
If a custom catalogue renderer expects a paired price contract, it may define the filter pressflow_catalogue_price. PressFlow does not register an adapter automatically. A theme/integration can use this example for managed products:
add_filter('pressflow_catalogue_price', static function ($incoming, $product) {
if (!class_exists('PFW_Config') || !$product instanceof WC_Product
|| !PFW_Config::active($product)) {
return $incoming;
}
$reference = PFW_From_Price::reference($product);
if (!$reference) {
return null; // Preserve a quote/configuration prompt; no nominal base-price fallback.
}
$display = PFW_Price_Display::job(
$product,
(float) $reference['price'],
(int) $reference['values']['copies']
);
return [
'excl_html' => wc_price($display['display_amounts']['excl']),
'incl_html' => wc_price($display['display_amounts']['incl']),
'from' => true,
];
}, 20, 2);
Use this optional example only when the integration expects that filter; do not assume every theme applies it. Its return format does not include the specification/quantity description, so the full PressFlow renderer is preferable where possible. Do not enumerate configurations in the theme or use a nominal WooCommerce placeholder as the starting job.
Public offers
For a supporting theme, PressFlow subscribes to pressflow_product_offer and pressflow_native_sale_badge, each with two arguments. A verified mapped public percentage offer supplies percent, up_to and code; managed print products suppress misleading sale badges based on placeholder native prices. Quote-only products retain their quote route.
These filters concern presentation. Eligible automatic shop promotions still use the mapped native WooCommerce coupon in the basket. Arbitrary/private coupons are not discovered or advertised by the theme integration.
Example files
Reference examples for adapting to your shop. PHP examples are not plugin installers; review the guide and replace sample IDs before using them.
Need a hand?
Contact the PressFlow team with details of what you are trying to do.