From c27f0c3a27592170f1a974b8f405f73f15506aa8 Mon Sep 17 00:00:00 2001 From: NiclasNorin Date: Tue, 30 Jun 2026 15:14:12 +0200 Subject: [PATCH] feat: adding buy renew for profile --- .../KulturkortetProfileEditorAuthViewFactory.php | 12 ++++++++++-- .../KulturkortetProfileEditorFeature.php | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/library/Kulturkortet/ProfileEditor/KulturkortetProfileEditorAuthViewFactory.php b/library/Kulturkortet/ProfileEditor/KulturkortetProfileEditorAuthViewFactory.php index 89bf375bc..96bc71c91 100644 --- a/library/Kulturkortet/ProfileEditor/KulturkortetProfileEditorAuthViewFactory.php +++ b/library/Kulturkortet/ProfileEditor/KulturkortetProfileEditorAuthViewFactory.php @@ -74,7 +74,7 @@ public function whenAuthenticated(MunicipioAuthenticatedUserInterface $user, Mun 'email' => $ticket['email'] ?? '', ], 'saveUrl' => $navigation->getModifiedHomeUrl(removeQueryArgs: ['action']), - 'actions' => $this->getActions($navigation), + 'actions' => $this->getActions($navigation, true), 'logoutUrl' => $navigation->getModifiedHomeUrl(addQueryArgs: ['action' => 'logout']), 'ticket' => [ 'validUntil' => $this->formatDate($ticket['validUntil'] ?? null), @@ -82,7 +82,7 @@ public function whenAuthenticated(MunicipioAuthenticatedUserInterface $user, Mun ]); } - private function getActions(MunicipioAuthNavigationInterface $navigation): array + private function getActions(MunicipioAuthNavigationInterface $navigation, bool $hasValidKulturkort = false): array { $actions = []; @@ -94,6 +94,14 @@ private function getActions(MunicipioAuthNavigationInterface $navigation): array ); } + if (!empty($this->attributes['renewLink'] ?? '')) { + $actions[] = ActionCreator::create( + $hasValidKulturkort ? $this->wpService->__('Renew', 'municipio') : $this->wpService->__('Buy', 'municipio'), + $this->attributes['renewLink'], + 'shopping_cart' + ); + } + $actions[] = ActionCreator::create( $this->wpService->__('Logout', 'municipio'), $navigation->getModifiedHomeUrl(addQueryArgs: ['action' => 'logout']), diff --git a/library/Kulturkortet/ProfileEditor/KulturkortetProfileEditorFeature.php b/library/Kulturkortet/ProfileEditor/KulturkortetProfileEditorFeature.php index b95e78531..f93cede3c 100644 --- a/library/Kulturkortet/ProfileEditor/KulturkortetProfileEditorFeature.php +++ b/library/Kulturkortet/ProfileEditor/KulturkortetProfileEditorFeature.php @@ -59,6 +59,11 @@ function registerBlock(): void 'type' => 'string', 'default' => '', ], + 'renewLink' => [ + 'label' => $this->wpService->__('Link to renew/buy page', 'municipio'), + 'type' => 'string', + 'default' => '', + ] ], ], );