Calculators · Gutenberg
Discount Calculator block for WordPress
Calculate sale prices from discount percentages, find original prices from sale prices, or determine what discount percentage was applied. Three versatile calculation modes.
Get Blockenberg
Free Gutenberg block in Blockenberg. The inspector controls and front-end behavior on this page come from this block’s source, not a shared stub.
What it actually does
Calculate sale prices from discount percentages, find original prices from sale prices, or determine what discount percentage was applied. Three versatile calculation modes.
Inspector panels on this block: Header, Calculator Settings, Sizing & Layout. Those titles come from index.js, not from a shared template.
Behavior controls: “Default Mode” options: Find Sale Price, Find Discount %, Find Original Price; “Currency Position” options: Before ($100), After (100$).
Where to find it
Gutenberg inserter → Calculators → search “Discount Calculator” (block name `blockenberg/discount-calculator` in block.json). Style it in the sidebar after insert.
How to use Discount Calculator block for WordPress
- Install Blockenberg. Install from WordPress.org and activate the plugin.
- Insert the block. Edit a page, click +, search for “Discount Calculator”, insert it. Category: Calculators.
- Configure inspector controls that exist on this block. Open Header. Set “Show Title”, “Show Subtitle”, “Header — Title”, “Subtitle”.
- Check the published page. The view script reads HTML data attributes: data-opts. The block editor preview may not run the same view script.
Inspector controls from this block’s code
| Control | What the code does |
|---|---|
| Show Title | On/off toggle in the inspector. On by default. Saved as `showTitle`. |
| Show Subtitle | On/off toggle in the inspector. On by default. Saved as `showSubtitle`. |
| Header — Title | Text field in the inspector. block.json default: Discount Calculator. Saved as `title`. |
| Subtitle | Text field in the inspector. block.json default: Find sale prices, original prices, or what discount was applied.. Saved as `subtitle`. |
| Default Mode | Select control; the chosen value is saved on the block. Options: Find Sale Price; Find Discount %; Find Original Price. block.json default: sale_price. Saved as `mode`. |
| Currency Symbol | Text field in the inspector. block.json default: $. Saved as `currency`. |
| Currency Position | Select control; the chosen value is saved on the block. Options: Before ($100); After (100$). block.json default: before. Saved as `currencyPos`. |
| Default Original Price | Text field in the inspector. block.json default: 200. Saved as `defaultOriginal`. |
| Default Discount % | Text field in the inspector. block.json default: 25. Saved as `defaultDiscount`. |
| Default Sale Price | Text field in the inspector. block.json default: 150. Saved as `defaultSale`. |
| Show Savings Bar | On/off toggle in the inspector. On by default. Saved as `showSavingsBar`. |
| Show Discount Badge | On/off toggle in the inspector. On by default. Saved as `showBadge`. |
| Typography — Title | Shared Blockenberg typography popover (family, size, weight, spacing). Saved as `typoTitle`. |
| Subtitle (Typo Subtitle) | Shared Blockenberg typography popover (family, size, weight, spacing). Saved as `typoSubtitle`. |
| Sale Price Size | Numeric range control in the inspector. Range 28–96. block.json default: 56. Saved as `salePriceSize`. |
| Card Border Radius | Numeric range control in the inspector. Range 0–40. block.json default: 16. Saved as `cardRadius`. |
| Input Border Radius | Numeric range control in the inspector. Range 0–24. block.json default: 8. Saved as `inputRadius`. |
| Max Width (px) | Numeric range control in the inspector. Range 300–900. block.json default: 520. Saved as `maxWidth`. |
| Padding Top (px) | Numeric range control in the inspector. Range 0–160. block.json default: 60. Saved as `paddingTop`. |
| Padding Bottom (px) | Numeric range control in the inspector. Range 0–160. block.json default: 60. Saved as `paddingBottom`. |
What the front-end script actually does
- The view script reads HTML data attributes: data-opts.
- JavaScript functions that perform the math: calcSalePrice, calcDiscountPct, calcOrigPrice.
When this is the right block
- Calculate sale prices from discount percentages, find original prices from sale prices, or determine what discount percentage was applied. Three versatile calculation modes — that is the job of Discount Calculator, not a generic content block.
- Use it when you need the editor control labeled “Show Title”, which exists on this block’s inspector.
- It matches pages about discount, sale, price.
- The math runs in the visitor’s browser after publish — no extra calculator plugin.
Notes from the implementation
viewScript: this folder’s frontend.js is enqueued on the front end for this block.
FAQ
How do I add the Discount Calculator block in WordPress?
Install Blockenberg from WordPress.org, edit a page in the block editor, click +, and search for “Discount Calculator”. It sits under Calculators. After insert, open Header and set “Show Title”, “Show Subtitle”, “Header — Title”, “Subtitle”.
Does Discount Calculator need a server or extra plugin?
No. After Blockenberg is active, the view script runs in the browser with the values you saved on the block.
Is the Discount Calculator Gutenberg block free?
Yes. Discount Calculator ships inside Blockenberg. Get the plugin from WordPress.org — no paid add-on is required for this block.
Can I style Discount Calculator to match my theme?
Yes. Blockenberg’s shared typography and color panels apply here, plus any block-specific style controls listed on this page (panels: Header, Calculator Settings, Sizing & Layout).
Related calculators blocks
Invoice Calculator
A line-item invoice builder with editable rows, discount, tax, and grand total.
Percentage Calculator
An interactive percentage calculator with three modes: find percentage of a number, find what percentage one number is of another, and calculate percentage change between two values.
Price Calculator
Interactive SaaS pricing calculator with sliders, toggle switches, checkbox add-ons, and live price calculation. Supports monthly/annual billing and custom formulas.
Retirement Calculator
Project retirement savings based on current age, target retirement age, monthly contributions, and expected investment returns. Shows inflation-adjusted projections with a visual breakdown.
Savings Calculator
An interactive compound interest savings calculator. Enter initial deposit, monthly contribution, annual interest rate, and years to see total savings, interest earned, and a year-by-year growth breakdown.
Tax Calculator
Calculate sales tax, VAT, or estimate income tax brackets. Supports before-tax and after-tax price calculations with customizable tax rates and display options.
Get Blockenberg
Install Blockenberg from WordPress.org, then insert Discount Calculator from the Gutenberg inserter.