Checkout Promo Codes
Checkout promo-codes for WordPress that don't require a defined product catalog
★ 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.zipReadme
Checkout Promo Codes
WordPress plugin for creating and validating promo codes on custom checkout flows.
Requirements
- WordPress 6.0+
- PHP 8.0+
Install
- Copy
checkout-promo-codestowp-content/plugins/ - Activate Checkout Promo Codes in wp-admin
- 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
- docs/INTEGRATION.md
- docs/HOOKS.md
- docs/REST-API.md
- docs/ADMIN.md
- docs/SECURITY.md
- docs/DATA-MODEL.md
License
GPLv2 or later