Skip to content

Commit

Permalink
Merged in thobk/membership-2-thobk/fix/855655593931802-confusion-word…
Browse files Browse the repository at this point in the history
…ing (pull request #135)

Fix/855655593931802 confusion wording

Approved-by: Joel James <[email protected]>
  • Loading branch information
thobk authored and Joel James committed Mar 4, 2019
2 parents 122fb3d + dc23291 commit 4696d7d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/controller/class-ms-controller-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ public function payment_table( $content ) {
$subscription,
$membership
);
$invoice->save();
// $invoice->save();//already run save action in MS_View_Frontend_Payment->to_html

$data['invoice'] = $invoice;
$data['membership'] = $membership;
Expand Down
7 changes: 4 additions & 3 deletions app/model/class-ms-model-relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,7 @@ public function get_payment_description( $invoice = null, $short = false ) {
break;

case MS_Model_Membership::PAYMENT_TYPE_RECURRING:
$no_payment_rest = $membership->pay_cycle_repetitions - $this->get_current_invoice_number() + 1;
if ( 1 == $membership->pay_cycle_repetitions ) {
// Exactly 1 payment. Actually same as the "finite" type.
if ( $short ) {
Expand All @@ -2163,9 +2164,9 @@ public function get_payment_description( $invoice = null, $short = false ) {
if ( $membership->pay_cycle_repetitions > 1 ) {
// Fixed number of payments (more than 1)
if ( $short ) {
$lbl = __( '%4$s times <span class="price">%1$s %2$s</span> (each %3$s)', 'membership2' );
$lbl = _n( 'One time <span class="price">%1$s %2$s</span>.', '%4$s times <span class="price">%1$s %2$s</span> (each %3$s)', $no_payment_rest, 'membership2' );
} else {
$lbl = __( 'You will make %4$s payments of <span class="price">%1$s %2$s</span>, one each %3$s.', 'membership2' );
$lbl = _n( 'You will make a payment of <span class="price">%1$s %2$s</span>.', 'You will make %4$s payments of <span class="price">%1$s %2$s</span>, one each %3$s.', $no_payment_rest, 'membership2' );
}
} else {
// Indefinite number of payments
Expand All @@ -2184,7 +2185,7 @@ public function get_payment_description( $invoice = null, $short = false ) {
$currency,
$total_price,
MS_Helper_Period::get_period_desc( $membership->pay_cycle_period ),
$membership->pay_cycle_repetitions
$no_payment_rest
),
$short,
$currency,
Expand Down
2 changes: 2 additions & 0 deletions app/view/frontend/class-ms-view-frontend-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function to_html() {

/**
* Log the users IP and current timestamp inside the invoice.
*
* And also save coupon if it have applied, see filter ms_signup_payment_details
*
* @since 1.0.2.0
*/
Expand Down
25 changes: 13 additions & 12 deletions premium/addon/coupon/class-ms-addon-coupon.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ public function init() {
10, 2
);

$this->add_filter(
'ms_model_relationship_get_payment_description/recurring',
'payment_description_recurring',
10, 6
);

// Apply Coupon-Discount to invoice
$this->add_filter(
'ms_signup_payment_details',
Expand All @@ -136,12 +142,6 @@ public function init() {
'process_payment_table',
10, 4
);

$this->add_filter(
'ms_model_relationship_get_payment_description/recurring',
'payment_description_recurring',
10, 6
);

}
}
Expand Down Expand Up @@ -729,15 +729,16 @@ public function payment_description_recurring( $desc, $short, $currency, $total_

if ( ! $coupon || ! $coupon->is_valid( $membership->id, $invoice ) ) return $desc;

if ( MS_Model_Membership::PAYMENT_TYPE_RECURRING === $membership->payment_type && MS_Addon_Coupon_Model::DURATION_ONCE !== $invoice->duration ) return $desc;
if ( MS_Model_Membership::PAYMENT_TYPE_RECURRING === $membership->payment_type && MS_Addon_Coupon_Model::DURATION_ONCE !== $coupon->duration ) return $desc;

$lbl = '';
$no_payment_repeat = $membership->pay_cycle_repetitions - 1;
if ( $membership->pay_cycle_repetitions > 1 ) {
// Fixed number of payments (more than 1)
if ( $short ) {
$lbl = __( '<span class="price">%1$s %2$s</span> first time and then <span class="price">%1$s %3$s</span> (each %4$s)', 'membership2' );
$lbl = _n( '<span class="price">%1$s %2$s</span> first time and then <span class="price">%1$s %3$s</span>', '<span class="price">%1$s %2$s</span> first time and then <span class="price">%1$s %3$s</span> (each %4$s)', $no_payment_repeat, 'membership2' );
} else {
$lbl = __( 'First payment <span class="price">%1$s %2$s</span> and then you will make %5$s payments of <span class="price">%1$s %3$s</span>, one each %4$s.', 'membership2' );
$lbl = _n( 'First payment <span class="price">%1$s %2$s</span> and then you will make a payment of <span class="price">%1$s %3$s</span>.', 'First payment <span class="price">%1$s %2$s</span> and then you will make %5$s payments of <span class="price">%1$s %3$s</span>, one each %4$s.', $no_payment_repeat, 'membership2' );
}
} else {
// Indefinite number of payments
Expand All @@ -752,11 +753,11 @@ public function payment_description_recurring( $desc, $short, $currency, $total_
$lbl,
$currency,
$total_price,
$membership->price,
MS_Helper_Billing::format_price($membership->price),
MS_Helper_Period::get_period_desc( $membership->pay_cycle_period ),
$membership->pay_cycle_repetitions - 1
$no_payment_repeat
);

}

return $desc;
Expand Down

0 comments on commit 4696d7d

Please sign in to comment.