Version 4.7.6
This commit is contained in:
1 parent
8ba7d43898
commit
7b7404e741
1085 files changed
+30590
-7837
No files matched your search
@@ -82,36 +82,41 @@ class _FixMissingSubscriptionPurchases
|
||||
}
|
||||
catch( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
$package = \IPS\nexus\Subscription\Package::load( $subscription['sub_package_id'] );
|
||||
|
||||
if( !$subscription['sub_added_manually'] AND $subscription['sub_renews'] )
|
||||
try
|
||||
{
|
||||
$term = $package->renewalTerm( \IPS\nexus\Customer::load( $subscription['sub_member_id'] )->defaultCurrency() );
|
||||
$termData = $term->getTerm();
|
||||
$package = \IPS\nexus\Subscription\Package::load( $subscription['sub_package_id'] );
|
||||
|
||||
if( !$subscription['sub_added_manually'] AND $subscription['sub_renews'] )
|
||||
{
|
||||
$term = $package->renewalTerm( \IPS\nexus\Customer::load( $subscription['sub_member_id'] )->defaultCurrency() );
|
||||
$termData = $term->getTerm();
|
||||
}
|
||||
|
||||
/* Create purchase manually - we don't want to trigger any on* methods */
|
||||
$purchaseId = \IPS\Db::i()->insert( 'nexus_purchases', [
|
||||
'ps_member' => $subscription['sub_member_id'],
|
||||
'ps_name' => \IPS\nexus\Customer::load( $subscription['sub_member_id'] )->language()->get( $package::$titleLangPrefix . $subscription['sub_package_id'] ),
|
||||
'ps_active' => $subscription['sub_active'],
|
||||
'ps_cancelled' => $subscription['sub_cancelled'],
|
||||
'ps_start' => $subscription['sub_start'],
|
||||
'ps_expire' => $subscription['sub_added_manually'] ? 0 : $subscription['sub_expire'],
|
||||
'ps_renewals' => $termData['term'] ?? 0,
|
||||
'ps_renewal_price' => $term->cost->amount ?? 0,
|
||||
'ps_renewal_unit' => $termData['unit'] ?? '',
|
||||
'ps_app' => 'nexus',
|
||||
'ps_type' => 'subscription',
|
||||
'ps_item_id' => $subscription['sub_package_id'],
|
||||
'ps_renewal_currency' => $term->cost->currency ?? '',
|
||||
'ps_original_invoice' => $subscription['sub_invoice_id'],
|
||||
'ps_tax' => isset( $term->tax ) ? $term->tax->id : 0
|
||||
]);
|
||||
|
||||
/* update sub with purchase id */
|
||||
\IPS\Db::i()->update( 'nexus_member_subscriptions', [ 'sub_purchase_id' => $purchaseId ], [ 'sub_id=?', $subscription['sub_id'] ] );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{}
|
||||
|
||||
/* Create purchase manually - we don't want to trigger any on* methods */
|
||||
$purchaseId = \IPS\Db::i()->insert( 'nexus_purchases', [
|
||||
'ps_member' => $subscription['sub_member_id'],
|
||||
'ps_name' => \IPS\nexus\Customer::load( $subscription['sub_member_id'] )->language()->get( $package::$titleLangPrefix . $subscription['sub_package_id'] ),
|
||||
'ps_active' => $subscription['sub_active'],
|
||||
'ps_cancelled' => $subscription['sub_cancelled'],
|
||||
'ps_start' => $subscription['sub_start'],
|
||||
'ps_expire' => $subscription['sub_added_manually'] ? 0 : $subscription['sub_expire'],
|
||||
'ps_renewals' => $termData['term'] ?? 0,
|
||||
'ps_renewal_price' => $term->cost->amount ?? 0,
|
||||
'ps_renewal_unit' => $termData['unit'] ?? '',
|
||||
'ps_app' => 'nexus',
|
||||
'ps_type' => 'subscription',
|
||||
'ps_item_id' => $subscription['sub_package_id'],
|
||||
'ps_renewal_currency' => $term->cost->currency ?? '',
|
||||
'ps_original_invoice' => $subscription['sub_invoice_id'],
|
||||
'ps_tax' => isset( $term->tax ) ? $term->tax->id : 0
|
||||
]);
|
||||
|
||||
/* update sub with purchase id */
|
||||
\IPS\Db::i()->update( 'nexus_member_subscriptions', [ 'sub_purchase_id' => $purchaseId ], [ 'sub_id=?', $subscription['sub_id'] ] );
|
||||
|
||||
$data['completed']++;
|
||||
$last = $subscription['sub_id'];
|
||||
|
||||
Reference in new issue
Block a user