DEV Community

Hiren Gediya
Hiren Gediya

Posted on

How I Built a Flash Sale System for WooCommerce Without Changing Product Prices

Running a flash sale in WooCommerce sounds simple.

For example:

Give customers 20% off selected products from 6 PM to midnight.

But once you start building this into a real WooCommerce store, things become more complicated.

You need to think about scheduling, product selection, product variations, existing sale prices, cart calculations, campaign expiration, and what happens when multiple promotions are active at the same time.

I ran into these problems while working on WooCommerce projects, and they eventually led me to build my own promotion system.

The Problem

The traditional WooCommerce approach is often to change a product's sale price or create a coupon.

Both approaches can work, but they don't always fit the way a store owner wants to run a campaign.

Imagine a store wants to run:

  • 20% off selected products
  • A flash sale for 4 hours
  • A weekend promotion
  • A Buy One Get One offer
  • A discount for a specific product category

The store owner shouldn't have to manually change product prices every time a campaign starts or ends.

I wanted the promotion itself to control when and where the discount was applied.

Building the Campaign System

I started designing promotions around a few basic pieces of information:

  • Campaign type
  • Start date and time
  • End date and time
  • Discount type
  • Discount amount
  • Products or categories
  • Campaign status

This made it possible to treat a promotion as a campaign rather than simply changing a product's price.

For example:

Weekend Flash Sale

Start: Friday 6:00 PM

End: Sunday 11:59 PM

Products: Selected products

Discount: 20%

Once the campaign is active, the promotional rules can be applied without requiring the store owner to manually update every product.

The WooCommerce Side

One of the interesting parts of building this system was figuring out where WooCommerce should apply the campaign logic.

WooCommerce provides hooks and filters that can be used to work with product prices and cart calculations.

The important part isn't simply applying a discount.

The discount needs to behave correctly throughout the shopping experience:

  • Product pages
  • Shop pages
  • Cart
  • Checkout
  • Order totals

You also need to consider variable products, existing sale prices, and different campaign conditions.

A discount that looks correct on the product page but behaves differently in the cart isn't a successful implementation.

Check Out the Project

If you'd like to see the WooCommerce plugin I built from this experience:

PromoForge – Smart Campaigns for WooCommerce

https://hirengediya.com/projects/promoforge-smart-campaigns-for-woocommerce/

PromoForge includes tools for Flash Sales, BOGO offers, scheduled discounts, and product/category-based promotions.

I'd love to hear your feedback or your experience with building and managing WooCommerce promotions.

Top comments (0)