Skip to content

Commit

Permalink
Merge pull request #55 from strangerstudios/dev
Browse files Browse the repository at this point in the history
Update Master to V0.9
  • Loading branch information
andrewlimaza committed Sep 1, 2020
2 parents d321257 + 6ae07a8 commit ce1b932
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 18 deletions.
45 changes: 40 additions & 5 deletions js/pmpro-pay-by-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ function pmpropbc_isCheckGatewayChosen() {
}

function pmpropbc_isPayPalExpressChosen() {
if(jQuery('input[name=gateway]:checked').val() == 'paypalexpress') {
if(jQuery('input[name=gateway]:checked').val() == 'paypalexpress' ) {
return true;
} else {
return false;
}
}

function pmpropbc_isPayFast() {
if(jQuery('input[name=gateway]:checked').val() == 'payfast' ) {
return true;
} else {
return false;
Expand All @@ -67,7 +75,7 @@ function pmpropbc_toggleCheckoutFields() {
pmpro_require_billing = false;

//hide paypal button if applicable
if(pmpropbc.gateway === 'paypalexpress' || pmpropbc.gateway === 'paypalstandard')
if(pmpropbc.gateway === 'paypalexpress' || pmpropbc.gateway === 'paypalstandard' )
{
jQuery('#pmpro_paypalexpress_checkout').hide();
jQuery('#pmpro_submit_span').show();
Expand All @@ -88,25 +96,52 @@ function pmpropbc_toggleCheckoutFields() {
jQuery('#pmpro_paypalexpress_checkout').show();
jQuery('.pmpro_check_instructions').hide();
pmpro_require_billing = false;
} else if ( pmpropbc_isPayFast()) {
jQuery('#pmpro_billing_address_fields').hide();
jQuery('#pmpro_payment_information_fields').hide();
jQuery('.pmpro_check_instructions').hide();
pmpro_require_billing = false;
} else {
//paid and default
jQuery('#pmpro_billing_address_fields').show();
jQuery('#pmpro_payment_information_fields').show();
jQuery('.pmpro_check_instructions').hide();
pmpro_require_billing = true;
}

//show paypal button if applicable
if(pmpropbc.gateway === 'paypalexpress' || pmpropbc.gateway === 'paypalstandard') {
if(pmpropbc.gateway === 'paypalexpress' || pmpropbc.gateway === 'paypalstandard' ) {
if(pmpropbc_isCheckGatewayChosen()) {
jQuery('#pmpro_paypalexpress_checkout').hide();
jQuery('#pmpro_submit_span').show();
} else {
jQuery('#pmpro_paypalexpress_checkout').show();
jQuery('#pmpro_submit_span').hide();
}
else {
}

//Integration for PayPal Website Payments Pro.
if ( pmpropbc.gateway == 'paypal' ) {
// Figure out if they selected check or not.
if ( pmpropbc_isCheckGatewayChosen() ) {
jQuery('#pmpro_paypalexpress_checkout').hide();
jQuery('#pmpro_submit_span').show();
} else if( pmpropbc_isPayPalExpressChosen() ) { // see if PayPal Express is selected.
jQuery('#pmpro_paypalexpress_checkout').show();
jQuery('#pmpro_submit_span').hide();
} else { // Revert back to defaults just in-case.
jQuery('#pmpro_paypalexpress_checkout').hide();
jQuery('#pmpro_submit_span').show();
}
}

// If only Pay By Check is chosen.
if ( pmpropbc.gateway === 'check' ) {
jQuery('#pmpro_billing_address_fields').show();
jQuery('#pmpro_payment_information_fields').hide();
jQuery('.pmpro_check_instructions').show();
pmpro_require_billing = false;
}
}

//check if billing address hide/show is overriden by filters
Expand Down
File renamed without changes.
167 changes: 167 additions & 0 deletions languages/pmpro-pay-by-check-fr_FR.po~Updated upstream
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#
# Hi there! Details on how to help out translating Paid Memberships Pro can be found at:
# http://www.paidmembershipspro.com/documentation/languages/
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: jason@strangerstudios.com\n"
"POT-Creation-Date: 2017-08-01 13:28-0400\n"
"PO-Revision-Date: 2018-02-14 22:04+0100\n"
"Language-Team: Stranger Studios <jason@strangerstudios.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.3\n"
"Last-Translator: Alfonso Sánchez Uzábal <skotperez@voragine.net>\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Language: fr_FR\n"
"X-Poedit-KeywordsList: __;_e;_x\n"

#: pmpro-pay-by-check.php:46 pmpro-pay-by-check.php:45
msgid "Pay by Check Settings"
msgstr "Paramètres pour le paiement par chèque"

#: pmpro-pay-by-check.php:47 pmpro-pay-by-check.php:46
msgid ""
"Change this setting to allow or disallow the pay by check option for this "
"level."
msgstr ""
"Modifiez ce paramètre pour autoriser ou interdire l'option de paiement par "
"chèque pour ce niveau."

#: pmpro-pay-by-check.php:51 pmpro-pay-by-check.php:50
msgid "Allow Pay by Check:"
msgstr "Autoriser le paiement par chèque:"

#: pmpro-pay-by-check.php:54 pmpro-pay-by-check.php:53
msgid "No. Use the default gateway only."
msgstr "Utilisez la passerelle par défaut uniquement."

#: pmpro-pay-by-check.php:55 pmpro-pay-by-check.php:54
msgid "Yes. Users choose between default gateway and check."
msgstr ""
"Oui. Les utilisateurs choisissent entre la passerelle par défaut et la "
"vérification."

#: pmpro-pay-by-check.php:56 pmpro-pay-by-check.php:55
msgid "Yes. Users can only pay by check."
msgstr "Oui. Les utilisateurs ne peuvent payer que par chèque."

#: pmpro-pay-by-check.php:61 pmpro-pay-by-check.php:60
msgid "Send Renewal Emails:"
msgstr "Envoyer des courriels de renouvellement:"

#: pmpro-pay-by-check.php:63 pmpro-pay-by-check.php:62
msgid "days before renewal."
msgstr "jours avant le renouvellement."

#: pmpro-pay-by-check.php:67 pmpro-pay-by-check.php:66
msgid "Send Reminder Emails:"
msgstr "Envoyer des e-mails de rappel:"

#: pmpro-pay-by-check.php:69 pmpro-pay-by-check.php:75
#: pmpro-pay-by-check.php:68 pmpro-pay-by-check.php:74
msgid "days after a missed payment."
msgstr "jours après un paiement manqué."

#: pmpro-pay-by-check.php:73 pmpro-pay-by-check.php:72
msgid "Cancel Membership:"
msgstr "Annuler l'adhésion:"

#: pmpro-pay-by-check.php:165 pmpro-pay-by-check.php:182
msgid "Choose Your Payment Method"
msgstr "Choisissez votre méthode de paiement"

#: pmpro-pay-by-check.php:174 pmpro-pay-by-check.php:191
msgid "Pay with PayPal"
msgstr "Payer avec PayPal"

#: pmpro-pay-by-check.php:176
msgid "Pay with 2Checkout"
msgstr "Payeur avec 2Checkout"

#: pmpro-pay-by-check.php:178 pmpro-pay-by-check.php:193
msgid "Pay by Credit Card"
msgstr "Payer par carte de crédit"

#: pmpro-pay-by-check.php:181 pmpro-pay-by-check.php:196
msgid "Pay by Check"
msgstr "Payer par chèque ou virement"

#: pmpro-pay-by-check.php:513 pmpro-pay-by-check.php:462
msgid ""
"<strong>Membership pending.</strong> We are still waiting for payment of "
"this invoice."
msgstr ""
"<strong>Adhésion en attente.</strong> Nous attendons toujours le paiement de "
"cette facture."

#: pmpro-pay-by-check.php:515 pmpro-pay-by-check.php:464
msgid ""
"<strong>Important Notice:</strong> We are still waiting for payment of this "
"invoice."
msgstr ""
"<strong>Avis important:</strong> Nous attendons toujours le paiement de "
"cette facture."

#: pmpro-pay-by-check.php:525 pmpro-pay-by-check.php:474
#, php-format
msgid ""
"<strong>Membership pending.</strong> We are still waiting for payment for <a "
"href=\"%s\">your latest invoice</a>."
msgstr ""
"<strong>Adhésion en attente.</strong> Nous attendons toujours le paiement de "
"<a href=\"%s\">votre dernière facture</a>."

#: pmpro-pay-by-check.php:527 pmpro-pay-by-check.php:476
#, php-format
msgid ""
"<strong>Important Notice:</strong> We are still waiting for payment for <a "
"href=\"%s\">your latest invoice</a>."
msgstr ""
"<strong>Avis important:</strong> Nous attendons toujours le paiement de <a "
"href=\"%s\">votre dernière facture</a>."

#: pmpro-pay-by-check.php:681 pmpro-pay-by-check.php:616
#, php-format
msgid "New Invoice for %s at %s"
msgstr "Nouvelle facture pour %s à %s"

#: pmpro-pay-by-check.php:768 pmpro-pay-by-check.php:703
#, php-format
msgid "Reminder: New Invoice for %s at %s"
msgstr "Rappel: Nouvelle facture pour% s at% s"

#: pmpro-pay-by-check.php:811 pmpro-pay-by-check.php:746
msgid "Discount Code"
msgstr "Code de réduction"

#: pmpro-pay-by-check.php:909 pmpro-pay-by-check.php:844
#, php-format
msgid "Membership expired email sent to %s. "
msgstr "Adhésion expirée. Émail envoyé à %s."

#: pmpro-pay-by-check.php:930
msgid ""
"Your payment is currently pending. You will gain access to this page once it "
"is approved."
msgstr ""
"Votre paiement est actuellement en attente. Vous aurez accès à cette page "
"une fois qu'il est approuvé."

#: pmpro-pay-by-check.php:978 pmpro-pay-by-check.php:885
msgid "Docs"
msgstr "Documents"

#: pmpro-pay-by-check.php:978 pmpro-pay-by-check.php:885
msgid "View Documentation"
msgstr "Afficher documentation"

#: pmpro-pay-by-check.php:979 pmpro-pay-by-check.php:886
msgid "Support"
msgstr "Support"

#: pmpro-pay-by-check.php:979 pmpro-pay-by-check.php:886
msgid "Visit Customer Support Forum"
msgstr "Visitez le forum de support client"
37 changes: 26 additions & 11 deletions pmpro-pay-by-check.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Paid Memberships Pro - Pay by Check Add On
Plugin URI: https://www.paidmembershipspro.com/add-ons/pmpro-pay-by-check-add-on/
Description: A collection of customizations useful when allowing users to pay by check for Paid Memberships Pro levels.
Version: .8.1
Version: 0.9
Author: Stranger Studios
Author URI: https://www.paidmembershipspro.com
Text Domain: pmpro-pay-by-check
Expand All @@ -24,7 +24,7 @@
Settings, Globals and Constants
*/
define("PMPRO_PAY_BY_CHECK_DIR", dirname(__FILE__));
define("PMPROPBC_VER", '.8');
define("PMPROPBC_VER", '0.9');

/*
Load plugin textdomain.
Expand Down Expand Up @@ -158,7 +158,7 @@ function pmpropbc_checkout_boxes()
//only show if the main gateway is not check and setting value == 1 (value == 2 means only do check payments)
if($gateway_setting != "check" && $options['setting'] == 1)
{
?>
?>
<table id="pmpro_payment_method" class="pmpro_checkout top1em" width="100%" cellpadding="0" cellspacing="0" border="0" <?php if(!empty($pmpro_review)) { ?>style="display: none;"<?php } ?>>
<thead>
<tr>
Expand All @@ -174,6 +174,8 @@ function pmpropbc_checkout_boxes()
<a href="javascript:void(0);" class="pmpro_radio"><?php _e('Pay with PayPal', 'pmpro-pay-by-check');?></a> &nbsp;
<?php } elseif($gateway_setting == 'twocheckout') { ?>
<a href="javascript:void(0);" class="pmpro_radio"><?php _e('Pay with 2Checkout', 'pmpro-pay-by-check');?></a> &nbsp;
<?php } elseif( $gateway_setting == 'payfast' ) { ?>
<a href="javascript:void(0);" class="pmpro_radio"><?php _e('Pay with PayFast', 'pmpro-pay-by-check');?></a> &nbsp;
<?php } else { ?>
<a href="javascript:void(0);" class="pmpro_radio"><?php _e('Pay by Credit Card', 'pmpro-pay-by-check');?></a> &nbsp;
<?php } ?>
Expand Down Expand Up @@ -351,7 +353,9 @@ function pmpropbc_init_include_billing_address_fields()
add_filter('pmpro_include_payment_option_for_paypal', '__return_false');
} elseif($default_gateway == 'twocheckout') {
//undo the filter to change the checkout button text
remove_filter('pmpro_checkout_default_submit_button', array('PMProGateway_twocheckout', 'pmpro_checkout_default_submit_button'));
remove_filter('pmpro_checkout_default_submit_button', array('PMProGateway_twocheckout', 'pmpro_checkout_default_submit_button'));
} else if( $default_gateway == 'payfast' ) {
add_filter( 'pmpro_include_billing_address_fields', '__return_false' );
} else {
//onsite checkouts

Expand Down Expand Up @@ -384,7 +388,7 @@ function pmpropbc_pmpro_checkout_after_payment_information_fields() {

$options = pmpropbc_getOptions($pmpro_level->id);

if(!empty($options) && $options['setting'] > 0 && !pmpro_isLevelFree($pmpro_level)) {
if( !empty($options) && $options['setting'] > 0 ) {
$instructions = pmpro_getOption("instructions");
if($gateway != 'check')
$hidden = 'style="display:none;"';
Expand Down Expand Up @@ -642,6 +646,7 @@ function pmpropbc_recurring_orders()
- Set invoice date based on cycle and the day of the month of the member start date.
- Send a reminder email Y days after initial invoice is created if it's still pending.
- Cancel membership after Z days if invoice is not paid. Send email.
// ADDED Extra brackets round OR as sql results were missing some orders (match for same user id was not being used due to the missing brackets)
*/
//get all check orders still pending after X days
$sqlQuery = "
Expand All @@ -663,8 +668,8 @@ function pmpropbc_recurring_orders()
) as o2
ON o1.user_id = o2.user_id
AND o1.timestamp < o2.timestamp
OR (o1.timestamp = o2.timestamp AND o1.id < o2.id)
AND (o1.timestamp < o2.timestamp
OR (o1.timestamp = o2.timestamp AND o1.id < o2.id))
WHERE
o2.id IS NULL
AND DATE_ADD(o1.timestamp, INTERVAL $combo) <= '" . $date . "'
Expand All @@ -688,6 +693,10 @@ function pmpropbc_recurring_orders()
if(empty($user->membership_level) || $order->membership_id != $user->membership_level->id)
continue;

// If Paid Memberships Pro - Auto-Renewal Checkbox is active there may be mixed recurring and non-recurring users at ths level
if( $user->membership_level->cycle_number == 0 || $user->membership_level->billing_amount == 0)
continue;

//create new pending order
$morder = new MemberOrder();
$morder->user_id = $order->user_id;
Expand Down Expand Up @@ -750,8 +759,10 @@ function pmpropbc_reminder_emails()
{
//get options
$options = pmpropbc_getOptions($level->id);
// subtract reminder_days from current date as we are looking for invoices from or before that date
// this is relative to the date the reminder was sent out not when it was due I think
if(!empty($options['reminder_days']))
$date = date("Y-m-d", strtotime("+ " . $options['reminder_days'] . " days", $now));
$date = date("Y-m-d", strtotime("- " . $options['reminder_days'] . " days", $now));
else
$date = $today;

Expand All @@ -765,13 +776,14 @@ function pmpropbc_reminder_emails()
foreach($combos as $combo)
{
//get all check orders still pending after X days
// don't add the INTERVAL here!
$sqlQuery = "
SELECT id
FROM $wpdb->pmpro_membership_orders
WHERE membership_id = $level->id
AND gateway = 'check'
AND status = 'pending'
AND DATE_ADD(timestamp, INTERVAL $combo) <= '" . $date . "'
AND timestamp <= '" . $date . "'
AND notes NOT LIKE '%Reminder Sent:%' AND notes NOT LIKE '%Reminder Skipped:%'
ORDER BY id
";
Expand Down Expand Up @@ -885,8 +897,11 @@ function pmpropbc_cancel_overdue_orders()
{
//get options
$options = pmpropbc_getOptions($level->id);

// subtract cancel_days not add, we want the older orders not paid
// this is relative to the date the reminder was sent out not when it was due
if(!empty($options['cancel_days']))
$date = date("Y-m-d", strtotime("+ " . $options['cancel_days'] . " days", $now));
$date = date("Y-m-d", strtotime("- " . $options['cancel_days'] . " days", $now));
else
$date = $today;

Expand All @@ -906,7 +921,7 @@ function pmpropbc_cancel_overdue_orders()
WHERE membership_id = $level->id
AND gateway = 'check'
AND status = 'pending'
AND DATE_ADD(timestamp, INTERVAL $combo) <= '" . $date . "'
AND timestamp <= '" . $date . "'
AND notes NOT LIKE '%Cancelled:%' AND notes NOT LIKE '%Cancellation Skipped:%'
ORDER BY id
";
Expand Down
Loading

0 comments on commit ce1b932

Please sign in to comment.