Skip to navigation Skip to main content
Smart Cycle Discounts is now available on WordPress.org — Download Free
🎉 SCD is now available — Download Free
  • WordPress
    WordPress Plugins
    View all
    Smart Cycle Discounts A cycling discount mark: rotating arrows around a center badge that cycles commerce icons.

    Smart Cycle Discounts

    Automate discount campaigns with scheduling, analytics, and smart product targeting.

    5 Discount Types Recurring Campaigns
    Free Pro from $59

    TrustLens

    Customer trust intelligence for WooCommerce. Score customers, spot abuse, protect revenue.

    Trust Scores Abuse Detection
    Free Pro from $79

    New Plugin

    Coming Soon

    Something exciting is in the works. Join the waitlist to be first to know.

    Get Notified
    Notify Me
    Secure Checkout
    WordPress.org
    14-Day Refund
    Resources
    Documentation Guides & tutorials
    Discount Calculator Plan your strategy
    Support Get help
    Changelog What's new
    Get notified on new releases
  • Affiliate
  • Blog
  • DOCS
    Documentation

    Choose a plugin to explore its documentation

    Smart Cycle Discounts Automated discount campaigns for WooCommerce
    Available
    New Plugin Something exciting is in development
    Coming Soon
    New Plugin Something exciting is in development
    Coming Soon
    Docs Home FAQ Get Support
    WordPress tools that solve real problems
  • Contact Us
  • About
    Company

    Our Story

    Founded 2020

    Built by store owners, for store owners. We create WordPress tools that solve real problems.

    Learn more
    Built from Experience Real solutions we use ourselves
    Time is Precious Simple, intuitive tools
    Real Support Talk to the founders
    Legal & Contact
    Contact Us Privacy Policy Terms of Service Refund Policy
    14-Day Money-Back Guarantee No questions asked
GET STARTED

Getting Started

5
  • What is Smart Cycle Discounts?
  • Installation Guide
  • Creating Your First Campaign
  • Plugin Dashboard Overview
  • Free & Pro Features

Campaign Wizard

7
  • Campaign Wizard Overview
  • Step 1 – Basic Information
  • Step 2 – Product Selection
  • Step 3 – Discount Configuration
  • Step 4 – Campaign Scheduling
  • Step 5 – Review & Launch
  • Campaign Health Scoring

Product Selection

5
  • All Products Mode
  • Specific Products Mode
  • Random Products Mode
  • Smart Selection Mode
  • Product Search Tips

Discount Types

7
  • Percentage Discounts
  • Fixed Amount Discount
  • Buy One Get One (BOGO)
  • Tiered Volume Pricing
  • Spend Threshold Discounts
  • Bundle Discounts
  • Discount Stacking and Priority

Scheduling

5
  • Setting Campaign Dates
  • Timezone Configuration
  • Recurring Campaigns
  • Campaign Status Explained
  • Automatic Activation

Campaign Management

6
  • Campaign List
  • Editing Existing Campaigns
  • Duplicating Campaigns
  • Bulk Actions
  • Campaign Priority System
  • Campaign Overview Panel

Notifications

5
  • Email Provider Setup
  • Email Notifications Setup
  • Basic Notifications
  • Proactive Alerts
  • Low Stock Alerts

Setting Configuration

5
  • General Settings
  • Display Settings
  • Advanced Settings
  • Tools and Diagnostics
  • License Management

Use Cases

7
  • Flash Sale Campaign
  • Seasonal Sale Campaign
  • Weekend Sale Recurring
  • BOGO Promotion
  • Volume Discount Campaign
  • Cart Threshold Promotion
  • Bundle Discount Campaign

Developer Documentation

5
  • Hooks and Filters Reference
  • Rest API Overview
  • Custom Discount Integration
  • Template Customization
  • Database Schema

Troubleshooting

6
  • Campaign Not Activating
  • Discounts Not Displaying
  • Scheduling Issues
  • Product Search Not Working
  • Performance Optimization
  • Common Error Messages

FAQ

3
  • General
  • Compatibility
  • Pricing & Licensing
View Categories
  • Home
  • Docs
  • Smart Cycle Discounts
  • Developer Documentation
  • Custom Discount Integration

Custom Discount Integration

4 min read

This guide covers how to integrate Smart Cycle Discounts with custom code, other plugins, and external systems. Learn how to programmatically interact with campaigns and discounts.


Checking if Plugin is Active #

PHP Check #

// Check if Smart Cycle Discounts is active
if ( class_exists( 'Smart_Cycle_Discounts' ) ) {
    // Plugin is active, safe to use SCD functions
}

// Or check for main class
if ( function_exists( 'SCD' ) ) {
    $scd = wsscd();
}

Wait for Plugin Load #

add_action( 'plugins_loaded', function() {
    if ( ! class_exists( 'Smart_Cycle_Discounts' ) ) {
        return;
    }

    // Your integration code here
}, 20 );

Getting Campaign Information #

Get All Active Campaigns #

$campaign_manager = wsscd()->get_service( 'campaign_manager' );
$active_campaigns = $campaign_manager->get_active_campaigns();

foreach ( $active_campaigns as $campaign ) {
    echo $campaign->get_name();
    echo $campaign->get_discount_value();
}

Get Campaign by ID #

$campaign = $campaign_manager->get_campaign( 123 );

if ( $campaign ) {
    $name = $campaign->get_name();
    $status = $campaign->get_status();
    $discount_type = $campaign->get_discount_type();
    $discount_value = $campaign->get_discount_value();
}

Check Campaign Status #

$campaign = $campaign_manager->get_campaign( 123 );

if ( $campaign->is_active() ) {
    // Campaign is currently active
}

if ( $campaign->is_scheduled() ) {
    // Campaign is scheduled for future
}

Getting Product Discounts #

Get Discounted Price for Product #

$discount_engine = wsscd()->get_service( 'discount_engine' );

$product_id = 45;
$original_price = 100.00;

$discounted_price = $discount_engine->get_discounted_price( $product_id, $original_price );

if ( $discounted_price !== $original_price ) {
    echo "Product is on sale: " . wc_price( $discounted_price );
}

Get Campaign Applying to Product #

$campaign = $discount_engine->get_campaign_for_product( $product_id );

if ( $campaign ) {
    echo "Discount from: " . $campaign->get_name();
}

Check if Product Has Any Discount #

$has_discount = $discount_engine->product_has_discount( $product_id );

if ( $has_discount ) {
    // Product is in an active campaign
}

Get All Discounted Products #

$campaign_id = 123;
$product_ids = $campaign_manager->get_campaign_products( $campaign_id );

// Returns array of product IDs

Creating Campaigns Programmatically #

Create a Simple Campaign #

$campaign_data = array(
    'name'            => 'API Created Campaign',
    'status'          => 'draft',
    'priority'        => 3,
    'discount_type'   => 'percentage',
    'discount_value'  => 25,
    'start_date'      => '2025-07-01 00:00:00',
    'end_date'        => '2025-07-31 23:59:59',
    'product_selection' => array(
        'type' => 'all',
    ),
);

$campaign_id = $campaign_manager->create_campaign( $campaign_data );

if ( $campaign_id ) {
    // Campaign created successfully
    $campaign_manager->activate_campaign( $campaign_id );
}

Create Campaign with Conditions #

$campaign_data = array(
    'name'            => 'Category Sale',
    'status'          => 'scheduled',
    'priority'        => 3,
    'discount_type'   => 'percentage',
    'discount_value'  => 20,
    'start_date'      => '2025-07-01 00:00:00',
    'end_date'        => '2025-07-31 23:59:59',
    'product_selection' => array(
        'type' => 'conditions',
        'conditions' => array(
            array(
                'field'    => 'category',
                'operator' => 'equals',
                'value'    => 'summer-collection',
            ),
        ),
    ),
);

$campaign_id = $campaign_manager->create_campaign( $campaign_data );

Modifying Campaigns #

Update Campaign Settings #

$campaign_id = 123;

$update_data = array(
    'discount_value' => 30,
    'end_date'       => '2025-08-15 23:59:59',
);

$campaign_manager->update_campaign( $campaign_id, $update_data );

Activate/Pause Campaign #

// Activate
$campaign_manager->activate_campaign( $campaign_id );

// Pause
$campaign_manager->pause_campaign( $campaign_id );

// Resume
$campaign_manager->resume_campaign( $campaign_id );

Delete Campaign #

$campaign_manager->delete_campaign( $campaign_id );

Working with Analytics #

Get Campaign Analytics #

$analytics = wsscd()->get_service( 'analytics_controller' );

$campaign_id = 123;
$data = $analytics->get_campaign_analytics( $campaign_id, array(
    'start_date' => '2025-06-01',
    'end_date'   => '2025-06-30',
) );

echo "Revenue: " . wc_price( $data['revenue'] );
echo "Conversions: " . $data['conversions'];

Track Custom Event #

$activity_tracker = wsscd()->get_service( 'activity_tracker' );

$activity_tracker->track( array(
    'event_type'  => 'custom_event',
    'campaign_id' => 123,
    'data'        => array( 'custom_field' => 'value' ),
) );

Integration Examples #

Member-Only Discounts #

add_filter( 'wsscd_is_product_eligible_for_discount', function( $eligible, $product, $context ) {
    if ( ! $eligible ) {
        return false;
    }

    $campaign_id = isset( $context['campaign_id'] ) ? (int) $context['campaign_id'] : 0;
    $members_only = $campaign_id ? get_post_meta( $campaign_id, '_members_only', true ) : false;

    if ( $members_only && ! is_user_logged_in() ) {
        return false;
    }

    return $eligible;
}, 10, 3 );

Time-Based Dynamic Discounts #

add_filter( 'wsscd_is_discount_rule_applicable', function( $applicable, $product_id, $rule, $context ) {
    if ( ! $applicable ) {
        return false;
    }

    // Example: block one rule during a specific hour window.
    $hour = (int) current_time( 'G' );
    if ( $hour >= 16 && $hour < 18 && isset( $rule['name'] ) && 'Happy Hour' !== $rule['name'] ) {
        return false;
    }

    return $applicable;
}, 10, 4 );

Custom Stock-Based Exclusions #

add_filter( 'wsscd_is_product_eligible_for_discount', function( $eligible, $product, $context ) {
    if ( ! $eligible ) {
        return false;
    }

    // Exclude low-stock products
    if ( $product instanceof WC_Product && $product->get_stock_quantity() < 5 ) {
        return false;
    }

    return true;
}, 10, 3 );

External System Integration #

// Sync campaigns to external system when campaign status changes to active.
add_action( 'wsscd_campaign_status_changed', function( $campaign, $from, $to ) {
    if ( 'active' !== $to ) {
        return;
    }

    $api_endpoint = 'https://external-system.com/api/campaigns';

    wp_remote_post( $api_endpoint, array(
        'body' => json_encode( array(
            'external_id'    => $campaign->get_id(),
            'name'           => $campaign->get_name(),
            'discount_type'  => $campaign->get_discount_type(),
            'discount_value' => $campaign->get_discount_value(),
            'start_date'     => $campaign->get_start_date() ? $campaign->get_start_date()->format( 'c' ) : null,
            'end_date'       => $campaign->get_end_date() ? $campaign->get_end_date()->format( 'c' ) : null,
        ) ),
        'headers' => array(
            'Content-Type' => 'application/json',
            'Authorization' => 'Bearer ' . EXTERNAL_API_KEY,
        ),
    ) );
}, 10, 3 );

Cache Considerations #

Clear Cache After Changes #

// Clear campaign cache
$cache_manager = wsscd()->get_service( 'cache_manager' );
$cache_manager->clear_campaign_cache( $campaign_id );

// Clear all plugin cache
$cache_manager->clear_all();

Bypass Cache for Custom Queries #

$discount_engine = wsscd()->get_service( 'discount_engine' );

// Get price without using cache
$price = $discount_engine->get_discounted_price( $product_id, $original_price, array(
    'bypass_cache' => true,
) );

Error Handling #

Try-Catch Pattern #

try {
    $campaign_id = $campaign_manager->create_campaign( $data );
} catch ( WSSCD_Exception $e ) {
    error_log( 'SCD Error: ' . $e->getMessage() );
    // Handle error appropriately
}

Validation Before Operations #

$validation = wsscd()->get_service( 'validation' );

$errors = $validation->validate_campaign_data( $campaign_data );

if ( ! empty( $errors ) ) {
    foreach ( $errors as $field => $message ) {
        echo "Error in {$field}: {$message}";
    }
} else {
    // Safe to create campaign
    $campaign_manager->create_campaign( $campaign_data );
}
Updated on February 17, 2026

What are your Feelings

  • Happy
  • Normal
  • Sad

Share This Article :

  • Facebook
  • X
  • LinkedIn
  • Pinterest
Rest API OverviewTemplate Customization
Table of Contents
  • Checking if Plugin is Active
    • PHP Check
    • Wait for Plugin Load
  • Getting Campaign Information
    • Get All Active Campaigns
    • Get Campaign by ID
    • Check Campaign Status
  • Getting Product Discounts
    • Get Discounted Price for Product
    • Get Campaign Applying to Product
    • Check if Product Has Any Discount
    • Get All Discounted Products
  • Creating Campaigns Programmatically
    • Create a Simple Campaign
    • Create Campaign with Conditions
  • Modifying Campaigns
    • Update Campaign Settings
    • Activate/Pause Campaign
    • Delete Campaign
  • Working with Analytics
    • Get Campaign Analytics
    • Track Custom Event
  • Integration Examples
    • Member-Only Discounts
    • Time-Based Dynamic Discounts
    • Custom Stock-Based Exclusions
    • External System Integration
  • Cache Considerations
    • Clear Cache After Changes
    • Bypass Cache for Custom Queries
  • Error Handling
    • Try-Catch Pattern
    • Validation Before Operations
Newsletter

Insights that grow your business

Join thousands of WooCommerce store owners who get actionable tips, plugin updates, and industry news every week.

We respect your privacy. Unsubscribe at any time.

Weekly updates — Fresh content every Tuesday
Exclusive content — Tips you won't find on our blog
Early access — Be first to know about new plugins
Webstepper
Weekly WooCommerce Tips
Just now
This week: 5 proven strategies to boost your average order value using smart discount campaigns...
New issue!
Webstepper

Tools for store owners who'd rather grow than grind.

Simple, powerful plugins that help WooCommerce store owners sell more — without the learning curve.

500+ happy stores

Products

  • Smart Cycle Discounts
  • Pricing
  • Documentation
  • Changelog

Company

  • About Us
  • Blog
  • Contact
  • Affiliates

Resources

  • Help Center
  • Guides
  • Roadmap
  • Status

Questions? We actually answer.

Real humans, real help. No bots, no runaround. Usually within a few hours.

Get in touch

© 2026 Webstepper. All rights reserved.

Privacy Terms Refunds
Visa Mastercard PayPal Apple Pay Google Pay & more
  • WordPress
    Back
    WordPress Plugins
    View all
    Smart Cycle Discounts A cycling discount mark: rotating arrows around a center badge that cycles commerce icons.

    Smart Cycle Discounts

    Automate discount campaigns with scheduling, analytics, and smart product targeting.

    5 Discount Types Recurring Campaigns
    Free Pro from $59

    TrustLens

    Customer trust intelligence for WooCommerce. Score customers, spot abuse, protect revenue.

    Trust Scores Abuse Detection
    Free Pro from $79

    New Plugin

    Coming Soon

    Something exciting is in the works. Join the waitlist to be first to know.

    Get Notified
    Notify Me
    Secure Checkout
    WordPress.org
    14-Day Refund
    Resources
    Documentation Guides & tutorials
    Discount Calculator Plan your strategy
    Support Get help
    Changelog What's new
    Get notified on new releases
  • Affiliate
  • Blog
  • DOCS
    Back
    Documentation

    Choose a plugin to explore its documentation

    Smart Cycle Discounts Automated discount campaigns for WooCommerce
    Available
    New Plugin Something exciting is in development
    Coming Soon
    New Plugin Something exciting is in development
    Coming Soon
    Docs Home FAQ Get Support
    WordPress tools that solve real problems
  • Contact Us
  • About
    Back
    Company

    Our Story

    Founded 2020

    Built by store owners, for store owners. We create WordPress tools that solve real problems.

    Learn more
    Built from Experience Real solutions we use ourselves
    Time is Precious Simple, intuitive tools
    Real Support Talk to the founders
    Legal & Contact
    Contact Us Privacy Policy Terms of Service Refund Policy
    14-Day Money-Back Guarantee No questions asked