Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ’ฐ Profit Calculator

A modern, SaaS-style profit calculator WordPress plugin โ€” with live projections, animated counters, and a beautiful Chart.js dashboard. Drop it anywhere with a single shortcode.


โœจ Features at a Glance

Feature Details
๐Ÿ“Š Live Chart Interactive Chart.js line chart โ€” Total Sales vs Gross Profit
๐Ÿ”ข Animated Counters Smooth ease-out cubic animation on every value update
๐Ÿ’ฑ Multi-Currency 9 currencies: USD, EUR, GBP, INR, JPY, AUD, CAD, AED, SAR
๐Ÿ“… Duration Selector Switch between 6, 12, or 24-month projections instantly
๐Ÿ“ˆ Compound Growth Monthly growth rate applied with exponential compounding
๐Ÿ”’ Input Validation Real-time error highlighting with boundary checks
๐Ÿ“ฑ Fully Responsive Mobile-first, adapts gracefully from 400px to 4K
๐Ÿงฉ Shortcode-Ready Single line [profit_calculator] drops it anywhere
โšก Zero jQuery Pure vanilla JS โ€” no bloat, no dependencies beyond Chart.js

๐Ÿš€ Quick Start

1. Install the Plugin

Option A โ€” Upload via WordPress Admin

  1. Go to Plugins โ†’ Add New โ†’ Upload Plugin
  2. Choose profit-calculator-pro.zip
  3. Click Install Now, then Activate

Option B โ€” Manual Upload via FTP

wp-content/
โ””โ”€โ”€ plugins/
    โ””โ”€โ”€ profit-calculator-pro/
        โ”œโ”€โ”€ profit-calculator-pro.php
        โ””โ”€โ”€ assets/
            โ”œโ”€โ”€ css/
            โ”‚   โ””โ”€โ”€ profit-calculator.css
            โ””โ”€โ”€ js/
                โ””โ”€โ”€ profit-calculator.js

2. Add the Shortcode

Paste this shortcode into any page, post, or widget:

[profit_calculator]

With a custom currency:

[profit_calculator currency="โ‚ฌ"]

That's it โ€” the calculator renders automatically. ๐ŸŽ‰


๐Ÿ–ฅ๏ธ Preview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ๐Ÿ–ฅ  Calculator Inputs       โ”‚  Profit Projections          24 Monthsโ–พโ”‚
โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚
โ”‚  Avg. Order Value           โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  $ [    120.00           ]  โ”‚  โ”‚ $216.00K โ”‚ โ”‚ $54.00K  โ”‚ โ”‚$18.00K โ”‚ โ”‚
โ”‚                             โ”‚  โ”‚TOTAL     โ”‚ โ”‚GROSS     โ”‚ โ”‚DELIVERYโ”‚ โ”‚
โ”‚  Commission per Order (%)   โ”‚  โ”‚SALES     โ”‚ โ”‚PROFIT    โ”‚ โ”‚FEE     โ”‚ โ”‚
โ”‚  [  25  ] %                 โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                             โ”‚                                        โ”‚
โ”‚  Avg. Daily Orders          โ”‚  โ–ฒ $25K โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ   โ”‚
โ”‚  [  50  ] /day              โ”‚        โ•ญโ•ฏ  Total Sales             โ”‚   โ”‚
โ”‚                             โ”‚  โ–ฒ $10Kโ”‚       โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ   โ”‚
โ”‚  Delivery Fee per Order     โ”‚       โ•ญโ•ฏ  Gross Profit                  โ”‚
โ”‚  $ [  5.00              ]   โ”‚  โ–ฒ $0 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€   โ”‚
โ”‚                             โ”‚       M1  M4  M8  M12 M16 M20  M24    โ”‚
โ”‚  Monthly Growth Rate (%)    โ”‚                                        โ”‚
โ”‚  [   5  ] %                 โ”‚                                        โ”‚
โ”‚                             โ”‚                                        โ”‚
โ”‚  Currency    [ $ USD      ] โ”‚                                        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โš™๏ธ Calculator Inputs

Input Default Description
Avg. Order Value $120.00 Average revenue generated per single order
Commission per Order 25% Your margin or commission rate on each order (max 100%)
Avg. Daily Orders 50 Number of orders received per day on average
Delivery / Service Fee $5.00 Fee charged per order for delivery or service
Monthly Growth Rate 5% Compound monthly growth applied to order volume
Currency $ USD Symbol displayed throughout the calculator
Duration 24 Months Projection window: 6, 12, or 24 months

๐Ÿ“ How the Math Works

The calculator uses compound growth applied monthly to your daily order volume:

Monthly Orders  = Daily Orders ร— 30 ร— (1 + growthRate)^(month - 1)

Monthly Sales   = Monthly Orders ร— Avg. Order Value
Monthly Profit  = Monthly Sales  ร— (Commission% / 100)
Monthly Delivery= Monthly Orders ร— Delivery Fee

Total Sales     = ฮฃ Monthly Sales    (over N months)
Gross Profit    = ฮฃ Monthly Profit   (over N months)
Total Delivery  = ฮฃ Monthly Delivery (over N months)

All values update instantly as you type โ€” no submit button needed.


๐Ÿ’ฑ Supported Currencies

Symbol Currency
$ USD โ€“ US Dollar
โ‚ฌ EUR โ€“ Euro
ยฃ GBP โ€“ British Pound
โ‚น INR โ€“ Indian Rupee
ยฅ JPY โ€“ Japanese Yen
A$ AUD โ€“ Australian Dollar
C$ CAD โ€“ Canadian Dollar
AED UAE Dirham
SAR Saudi Riyal

๐Ÿ“ File Structure

profit-calculator-pro/
โ”œโ”€โ”€ profit-calculator-pro.php       โ† Plugin bootstrap, shortcode, asset loader
โ””โ”€โ”€ assets/
    โ”œโ”€โ”€ css/
    โ”‚   โ””โ”€โ”€ profit-calculator.css   โ† All styles (scoped to .pcp-wrap)
    โ””โ”€โ”€ js/
        โ””โ”€โ”€ profit-calculator.js    โ† Calculator logic + Chart.js integration

Key Constants (PHP)

PCP_VERSION      // Cache-busting version (uses time() in dev)
PCP_PLUGIN_DIR   // Absolute server path to plugin folder
PCP_PLUGIN_URL   // Public URL to plugin folder

๐Ÿ”ง Developer Notes

Shortcode Parameters

[profit_calculator currency="โ‚ฌ"]
Attribute Default Type Description
currency $ string Currency symbol shown in inputs and stat cards

Overriding the Currency Filter

You can override the currency symbol programmatically via the pcp_currency_symbol filter:

add_filter( 'pcp_currency_symbol', function( $symbol ) {
    return 'โ‚ฌ';
} );

Assets Are Conditionally Loaded

CSS and JS are only enqueued when the shortcode is present on the page โ€” your site's performance is not affected on pages without the calculator.

// Triggered inside pcp_render_shortcode(), not globally
pcp_enqueue_assets();

JavaScript Architecture

The JS is a self-contained IIFE module โ€” no global pollution, no jQuery required.

ProfitCalculator
โ”œโ”€โ”€ init(root)          โ€” bootstraps DOM refs, chart, events
โ”œโ”€โ”€ bindEvents()        โ€” attaches input/change listeners
โ”œโ”€โ”€ onInputChange(e)    โ€” debounced handler (80ms)
โ”œโ”€โ”€ validateField(el)   โ€” inline validation with error state
โ”œโ”€โ”€ getInputs()         โ€” reads + sanitises all values
โ”œโ”€โ”€ calculate(inputs)   โ€” core math, returns arrays for chart
โ”œโ”€โ”€ update()            โ€” orchestrates counters + chart refresh
โ”œโ”€โ”€ animateCounter()    โ€” requestAnimationFrame ease-out animation
โ”œโ”€โ”€ formatCurrency()    โ€” smart B/M/K formatting with symbol
โ”œโ”€โ”€ formatAxisValue()   โ€” Y-axis tick label formatter
โ”œโ”€โ”€ initChart()         โ€” Chart.js initialisation
โ”œโ”€โ”€ chartOptions()      โ€” full Chart.js options object
โ””โ”€โ”€ updateChart()       โ€” pushes new data, triggers re-render

CSS Scope

All styles are scoped under .pcp-wrap to prevent conflicts with your theme:

.pcp-wrap { /* CSS custom properties declared here */ }
.pcp-wrap * { box-sizing: border-box; }

๐Ÿ“ฑ Responsive Breakpoints

Breakpoint Behaviour
> 1100px Two-column layout: 360px inputs + fluid results
900โ€“1100px Narrower inputs column: 300px
< 900px Single-column stacked layout, inputs panel un-sticks
< 640px Cards stack vertically, duration select goes full-width
< 400px Stat card values shrink to 17px for compact display

๐Ÿงช Validation Rules

Field Rule
All numeric fields Must be โ‰ฅ 0 and a valid number
Commission (%) Must be โ‰ค 100
Invalid state Red border + box-shadow highlight applied via .pcp-input--error

๐Ÿ“ฆ Dependencies

Library Version How It's Loaded
Chart.js 4.4.0 CDN via wp_enqueue_script
DM Sans โ€” Google Fonts @import in CSS
DM Mono โ€” Google Fonts @import in CSS

No jQuery. No other dependencies.


๐Ÿ› ๏ธ Requirements

Requirement Minimum
WordPress 5.5+
PHP 7.4+
Browser Any modern browser (Chrome, Firefox, Safari, Edge)

๐Ÿ” Security

  • All shortcode attributes are passed through shortcode_atts() with defined defaults
  • Output is escaped with esc_attr() and esc_html() before rendering
  • Plugin aborts immediately if accessed outside WordPress (ABSPATH check)
if ( ! defined( 'ABSPATH' ) ) {
    exit; // No direct access
}

โ“ FAQ

Q: Can I use the shortcode more than once on the same page?
A: The calculator targets a single #pcp-root element. For multiple instances, reach out for a custom build.

Q: Will this slow down my site?
A: No. Assets are only enqueued on pages that contain the shortcode, and Chart.js is loaded from a fast CDN.

Q: Can I change the default values?
A: Default values (120 order value, 25% commission, 50 daily orders, etc.) are set in the HTML rendered by the shortcode. You can modify profit-calculator-pro.php to change them.

Q: Does it work with page builders?
A: Yes โ€” paste [profit_calculator] into any shortcode block in Elementor, Divi, Beaver Builder, or the default Gutenberg editor.

Q: Can I change the chart colors?
A: Yes. In profit-calculator.js, find the datasets array inside initChart() and update the borderColor and backgroundColor values.


๐Ÿ“œ License

Licensed under the GPL-2.0+ license.
You are free to use, modify, and distribute this plugin in accordance with the terms of the GPL.


๐Ÿ‘ค Author

Muhammad Hussain Mehrani
๐ŸŒ ninjascode.com

Powered by Enatega โ€” Open-source food delivery solution.


๐Ÿ“ Changelog

v1.0.0 โ€” Initial Release

  • SaaS-style two-panel layout (inputs + results)
  • Live Chart.js line chart with animated transitions
  • Animated stat card counters (ease-out cubic)
  • 9 currency options with dynamic symbol updates
  • 6 / 12 / 24-month duration selector
  • Compound monthly growth rate calculation
  • Real-time input validation
  • Fully responsive design (mobile โ†’ 4K)
  • Zero jQuery dependency
  • Assets conditionally loaded via shortcode detection

Built with โค๏ธ by NinjasCode ยท Powered by Enatega

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages