Skip to content

Commit

Permalink
Merge pull request #120 from MaximilianoRicoTabo/enhancement/add-supp…
Browse files Browse the repository at this point in the history
…ort-for-3.1

* Add support for pmpro-card classes
  • Loading branch information
dparker1005 committed Jul 10, 2024
2 parents 1f61082 + 98afb84 commit 5af8ebd
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 46 deletions.
83 changes: 49 additions & 34 deletions includes/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,55 @@ 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 ) { ?>
<div id="pmpro_payment_method" class="pmpro_checkout">
<hr />
<h2>
<span class="pmpro_checkout-h2-name"><?php esc_html_e( 'Choose Your Payment Method', 'pmpro-pay-by-check'); ?></span>
</h2>
<div class="pmpro_checkout-fields">
<span class="gateway_<?php echo esc_attr($gateway_setting); ?>">
<input type="radio" name="gateway" value="<?php echo $gateway_setting;?>" <?php if(!$gateway || $gateway == $gateway_setting) { ?>checked="checked"<?php } ?> />
<?php if($gateway_setting == "paypalexpress" || $gateway_setting == "paypalstandard") { ?>
<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 } ?>
</span> <!-- end gateway_$gateway_setting -->
<span class="gateway_check">
<input type="radio" name="gateway" value="check" <?php if($gateway == "check") { ?>checked="checked"<?php } ?> />
<a href="javascript:void(0);" class="pmpro_radio"><?php echo esc_html( sprintf( __( 'Pay by %s', 'pmpro-pay-by-check' ), $check_gateway_label ) ); ?></a> &nbsp;
</span> <!-- end gateway_check -->
<?php
//support the PayPal Website Payments Pro Gateway which has PayPal Express as a second option natively
if ( $gateway_setting == "paypal" ) { ?>
<span class="gateway_paypalexpress">
<input type="radio" name="gateway" value="paypalexpress" <?php if($gateway == "paypalexpress") { ?>checked="checked"<?php } ?> />
<a href="javascript:void(0);" class="pmpro_radio"><?php esc_html_e( 'Check Out with PayPal', 'pmpro-pay-by-check' ); ?></a>
</span>
<?php
}
?>
</div> <!-- end pmpro_checkout-fields -->
</div> <!-- end #pmpro_payment_method -->
<fieldset id="pmpro_payment_method" class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_fieldset', 'pmpro_payment_method' ) ); ?>">
<div class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_card' ) ); ?>">
<div class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_card_content' ) ); ?>">
<legend class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_legend' ) ); ?>">
<h2 class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_heading pmpro_font-large' ) ); ?>">
<?php esc_html_e( 'Choose Your Payment Method', 'pmpro-shipping' ); ?>
</h2>
</legend>
<div class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_fields' ) ); ?>">
<div class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_field pmpro_form_field-radio' ) ); ?>">
<div class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_field-radio-items pmpro_cols-2' ) ); ?>">
<div class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_field pmpro_form_field-radio-item' ) ); ?> gateway_<?php echo esc_attr($gateway_setting); ?>">
<input type="radio" id="gateway_<?php echo esc_attr( $gateway_setting ); ?>" name="gateway" class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_input pmpro_form_input-radio' ) ); ?>" value="<?php echo $gateway_setting;?>" <?php if(!$gateway || $gateway == $gateway_setting) { ?>checked="checked"<?php } ?> />
<label for="gateway_<?php echo esc_attr( $gateway_setting ); ?>" class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_label pmpro_form_label-inline pmpro_clickable' ) ); ?>">
<?php if($gateway_setting == "paypalexpress" || $gateway_setting == "paypalstandard") { ?>
<?php _e('Pay with PayPal', 'pmpro-pay-by-check');?>
<?php } elseif($gateway_setting == 'twocheckout') { ?>
<?php _e('Pay with 2Checkout', 'pmpro-pay-by-check');?>
<?php } elseif( $gateway_setting == 'payfast' ) { ?>
<?php _e('Pay with PayFast', 'pmpro-pay-by-check');?>
<?php } else { ?>
<?php _e('Pay by Credit Card', 'pmpro-pay-by-check');?>
<?php } ?>
</label>
</div> <!-- end pmpro_form_field pmpro_form_field-radio-item -->
<div class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_field pmpro_form_field-radio-item' ) ); ?> gateway_check">
<input type="radio" id="gateway_check" name="gateway" class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_input pmpro_form_input-radio' ) ); ?>" value="check" <?php if($gateway == "check") { ?>checked="checked"<?php } ?> />
<label for="gateway_check" class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_label pmpro_form_label-inline pmpro_clickable' ) ); ?>">
<?php echo esc_html( sprintf( __( 'Pay by %s', 'pmpro-pay-by-check' ), $check_gateway_label ) ); ?>
</label>
</div> <!-- end pmpro_form_field pmpro_form_field-radio-item -->
<?php
// Support the PayPal Website Payments Pro Gateway which has PayPal Express as a second option natively
if ( $gateway_setting == "paypal" ) { ?>
<div class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_field pmpro_form_field-radio-item' ) ); ?> gateway_paypalexpress">
<input type="radio" id="gateway_paypalexpress" name="gateway" class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_input pmpro_form_input-radio' ) ); ?>" value="paypalexpress" <?php checked( 'paypalexpress', $gateway ); ?> />
<label for="gateway_paypalexpress" class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_form_label pmpro_form_label-inline pmpro_clickable' ) ); ?>">
<?php esc_html_e( 'Check Out with PayPal', 'pmpro-pay-by-check' ); ?>
</label>
</div> <!-- end pmpro_form_field pmpro_form_field-radio-item -->
<?php
}
?>
</div> <!-- end pmpro_form_field-radio-items -->
</div> <!-- end pmpro_form_field pmpro_form_field-radio -->
</div> <!-- end pmpro_form_fields -->
</div> <!-- end pmpro_card_content -->
</div> <!-- end pmpro_card -->
</fieldset> <!-- end pmpro_payment_method -->
<?php
} elseif ( $gateway_setting != "check" && $options['setting'] == 2 ) { ?>
<input type="hidden" name="gateway" value="check" />
Expand Down
19 changes: 7 additions & 12 deletions js/pmpro-pay-by-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,23 @@ function pmpropbc_toggleCheckoutFields() {
}

function pmpropbc_togglePaymentMethodBox() {
"use strict";
"use strict";

//check if level is paid or free
if(pmpropbc_isLevelFree()) {
//free
jQuery('#pmpro_payment_method').hide();
jQuery( '#pmpro_payment_method' ).hide();
} else {
//not free
jQuery('#pmpro_payment_method').show();
jQuery( '#pmpro_payment_method' ).show();
}

//update checkout fields as well
pmpropbc_toggleCheckoutFields();
pmpropbc_toggleCheckoutFields();
}

jQuery(document).ready(function () {
"use strict";

"use strict";
//choosing payment method
jQuery('input[name=gateway]').bind('click change keyup', function () {
pmpropbc_toggleCheckoutFields();
Expand All @@ -179,8 +178,4 @@ jQuery(document).ready(function () {
pmpropbc_togglePaymentMethodBox();
}

//select the radio button if the label is clicked on
jQuery('a.pmpro_radio').click(function () {
jQuery(this).prev().click();
});
});

0 comments on commit 5af8ebd

Please sign in to comment.