The WPSmartPay Products System provides comprehensive functionality for managing digital products, including product creation, updates, deletion, and purchase validation. This system includes hooks for product lifecycle management and custom purchase logic.

Action Hooks

smartpay_product_created / smartpay_product_updated / smartpay_product_deleted

Fires: On product created, updated and deleted

Parameters:

  • $product (SmartPay\Models\Product) - Product Model

add_action('smartpay_product_created', function( $product ) {
// Index product in search service or sync to external systems
});

add_action('smartpay_product_updated', function($product) {
// Sync changes or Update cache
});

// Product deleted
add_action('smartpay_product_deleted', function($product) {
// Clean up data or Archive product
});

smartpay_product_modal_popup_content / smartpay_before_product_payment_form_button / smartpay_after_product_payment_form_button

Fires: Within the modal checkout UI to inject content before/after the pay button.

Parameters:

  • $product (SmartPay\Models\Product|null)

add_action('smartpay_product_modal_popup_content', function( $product ) {
echo '<p class="text-muted">Secure checkout</p>';
});

Filter Hooks

smartpay_product_is_purchasable

Fires: When checking if a product can be purchased.

Parameters:

  • $isPurchasable (bool) — Default purchasable state.

  • $product (SmartPay\Models\Product) — Product Model.

add_filter('smartpay_product_is_purchasable', function( $is_purchasable, $product ) {
return $product->status === 'publish' ? $is_purchasable : false;
}, 10, 2);

Common Use Cases

  • Product validation

  • Stock management

  • Access control

  • User permissions

  • Product analytics