Skip to content

Commit c27f0c3

Browse files
committed
feat: adding buy renew for profile
1 parent a03ff45 commit c27f0c3

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

library/Kulturkortet/ProfileEditor/KulturkortetProfileEditorAuthViewFactory.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ public function whenAuthenticated(MunicipioAuthenticatedUserInterface $user, Mun
7474
'email' => $ticket['email'] ?? '',
7575
],
7676
'saveUrl' => $navigation->getModifiedHomeUrl(removeQueryArgs: ['action']),
77-
'actions' => $this->getActions($navigation),
77+
'actions' => $this->getActions($navigation, true),
7878
'logoutUrl' => $navigation->getModifiedHomeUrl(addQueryArgs: ['action' => 'logout']),
7979
'ticket' => [
8080
'validUntil' => $this->formatDate($ticket['validUntil'] ?? null),
8181
]
8282
]);
8383
}
8484

85-
private function getActions(MunicipioAuthNavigationInterface $navigation): array
85+
private function getActions(MunicipioAuthNavigationInterface $navigation, bool $hasValidKulturkort = false): array
8686
{
8787
$actions = [];
8888

@@ -94,6 +94,14 @@ private function getActions(MunicipioAuthNavigationInterface $navigation): array
9494
);
9595
}
9696

97+
if (!empty($this->attributes['renewLink'] ?? '')) {
98+
$actions[] = ActionCreator::create(
99+
$hasValidKulturkort ? $this->wpService->__('Renew', 'municipio') : $this->wpService->__('Buy', 'municipio'),
100+
$this->attributes['renewLink'],
101+
'shopping_cart'
102+
);
103+
}
104+
97105
$actions[] = ActionCreator::create(
98106
$this->wpService->__('Logout', 'municipio'),
99107
$navigation->getModifiedHomeUrl(addQueryArgs: ['action' => 'logout']),

library/Kulturkortet/ProfileEditor/KulturkortetProfileEditorFeature.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ function registerBlock(): void
5959
'type' => 'string',
6060
'default' => '',
6161
],
62+
'renewLink' => [
63+
'label' => $this->wpService->__('Link to renew/buy page', 'municipio'),
64+
'type' => 'string',
65+
'default' => '',
66+
]
6267
],
6368
],
6469
);

0 commit comments

Comments
 (0)