From 9964bf4277c88da73e5757a09a73534a1edf14f4 Mon Sep 17 00:00:00 2001 From: MemberPress Date: Thu, 19 Dec 2024 10:17:04 +0000 Subject: [PATCH] Updates to 1.11.37 --- app/controllers/MeprAppCtrl.php | 15 +- app/controllers/MeprCheckoutCtrl.php | 34 ++ app/controllers/MeprCoachkitCtrl.php | 10 +- app/controllers/MeprOnboardingCtrl.php | 5 +- app/controllers/MeprProductsCtrl.php | 5 +- app/controllers/MeprRulesCtrl.php | 19 +- app/controllers/MeprUsersCtrl.php | 2 +- app/data/events.php | 4 +- app/gateways/MeprPayPalStandardGateway.php | 51 +- app/gateways/MeprStripeGateway.php | 5 +- app/helpers/MeprOnboardingHelper.php | 4 +- app/helpers/MeprOptionsHelper.php | 6 +- app/helpers/MeprProductsHelper.php | 10 +- app/helpers/MeprTransactionsHelper.php | 26 +- app/helpers/MeprUsersHelper.php | 2 +- app/lib/MeprDb.php | 6 +- app/lib/MeprUsage.php | 1 + app/lib/MeprUtils.php | 56 +- app/models/MeprOptions.php | 6 + app/models/MeprProduct.php | 23 + app/models/MeprSubscription.php | 2 +- app/models/MeprUser.php | 17 + app/views/admin/options/form.php | 21 + app/views/readylaunch/layout/app.php | 2 +- css/admin-shared.css | 12 +- css/readylaunch/theme.css | 6 +- css/ui/theme.css | 5 + i18n/locale_date_map.php | 304 ++++++++++ i18n/memberpress.pot | 626 +++++++++++++-------- i18n/states/IE.php | 35 ++ i18n/states/MX.php | 2 +- js/account.js | 26 + js/readylaunch/account.js | 14 + js/signup.js | 73 ++- memberpress.php | 4 +- 35 files changed, 1104 insertions(+), 335 deletions(-) create mode 100644 i18n/locale_date_map.php create mode 100644 i18n/states/IE.php diff --git a/app/controllers/MeprAppCtrl.php b/app/controllers/MeprAppCtrl.php index 880ea5e..70ce82f 100644 --- a/app/controllers/MeprAppCtrl.php +++ b/app/controllers/MeprAppCtrl.php @@ -460,10 +460,16 @@ public static function setup_menus() public static function admin_bar_menu($wp_admin_bar) { + $mepr_options = MeprOptions::fetch(); + if (! MeprUtils::is_mepr_admin()) { return; } + if ($mepr_options->hide_admin_bar_menu) { + return; + } + $notifications_count = MeprNotifications::has_access() ? count( MeprGrdLvlCtrl::getContainer()->get(Store::class)->fetch()->notifications(false, Store::FILTER_UNREAD) @@ -934,10 +940,11 @@ public static function load_scripts() 'spc_enabled' => ( $mepr_options->enable_spc || $mepr_options->design_enable_checkout_template ), 'spc_invoice' => ( $mepr_options->enable_spc_invoice || $mepr_options->design_enable_checkout_template ), 'no_compatible_pms' => __('There are no payment methods available that can purchase this product, please contact the site administrator or purchase it separately.', 'memberpress'), - 'switch_pm_prompt' => __('It looks like your purchase requires %s. No problem! Just click below to switch.', 'memberpress'), - 'switch_pm' => __('Switch to %s', 'memberpress'), - 'cancel' => __('Cancel', 'memberpress'), - 'warning_icon_url' => MEPR_IMAGES_URL . '/notice-icon-error.png', + 'switch_pm_prompt' => __('It looks like your purchase requires %s. No problem! Just click below to switch.', 'memberpress'), + 'switch_pm' => __('Switch to %s', 'memberpress'), + 'cancel' => __('Cancel', 'memberpress'), + 'no_compatible_pms_ob_required' => __('Payment Gateway(s) do not support required order configuration.', 'memberpress'), + 'warning_icon_url' => MEPR_IMAGES_URL . '/notice-icon-error.png', ]; wp_localize_script('mp-signup', 'MeprSignup', $local_data); diff --git a/app/controllers/MeprCheckoutCtrl.php b/app/controllers/MeprCheckoutCtrl.php index 71b68e3..54306d2 100644 --- a/app/controllers/MeprCheckoutCtrl.php +++ b/app/controllers/MeprCheckoutCtrl.php @@ -944,6 +944,16 @@ public static function prepare_transaction(MeprProduct $product, $order_id, $use public static function get_order_bump_products($product_id, array $order_bump_product_ids) { $order_bump_products = []; + $base_product = new MeprProduct($product_id); + $required_order_bumps = $base_product->get_required_order_bumps(); + + // Track if all required order bumps are found + if (!empty($required_order_bumps) && !empty($order_bump_product_ids)) { + $missing_required_order_bumps = array_diff($required_order_bumps, $order_bump_product_ids); + if (!empty($missing_required_order_bumps)) { + throw new Exception(__('One of the required products is missing.', 'memberpress')); + } + } foreach ($order_bump_product_ids as $order_bump_product_id) { $product = new MeprProduct($order_bump_product_id); @@ -1022,6 +1032,30 @@ public function get_checkout_state() MeprProductsHelper::display_invoice($prd, $coupon_code); $price_string = ob_get_clean(); + // By default hide required order bumps pricing terms on SPC and ReadyLaunch™ Templates. + $disable_ob_required_terms = $mepr_options->enable_spc || $mepr_options->design_enable_checkout_template; + if (! $mepr_options->enable_spc_invoice) { + $disable_ob_required_terms = false; + } + + if (! MeprHooks::apply_filters('mepr_signup_disable_order_bumps_required_terms', $disable_ob_required_terms, $prd)) { + $required_order_bumps = $prd->get_required_order_bumps(); + if (! empty($required_order_bumps)) { + ob_start(); + foreach ($required_order_bumps as $required_order_bump_id) { + if (! MeprHooks::apply_filters('mepr_signup_skip_order_bump_required_terms', false, $required_order_bump_id, $prd)) { + echo'
'; + MeprProductsHelper::display_invoice(new MeprProduct($required_order_bump_id), false, true); + } + } + + $required_order_bumps_terms = ob_get_clean(); + if (! empty($required_order_bumps_terms)) { + $price_string .= wp_kses_post($required_order_bumps_terms); + } + } + } + ob_start(); MeprProductsHelper::display_spc_invoice($prd, $coupon_code, $order_bump_products); $invoice_html = ob_get_clean(); diff --git a/app/controllers/MeprCoachkitCtrl.php b/app/controllers/MeprCoachkitCtrl.php index 2e309f2..7e1d2ae 100644 --- a/app/controllers/MeprCoachkitCtrl.php +++ b/app/controllers/MeprCoachkitCtrl.php @@ -14,18 +14,18 @@ public function load_hooks() add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']); add_action('wp_ajax_mepr_coachkit_action', [$this, 'ajax_coachkit_action']); } else { - add_action( 'admin_notices', array( $this, 'activated_admin_notice' ) ); + add_action('admin_notices', [$this, 'activated_admin_notice']); } } public function activated_admin_notice() { - if ( isset( $_GET['coachkit_activated'] ) && ! empty( $_GET['coachkit_activated'] ) && 'true' === $_GET['coachkit_activated'] ) : ?> + if (isset($_GET['coachkit_activated']) && ! empty($_GET['coachkit_activated']) && 'true' === $_GET['coachkit_activated']) : ?>
-

+

$addon_slug)) { + if (! empty($license_addons) && isset($license_addons->$addon_slug)) { $addon_info = $license_addons->$addon_slug; $plugin_url = $addon_info->url; @@ -1258,13 +1258,12 @@ public static function install_addons() } else { $message = esc_html__('Unable to install. Please download and install manually.', 'memberpress'); if (-1 === (int) $response) { - $purchase_links = MeprOnboardingHelper::features_addons_purchase_links(); $features_data['addons_upgrade_failed'][] = $addon_slug; $features_data['addons_upgrade_failed'] = array_unique($features_data['addons_upgrade_failed']); - if( isset($purchase_links[$addon_slug])) { + if (isset($purchase_links[$addon_slug])) { $message = MeprOnboardingHelper::prepare_purchase_message($purchase_links[$addon_slug]); } } diff --git a/app/controllers/MeprProductsCtrl.php b/app/controllers/MeprProductsCtrl.php index 3a9f595..9e7d4ab 100644 --- a/app/controllers/MeprProductsCtrl.php +++ b/app/controllers/MeprProductsCtrl.php @@ -274,7 +274,8 @@ public static function save_postdata($post_id) $product->customize_payment_methods = isset($_mepr_customize_payment_methods); $product->customize_profile_fields = isset($_mepr_customize_profile_fields); $product->custom_profile_fields = []; // We'll populate it below if we need to - $product->custom_payment_methods = json_decode(sanitize_text_field(wp_unslash($_POST['mepr-product-payment-methods-json']))); + $custom_payment_methods = json_decode(sanitize_text_field(wp_unslash($_POST['mepr-product-payment-methods-json']))); + $product->custom_payment_methods = is_array($custom_payment_methods) ? $custom_payment_methods : []; $product->custom_login_urls_enabled = isset($_mepr_custom_login_urls_enabled); $product->expire_type = isset(${MeprProduct::$expire_type_str}) ? sanitize_text_field($_POST[MeprProduct::$expire_type_str]) : $product->attrs['expire_type']; $product->expire_after = isset(${MeprProduct::$expire_after_str}) ? sanitize_text_field($_POST[MeprProduct::$expire_after_str]) : $product->attrs['expire_after']; @@ -451,7 +452,7 @@ public static function validate_product($product) } // Make sure there's at least one payment method selected when customizing payment methods. - if ($product->customize_payment_methods && count($product->custom_payment_methods) <= 0) { + if ($product->customize_payment_methods && (empty($product->custom_payment_methods) || ! is_array($product->custom_payment_methods))) { $product->customize_payment_methods = false; } diff --git a/app/controllers/MeprRulesCtrl.php b/app/controllers/MeprRulesCtrl.php index 3ca7c08..a4a0734 100644 --- a/app/controllers/MeprRulesCtrl.php +++ b/app/controllers/MeprRulesCtrl.php @@ -56,7 +56,6 @@ public function load_hooks() add_filter('woocommerce_variation_is_visible', 'MeprRulesCtrl::override_wc_is_visible', 11, 4); add_filter('mepr-pre-run-rule-content', 'MeprRulesCtrl::dont_hide_wc_product_content', 11, 3); } - add_action('wp_enqueue_scripts', 'MeprRulesCtrl::enqueue_scripts_paywall'); } public function register_post_type() @@ -418,6 +417,7 @@ public static function unauthorized_message($post) MeprView::render('/readylaunch/shared/unauthorized_message', get_defined_vars()); } else { if (isset($unauth->modern_paywall) && true === $unauth->modern_paywall && ! MeprAppHelper::is_memberpress_page($post)) { + wp_enqueue_script('mepr-modern-paywall', MEPR_JS_URL . '/modern_paywall.js', ['jquery'], MEPR_VERSION, true); MeprView::render('/shared/unauthorized_message_modern_paywall', get_defined_vars()); } else { MeprView::render('/shared/unauthorized_message', get_defined_vars()); @@ -1050,19 +1050,4 @@ public static function validate_rule_content($rule, $post_id) MeprUtils::debug_log("Rule (#{$post_id}) content can't be empty. Post status forced to 'draft'"); } } - - /** - * Enqueue Scripts for modern paywall. - */ - public static function enqueue_scripts_paywall() - { - $current_post = MeprUtils::get_current_post(); - if (false === $current_post) { - return; - } - $unauth = MeprRule::get_unauth_settings_for($current_post); - if (MeprRule::is_locked($current_post) && isset($unauth->modern_paywall) && true === $unauth->modern_paywall && ! MeprAppHelper::is_memberpress_page($current_post)) { - wp_enqueue_script('modern-paywall', MEPR_JS_URL . '/modern_paywall.js', ['jquery'], MEPR_VERSION, true); - } - } -} //End class +} diff --git a/app/controllers/MeprUsersCtrl.php b/app/controllers/MeprUsersCtrl.php index 70d0f54..eb69bff 100644 --- a/app/controllers/MeprUsersCtrl.php +++ b/app/controllers/MeprUsersCtrl.php @@ -372,7 +372,7 @@ public static function validate_extra_profile_fields( // Prevent checking when adding a new user via WP's New User system // or if an admin is editing the profile in the dashboard - if ($update === false || ($update !== false && MeprUtils::is_mepr_admin())) { + if ($update === false || ($update !== false && MeprUtils::is_mepr_admin() && is_admin())) { return $errs; } diff --git a/app/data/events.php b/app/data/events.php index 8a3e98b..0724799 100644 --- a/app/data/events.php +++ b/app/data/events.php @@ -1,6 +1,6 @@ (object) [ 'unique' => false, ], -]; +]); diff --git a/app/gateways/MeprPayPalStandardGateway.php b/app/gateways/MeprPayPalStandardGateway.php index 9465389..26ff0fd 100644 --- a/app/gateways/MeprPayPalStandardGateway.php +++ b/app/gateways/MeprPayPalStandardGateway.php @@ -627,7 +627,10 @@ public function record_refund() $txn->store(); - MeprUtils::send_refunded_txn_notices($txn); + MeprUtils::send_refunded_txn_notices( + $txn, + MeprHooks::apply_filters('mepr_paypal_std_transaction_refunded_event_args', '', $txn) + ); return $txn; } @@ -1382,6 +1385,19 @@ private function update_paypal_payment_profile($sub_id, $action = 'cancel') $_REQUEST['recurring_payment_id'] = $sub->subscr_id; } + /** + * Determine if the current request is a redirect from PayPal + * + * @return boolean + */ + private function is_paypal_referrer() + { + $referrer = isset($_SERVER['HTTP_REFERER']) ? wp_unslash($_SERVER['HTTP_REFERER']) : ''; + $is_paypal_referrer = (strpos($referrer, 'paypal.com') !== false); + + return MeprHooks::apply_filters('mepr_paypal_standard_is_paypal_referrer', $is_paypal_referrer); + } + /** * Find the transaction from a PayPal return * @@ -1424,14 +1440,17 @@ protected function get_paypal_return_txn() public function return_handler() { - $this->email_status("Paypal Return \$_REQUEST:\n" . MeprUtils::object_to_string($_REQUEST, true) . "\n", $this->settings->debug); - $mepr_options = MeprOptions::fetch(); + if (! $this->is_paypal_referrer()) { + wp_die(_x('Something unexpected has occurred. Please contact us for assistance.', 'ui', 'memberpress') . '
View my Subscriptions'); + } + + $this->email_status("Paypal Return \$_REQUEST:\n" . MeprUtils::object_to_string($_REQUEST, true) . "\n", $this->settings->debug); + // Let's find the transaction from the PayPal return URL vars $txn = $this->get_paypal_return_txn(); - if (isset($txn->id) && $txn->id) { $product = new MeprProduct($txn->product_id); @@ -1498,33 +1517,33 @@ public function return_handler() // If $sub let's set this up as a confirmation txn until the IPN comes in later so the user can have access now if ($sub) { - $sub->status = MeprSubscription::$active_str; - $sub->created_at = $txn->created_at; // Set the created at too + $sub->status = MeprSubscription::$active_str; + $sub->created_at = $txn->created_at; // Set the created at too $sub->store(); if (!$mepr_options->disable_grace_init_days && $mepr_options->grace_init_days > 0) { - $expires_at = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days($mepr_options->grace_init_days), 'Y-m-d 23:59:59'); + $expires_at = MeprUtils::ts_to_mysql_date(time() + MeprUtils::days($mepr_options->grace_init_days), 'Y-m-d 23:59:59'); } else { - $expires_at = $txn->created_at; // Expire immediately + $expires_at = $txn->created_at; // Expire immediately } - $txn->trans_num = uniqid(); - $txn->txn_type = MeprTransaction::$subscription_confirmation_str; - $txn->status = MeprTransaction::$confirmed_str; - $txn->expires_at = $expires_at; + $txn->trans_num = uniqid(); + $txn->txn_type = MeprTransaction::$subscription_confirmation_str; + $txn->status = MeprTransaction::$confirmed_str; + $txn->expires_at = $expires_at; $txn->store(true); } else { // The amount can be fudged in the URL with PayPal Standard - so let's make sure no fudgyness is goin' on if (isset($_GET['amt']) && (float)$_GET['amt'] < (float)$txn->total) { - $txn->status = MeprTransaction::$pending_str; - $txn->txn_type = MeprTransaction::$payment_str; + $txn->status = MeprTransaction::$pending_str; + $txn->txn_type = MeprTransaction::$payment_str; $txn->store(); wp_die(_x('Your payment amount was lower than expected. Please contact us for assistance if necessary.', 'ui', 'memberpress') . '
View my Subscriptions'); } // Don't set a trans_num here - it will get updated when the IPN comes in - $txn->txn_type = MeprTransaction::$payment_str; - $txn->status = MeprTransaction::$complete_str; + $txn->txn_type = MeprTransaction::$payment_str; + $txn->status = MeprTransaction::$complete_str; $txn->store(); } diff --git a/app/gateways/MeprStripeGateway.php b/app/gateways/MeprStripeGateway.php index 29d86da..34dd39b 100644 --- a/app/gateways/MeprStripeGateway.php +++ b/app/gateways/MeprStripeGateway.php @@ -1652,7 +1652,10 @@ public function record_refund() $txn->status = MeprTransaction::$refunded_str; $txn->store(); - MeprUtils::send_refunded_txn_notices($txn); + MeprUtils::send_refunded_txn_notices( + $txn, + MeprHooks::apply_filters('mepr_stripe_transaction_refunded_event_args', '', $txn, $charge) + ); return $txn->id; } diff --git a/app/helpers/MeprOnboardingHelper.php b/app/helpers/MeprOnboardingHelper.php index fcd4657..c6b5e47 100644 --- a/app/helpers/MeprOnboardingHelper.php +++ b/app/helpers/MeprOnboardingHelper.php @@ -127,8 +127,8 @@ public static function features_addons_purchase_links() public static function prepare_purchase_message($purchase_link) { return sprintf( - esc_html__('Unable to install. You can %spurchase it here%s, afterwards you can install it from the add-ons page.', 'memberpress'), - '', + esc_html__('Unable to install. You can %1$spurchase it here%2$s, afterwards you can install it from the add-ons page.', 'memberpress'), + '', '' ); } diff --git a/app/helpers/MeprOptionsHelper.php b/app/helpers/MeprOptionsHelper.php index b2f73ed..103f903 100644 --- a/app/helpers/MeprOptionsHelper.php +++ b/app/helpers/MeprOptionsHelper.php @@ -65,7 +65,7 @@ public static function payment_types_dropdown($field_name, $payment_type) public static function payment_currencies_dropdown($field_name, $payment_currency) { - $payment_currencies = MeprHooks::apply_filters('mepr-currency-symbols', ['$', 'US$', '£', '€', '¥', ' kr.', 'Kn', 'R$', '฿', '₹', 'zł', ' лв', ' Ft', 'Rp', 'R', '₪', '﷼', 'CHF', ' din.', ' дин.', 'KSh', 'RM', 'Rs', 'руб', '₽', 'NT$', 'Mex$', 'P', 'lei', 'JOD', '₺', 'S/.', '₱', 'د.إ', 'Kč', '₦', '₩', 'ل.د', '₫', 'ƒ', 'GH₵', 'S$', 'K', 'CFA', 'USh', 'AED', 'د.م.']); + $payment_currencies = MeprHooks::apply_filters('mepr-currency-symbols', ['$', 'US$', '£', '€', '¥', ' kr', 'Kn', 'R$', '฿', '₹', 'zł', ' лв', ' Ft', 'Rp', 'R', '₪', '﷼', 'CHF', ' din.', ' дин.', 'KSh', 'RM', 'Rs', 'руб', '₽', 'NT$', 'Mex$', 'P', 'lei', 'JOD', '₺', 'S/.', '₱', 'د.إ', 'Kč', '₦', '₩', 'ل.د', '₫', 'ƒ', 'GH₵', 'S$', 'K', 'CFA', 'USh', 'AED', 'د.م.', 'रु']); $field_value = isset($_POST[$field_name]) ? $_POST[$field_name] : null; ?> @@ -83,7 +83,7 @@ public static function payment_currencies_dropdown($field_name, $payment_currenc public static function payment_currency_code_dropdown($field_name, $code) { - $codes = MeprHooks::apply_filters('mepr-currency-codes', ['USD', 'AED', 'AUD', 'AWG', 'BGN', 'BRL', 'BWP', 'CAD', 'CHF', 'CLP', 'CNY', 'COP', 'CVE', 'CZK', 'DKK', 'EUR', 'GBP', 'GHS', 'HKD', 'HRK', 'HUF', 'HUN', 'IDR', 'ILS', 'INR', 'ISK', 'JOD', 'JPY', 'KES', 'KRW', 'LYD', 'MAD', 'MMK', 'MXN', 'MYR', 'NGN', 'NOK', 'NZD', 'PEN', 'PHP', 'PKR', 'PLN', 'RON', 'RSD', 'RUB', 'SAR', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'UGX', 'VND', 'XOF', 'ZAR', 'ZMW']); + $codes = MeprHooks::apply_filters('mepr-currency-codes', ['USD', 'AED', 'AUD', 'AWG', 'BGN', 'BRL', 'BWP', 'CAD', 'CHF', 'CLP', 'CNY', 'COP', 'CVE', 'CZK', 'DKK', 'EUR', 'GBP', 'GHS', 'HKD', 'HRK', 'HUF', 'HUN', 'IDR', 'ILS', 'INR', 'ISK', 'JOD', 'JPY', 'KES', 'KRW', 'LYD', 'MAD', 'MMK', 'MXN', 'MYR', 'NGN', 'NOK', 'NPR', 'NZD', 'PEN', 'PHP', 'PKR', 'PLN', 'RON', 'RSD', 'RUB', 'SAR', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'UGX', 'VND', 'XOF', 'ZAR', 'ZMW']); $field_value = isset($_POST[$field_name]) ? $_POST[$field_name] : null; ?> @@ -101,7 +101,7 @@ public static function payment_currency_code_dropdown($field_name, $code) public static function payment_language_code_dropdown($field_name, $code) { - $codes = MeprHooks::apply_filters('mepr-language-codes', ['US', 'AE', 'AR', 'AU', 'BG', 'BR', 'CH', 'CN', 'CO', 'CZ', 'DE', 'DK', 'EN', 'ES', 'ET', 'FI', 'FR', 'GB', 'HE', 'HR', 'HU', 'ID', 'IS', 'IT', 'JP', 'KR', 'MS', 'MX', 'NL', 'NO', 'PE', 'PH', 'PL', 'PT', 'RO', 'RU', 'SE', 'SG', 'SK', 'SR', 'SW', 'TH', 'TN', 'TR', 'TW', 'VI', 'ZA']); + $codes = MeprHooks::apply_filters('mepr-language-codes', ['US', 'AE', 'AR', 'AU', 'BG', 'BR', 'CH', 'CN', 'CO', 'CZ', 'DE', 'DK', 'EN', 'ES', 'ET', 'FI', 'FR', 'GB', 'HE', 'HR', 'HU', 'ID', 'IS', 'IT', 'JP', 'KR', 'MS', 'MX', 'NL', 'NO', 'NP', 'PE', 'PH', 'PL', 'PT', 'RO', 'RU', 'SE', 'SG', 'SK', 'SR', 'SW', 'TH', 'TN', 'TR', 'TW', 'VI', 'ZA']); $field_value = isset($_POST[$field_name]) ? $_POST[$field_name] : null; ?> diff --git a/app/helpers/MeprProductsHelper.php b/app/helpers/MeprProductsHelper.php index b907ed7..be34177 100644 --- a/app/helpers/MeprProductsHelper.php +++ b/app/helpers/MeprProductsHelper.php @@ -181,7 +181,7 @@ public static function generate_product_link_html($product, $content) return ob_get_clean(); } - public static function display_invoice($product, $coupon_code = false) + public static function display_invoice($product, $coupon_code = false, $display_title = false) { $current_user = MeprUtils::get_currentuserinfo(); MeprUtils::get_currentuserinfo(); @@ -198,6 +198,10 @@ public static function display_invoice($product, $coupon_code = false) $tmp_txn->expire_after = $product->expire_after; $tmp_txn->expire_fixed = $product->expire_fixed; + if ($display_title) { + echo esc_html($product->post_title) . ': '; + } + if (empty($coupon_code)) { // We've already validated the coupon before including signup_form.php if ($product->register_price_action == 'custom') { echo stripslashes($product->register_price); @@ -223,6 +227,10 @@ public static function display_invoice($product, $coupon_code = false) $tmp_sub = MeprHooks::apply_filters('mepr_display_invoice_sub', $tmp_sub); + if ($display_title) { + echo esc_html($product->post_title) . ': '; + } + if ($product->register_price_action == 'custom' && empty($coupon_code) && !$tmp_sub->prorated_trial) { printf('%s', stripslashes($product->register_price)); } else { diff --git a/app/helpers/MeprTransactionsHelper.php b/app/helpers/MeprTransactionsHelper.php index 89bbb75..5365aea 100644 --- a/app/helpers/MeprTransactionsHelper.php +++ b/app/helpers/MeprTransactionsHelper.php @@ -362,14 +362,20 @@ public static function get_invoice($txn, $tmpsub = '') } // If the coupon amount is HIGHER than the membership renewal price, then HIDE the coupon line in the invoice. + // If the coupon amount is higher than the membership renewal price. + // or if the trial amount is greater than 0 and less than the product price, + // hide the coupon line in the invoice by unsetting the coupon and updating the item amount. if ( isset($invoice['coupon']) && $cpn_id > 0 - && $coupon && $coupon->discount_mode == 'trial-override' + && $coupon && $sub instanceof MeprSubscription && $sub->trial - && $coupon->trial_amount > $prd->price + && ( + ($coupon->discount_mode == 'trial-override' && $coupon->trial_amount > $prd->price) + || ($sub->trial_amount > 0 && $sub->trial_amount < $prd->price) + ) ) { $invoice['items'][0]['amount'] = $txn->amount; - $invoice['coupon']['amount'] = '0'; + unset($invoice['coupon']); } } @@ -682,14 +688,20 @@ public static function get_invoice_order_bumps($txn, $tmpsub = '', $order_bumps } // If the coupon amount is HIGHER than the membership renewal price, then HIDE the coupon line in the invoice. + // If the coupon amount is higher than the membership renewal price + // or if the trial amount is greater than 0 and less than the product price, + // hide the coupon line in the invoice by unsetting the coupon and updating the item amount. if ( - isset($invoice['coupon']) - && $cpn_id > 0 && $coupon && $coupon->discount_mode == 'trial-override' + isset($invoice['coupon']) && $cpn_id > 0 + && $coupon && $sub instanceof MeprSubscription && $sub->trial - && $coupon->trial_amount > $prd->price + && ( + ($coupon->discount_mode == 'trial-override' && $coupon->trial_amount > $prd->price) + || ($sub->trial_amount > 0 && $sub->trial_amount < $prd->price) + ) ) { $invoice['items'][0]['amount'] = $txn->amount; - $invoice['coupon']['amount'] = '0'; + unset($invoice['coupon']); } } diff --git a/app/helpers/MeprUsersHelper.php b/app/helpers/MeprUsersHelper.php index cf7739d..bbbac10 100644 --- a/app/helpers/MeprUsersHelper.php +++ b/app/helpers/MeprUsersHelper.php @@ -363,7 +363,7 @@ public static function render_pro_templates_custom_field_values($field, $user) ?>
- field_name) ?> + field_name)); ?>