Receipt Templates
The Receipt Template editor allows you to customize the appearance and content of receipts printed from your POS system. You can access the template editor by navigating to: WP Admin > POS > Templates
Overview
The template system provides two types of templates:
- Default Templates: Automatically detected from your plugin and theme files. These cannot be deleted but can be copied to create custom versions.
- Custom Templates: User-created templates that you can fully customize, edit, and manage.
Accessing the Template Editor
- Navigate to your WordPress Admin dashboard
- Go to POS > Templates
- You'll see a list of available templates organized into two sections:
- Default Templates (from plugin/theme files)
- Custom Templates (your custom creations)
Default Templates
The system automatically detects receipt templates from three sources:
Template Sources
| Source | Description | Status |
|---|---|---|
| Plugin | Core receipt template included with WooCommerce POS | Always available |
| Pro Plugin | Enhanced template from WooCommerce POS Pro | Available with active license |
| Theme | Custom template from your active theme | Available if theme includes template |
Template Actions
For each default template, you can:
- Preview: View how the template looks with sample data
- Copy: Create a custom copy that you can edit
- Activate: Set as the active template for your POS
Creating Custom Templates
Method 1: Copy from Default Template
- In the Default Templates section, find the template you want to customize
- Click the Copy button
- Enter a name for your custom template
- Click Copy Template
- Edit the newly created custom template
Method 2: Create from Scratch
- Click Add New Template at the top of the page
- Enter a template name
- Select Receipt as the template type
- Start coding your template in the editor
Template Editor Features
The template editor provides:
Code Editor
- Syntax Highlighting: PHP syntax highlighting for better code readability
- Line Numbers: Easy navigation and debugging
- Full-Screen Editing: Distraction-free editing environment
Template Settings Panel
- Language: Set to PHP for proper syntax highlighting
- Template Type: Choose between Receipt or Report templates
- Status: Publish/Draft status management
- Visibility: Control template visibility
Template Actions
- Preview: See how your template renders with sample data
- Set as Active: Make this template the default for your POS
- Update: Save your changes
- Move to Trash: Delete custom templates
Template Structure
Receipt templates are PHP files that generate HTML output. Here's the basic structure:
<?php
/**
* Custom Receipt Template
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* Your custom CSS styles */
body { font-family: sans-serif; font-size: 14px; }
.receipt-header { text-align: center; margin-bottom: 20px; }
/* Add more styles as needed */
</style>
</head>
<body>
<!-- Your receipt content -->
<div class="receipt-header">
<h1><?php echo get_bloginfo( 'name' ); ?></h1>
<p><?php echo get_bloginfo( 'description' ); ?></p>
</div>
<!-- Order details, items, totals, etc. -->
</body>
</html>
Available Template Variables
When creating custom templates, you have access to various WordPress and WooCommerce functions and data:
Store Information
get_bloginfo( 'name' )- Store nameget_bloginfo( 'description' )- Store taglineget_bloginfo( 'url' )- Store URL
Order Data
The current order data is available through standard WooCommerce order functions when the template is rendered.
WCPOS Functions
You can use WCPOS-specific functions (prefixed with wcpos_) to access POS-related data and functionality.
Best Practices
Template Development
- Start with a Copy: Always start by copying a default template rather than creating from scratch
- Test Thoroughly: Use the preview function to test your template before activating
- Keep Backups: Export your custom templates or keep copies of your code
- Mobile-Friendly: Ensure your templates work well on different screen sizes
Code Quality
- Validate HTML: Ensure your HTML is well-formed
- Escape Output: Use WordPress escaping functions for security
- Error Handling: Include proper error checking in your PHP code
- Comments: Document your customizations for future reference
Performance
- Optimize CSS: Keep styles minimal and efficient
- Minimize PHP: Avoid complex logic in templates
- Test Printing: Verify templates work well with your receipt printers
Troubleshooting
Common Issues
Template Not Showing Changes
- Ensure you've clicked "Update" to save your changes
- Check that the template is set as "Active"
- Clear any caching plugins
Syntax Errors
- Use the syntax highlighting to identify issues
- Check for missing semicolons, brackets, or quotes
- Validate your PHP syntax
Styling Issues
- Test your CSS in the preview mode
- Ensure styles are compatible with receipt printers
- Keep print-friendly design principles in mind
Template Not Available
- Check that the template type is set to "Receipt"
- Verify the template status is "Published"
- Ensure you have proper permissions
Getting Help
If you encounter issues with template customization:
- Check the template preview for error messages
- Review the WordPress debug log for PHP errors
- Test with a copy of the default template first
- AI Assistance: Modern AI tools like Gemini, ChatGPT, and Claude are excellent at helping with simple WordPress templates like these. You can paste your template code and describe what you want to achieve.
- Consult the WooCommerce POS documentation for advanced customization
Advanced Customization
For advanced users who need more control over receipt templates:
Theme Integration
You can override the default template by placing a custom receipt.php file in your theme:
your-theme/woocommerce-pos/receipt.php
Hooks and Filters
WooCommerce POS provides various hooks and filters for template customization. Consult the developer documentation for available options.
Custom Fields
You can include custom order fields, product attributes, and other metadata in your receipt templates using appropriate WordPress and WooCommerce functions.