WP Manifestindependent plugin directory
manifest / ecommerce / wp_promocodes

Checkout Promo Codes

Checkout promo-codes for WordPress that don't require a defined product catalog

★ 1stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/randomingenuity/wp_promocodes/archive/refs/heads/master.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

WordPress plugin for creating and validating promo codes on custom checkout flows.

Requirements

  • WordPress 6.0+
  • PHP 8.0+

Install

  1. Copy checkout-promo-codes to wp-content/plugins/
  2. Activate Checkout Promo Codes in wp-admin
  3. Create codes under Promo Codes

Integration

$context = array(
    'subtotal' => 224.00,
    'currency' => 'USD',
    'user_id'  => get_current_user_id(),
    'email'    => 'customer@example.com',
    'items'    => $cart_items,
);

$result = checkout_promo_codes_validate( 'SAVE10', $context );
if ( is_wp_error( $result ) ) {
    // handle invalid code
}

$discounted_total = $result->total;

After payment succeeds:

checkout_promo_codes_redeem(
    (int) $result->promo['id'],
    array_merge( $context, array( 'order_ref' => (string) $order_id ) ),
    array( 'order_reference' => (string) $order_id )
);

REST API

POST /wp-json/checkout-promo-codes/v1/validate

{
  "code": "SAVE10",
  "subtotal": 224,
  "email": "customer@example.com"
}

Companion integrations may pass integration and cartItems for server-side subtotal resolution.

Documentation

License

GPLv2 or later