Skip to content

printdotcom/pdc-wordpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

222 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Print.com Print on Demand - WordPress Plugin

WordPress WooCommerce PHP License

A WordPress plugin that integrates with the Print.com API to enable custom print-on-demand products in WooCommerce stores. Configure, edit, and sell custom printed products seamlessly through your WordPress/WooCommerce site.

✨ Features

  • πŸ–¨οΈ Print.com API Integration - Direct connection to Print.com's print-on-demand services
  • 🎨 Product Configuration - Connect your product to a Print.com and we will take care of the fulfilment
  • 🎨 Order Synchronization - Automatically receive track-and-trace data from Print.com

πŸš€ Quick Start

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/printdotcom/pdc-pod.git
    cd pdc-pod
  2. Run composer

    composer dump-autoload
  3. Start the development environment:

    # Start WordPress with PHP 8.2 and WordPress 6.8
    bin/run-wordpress 68 82
  4. Optionally Seed WooCommerce with sample data:

    # Configure WooCommerce and create sample products
    bin/seed-woocommerce 68 82
  5. Optionally use the mock api:

# Configure WooCommerce and create sample products
bin/run-mock-api start
  1. Access your site:

🐳 Local Environment

Available Commands

Command Description Example
bin/run-wordpress [WP_VER] [PHP_VER] Start WordPress environment bin/run-wordpress 68 82
bin/stop-wordpress [WP_VER] [PHP_VER] Stop WordPress environment bin/stop-wordpress 68 82
bin/seed-woocommerce [WP_VER] [PHP_VER] Seed WooCommerce with sample data bin/seed-woocommerce 68 82
bin/run-mock-api {start|stop|status} Manage Print.com Mock API bin/run-mock-api start

Supported Versions

Check config/wp-version.conf for available WordPress/PHP combinations:

# WordPress 6.7 with PHP 7.0
bin/run-wordpress 67 70

# WordPress 6.8 with PHP 8.2 (if available)
bin/run-wordpress 68 82

Port Mapping

The port format is 80[WORDPRESS_VERSION]:

  • WordPress 6.7: http://localhost:8067
  • WordPress 6.8: http://localhost:8068

πŸ”§ Configuration

Print.com API Credentials

  1. Navigate to WordPress Admin β†’ Print.com β†’ Settings
  2. Enter your Print.com API credentials:
    • API Key
    • API Secret
    • Environment (Sandbox/Production)

πŸ› οΈ Development

Code Standards

This project follows:

Translations

When a new translation is added

When you add new strings that need translation in your PHP code:

  1. Regenerate the POT template file:

    wp i18n make-pot . languages/pdc-pod.pot
  2. Update existing PO files with new strings:

    wp i18n update-po languages/pdc-pod.pot
  3. Translate the new strings in each .po file using Poedit or a text editor

  4. Compile translations to MO files:

    wp i18n make-mo languages

Adding a New Language

When you want to add a new language:

  1. Create a new PO file from the template:

    cd languages
    cp pdc-pod.pot pdc-pod-[LOCALE].po

    Replace [LOCALE] with the WordPress locale code (e.g., es_ES for Spanish, it_IT for Italian)

  2. Update the PO file header with language information:

    • Set Language-Team and Language fields
    • Add appropriate plural forms for the language
  3. Translate all strings using Poedit or manually edit the msgstr values

  4. Compile to MO file:

    wp i18n make-mo languages

πŸ—οΈ Project Structure

pdc-pod/
β”œβ”€β”€ admin/                  # Admin-specific functionality
β”‚   β”œβ”€β”€ AdminCore.php      # Main admin class
β”‚   β”œβ”€β”€ PrintDotCom/       # Print.com API integration
β”‚   β”‚   β”œβ”€β”€ APIClient.php  # API client
β”‚   β”‚   β”œβ”€β”€ Product.php    # Product model
β”‚   β”‚   └── Preset.php     # Preset model
β”‚   β”œβ”€β”€ css/               # Admin stylesheets
β”‚   β”œβ”€β”€ js/                # Admin JavaScript
β”‚   └── partials/          # Admin template partials
β”œβ”€β”€ bin/                   # Development scripts
β”‚   β”œβ”€β”€ run-wordpress      # Start WordPress environment
β”‚   β”œβ”€β”€ stop-wordpress     # Stop WordPress environment
β”‚   └── seed-woocommerce   # Seed WooCommerce data
β”œβ”€β”€ config/                # Configuration files
β”‚   β”œβ”€β”€ docker-compose.yml # Docker Compose configuration
β”‚   └── wp-version.conf    # WordPress/PHP version mapping
β”œβ”€β”€ includes/              # Core plugin files
β”‚   β”œβ”€β”€ Core.php          # Main plugin class
β”‚   β”œβ”€β”€ Activator.php     # Plugin activation
β”‚   β”œβ”€β”€ Deactivator.php   # Plugin deactivation
β”‚   └── Loader.php        # Hook loader
β”œβ”€β”€ front/                 # Public-facing functionality
β”‚   └── FrontCore.php      # Main public class
└── vendor/                # Composer dependencies

Autoloading

The project uses PSR-4 autoloading via Composer:

{
  "autoload": {
    "psr-4": {
      "PdcPod\\Admin\\": "admin/",
      "PdcPod\\Front\\": "front/",
      "PdcPod\\Includes\\": "includes/"
    }
  }
}

Unit tests

Running automated unit tests via phpunit is possible through:

bin/test-unit

Mock API

When working locally or running end-2-end tests, the mock-api via wiremock will mock the Print.com API.

# Start the mock API
bin/run-mock-api start

See test/wiremock/README.md for detailed documentation.

Releasing

bin/create-dist

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feat/amazing-feature)
  3. Open a Pull Request

πŸ“ž Support

πŸ“Š Changelog

See CHANGELOG.md for a detailed history of changes.


Made with ❀️ by the Print.com team

About

Print.com Connector

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors