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 logo

    Smart Cycle Discounts

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

    7 Discount Types Cycle AI
    Free Pro from $59
    TrustLens logo

    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
    SCD Changelog Discount plugin updates
    TrustLens Changelog Trust intelligence updates
    Get notified on new releases
  • Affiliate
    Program
    Overview How the program works
    How It Works 4 steps from apply to earn
    Commission Details 30% · 60-day cookie · recurring
    Get Started
    Apply Now Open
    Takes ~2 minutes
    Earnings Calculator Estimate your monthly income
    FAQ Payouts, cookies, renewals
    Resources
    Brand Kit Logos, banners, copy, social
    Playbook Tactics that actually convert
    FTC Disclosure How to disclose properly
    Affiliate Terms Full program agreement
    Contact Team Open the contact form
    Earn 30% recurring on every sale Free to join · 60-day cookie · monthly PayPal payouts
    Apply Now
  • Blog
  • DOCS
    Docs & Resources

    Choose a plugin or WooCommerce resource to keep moving

    Smart Cycle Discounts Automated discount campaigns for WooCommerce
    Available
    TrustLens Customer trust intelligence documentation for WooCommerce
    Live
    Docs Home FAQ Calculator 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

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

Product Selection

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

Discount Types

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

Scheduling

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

Campaign Management

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

Setting Configuration

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

Use Cases

8
  • Coupon Code Campaign
  • 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

Notifications

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

Cycle AI

6
  • What is Cycle AI
  • Creating Campaign With AI
  • Refining With Conversation
  • Managing Campaigns With AI
  • Prompt Writing Tips
  • Rate Limit And Troubleshooting
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
  • TrustLens
  • Discount Calculator
  • Sale Calendar

Company

  • About Us
  • Blog
  • Contact
  • Affiliates

Resources

  • Help Center
  • Guides
  • Roadmap
  • Status
  • Affiliate Program
  • Become a Partner

Questions? We actually answer.

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

Get in touch
Operated by Setmood LLC · 7901 4th St N, St Petersburg, FL 33702 · United States

© 2026 Webstepper. All rights reserved.

Privacy Terms Refunds
Visa Mastercard PayPal Apple Pay Google Pay & more
Limited Time Offer

Save 15% on
SCD, TrustLens & the Bundle

Smart Cycle Discounts and TrustLens — buy either plugin or grab both in the bundle. Use code at checkout.

WELCOME15
23 hours
:
59 minutes
:
59 seconds
Claim My Discount

  • WordPress
    Back
    WordPress Plugins
    View all
    Smart Cycle Discounts logo

    Smart Cycle Discounts

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

    7 Discount Types Cycle AI
    Free Pro from $59
    TrustLens logo

    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
    SCD Changelog Discount plugin updates
    TrustLens Changelog Trust intelligence updates
    Get notified on new releases
  • Affiliate
    Back
    Program
    Overview How the program works
    How It Works 4 steps from apply to earn
    Commission Details 30% · 60-day cookie · recurring
    Get Started
    Apply Now Open
    Takes ~2 minutes
    Earnings Calculator Estimate your monthly income
    FAQ Payouts, cookies, renewals
    Resources
    Brand Kit Logos, banners, copy, social
    Playbook Tactics that actually convert
    FTC Disclosure How to disclose properly
    Affiliate Terms Full program agreement
    Contact Team Open the contact form
    Earn 30% recurring on every sale Free to join · 60-day cookie · monthly PayPal payouts
    Apply Now
  • Blog
  • DOCS
    Back
    Docs & Resources

    Choose a plugin or WooCommerce resource to keep moving

    Smart Cycle Discounts Automated discount campaigns for WooCommerce
    Available
    TrustLens Customer trust intelligence documentation for WooCommerce
    Live
    Docs Home FAQ Calculator 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
We use cookies to improve your experience on our website. By browsing this website, you agree to our use of cookies.
More info More info Accept