private static function get_header_details($level = false) { global $psts; $recurring = $psts->get_setting('recurring_subscriptions', 1); $active_periods = (array) $psts->get_setting('enabled_periods'); $periods = array('price_1' => __('every month', 'psts'), 'price_3' => __('every 3 months', 'psts'), 'price_12' => __('every 12 months', 'psts')); $periods_non_recurring = array('price_1' => __('for 1 month', 'psts'), 'price_3' => __('for 3 months', 'psts'), 'price_12' => __('for 12 months', 'psts')); $payment_type = array('price_1' => __('Monthly', 'psts'), 'price_3' => __('Quarterly', 'psts'), 'price_12' => __('Annually', 'psts')); $plan_text = apply_filters('prosites_pricing_labels', array('payment_type' => __('Payment period', 'psts'), 'setup' => __('Plus a One Time %s Setup Fee', 'psts'), 'summary' => __('That\'s equivalent to <strong>only %s Monthly</strong>. ', 'psts'), 'saving' => __('A saving of <strong>%s</strong> by paying for %d months in advance.', 'psts'), 'monthly' => __('Take advantage of <strong>extra savings</strong> by paying in advance.', 'psts'), 'monthly_alt' => __('<em>Try it out!</em><br /><span>You can easily upgrade to a better value plan at any time.</span>', 'psts')), $level); if (empty($level)) { $content = '<div class="period-selector"><div class="heading">' . esc_html($plan_text['payment_type']) . '</div> <select class="chosen">'; if (in_array(1, $active_periods)) { $content .= '<option value="price_1" ' . selected(self::$default_period, 'price_1', false) . '>' . esc_html($payment_type['price_1']) . '</option>'; } if (in_array(3, $active_periods)) { $content .= '<option value="price_3" ' . selected(self::$default_period, 'price_3', false) . '>' . esc_html($payment_type['price_3']) . '</option>'; } if (in_array(12, $active_periods)) { $content .= '<option value="price_12" ' . selected(self::$default_period, 'price_12', false) . '>' . esc_html($payment_type['price_12']) . '</option>'; } $content .= '</select></div>'; return $content; } else { $content = ''; if ('enabled' == $psts->get_setting('psts_checkout_show_featured')) { $featured_level = $psts->get_setting('featured_level'); } else { $featured_level = -1; } $level_list = get_site_option('psts_levels'); $setup_fee_amount = $psts->get_setting('setup_fee', 0); $level_details = array(); $level_details['title'] = apply_filters('prosites_pricing_level_title', $level_list[$level]['name'], $level); // Is this the featured level? if ($featured_level == $level) { $level_details['featured'] = true; } else { $level_details['featured'] = false; } $level_details['featured'] = apply_filters('prosites_pricing_level_featured', $level_details['featured'], $level); $setup_msg = ''; if (!empty($setup_fee_amount)) { $setup_fee = ProSites_Helper_UI::rich_currency_format($setup_fee_amount); $setup_fee_plain = ProSites_Helper_UI::rich_currency_format($setup_fee_amount, true); $setup_msg = '<div class="setup-fee">' . sprintf($plan_text['setup'], $setup_fee) . '</div>'; $setup_msg .= '<div class="price-plain hidden setup-fee-plain">' . $setup_fee_plain . '</div>'; } $level_details['breakdown'] = array(); $level_details['savings_msg'] = array(); $period_count = 0; foreach ($periods as $period_key => $period) { if (!in_array((int) str_replace('price_', '', $period_key), $active_periods)) { continue; } $period_count += 1; switch ($period_key) { case 'price_1': $months = 1; break; case 'price_3': $months = 3; break; case 'price_12': $months = 12; break; } $display_style = self::$default_period != $period_key ? ' hide' : ''; $create_hidden = false; if (1 == $period_count) { $display_style = ''; $create_hidden = (int) str_replace('price_', '', $period_key); } if (!$recurring) { $period = $periods_non_recurring[$period_key]; } // Get level price and format it $price = ProSites_Helper_UI::rich_currency_format($level_list[$level][$period_key]); $price_plain = ProSites_Helper_UI::rich_currency_format($level_list[$level][$period_key], true); $period_content = '<div class="price ' . esc_attr($period_key) . esc_attr($display_style) . '">'; $period_content .= '<div class="plan-price original-amount">' . $price . '</div>'; $period_content .= '<div class="price-plain hidden plan-' . $level . '' . $months . '-plain">' . $price_plain . '</div>'; $period_content .= '<div class="period original-period">' . esc_html($period) . '</div>'; $period_content .= !empty($setup_msg) ? $setup_msg : ''; if ($period_count == 1) { $period_content .= '<div class="hidden" name="single_period">' . $create_hidden . '</div>'; } $period_content .= '</div>'; $level_details['breakdown'][$period_key] = str_replace('hide', '', $period_content); $content .= $period_content; $monthly_price = $level_list[$level]['price_1']; $monthly_calculated = $level_list[$level][$period_key] / $months * 1.0; $difference = ($monthly_price - $monthly_calculated) * $months; $calculated_monthly = ProSites_Helper_UI::rich_currency_format($monthly_calculated, true); $calculated_saving = ProSites_Helper_UI::rich_currency_format($difference, true); $formatted_calculated = '<div class="monthly-price original-amount">' . $calculated_monthly . '</div>'; $formatted_calculated .= '<div class="monthly-price-hidden hidden">' . $calculated_monthly . '</div>'; $formatted_savings = '<div class="savings-price original-amount">' . $calculated_saving . '</div>'; $formatted_savings .= '<div class="savings-price-hidden hidden">' . $calculated_saving . '</div>'; $summary_msg = sprintf($plan_text['monthly']); $periods = (array) $psts->get_setting('enabled_periods'); $show_periods = 2 <= count($periods) ? true : false; $override = $show_periods ? '' : 'no-periods'; if ($months > 1) { $summary_msg = sprintf($plan_text['summary'], $formatted_calculated); if ($difference > 0.0) { $summary_msg .= sprintf($plan_text['saving'], $formatted_savings, $months); } $level_details['savings_msg'][$period_key] = '<div class="level-summary ' . esc_attr($period_key) . ' ' . $override . '">' . $summary_msg . '</div>'; } else { $level_details['savings_msg'][$period_key] = '<div class="level-summary ' . esc_attr($period_key) . ' ' . $override . '">' . esc_html($plan_text['monthly_alt']) . '</div>'; } $content .= '<div class="level-summary ' . esc_attr($period_key) . ' ' . $override . esc_attr($display_style) . '">' . $summary_msg . '</div>'; } $level_details['summary'] = apply_filters('prosites_pricing_summary_text', $content, $level); return $level_details; } }
/** * 'Payment Settings' * * @return string */ public static function render_tab_taxes() { global $psts; ProSites_Helper_Settings::settings_header(ProSites_Helper_Tabs_Settings::get_active_tab()); ?> <div class="inside"> <!--<table class="form-table">--> <!--</table>--> <!--<hr />--> <h3 class="psts-settings-title"><br />EU VAT - Taxamo Integration</h3> <div class="psts-settings-desc psts-description">Setup integration with Taxamo.com to handle your EU VAT requirements. Taxamo pricing starts at €0.20c per transaction when switching to LIVE mode.</div> <table class="form-table"> <tr valign="top"> <th scope="row" class="pay-for-signup"><?php echo __('Enable Taxamo', 'psts'); ?> </th> <td> <label><input type="checkbox" name="psts[taxamo_status]" value="1"<?php checked($psts->get_setting('taxamo_status')); ?> /> </td> </tr> <tr valign="top"> <th scope="row" class="psts-help-div psts-rebrand-pro"><?php echo __('Taxamo Public Key', 'psts') . ProSites_Helper_UI::help_text(__('You will need to setup your API token in the Taxamo dashboard. Once you switch Taxamo to "LIVE" you will need to update this key.', 'psts')); ?> </th> <td> <input type="text" name="psts[taxamo_token]" value="<?php echo esc_attr($psts->get_setting('taxamo_token')); ?> "/> </td> </tr> <tr valign="top"> <th scope="row" class="psts-help-div psts-rebrand-pro"><?php echo __('Taxamo Private Key', 'psts') . ProSites_Helper_UI::help_text(__('You will need to setup your API token in the Taxamo dashboard. Once you switch Taxamo to "LIVE" you will need to update this key.', 'psts')); ?> </th> <td> <input type="text" name="psts[taxamo_private_token]" value="<?php echo esc_attr($psts->get_setting('taxamo_private_token')); ?> "/> </td> </tr> </table> <p class="description"><?php echo sprintf(__('Create an account at Taxamo.com. You can then get your API keys from the <a href="%s">API Access</a> page.', 'psts'), esc_url('https://dashboard.taxamo.com/merchant/app.html#/account/api')); ?> </p> <p class="description"><?php echo sprintf(__('Please also add your site domain to the "Web API referers" section on the <a href="%s">JavaScript API</a> page for Taxamo integration to work.', 'psts'), esc_url('https://dashboard.taxamo.com/merchant/app.html#/account/api/javascript')); ?> </p> </div> <?php }
function load_settings_style() { ProSites_Helper_UI::load_psts_style(); ProSites_Helper_UI::load_chosen(); }
public static function apply_coupon_to_checkout() { $doing_ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false; $ajax_response = array(); if ($doing_ajax) { $coupon_code = sanitize_text_field($_POST['coupon_code']); $valid_coupon = self::check_coupon($coupon_code); if (!empty($valid_coupon)) { $ajax_response['valid'] = true; ProSites_Helper_Session::session('COUPON_CODE', $coupon_code); } else { $ajax_response['valid'] = false; ProSites_Helper_Session::unset_session('COUPON_CODE'); } // $ajax_response['value'] = self::coupon_value( $coupon_code, '200' ); $first_periods = array('price_1' => __('first month only', 'psts'), 'price_3' => __('first 3 months only', 'psts'), 'price_12' => __('first 12 months only', 'psts')); // New pricing if ($valid_coupon) { $original_levels = get_site_option('psts_levels'); $level_list = self::get_adjusted_level_amounts($coupon_code); $coupon_obj = self::get_coupon($coupon_code); foreach ($level_list as $key => $level) { unset($level_list[$key]['is_visible']); unset($level_list[$key]['name']); unset($level_list[$key]['setup_fee']); if ($original_levels[$key]['price_1'] == $level['price_1']) { $level_list[$key]['price_1_adjust'] = false; unset($level_list[$key]['price_1']); } else { $level_list[$key]['price_1'] = '<div class="plan-price coupon-amount">' . ProSites_Helper_UI::rich_currency_format($level['price_1']) . '</div>'; if ('first' == $coupon_obj['lifetime']) { $level_list[$key]['price_1_period'] = '<div class="period coupon-period">' . $first_periods['price_1'] . '</div>'; } else { $level_list[$key]['price_1_period'] = ''; } $level_list[$key]['price_1_adjust'] = true; } if ($original_levels[$key]['price_3'] == $level['price_3']) { $level_list[$key]['price_3_adjust'] = false; unset($level_list[$key]['price_3']); } else { $level_list[$key]['price_3'] = '<div class="plan-price coupon-amount">' . ProSites_Helper_UI::rich_currency_format($level['price_3']) . '</div>'; $total_1 = $original_levels[$key]['price_1'] * 3; $total_3 = $level['price_3']; $monthly = $level['price_3'] / 3; $saving = $total_1 - $total_3; $level_list[$key]['price_3_monthly'] = '<div class="monthly-price coupon-amount">' . ProSites_Helper_UI::rich_currency_format($monthly) . '</div>'; $level_list[$key]['price_3_savings'] = '<div class="savings-price coupon-amount">' . ProSites_Helper_UI::rich_currency_format($saving) . '</div>'; if ('first' == $coupon_obj['lifetime']) { $level_list[$key]['price_3_period'] = '<div class="period coupon-period">' . $first_periods['price_3'] . '</div>'; } else { $level_list[$key]['price_3_period'] = ''; } $level_list[$key]['price_3_adjust'] = true; } if ($original_levels[$key]['price_12'] == $level['price_12']) { $level_list[$key]['price_12_adjust'] = false; unset($level_list[$key]['price_12']); } else { $level_list[$key]['price_12'] = '<div class="plan-price coupon-amount">' . ProSites_Helper_UI::rich_currency_format($level['price_12']) . '</div>'; $total_1 = $original_levels[$key]['price_1'] * 12; $total_12 = $level['price_12']; $monthly = $level['price_12'] / 12; $saving = $total_1 - $total_12; $level_list[$key]['price_12_monthly'] = '<div class="monthly-price coupon-amount">' . ProSites_Helper_UI::rich_currency_format($monthly) . '</div>'; $level_list[$key]['price_12_savings'] = '<div class="savings-price coupon-amount">' . ProSites_Helper_UI::rich_currency_format($saving) . '</div>'; if ('first' == $coupon_obj['lifetime']) { $level_list[$key]['price_12_period'] = '<div class="period coupon-period">' . $first_periods['price_12'] . '</div>'; } else { $level_list[$key]['price_12_period'] = ''; } $level_list[$key]['price_12_adjust'] = true; } } $ajax_response['levels'] = $level_list; } $response = array('what' => 'response', 'action' => 'apply_coupon_to_checkout', 'id' => 1, 'data' => json_encode($ajax_response)); // Buffer used to isolate AJAX response from unexpected output ob_end_clean(); ob_start(); $xmlResponse = new WP_Ajax_Response($response); $xmlResponse->send(); ob_end_flush(); } }
/** * Loads the Chosen Style and script */ function load_chosen() { ProSites_Helper_UI::load_chosen(); }