Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discount code causes issues with checkouts #25

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions includes/parents.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,37 @@ function pmprogroupacct_pmpro_invoice_bullets_bottom_parent( $invoice ) {
<?php
}
add_action( 'pmpro_invoice_bullets_bottom', 'pmprogroupacct_pmpro_invoice_bullets_bottom_parent' );

/**
* Whether or not make the payment information fields required. We need to do it through the global $pmpro_requirebilling
*
* @param bool $include Whether or not to include the payment information fields.
* @return bool Whether or not to include the payment information fields.
* @since TBD
*/
function pmprogroupcct_pmpro_include_payment_information_fields( $include ) {
// Get the level being checked out for.
$level = pmpro_getLevelAtCheckout();

// Get the group settings for this level.
$settings = null;
if ( ! empty( $level->id ) ) {
$settings = pmprogroupacct_get_settings_for_level( $level->id );
}

// If there are no settings, then this is not a group parent level. Bail.
if ( empty( $settings ) ) {
return $include;
}

// If seats aren't free we must require billing fields despite parent level is free.
if ( intval( $settings['pricing_model_settings'] ) > 0 ) {
global $pmpro_requirebilling;
$pmpro_requirebilling = true;
}

return $include;
}

// Hook to include payment information fields.
add_filter( 'pmpro_include_payment_information_fields', 'pmprogroupcct_pmpro_include_payment_information_fields' );