Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,59 +12,87 @@
|
||||
namespace IPS\nexus\Invoice\Item;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use DomainException;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\File;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Date;
|
||||
use IPS\Helpers\Form\Interval;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Coupon;
|
||||
use IPS\nexus\Customer;
|
||||
use IPS\nexus\Form\RenewalTerm;
|
||||
use IPS\nexus\Invoice;
|
||||
use IPS\nexus\Invoice\Item;
|
||||
use IPS\nexus\Purchase as NexusPurchase;
|
||||
use IPS\nexus\Purchase\RenewalTerm as PurchaseRenewalTerm;
|
||||
use IPS\nexus\Tax;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Settings;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoice Item Class for Purchases
|
||||
*/
|
||||
abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
abstract class Purchase extends Item
|
||||
{
|
||||
/**
|
||||
* @brief string Act (new/charge)
|
||||
*/
|
||||
public static $act = 'new';
|
||||
public static string $act = 'new';
|
||||
|
||||
/**
|
||||
* @brief Requires login to purchase?
|
||||
*/
|
||||
public static $requiresAccount = TRUE;
|
||||
public static bool $requiresAccount = TRUE;
|
||||
|
||||
/**
|
||||
* @brief \DateInterval Length granted by initial purchase before normal renewal term starts (or NULL to match renewal term)
|
||||
*/
|
||||
public $initialInterval;
|
||||
public ?DateInterval $initialInterval = null;
|
||||
|
||||
/**
|
||||
* @brief \IPS\nexus\Purchase\RenewalTerm Renewal Term
|
||||
*/
|
||||
public $renewalTerm;
|
||||
public ?PurchaseRenewalTerm $renewalTerm = null;
|
||||
|
||||
/**
|
||||
* @brief \IPS\DateTime Expiry Date (only if the purchase needs to expire but not renew)
|
||||
*/
|
||||
public $expireDate;
|
||||
public ?DateTime $expireDate = null;
|
||||
|
||||
/**
|
||||
* @brief \IPS\nexus\Purchase|int The parent purchase or item ID
|
||||
*/
|
||||
public $parent = NULL;
|
||||
public NexusPurchase|int|null $parent = NULL;
|
||||
|
||||
/**
|
||||
* @brief bool Group with parent?
|
||||
*/
|
||||
public $groupWithParent = FALSE;
|
||||
public bool $groupWithParent = FALSE;
|
||||
|
||||
/**
|
||||
* Get Icon
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return string
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return string
|
||||
*/
|
||||
public static function getIcon( \IPS\nexus\Purchase $purchase )
|
||||
public static function getIcon( NexusPurchase $purchase ): string
|
||||
{
|
||||
return static::$icon;
|
||||
}
|
||||
@@ -72,10 +100,10 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return string
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return string
|
||||
*/
|
||||
public static function getTypeTitle( \IPS\nexus\Purchase $purchase )
|
||||
public static function getTypeTitle( NexusPurchase $purchase ): string
|
||||
{
|
||||
return static::$title;
|
||||
}
|
||||
@@ -83,10 +111,10 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* Image
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return |IPS\File|NULL
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return File|null
|
||||
*/
|
||||
public static function purchaseImage( \IPS\nexus\Purchase $purchase )
|
||||
public static function purchaseImage( NexusPurchase $purchase ): File|null
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -94,20 +122,20 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* Get purchases made by a customer of this item
|
||||
*
|
||||
* @param \IPS\nexus\Customer $customer The customer
|
||||
* @param int|array|NULL $id Item ID(s)
|
||||
* @param bool $includeInactive Include expired purchases?
|
||||
* @param bool $includeCanceled Include canceled purchases?
|
||||
* @return \IPS\Patterns\ActiveRecordIterator
|
||||
* @param Customer $customer The customer
|
||||
* @param int|array|NULL $id Item ID(s)
|
||||
* @param bool $includeInactive Include expired purchases?
|
||||
* @param bool $includeCanceled Include canceled purchases?
|
||||
* @return ActiveRecordIterator
|
||||
*/
|
||||
public static function getPurchases( \IPS\nexus\Customer $customer, $id = NULL, $includeInactive = TRUE, $includeCanceled = FALSE )
|
||||
public static function getPurchases(Customer $customer, int|array|null $id = NULL, bool $includeInactive = TRUE, bool $includeCanceled = FALSE ): ActiveRecordIterator
|
||||
{
|
||||
$where = array( array( 'ps_app=? AND ps_type=? AND ps_member=?', static::$application, static::$type, $customer->member_id ) );
|
||||
if ( $id !== NULL )
|
||||
{
|
||||
if ( \is_array( $id ) )
|
||||
if ( is_array( $id ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'ps_item_id', $id ) );
|
||||
$where[] = array( Db::i()->in( 'ps_item_id', $id ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -123,16 +151,16 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
$where[] = array( 'ps_cancelled=0' );
|
||||
}
|
||||
|
||||
return new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_purchases', $where ), 'IPS\nexus\Purchase' );
|
||||
return new ActiveRecordIterator( Db::i()->select( '*', 'nexus_purchases', $where ), 'IPS\nexus\Purchase' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get additional name info
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return array
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return array
|
||||
*/
|
||||
public static function getPurchaseNameInfo( \IPS\nexus\Purchase $purchase )
|
||||
public static function getPurchaseNameInfo( NexusPurchase $purchase ): array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
@@ -140,10 +168,10 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* Get ACP Page HTML
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return string
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return string
|
||||
*/
|
||||
public static function acpPage( \IPS\nexus\Purchase $purchase )
|
||||
public static function acpPage( NexusPurchase $purchase ): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
@@ -151,11 +179,11 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* Get ACP Page Buttons
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param \IPS\Http\Url $url The page URL
|
||||
* @return array
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @param Url $url The page URL
|
||||
* @return array
|
||||
*/
|
||||
public static function acpButtons( \IPS\nexus\Purchase $purchase, \IPS\Http\Url $url )
|
||||
public static function acpButtons( NexusPurchase $purchase, Url $url ): array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
@@ -163,51 +191,51 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* ACP Action
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return void
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return string|null
|
||||
*/
|
||||
public static function acpAction( \IPS\nexus\Purchase $purchase )
|
||||
public static function acpAction( NexusPurchase $purchase ): string|null
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACP Edit Form
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @param \IPS\nexus\Purchase\RenewalTerm $renewals The renewal term
|
||||
* @return string
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @param Form $form The form
|
||||
* @param PurchaseRenewalTerm|null $renewals The renewal term
|
||||
* @return void
|
||||
*/
|
||||
public static function acpEdit( \IPS\nexus\Purchase $purchase, \IPS\Helpers\Form $form, $renewals )
|
||||
public static function acpEdit(NexusPurchase $purchase, Form $form, ?PurchaseRenewalTerm $renewals ) : void
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ps_name', $purchase->_name, TRUE, array( 'maxLength' => 128 ) ) );
|
||||
$form->add( new Text( 'ps_name', $purchase->_name, TRUE, array( 'maxLength' => 128 ) ) );
|
||||
|
||||
if ( !$purchase->grouped_renewals and ( !$purchase->billing_agreement or $purchase->billing_agreement->canceled ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Date( 'ps_expire', $purchase->expire ?: 0, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'does_not_expire', 'disabled' => !$purchase->canChangeExpireDate() ) ) );
|
||||
$form->add( new Date( 'ps_expire', $purchase->expire ?: 0, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'does_not_expire', 'disabled' => !$purchase->canChangeExpireDate() ) ) );
|
||||
}
|
||||
|
||||
if ( !$purchase->billing_agreement or $purchase->billing_agreement->canceled )
|
||||
{
|
||||
$form->add( new \IPS\nexus\Form\RenewalTerm( 'ps_renewals', $renewals, FALSE, array( 'lockTerm' => !$purchase->canChangeExpireDate() ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'ps_grace_period', $purchase->grace_period / 86400, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'max' => \IPS\Settings::i()->cm_invoice_expireafter ?: NULL, 'min' => NULL ), NULL, NULL, NULL ) );
|
||||
$form->add( new RenewalTerm( 'ps_renewals', $renewals, FALSE, array( 'lockTerm' => !$purchase->canChangeExpireDate() ) ) );
|
||||
$form->add( new Interval( 'ps_grace_period', $purchase->grace_period / 86400, FALSE, array( 'valueAs' => Interval::DAYS, 'max' => Settings::i()->cm_invoice_expireafter ?: NULL, 'min' => NULL ), NULL, NULL, NULL ) );
|
||||
}
|
||||
|
||||
if ( !$purchase->grouped_renewals )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'ps_parent', $purchase->parent(), FALSE, array( 'class' => 'IPS\nexus\Purchase', 'forceOwner' => $purchase->member, 'zeroVal' => 'no_parent', 'disabledIds' => array( $purchase->id ) ) ) );
|
||||
$form->add( new Node( 'ps_parent', $purchase->parent(), FALSE, array( 'class' => 'IPS\nexus\Purchase', 'forceOwner' => $purchase->member, 'zeroVal' => 'no_parent', 'disabledIds' => array( $purchase->id ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ACP Edit Save
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @param array $values Values from form
|
||||
* @return string
|
||||
* @return void
|
||||
*/
|
||||
public static function acpEditSave( \IPS\nexus\Purchase $purchase, array $values )
|
||||
public static function acpEditSave( NexusPurchase $purchase, array $values ): void
|
||||
{
|
||||
$purchase->name = $values['ps_name'];
|
||||
|
||||
@@ -218,10 +246,10 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
{
|
||||
if( $purchase->tax )
|
||||
{
|
||||
$tax = \IPS\nexus\Tax::load( $purchase->tax );
|
||||
$tax = Tax::load( $purchase->tax );
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e ){}
|
||||
catch( OutOfRangeException ){}
|
||||
|
||||
if( $tax AND $values['ps_renewals'] )
|
||||
{
|
||||
@@ -251,25 +279,51 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
$purchase->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Client Area Page HTML
|
||||
* Additional elements that will be used to create coupons
|
||||
* Also used on the Commission Rules
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return string
|
||||
* @param array|string|null $current Current data
|
||||
* @return array
|
||||
*/
|
||||
public static function clientAreaPage( \IPS\nexus\Purchase $purchase )
|
||||
public static function customFormElements( array|string|null $current =null ) : array
|
||||
{
|
||||
return '';
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of values that will be stored with the coupon
|
||||
* Note: If you have any additional fields that have been added to the form
|
||||
* but are NOT saved to the database, you MUST unset them from the values array
|
||||
*
|
||||
* @param array $values
|
||||
* @param mixed $object The coupon or commission rule (or other object)
|
||||
* @return array|null
|
||||
*/
|
||||
public static function saveCustomForm( array &$values=array(), mixed $object = null ) : ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Client Area Page HTML
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return string
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return array
|
||||
*/
|
||||
public static function clientAreaAction( \IPS\nexus\Purchase $purchase )
|
||||
public static function clientAreaPage( NexusPurchase $purchase ): array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Client Area Page HTML
|
||||
*
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return void
|
||||
*/
|
||||
public static function clientAreaAction( NexusPurchase $purchase ): void
|
||||
{
|
||||
|
||||
}
|
||||
@@ -277,10 +331,10 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* Admin can change expire date / renewal term?
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return bool
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return bool
|
||||
*/
|
||||
public static function canChangeExpireDate( \IPS\nexus\Purchase $purchase )
|
||||
public static function canChangeExpireDate( NexusPurchase $purchase ): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -288,10 +342,10 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* Purchase can be renewed?
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return boolean
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return boolean
|
||||
*/
|
||||
public static function canBeRenewed( \IPS\nexus\Purchase $purchase )
|
||||
public static function canBeRenewed( NexusPurchase $purchase ): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -299,56 +353,34 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* Purchase can be reactivated in the ACP?
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param NULL $error Error to show, passed by reference
|
||||
* @return bool
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @param string|NULL $error Error to show, passed by reference
|
||||
* @return bool
|
||||
*/
|
||||
public static function canAcpReactivate( \IPS\nexus\Purchase $purchase, &$error=NULL )
|
||||
public static function canAcpReactivate(NexusPurchase $purchase, string|null &$error=NULL ): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can Renew Until
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @param bool $admin If TRUE, is for ACP. If FALSE, is for front-end.
|
||||
* @return \IPS\DateTime|bool TRUE means can renew as much as they like. FALSE means cannot renew at all. \IPS\DateTime means can renew until that date
|
||||
* @return DateTime|bool TRUE means can renew as much as they like. FALSE means cannot renew at all. \IPS\DateTime means can renew until that date
|
||||
*/
|
||||
public static function canRenewUntil( \IPS\nexus\Purchase $purchase, $admin )
|
||||
public static function canRenewUntil( NexusPurchase $purchase, bool $admin=FALSE ): DateTime|bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ACP Support View HTML
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return string
|
||||
*/
|
||||
public static function acpSupportView( \IPS\nexus\Purchase $purchase )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Support Severity
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return \IPS\nexus\Support\Severity|NULL
|
||||
*/
|
||||
public static function supportSeverity( \IPS\nexus\Purchase $purchase )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get renewal payment methods IDs
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return array|NULL
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return array|NULL
|
||||
*/
|
||||
public static function renewalPaymentMethodIds( \IPS\nexus\Purchase $purchase )
|
||||
public static function renewalPaymentMethodIds( NexusPurchase $purchase ): array|null
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -356,11 +388,11 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* On Purchase Generated
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param \IPS\nexus\Invoice $invoice The invoice
|
||||
* @return void
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @param Invoice $invoice The invoice
|
||||
* @return void
|
||||
*/
|
||||
public static function onPurchaseGenerated( \IPS\nexus\Purchase $purchase, \IPS\nexus\Invoice $invoice )
|
||||
public static function onPurchaseGenerated( NexusPurchase $purchase, Invoice $invoice ): void
|
||||
{
|
||||
|
||||
}
|
||||
@@ -368,11 +400,11 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* On Renew (Renewal invoice paid. Is not called if expiry data is manually changed)
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param int $cycles Cycles
|
||||
* @return void
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @param int $cycles Cycles
|
||||
* @return void
|
||||
*/
|
||||
public static function onRenew( \IPS\nexus\Purchase $purchase, $cycles )
|
||||
public static function onRenew(NexusPurchase $purchase, int $cycles = 1): void
|
||||
{
|
||||
|
||||
}
|
||||
@@ -380,10 +412,10 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* On Expiration Date Change
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return void
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return void
|
||||
*/
|
||||
public static function onExpirationDateChange( \IPS\nexus\Purchase $purchase )
|
||||
public static function onExpirationDateChange( NexusPurchase $purchase ): void
|
||||
{
|
||||
|
||||
}
|
||||
@@ -392,10 +424,10 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
* On expire soon
|
||||
* If returns TRUE, the normal expire warning email will not be sent
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return void
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return bool
|
||||
*/
|
||||
public static function onExpireWarning( \IPS\nexus\Purchase $purchase )
|
||||
public static function onExpireWarning( NexusPurchase $purchase ): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -403,10 +435,10 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* On Purchase Expired
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return void
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return void
|
||||
*/
|
||||
public static function onExpire( \IPS\nexus\Purchase $purchase )
|
||||
public static function onExpire( NexusPurchase $purchase ): void
|
||||
{
|
||||
|
||||
}
|
||||
@@ -414,21 +446,21 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* On Purchase Canceled
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return void
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return void
|
||||
*/
|
||||
public static function onCancel( \IPS\nexus\Purchase $purchase )
|
||||
public static function onCancel( NexusPurchase $purchase ): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Warning to display to admin when cancelling a purchase
|
||||
*
|
||||
* @param \IPS\nexus\Invoice $invoice The invoice
|
||||
* @return string
|
||||
* @param NexusPurchase $purchase
|
||||
* @return string|null
|
||||
*/
|
||||
public static function onCancelWarning( \IPS\nexus\Purchase $purchase )
|
||||
public static function onCancelWarning( NexusPurchase $purchase ): string|null
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -436,10 +468,10 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* On Purchase Deleted
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return void
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return void
|
||||
*/
|
||||
public static function onDelete( \IPS\nexus\Purchase $purchase )
|
||||
public static function onDelete( NexusPurchase $purchase ): void
|
||||
{
|
||||
|
||||
}
|
||||
@@ -447,10 +479,10 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* On Purchase Reactivated (renewed after being expired or reactivated after being canceled)
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return void
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @return void
|
||||
*/
|
||||
public static function onReactivate( \IPS\nexus\Purchase $purchase )
|
||||
public static function onReactivate( NexusPurchase $purchase ): void
|
||||
{
|
||||
|
||||
}
|
||||
@@ -458,11 +490,11 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
/**
|
||||
* On Transfer (is ran before transferring)
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param \IPS\Member $newCustomer New Customer
|
||||
* @return void
|
||||
* @param NexusPurchase $purchase The purchase
|
||||
* @param Member $newCustomer New Customer
|
||||
* @return void
|
||||
*/
|
||||
public static function onTransfer( \IPS\nexus\Purchase $purchase, \IPS\Member $newCustomer )
|
||||
public static function onTransfer( NexusPurchase $purchase, Member $newCustomer ): void
|
||||
{
|
||||
|
||||
}
|
||||
@@ -471,19 +503,19 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
* Requires Billing Address
|
||||
*
|
||||
* @return bool
|
||||
* @throws \DomainException
|
||||
* @throws DomainException
|
||||
*/
|
||||
public function requiresBillingAddress()
|
||||
public function requiresBillingAddress(): bool
|
||||
{
|
||||
return \in_array( 'product', explode( ',', \IPS\Settings::i()->nexus_require_billing ) );
|
||||
return in_array( 'product', explode( ',', Settings::i()->nexus_require_billing ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Purchase Record?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function showPurchaseRecord()
|
||||
public function showPurchaseRecord(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -492,15 +524,15 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
* Is this item the same as another item in the cart?
|
||||
* Used to decide when an item is added to the cart if we should just increase the quantity of this item instead of creating a new item.
|
||||
*
|
||||
* @param \IPS\nexus\Invoice\Item $item The other item
|
||||
* @return bool
|
||||
* @param Item $item The other item
|
||||
* @return bool
|
||||
*/
|
||||
public function isSameAsOtherItem( $item )
|
||||
public function isSameAsOtherItem( Item $item ): bool
|
||||
{
|
||||
// You can't compare DateInterval objects, it just throws an exception, so we have to
|
||||
// manually figure out if the renewal terms have any differences
|
||||
|
||||
if ( $item instanceof \IPS\nexus\Invoice\Item\Purchase )
|
||||
if ( $item instanceof static )
|
||||
{
|
||||
if ( $item->renewalTerm xor $this->renewalTerm )
|
||||
{
|
||||
@@ -518,7 +550,7 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if ( $item->renewalTerm->cost != $item->renewalTerm->cost )
|
||||
if ( $item->renewalTerm->cost != $this->renewalTerm->cost )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user