Add validation to coupon code

This commit is contained in:
David Bomba 2023-03-01 14:47:04 +11:00
parent f67959fb06
commit 8247ff41e4
3 changed files with 16 additions and 1 deletions

View File

@ -271,6 +271,10 @@ class BillingPortalPurchasev2 extends Component
*/
public function handleCoupon()
{
$this->resetErrorBag('coupon');
$this->resetValidation('coupon');
if ($this->coupon == $this->subscription->promo_code) {
$this->valid_coupon = true;
$this->buildBundle();
@ -278,6 +282,9 @@ class BillingPortalPurchasev2 extends Component
$this->discount = 0;
$this->valid_coupon = false;
$this->buildBundle();
$errors = $this->getErrorBag();
$errors->add('coupon', ctrans('texts.invalid_coupon'));
return $this;
}
}

View File

@ -5010,6 +5010,7 @@ $LANG = array(
'change_plan_description' => 'Upgrade or downgrade your current plan.',
'add_company_logo' => 'Add Logo',
'add_stripe' => 'Add Stripe',
'invalid_coupon' => 'Invalid Coupon',
);

View File

@ -253,6 +253,14 @@
<span>{{ ctrans('texts.apply') }}</span>
</button>
</div>
@if($errors && $errors->has('coupon'))
@error("coupon")
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
<span class="block sm:inline text-sm">{{ $message }} </span>
<span class="absolute top-0 bottom-0 right-0 px-4 py-3">
</div>
@enderror
@endif
</div>
</form>
@endif
@ -347,7 +355,6 @@
<span class="absolute top-0 bottom-0 right-0 px-4 py-3">
</div>
@enderror
</div>
</form>
@endif