From 1b3642624244dadaf9ed008cfa7bccb63b379dbc Mon Sep 17 00:00:00 2001 From: Luke Holder Date: Tue, 15 Oct 2024 10:35:25 +0800 Subject: [PATCH] Fix PHP error when subscribing --- CHANGELOG.md | 4 ++++ src/controllers/SubscriptionsController.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d16c4aa326..6f456f3268 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft Commerce +## Unreleased + +- Fixed a PHP error that could occur when creating a subscription. ([#3710](https://github.com/craftcms/commerce/issues/)) + ## 4.6.13 - 2024-10-02 - Fixed a PHP error that could occur when deleting a user with orders. ([#3686](https://github.com/craftcms/commerce/issues/3686)) diff --git a/src/controllers/SubscriptionsController.php b/src/controllers/SubscriptionsController.php index d020da650a..33d478bdd7 100644 --- a/src/controllers/SubscriptionsController.php +++ b/src/controllers/SubscriptionsController.php @@ -236,7 +236,7 @@ public function actionSubscribe(): ?Response $error = $exception->getMessage(); } - if ($returnUrl) { + if (!$error && $returnUrl) { $returnUrl = $this->getView()->renderObjectTemplate($returnUrl, $subscription); $subscriptionRecord = SubscriptionRecord::findOne($subscription->id); $subscriptionRecord->returnUrl = $returnUrl;