WP Manifestindependent plugin directory
manifest / ecommerce / wp_promocodes

Checkout Promo Codes

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

by 717 Tickets · github.com/randomingenuity/wp_promocodes

1stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/randomingenuity/wp_promocodes/archive/refs/heads/master.zip

Readme

Checkout Promo Codes

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

Read the full README on GitHub →