A lightweight WooCommerce extension that helps store owners calculate profit margins by adding a Buying Price field to products and tracking it across orders.
The Profit Calculation plugin allows shop administrators to set a "Buying Price" (cost price) for their products. When an order is placed, this cost is recorded in the order item metadata to ensure historical accuracy, even if the product's cost changes later. The plugin provides a dedicated admin dashboard to view the profit per order and the total profit for visible orders.
- Buying Price Field: Adds a "Buying Price (Before Profit)" field to the General tab of WooCommerce Product Data.
- Order Snapshot: Automatically saves the Buying Price to the order item metadata (
_samrprca_buying_price) when an order is placed. This protects your reports from future cost price changes.
- Dedicated Dashboard: Accessible via
WooCommerce > Profit Calculation. - Detailed Table: Lists orders with Selling Price, Buying Price, and calculated Profit.
- Total Profit: Automatically calculates and displays the total profit for all valid orders.
- Smart Filtering: Only shows orders that contain valid Buying Price data to ensure calculation accuracy.
- Upload the plugin files to
/wp-content/plugins/profit-calculation/. - Run
composer install(orcomposer dump-autoloadif dependencies are already present) to generate the autoloader. - Activate the plugin through the 'Plugins' screen in WordPress.
- Go to any Product > General Tab and set the "Buying Price".
- WordPress 5.0 or higher
- WooCommerce 5.0.0 or higher
- PHP 7.4 or higher
- Set Buying Price: Edit a product and enter the cost in the "Buying Price (Before Profit)" field.
- Place Orders: As customers purchase products, the cost is recorded.
- View Profits: Navigate to
WooCommerce > Profit Calculationto see your earnings.
profit-calculation/
├── assets/
│ ├── css/ # Admin styles
│ └── js/ # Admin scripts (validation)
├── includes/
│ ├── Assets.php # Asset management
│ ├── ProductMeta.php # Product field & Order meta logic
│ ├── ProfitCalculation.php # Main class & container
│ ├── ProfitListTable.php # WP_List_Table implementation
│ └── ProfitTable.php # Admin page renderer
├── templates/
│ └── profit-index.php # Dashboard template
├── vendor/ # Composer dependencies
├── composer.json # Composer config
└── profit-calculation.php # Main plugin file
- Initial release.
- Added Buying Price field to products.
- Implemented Order Item meta snapshot.
- Added Profit Calculation admin table.
- Added Total Profit display.
This plugin is licensed under GPL2.