Exclusive Content
Unlocking with one-time purchases
For more complex membership setups involving recurring subscriptions, my other plugin, Kirby Klub, may be a better option. However, you can still use the Kirby Kart plugin to unlock content or services based on customers purchasing single products with one-time payments.
<?php
$product = page('products/vip-access');
if ($product->ownedByUser(kirby()->user())) {
}
// alternative
if (kirby()->user()?->hasPurchased($product)) {
}
You could use this approach to forward specific flags to the provider's checkout callback as well.
site/config/config.php
<?php
return [
'bnomei.kart.provider.stripe.checkout_options' => function (\Bnomei\Kart\Kart $kart) {
// https://docs.stripe.com/api/checkout/sessions/create
return [
'discounts' => array_filter([
'coupon' => page('products/vip-access')->ownedByUser() ? 'VIP_ACCESS' : null,
]),
];
},
// other options
];
Creating Subscriptions
Since you have full control over the checkout_options
, as shown in the example for Stripe above, you could transform a checkout session from the payment mode to the subscription mode and create subscriptions. If you need something like that consider using the Klub plugin, booking a call or hiring me.