Free shipping on orders over $75  ·  Shop Now

How to Build a Print-on-Demand T-Shirt Website from Scratch

PHP · MySQL · Shopify · Printify · APIs · Automation · SEO

What This Guide Builds

This series explains how I built The Conspiracy Shirt Company as a custom, database-driven print-on-demand storefront.

The finished system uses:

  • PHP to generate the storefront
  • MySQL to store products, variants, descriptions, and collections
  • HTML and CSS for the presentation layer
  • JavaScript for product interactions and cart behavior
  • Shopify for checkout and payment processing
  • Printify for production and fulfillment
  • APIs to synchronize products, prices, variants, and images
  • Custom administration tools to reduce repetitive work
  • LiteSpeed and image optimization for performance
The central idea:

Build the storefront once, keep the products in a database, use Shopify only where Shopify is valuable, use Printify only where Printify is valuable, and automate as much repetitive work as possible.

Contents

Why I Built the Site

The Conspiracy Shirt Company started as something for my mind to do while I was dealing with cancer treatments.

I wanted a project that gave me something creative and technical to think about. I wanted to make T-shirts, but I did not want to make another collection of generic graphics.

I wanted every design to feel like part of a larger story.

Bigfoot did not need to spend the rest of his life walking through the same forest. He could ride a mountain bike, work in a small-town barbershop, get chased by a UFO, or be beamed directly into one.

I also liked taking ridiculous conspiracy theories and making them even dumber.

The moon landing was fake?

That was not stupid enough.

What if the moon itself was fake?

The basic creative rule became: take something strange, push it one step past reasonable, and build a shirt and a story around the result.

T-Shirts as Small Stories

The shirt is the final product, but the idea usually begins as a scene.

Instead of starting with:

I need a Bigfoot shirt.

I could start with:

  • What would Bigfoot do if he lived in a small American town?
  • What job would a classic monster have?
  • What happens when a giant cat becomes a city-level emergency?
  • What conspiracy becomes funnier when taken completely literally?
  • What would a classified government memo say about something absurd?

That approach led to collections instead of isolated products. Collections could have their own visual style, characters, jokes, product descriptions, landing pages, and advertising.

The website therefore needed to support more than shirts. It needed to support collections, stories, images, related products, custom fields, and constantly changing ideas.

Why the Storefront Uses Two Main PHP Pages

I wanted to build many shirts and collections, but I was also dealing with treatment and limited energy.

I did not want to create and maintain a separate PHP file for every shirt.

I am also lazy.

That is an important part of the architecture.

I built the customer-facing store around two main PHP pages:

  1. index.php displays the catalog, collection filters, product cards, sorting, and pagination.
  2. shirt.php displays an individual product based on an item number passed in the URL.

Instead of creating a new page, I add a new database record.

Instead of creating a separate PHP file for every shirt, I add one product record to the database.

One catalog page index.php
One product template shirt.php
Unlimited products
shirt.php?item=1001 shirt.php?item=1002 shirt.php?item=1003
One template, many products.

The same shirt.php file displays every shirt. It reads the item number from the URL, loads the matching database record, finds its variants and images, and builds the complete product page automatically. Adding a product should mean adding data, not adding another webpage.

Complete Store Architecture

High-level flow:

Visitor → Custom PHP Storefront → MySQL, Shopify, and Printify
Visitor A customer lands on the catalog or product page and interacts with the custom storefront.
Custom PHP Storefront The custom site displays products, collections, variants, images, descriptions, reviews, and SEO content.
The storefront connects to three systems:
MySQL Product Database Handles:
Products
Collections
Variants
Prices
Images
Reviews
SEO content
Shopify Storefront API Handles:
Cart
Checkout
Payment
Customer order
Printify Handles:
Product
Print provider
Production
Packaging
Shipping

How a Storefront Page Request Works

When a visitor opens a product page, the site does not request all product information from Shopify or Printify in real time.

The storefront data is already stored in the local MySQL database. PHP can therefore build the page without waiting for an external platform to respond.

1
Page request

Visitor Opens a Product

/shirt.php?item=1001

The item number in the URL tells the site which product the visitor wants to view.

2
Validation

PHP Checks the Request

PHP validates the item number before using it in a prepared database query.

3
Local data

MySQL Loads the Product

The database returns the product record, available variants, colors, sizes, prices, descriptions, and collection information.

4
Assets

PHP Finds the Product Images

The site selects the correct front, back, color, and fallback images from the local product folders.

5
Page generation

PHP Builds the Complete Page

PHP renders the product content, metadata, canonical URL, Open Graph tags, breadcrumbs, and structured data.

6
Interaction

JavaScript Handles the Variants

JavaScript updates the selected color, size, image, availability, price, and Shopify variant ID.

7
External request

Shopify Is Contacted at Checkout

The Storefront API is used only when the visitor creates a cart or proceeds to checkout.

Why this matters:

Ordinary page views use fast local data. The storefront does not depend on Shopify or Printify responding every time someone views a shirt.

How a New Product Moves Through the System

The product workflow began as a series of manual steps. As the catalog grew, those steps were gradually connected through admin tools, local scripts, and APIs.

1
Creative work

Create the Idea and Artwork

The process begins with the shirt concept, illustration, collection theme, and story behind the design.

2
File preparation

Prepare the Production Files

Artwork is resized, converted, checked for transparency, and prepared for the required print areas.

3
Fulfillment setup

Create or Update the Printify Product

The design is assigned to a blank, print provider, colors, sizes, print areas, and production variants.

4
Commerce setup

Publish the Product to Shopify

Shopify receives the product and creates the variant IDs needed for the custom cart and checkout.

5
Synchronization

Import Product and Variant Data

The API tools connect the Printify product, Shopify variants, colors, sizes, prices, and availability to the local MySQL record.

6
Store content

Add the Storefront Details

The product receives its descriptions, collection, images, SEO fields, metadata, and related content.

7
Automatic storefront

The Two PHP Pages Do the Rest

The catalog page displays the new product, and the existing product template automatically builds its complete product page.

The eventual goal:

Create the design once, enter or synchronize the data once, and avoid repeatedly opening Printify, Shopify, phpMyAdmin, an image editor, and several separate scripts.

The Full Technology Stack

Layer Technology Purpose
Frontend HTML Page structure and semantic content
Frontend CSS Responsive layout, product cards, navigation, and branding
Frontend JavaScript Variant selection, image switching, cart behavior, and interface controls
Backend PHP Database queries, page generation, APIs, sessions, and administration
Database MySQL Products, variants, reviews, collections, pricing, and content
Database access PDO Prepared queries and secure database access
Checkout Shopify Storefront API Cart creation and secure customer checkout
Fulfillment Printify API Products, variants, providers, pricing, images, and fulfillment data
Hosting Apache and LiteSpeed Serving PHP pages, caching, redirects, and performance
Administration Custom PHP tools Product management, bulk updates, image handling, and synchronization
Automation PHP and Python scripts Image processing, imports, exports, updates, and repetitive workflows

Why the Database Is the Center of the Store

Shopify and Printify both contain product data, but neither platform contains every field I need for the custom storefront.

The local MySQL database acts as the store's central content layer. It connects the creative product information to the operational IDs used by Shopify and Printify.

Central content layer

MySQL Product Database

Stores everything the custom PHP storefront needs to build product and collection pages.

Product Content

  • Item number
  • Product title
  • Short description
  • Long description
  • Category
  • Collection or line

Variants and Pricing

  • Retail price
  • Colors
  • Sizes
  • Availability
  • Shopify variant IDs
  • Printify variant IDs

SEO and Images

  • SEO title
  • Meta description
  • Open Graph content
  • Product images
  • Canonical information

Store Activity

  • Likes
  • Buy-click counts
  • Customer reviews
  • Active status
  • Sorting information

Platform Connections

  • Printify product ID
  • Shopify product ID
  • Shopify variant mapping
  • Printify variant mapping
MySQL controls what the customer sees.

Shopify and Printify remain the operational services behind the store, while the local database controls the storefront content, organization, presentation, and platform connections.

Why Shopify Handles Checkout

Building custom product pages is one problem. Building and maintaining a secure payment system is a completely different problem.

The custom PHP site controls the shopping experience until the customer is ready to check out. Shopify then takes over the parts it is designed to handle.

Custom PHP storefront

Before Checkout

  • Displays the product
  • Loads colors and sizes
  • Checks variant availability
  • Updates the product image
  • Selects the Shopify variant ID
Shopify

Checkout and Order

  • Secure checkout
  • Payment processing
  • Customer information
  • Discount codes
  • Applicable tax logic
  • Shipping selection
  • Order creation and status
Custom Product Page
Selected Variant
cartCreate
Checkout URL
Secure Checkout
The custom site never processes the payment.

It sends Shopify the selected merchandise ID and quantity. Shopify creates the cart, returns a checkout URL, and securely handles the customer's payment and order information.

Why Printify Handles Production and Fulfillment

The store sells physical products without owning blank shirts, printing equipment, packing materials, or a warehouse.

Printify connects each product to the print provider that manufactures and ships the order.

1

Blank Product

The shirt model, available colors, sizes, and printable areas are selected.

2

Print Provider

A provider is selected based on products, print areas, pricing, location, and production options.

3

Production Files

The artwork is connected to the correct front, back, sleeve, or neck-label print area.

4

Printing

After an order is received, the provider produces the selected product and variant.

5

Packaging

The finished product is inspected, packaged, and prepared for carrier pickup.

6

Shipping

The provider hands the package to the carrier and returns tracking information.

Local MySQL Storefront product and variant data
Shopify Customer order and checkout variant
Printify Production product and fulfillment variant
The critical technical job is variant mapping.

The selected color and size must connect the local storefront variant to the correct Shopify merchandise ID and the corresponding Printify production variant.

Why Automation Became Essential

The first version of a workflow is often manual. That is manageable for one product but quickly becomes a problem across a growing catalog.

Original workflow

Manual Product Setup

  1. Create the product in Printify
  2. Publish the product to Shopify
  3. Add the product to MySQL
  4. Copy platform and variant IDs
  5. Write descriptions and SEO data
  6. Assign the collection
  7. Download and organize images
  8. Check availability and prices
Current workflow

Tools and API Automation

  • Product import tools
  • Variant synchronization
  • Bulk price updates
  • Image download and organization
  • Description editors
  • Collection management
  • Review administration
  • Image resizing and compression
  • Description and alt-text generation
The rule behind the system

I built a tool whenever I caught myself doing the same tedious task repeatedly.

Doing the work manually once helped define the process. Automating it meant I could spend more time creating designs and stories instead of copying the same data between Printify, Shopify, MySQL, and local image folders.

Tools and Platforms I Used

The site was not built with one all-in-one platform. I used a mix of programming languages, hosting tools, ecommerce services, image editors, APIs, and small scripts that each solved a specific part of the workflow.

Store development

Frontend and Backend

These technologies build the pages, load product data, manage interactions, and connect the storefront to outside services.

PHP MySQL PDO HTML CSS JavaScript Python
Hosting and administration

Server and Database Tools

These tools handle hosting, file management, databases, PHP execution, caching, redirects, and day-to-day server maintenance.

cPanel phpMyAdmin Apache LiteSpeed
Commerce

Checkout and Store Operations

Shopify provides the customer checkout and order system while the custom PHP site controls the storefront experience.

Shopify Shopify Storefront API Cart and Checkout
Production and fulfillment

Print-on-Demand Platform

Printify connects the designs to blank products, print providers, production files, variants, packaging, and shipping.

Printify Printify API Fulfillment
Artwork and product images

Image Creation and Editing

I use GIMP and Pixlr to create, clean up, resize, composite, and prepare artwork and product images before they enter the store workflow.

GIMP Pixlr Mockup Generators Local Image Scripts
Automation and maintenance

Custom Store Tools

These are the tools I built to reduce repetitive work and keep product data synchronized between the storefront, Shopify, Printify, and the database.

Product Importers Bulk Price Tools Product Editors Variant Mapping API Debugging Tools
Search and product distribution

Marketing and Product Feeds

Product information can also be prepared and sent to outside discovery platforms without making those platforms the source of the storefront data.

Google Merchant Center Product Feeds SEO Tools
The stack grew around the work.

I did not choose every tool before building the site. I added technologies, platforms, and scripts as new problems appeared. When a task became repetitive, slow, or annoying, I either found a tool for it or built one.

Tools I Built for the Store

Most of these tools began with the same thought: I am doing this too often, and I do not want to keep doing it by hand.

Some became public tools that anyone can use. Others remain private administration tools connected directly to the store and its database.

Image preparation

Image Resizer

Different print areas, marketplaces, product pages, and social platforms require different dimensions. This creates correctly sized copies without repeatedly opening an image editor.

Open the Image Resizer
Website performance

Image Compressor

Production artwork needs to remain large, but storefront images need to load quickly. This creates smaller web copies while leaving the production master untouched.

Open the Image Compressor
File preparation

Image Format Converter

Print files, product pages, social images, and modern browsers do not always need the same format. This converts images between PNG, JPG, WebP, and AVIF.

Open the Format Converter
Artwork cleanup

Background Remover

Product artwork often needs a transparent background before it can be printed on different garment colors. This removes the background without requiring a full desktop editing workflow.

Open the Background Remover
Image composition

Image Cropper

Mockups, thumbnails, social images, and product photography often need a cleaner composition or exact aspect ratio before publishing.

Open the Image Cropper
Product content

AI Product Description Generator

Writing product descriptions and image alt text for every new design became another repetitive task. This analyzes an uploaded image and creates a useful starting point.

Open the Description Generator
URLs and SEO

URL Slug Generator

Product, collection, and guide titles can be converted into clean, consistent, URL-friendly text without manually removing punctuation and replacing spaces.

Open the Slug Generator
Search presentation

Meta Tag Generator

This creates the title, description, canonical, Open Graph, and related metadata needed to give products and pages a consistent search and sharing presentation.

Open the Meta Tag Generator
Social sharing

Social Preview Tool

This previews how a page title, description, and Open Graph image may appear when a product or guide is shared on social platforms.

Open the Social Preview Tool
Image protection

Watermark Tool

Product images and previews can be marked before they are shared, published, or sent for review while keeping the original file clean.

Open the Watermark Tool
Behind the storefront

Private Administration Tools

The public tools solve individual image and content problems. The private tools manage the actual store, database, products, platforms, and repetitive operational work.

Adding and editing products
Updating descriptions and SEO data
Managing collections and categories
Activating and deactivating products
Bulk price and margin updates
Synchronizing Printify product data
Matching Shopify and Printify variants
Downloading and organizing product images
Managing customer reviews
Tracking likes and purchase clicks
The tools are part of the same architecture.

The two-page storefront reduced the number of pages I had to maintain. The database reduced duplicated product data. The APIs reduced platform updates. These tools reduced the small repetitive jobs left between them.

Public Tools Built from the Store Workflow

How the Project Is Organized

The storefront is divided by responsibility. Public pages handle the customer experience, API endpoints handle browser requests, admin pages manage the catalog, and sensitive credentials remain outside the public web directory.

Public web directory

/public_html/

Files inside this directory can be served by the web server. Public PHP pages, styles, scripts, tools, and images live here.

Storefront

Public Pages

The primary customer-facing PHP pages.

  • index.php Catalog, collections, sorting, and product cards
  • shirt.php Dynamic product page used by every shirt
  • about.php Company story and brand information
  • sitemap.php Human-readable site navigation
Reusable PHP

/includes/

Shared page components prevent the same markup from being repeated across the site.

  • tcsc-head.php Metadata, canonical tags, and Open Graph content
  • tcsc-header.php Site navigation and collection links
  • tcsc-footer.php Shared footer content
  • product-card.php Reusable catalog product-card template
Presentation

/css/

Styles are separated by the part of the storefront they control.

  • site.css Global typography, layout, navigation, and utilities
  • catalog.css Product grid, cards, filters, and pagination
  • product.css Product gallery, variants, descriptions, and reviews
Browser behavior

/js/

JavaScript handles interactions after PHP has rendered the page.

  • catalog.js Filtering, sorting, pagination, and catalog behavior
  • product.js Color, size, image, and variant selection
  • cart.js Cart requests and Shopify checkout behavior
Browser endpoints

/api/

Small server-side endpoints receive JavaScript requests and return structured responses.

  • create-cart.php Creates a Shopify cart and returns its checkout URL
  • like-shirt.php Records product likes
  • submit-review.php Validates and stores customer reviews
Public utilities

/tools/

Public image and content tools created from the store workflow.

  • resizer.phpResize images
  • compressor.phpReduce image file size
  • converter.phpConvert image formats
  • bg-remover.phpRemove image backgrounds
  • crop.phpCrop images and aspect ratios
  • alt-text.phpGenerate descriptions and alt text
  • slug-gen.phpCreate URL-friendly slugs
  • meta-gen.phpGenerate page metadata
  • social-preview.phpPreview social sharing cards
  • watermark.phpAdd watermarks to images
Protected management

/admin/

Authenticated pages used to manage products and automate store operations.

  • index.php Administration dashboard
  • products.php Product list and management controls
  • edit-product.php Descriptions, collections, SEO, and product data
  • bulk-pricing.php Bulk retail price and margin updates
  • sync-printify.php Printify product and variant synchronization
Product assets

/images/

Product images are stored locally so normal page views do not depend on Printify or Shopify image requests.

  • /products/ Product mockups, artwork, front images, and back images
Outside the public web root

/private/

Sensitive configuration and service integrations are stored outside /public_html/ so they cannot be requested directly through a browser.

connection.php PDO database connection
config.php Environment and application settings
printify.php Printify API authentication and request helpers
shopify.php Shopify Storefront API configuration
logging.php Private application and API error logging
Public code and private credentials should remain separate.

Database passwords, Shopify tokens, Printify tokens, private API helpers, and detailed error logs should not be placed in a publicly accessible directory or committed to a public repository.

Complete Six-Part Build Series

This pillar guide explains the complete system. The chapters below break the implementation into focused technical guides.

Advantages and Tradeoffs

A custom storefront gives me control that a standard ecommerce theme does not, but that control comes with maintenance and responsibility.

What I gained

Advantages

Complete design control The storefront is not limited by a Shopify theme or another platform's page structure.
Custom product data Products and collections can use fields that do not exist in Printify or Shopify.
Local SEO control Titles, descriptions, canonical URLs, structured data, and social metadata are generated locally.
Fast database-driven pages Normal page views use local product data instead of waiting for external API requests.
One template for every product New shirts require database records rather than new PHP files.
Features built around the brand Likes, reviews, custom sorting, collection pages, and unusual product relationships can be added.
Shopify without a Shopify storefront Shopify handles the secure checkout while the custom site controls the customer-facing experience.
Workflow-specific automation The tools and APIs follow the way I actually create and manage products.
What I accepted

Tradeoffs

Code maintenance I am responsible for fixing bugs, updating features, and keeping the site compatible with PHP changes.
Security responsibility Database credentials, sessions, forms, uploads, and API tokens must be protected correctly.
Variant mapping Local, Shopify, and Printify variants must remain connected to the correct color and size.
Complex product logic Availability, price changes, color images, and multiple print areas can become complicated.
External platform changes Shopify or Printify API changes can require updates to local scripts and integrations.
More testing Admin tools, checkout, pricing, synchronization, and fulfillment workflows must be tested regularly.
Backups and logging The database, product images, configuration, and error logs need reliable backup procedures.
Longer initial build A custom system takes more time to create than installing a standard ecommerce theme.
The actual design goal

This was not designed as a perfect enterprise ecommerce platform.

It was designed to solve my specific problem with the least repetitive work possible. The extra technical responsibility was worthwhile because it gave me a system built around how I create, organize, and sell the shirts.

Who This Architecture Is For

This approach makes the most sense when control and custom behavior are more important than launching as quickly as possible.

A good fit

This Approach May Work for You

PHP developers Developers who want a real ecommerce project using PHP, MySQL, JavaScript, and external APIs.
Custom POD brands Sellers whose products, collections, or storytelling do not fit a normal theme.
Sellers who want more control Store owners who want to control product data, navigation, SEO, and page behavior themselves.
Printify sellers with local data Sellers who want a database-driven catalog instead of relying entirely on platform data.
Custom Shopify storefronts Developers who want Shopify checkout without using a standard Shopify storefront.
People who like automation Anyone who would rather build a tool than repeatedly perform the same manual task.
Probably not the best fit

Use a Hosted Store Instead

A standard Shopify theme or another hosted ecommerce builder is probably the better choice when:

  • You want to launch a normal store as quickly as possible.
  • You do not want to write or maintain backend code.
  • Your catalog works well with standard product and collection templates.
  • You do not need unusual database fields or custom workflows.
  • You would rather pay for apps than build integrations.
  • You do not want responsibility for server security, backups, API maintenance, and debugging.

Custom code is valuable when it solves a real limitation. It should not be added only because building everything yourself sounds more impressive.

Building a Custom Print-on-Demand Store FAQ

These are the most common questions about separating the storefront, checkout, fulfillment, and local product database.

Can I build a print-on-demand website without using a Shopify theme?

Yes. A custom PHP website can display products and manage the customer-facing storefront while Shopify handles the cart and checkout through the Storefront API.

Why use Shopify only for checkout?

Using Shopify only for checkout provides control over the storefront design and local product database while retaining Shopify payments, checkout security, taxes, order handling, and ecommerce infrastructure.

What does Printify do in this architecture?

Printify provides product manufacturing and fulfillment. Product and variant data can be synchronized through the Printify API while Shopify receives and processes the customer order.

Why use a local MySQL database?

A local database allows the store to control product titles, descriptions, collections, images, prices, SEO fields, likes, reviews, and other custom data without requesting it from an external API on every page load.

Why did you build the store around two PHP pages?

One page generates the catalog and collection views, while another generates every individual product page. Product information comes from the database, so adding a shirt does not require creating another webpage.

Do I need to be an advanced programmer to follow this guide?

Basic familiarity with HTML, CSS, PHP, MySQL, and JavaScript is useful. The series explains the architecture and individual components, but readers should still understand server configuration and secure coding basics.

Can this architecture support hundreds of products?

Yes. The database-driven structure can support a large catalog when queries, indexes, image handling, pagination, caching, and synchronization processes are designed carefully.

Can I use WooCommerce instead of Shopify?

Yes, but the checkout integration, product synchronization, authentication, and order flow would need to be rewritten for WooCommerce.

Can I use another print-on-demand provider?

Yes. The same general architecture can work with another provider if it offers suitable products, fulfillment services, and API access.

Why not request Printify and Shopify data on every page load?

External API requests are slower, can fail, consume rate limits, and make the storefront dependent on another service being available. The local database acts as a fast storefront cache and content-management layer.

What custom tools are included in the project?

The project includes image resizing, compression, format conversion, product-description generation, alt-text generation, URL slug creation, product administration, bulk pricing, and API synchronization tools.

Is this a complete ecommerce platform?

The custom site handles product presentation, catalog data, content, and storefront features. Shopify handles the secure checkout and payment system, while Printify handles production and fulfillment.

Continue to Part 1

Start by building the database, folder structure, PDO connection, product records, collections, variants, and two-page PHP architecture.

0
cart