FileAccess Orion

SubscriptionBaskets
in package

Implement subscription basket reference handling

Tags
category

Helper

author

Tobias Teichner webmaster@teichner.biz

since

File available since v5.96.0

Table of Contents

$baskets  : array<string|int, mixed>|null
$user  : User|null
__construct()  : mixed
SubscriptionBaskets constructor.
Add()  : Result
Add an active subscription basket to this account
AllCanceled()  : bool
If all are canceled and user has at least one
CancelFromSwitch()  : Result
CancelFromTermination()  : Result
Terminate a pending subscription basket cancellation process
CancelReactivateTemporarily()  : Result
ChangePaymentMethod()  : Result
Trigger change payment
EndTrailOfSubscription()  : Result
Entries()  : array<string|int, SubscriptionBasket>
Get the list of available subscription baskets
Entry()  : SubscriptionBasket|null
Get single entry by index
First()  : Basket|null|array<string|int, mixed>
Get the main subscription
Has()  : int
Returns a number > -1 when the user has this basket at certain index
Lock()  : Result
Execute the switch to new target
MarkForTermination()  : Result
Set a subscription to expire in the future
MarkSubscriptionForSwitch()  : Result
Mark this as option to migrate to another basket on demand
ReactivateTemporarily()  : Result
Reset()  : Result
Reset user extras
Switch()  : Result
Execute the switch to new target
Unlink()  : Result
Unlink the subscription basket
getRoundedDate()  : DateTime
Get some rounded date
mapIndex()  : int|null
If a given index is actually a basket id, map it to the numeric index
write()  : Result
Store the changes

Properties

Methods

__construct()

SubscriptionBaskets constructor.

public __construct(User $user) : mixed
Parameters
$user : User
Return values
mixed

Add()

Add an active subscription basket to this account

public Add(string $id[, bool $as_main_restoration = false ]) : Result
Parameters
$id : string

The subscription basket id

$as_main_restoration : bool = false

Restore all the existing entries when locked

Return values
Result

The save result

AllCanceled()

If all are canceled and user has at least one

public AllCanceled() : bool
Return values
bool

CancelFromTermination()

Terminate a pending subscription basket cancellation process

public CancelFromTermination(int|string $index[, string $status = Basket::STATUS_REGISTERED ]) : Result
Parameters
$index : int|string
$status : string = Basket::STATUS_REGISTERED
Return values
Result

CancelReactivateTemporarily()

public CancelReactivateTemporarily(int|string $index) : Result
Parameters
$index : int|string
Return values
Result

ChangePaymentMethod()

Trigger change payment

public ChangePaymentMethod(int|string $index, array<string|int, mixed> $payload) : Result
Parameters
$index : int|string

The numeric index

$payload : array<string|int, mixed>

The form sent from the frontend, it is similar to a regular checkout form

Return values
Result

EndTrailOfSubscription()

public EndTrailOfSubscription(int|string $index, string $date_to) : Result
Parameters
$index : int|string
$date_to : string
Return values
Result

First()

Get the main subscription

public First([bool $must_be_active = false ][, bool $extra = false ]) : Basket|null|array<string|int, mixed>
Parameters
$must_be_active : bool = false

When set the returned basket will be the first active one

$extra : bool = false
Return values
Basket|null|array<string|int, mixed>

Has()

Returns a number > -1 when the user has this basket at certain index

public Has(string $id) : int
Parameters
$id : string

The basket id

Return values
int

The index or, -1

Lock()

Execute the switch to new target

public Lock(int|string $index, string $target_time) : Result
Parameters
$index : int|string
$target_time : string
Return values
Result

MarkForTermination()

Set a subscription to expire in the future

public MarkForTermination(string $index) : Result

Depending on the included subscription article the basket will be processed and the transition will be defined in the extra field of the user subscription assignment context

Parameters
$index : string

The basket uuid

Return values
Result

A result object

MarkSubscriptionForSwitch()

Mark this as option to migrate to another basket on demand

public MarkSubscriptionForSwitch(int|string $index, Basket $target_basket[, string|null $date_at = null ]) : Result
Parameters
$index : int|string

The numeric index

$target_basket : Basket

The target basket

$date_at : string|null = null
Return values
Result

ReactivateTemporarily()

public ReactivateTemporarily(int|string $index, string $date_to) : Result
Parameters
$index : int|string
$date_to : string
Return values
Result

Reset()

Reset user extras

public Reset(int|string $index[, bool $with_date = true ]) : Result

This method restores the users subscriptions as well if they have been linked to the affected basket

Parameters
$index : int|string
$with_date : bool = true
Return values
Result

Unlink the subscription basket

public Unlink(int $index[, bool $skip_transition = false ][, bool $keep_relation = false ]) : Result
Parameters
$index : int

The index in the list

$skip_transition : bool = false

Skip followup transition

$keep_relation : bool = false

Keep the relation but execute the subscription updates

Return values
Result

getRoundedDate()

Get some rounded date

private getRoundedDate(int $offset) : DateTime
Parameters
$offset : int
Tags
throws
Exception
Return values
DateTime

mapIndex()

If a given index is actually a basket id, map it to the numeric index

private mapIndex(array<string|int, mixed> $baskets, int|string $index) : int|null
Parameters
$baskets : array<string|int, mixed>
$index : int|string
Return values
int|null

Search results