Closed mark-chief closed 11 months ago
Hi @mark-chief you can use the beforeCreateSession Event If you want to create a session with an applied discount (docs), in your custom module/plugin you may need something like:
use enupal\stripe\services\Checkout;
use enupal\stripe\events\CheckoutEvent;
use enupal\stripe\Stripe;
use craft\base\Plugin;
use Craft;
class YourPlugin extends Plugin
{
public function init()
{
....
....
Event::on(Checkout::class, Checkout::EVENT_BEFORE_CREATE_SESSION, function(CheckoutEvent $e) {
$isCart = $e->isCart;
$sessionParams = $e->sessionParams;
//overwrite $sessionParams
$sessionParams['discounts'] = [['coupon' => 'COUPON_ID']];
$e->sessionParams = $sessionParams;
});
...
...
}
}
You have full control here about your checkout session, here the stripe docs with all the properties you can overwrite
Description
How can I apply a flat 20% discount to the cart? I have tried to add it as a negative line item but stripe doesn't allow negatives.
I have also tried adjusting the total in the options but it still calculates the total base don the lineitems.
calculateFinalAmount: false,
doesnt appear to work, if I think I know what its supposed to do.. but no info in docs on thatSteps to reproduce
1. 2.
Additional info