<div class="rcp_gateway_fields"> <?php $gateways = rcp_get_enabled_payment_gateways(); if( count( $gateways ) > 1 ) : $display = rcp_has_paid_levels() ? '' : ' style="display: none;"'; ?> <fieldset class="rcp_gateways_fieldset"> <p id="rcp_payment_gateways"<?php echo $display; ?>> <select name="rcp_gateway" id="rcp_gateway"> <?php foreach( $gateways as $key => $gateway ) : $recurring = rcp_gateway_supports( $key, 'recurring' ) ? 'yes' : 'no'; ?> <option value="<?php echo esc_attr( $key ); ?>" data-supports-recurring="<?php echo esc_attr( $recurring ); ?>"><?php echo esc_html( $gateway ); ?></option> <?php endforeach; ?> </select> <label for="rcp_gateway"><?php _e( 'Choose Your Payment Method', 'rcp' ); ?></label> </p> </fieldset> <?php else: ?> <?php foreach( $gateways as $key => $gateway ) : $recurring = rcp_gateway_supports( $key, 'recurring' ) ? 'yes' : 'no'; ?> <input type="hidden" name="rcp_gateway" value="<?php echo esc_attr( $key ); ?>" data-supports-recurring="<?php echo esc_attr( $recurring ); ?>"/> <?php endforeach; ?> <?php endif; ?> </div> <fieldset class="rcp_level_details_fieldset"> <p id="rcp_level_details_wrap" class="rcp_level" rel="<?php echo esc_attr( $level->price ); ?>"> <span class="rcp_price"><?php echo rcp_currency_filter( $level->price ); ?></span> <span class="rcp_sep"> / </span> <span class="rcp_duration"><?php echo $level->duration > 0 ? $level->duration . ' ' . rcp_filter_duration_unit( $level->duration_unit, $level->duration ) : __( 'unlimited', 'rcp' ); ?></span> </p> </fieldset> <?php endif; ?>
<?php } ?> </select> <label for="rcp_gateway"><?php _e('Choose Your Payment Method', 'rcp'); ?> </label> </p> </fieldset> <?php } else { ?> <?php foreach ($gateways as $key => $gateway) { $recurring = rcp_gateway_supports($key, 'recurring') ? 'yes' : 'no'; ?> <input type="hidden" name="rcp_gateway" value="<?php echo esc_attr($key); ?> " data-supports-recurring="<?php echo esc_attr($recurring); ?> "/> <?php } ?> <?php } ?> </div>
/** * Determine if this registration is recurring * * @since 2.5 * @return bool */ function rcp_registration_is_recurring() { $auto_renew = false; if ('3' == rcp_get_auto_renew_behavior()) { $auto_renew = isset($_POST['rcp_auto_renew']); } if ('1' == rcp_get_auto_renew_behavior()) { $auto_renew = true; } // make sure this gateway supports recurring payments if ($auto_renew && !empty($_POST['rcp_gateway'])) { $auto_renew = rcp_gateway_supports(sanitize_text_field($_POST['rcp_gateway']), 'recurring'); } if ($auto_renew && !empty($_POST['rcp_level'])) { $details = rcp_get_subscription_details($_POST['rcp_level']); // check if this is an unlimited or free subscription if (empty($details->duration) || empty($details->price)) { $auto_renew = false; } } if (!rcp_get_registration_recurring_total() > 0) { $auto_renew = false; } return apply_filters('rcp_registration_is_recurring', $auto_renew); }