Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ChrisF93's avatar

Spark Coupon code set automatically to blank as default

I'm currently in the process of implementing Spark promotions within my application upon user signup. Having read the documentation I have the following 2 pieces of code: Spark::promotion('Coupon'); in my SparkServiceProvider

and the following

public static function promotion($coupon = null) {

    if (is_null($coupon)) {
        return static::$promotion;
    } else {
        static::$promotion = $coupon;
    }
}

within src/Configuration/ManagesAvailablePlans.php.

The code works as expected and if a valid coupon is entered then the discount is applied and a user is created.

However currently when the sign up page is loaded the word coupon is set as default within input box, ideally I would like the default to be blank. So far I have tried Spark::promotion(''); and Spark::promotion(null); however neither of these produce the desired effect, instead the input box just disappears.

Is there a way for the Spark::promotion section to be set as default blank?

0 likes
0 replies

Please or to participate in this conversation.