woocommerce shows payment method two times after update - php

I updated WooCommerce to the latest version and now - in the checkout - the available payment methods are shown two times right after eachother as shown in the screenshot below.
In my WooCommerce files I found that the review-order.php file generate this page. I found the file here: /wp-content/themes/[mytheme]/woocommerce/checkout
Please note that there is some custom code in there - this might be the cause of this?
I know that everything within the tag is generating the payment method view but I cant figure out why it generates two of them.
I apologize for the long code. I was not sure what to include or exclude.
I hope you are able to help me out!
The review-order.php file:
<?php
global $woocommerce;
$available_methods = $woocommerce->shipping->load_shipping_methods();
?>
<div id="order_review" class="order_review">
<h2 id="order_review_heading"><?php _e('Betalingsoversigt', 'academy'); ?></h2>
<table class="shop_table" style="display:block;">
<tbody>
<?php
do_action('woocommerce_review_order_before_cart_contents');
if (sizeof($woocommerce->cart->get_cart()) > 0) :
foreach ($woocommerce->cart->get_cart() as $item_id => $values) :
$_product = $values['data'];
if ($_product->exists() && $values['quantity'] > 0) :
echo '
<tr class="' . esc_attr(apply_filters('woocommerce_checkout_table_item_class', 'checkout_table_item', $values, $item_id)) . '">
<td class="product-name">' . $_product->get_title() . ' <strong class="product-quantity">× ' . $values['quantity'] . '</strong>' . $woocommerce->cart->get_item_data($values) . '</td>
<td class="product-total">' . apply_filters('woocommerce_checkout_item_subtotal', $woocommerce->cart->get_product_subtotal($_product, $values['quantity']), $values, $item_id) . '</td>
</tr>';
endif;
endforeach;
endif;
do_action('woocommerce_review_order_after_cart_contents');
?>
</tbody>
<tfoot>
<tr class="cart-subtotal">
<th><?php _e('Subtotal', 'academy'); ?></th>
<td><?php echo $woocommerce->cart->get_cart_subtotal(); ?></td>
</tr>
<?php if ($woocommerce->cart->get_discounts_before_tax()) : ?>
<tr class="discount">
<th><?php _e('Rabat', 'academy'); ?></th>
<td>-<?php echo $woocommerce->cart->get_discounts_before_tax(); ?></td>
</tr>
<?php endif; ?>
<?php if ($woocommerce->cart->needs_shipping() && $woocommerce->cart->show_shipping()) : ?>
<?php do_action('woocommerce_review_order_before_shipping'); ?>
<tr class="shipping">
<th><?php _e('Levering', 'academy'); ?></th>
<td><?php woocommerce_get_template('cart/shipping-methods.php', array('available_methods' => $available_methods)); ?></td>
</tr>
<?php do_action('woocommerce_review_order_after_shipping'); ?>
<?php endif; ?>
<?php foreach ($woocommerce->cart->get_fees() as $fee) : ?>
<tr class="fee fee-<?php echo $fee->id ?>">
<th><?php echo $fee->name ?></th>
<td>
<?php
if ($woocommerce->cart->tax_display_cart == 'excl')
echo woocommerce_price($fee->amount);
else
echo woocommerce_price($fee->amount + $fee->tax);
?>
</td>
</tr>
<?php endforeach; ?>
<?php
if ($woocommerce->cart->tax_display_cart == 'excl') {
$taxes = $woocommerce->cart->get_taxes();
if (sizeof($taxes) > 0) {
$has_compound_tax = false;
foreach ($taxes as $key => $tax) {
if ($woocommerce->cart->tax->is_compound($key)) {
$has_compound_tax = true;
continue;
}
?>
<tr class="tax-rate tax-rate-<?php echo $key; ?>">
<th><?php echo $woocommerce->cart->tax->get_rate_label($key); ?></th>
<td><?php echo $tax; ?></td>
</tr>
<?php
}
if ($has_compound_tax) {
?>
<tr class="order-subtotal">
<th><?php _e('Subtotal', 'academy'); ?></th>
<td><?php echo $woocommerce->cart->get_cart_subtotal(true); ?></td>
</tr>
<?php
}
foreach ($taxes as $key => $tax) {
if (!$woocommerce->cart->tax->is_compound($key))
continue;
?>
<tr class="tax-rate tax-rate-<?php echo $key; ?>">
<th><?php echo $woocommerce->cart->tax->get_rate_label($key); ?></th>
<td><?php echo $tax; ?></td>
</tr>
<?php
}
} elseif ($woocommerce->cart->get_cart_tax()) {
?>
<tr class="tax">
<th><?php _e('Tax', 'academy'); ?></th>
<td><?php echo $woocommerce->cart->get_cart_tax(); ?></td>
</tr>
<?php
}
}
?>
<?php if ($woocommerce->cart->get_discounts_after_tax()) : ?>
<tr class="discount">
<th><?php _e('Order Discount', 'academy'); ?></th>
<td>-<?php echo $woocommerce->cart->get_discounts_after_tax(); ?></td>
</tr>
<?php endif; ?>
<?php do_action('woocommerce_review_order_before_order_total'); ?>
<tr class="total">
<th><strong><?php _e('Total', 'academy'); ?></strong></th>
<td>
<strong><?php echo $woocommerce->cart->get_total(); ?></strong>
<?php
if ($woocommerce->cart->tax_display_cart == 'incl') {
$tax_string_array = array();
$taxes = $woocommerce->cart->get_formatted_taxes();
if (sizeof($taxes) > 0) {
foreach ($taxes as $key => $tax) {
$tax_string_array[] = sprintf('%s %s', $tax, $woocommerce->cart->tax->get_rate_label($key));
}
} elseif ($woocommerce->cart->get_cart_tax()) {
$tax_string_array[] = sprintf('%s tax', $tax);
}
if (!empty($tax_string_array)) {
?><small class="includes_tax"><?php printf(__('(Includes %s)', 'academy'), implode(', ', $tax_string_array)); ?></small><?php
}
}
?>
</td>
</tr>
<?php do_action('woocommerce_review_order_after_order_total'); ?>
</tfoot>
</table>
</div>
<div id="payment">
<div id="price"><?php ?></div>
<?php
global $current_user;
$current_user_role = get_user_meta($current_user->data->ID, 'user_role');
?>
<?php if ($woocommerce->cart->needs_payment()) : ?>
<div class="accordion toggles-wrap payment-listing">
<?php
$available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways();
if ($available_gateways) :
$counter = 0;
if (sizeof($available_gateways)) :
$custom_gateway = get_option('woocommerce_default_gateway');
if ($current_user_role[0] == 'private_person') {
$custom_gateway = 'epay_dk';
}
if ($current_user_role[0] == 'driving_school_student') {
$custom_gateway = 'cod';
}
if ($current_user_role[0] == 'company') {
$custom_gateway = 'cod';
}
$default_gateway = $custom_gateway;
if (isset($_SESSION['_chosen_payment_method']) && isset($available_gateways[$_SESSION['_chosen_payment_method']])) :
$available_gateways[$_SESSION['_chosen_payment_method']]->set_current();
elseif (isset($available_gateways[$default_gateway])) :
$available_gateways[$default_gateway]->set_current();
else :
current($available_gateways)->set_current();
endif;
endif;
foreach ($available_gateways as $gateway) :
?>
<div class="toggle-container <?php if ($gateway->get_title() == $payment_def) echo 'expanded'; ?>" >
<label for="payment_method_<?php echo $gateway->id; ?>" class="toggle-title"><h5 class="nomargin"><?php echo $gateway->get_title(); ?></h5></label>
<input type="radio" id="payment_method_<?php echo $gateway->id; ?>" class="hidden" name="payment_method" value="<?php echo esc_attr($gateway->id); ?>" <?php if ($gateway->chosen) echo 'checked="checked"'; ?> />
<?php if ($gateway->has_fields() || $gateway->get_description()) : ?>
<div class="toggle-content payment_method_<?php echo $gateway->id; ?>"><?php $gateway->payment_fields(); ?></div>
<?php endif; ?>
</div>
<?php
$counter++;
endforeach;
endif;
?>
</div>
<?php endif; ?>
<div class="form-row place-order">
<?php $woocommerce->nonce_field('process_checkout') ?>
<?php if (woocommerce_get_page_id('terms') > 0) : ?>
<div class="terms">
<input type="checkbox" class="input-checkbox" name="terms" <?php checked(isset($_POST['terms']), true); ?> id="terms" />
<label for="terms" class="checkbox"><?php _e('Jeg accepterer', 'academy'); ?> <?php _e('Reddernes Vilkår', 'academy'); ?></label>
</div>
<?php endif; ?>
<?php do_action('woocommerce_review_order_before_submit'); ?>
<input type="submit" class="button alt place-order-button" name="woocommerce_checkout_place_order" id="place_order" value="<?php echo apply_filters('woocommerce_order_button_text', __('Betal nu', 'academy')); ?>" />
<?php do_action('woocommerce_review_order_after_submit'); ?>
</div>
</div>
</div>
<style>.woocommerce-checkout .checkout .order_review table.shop_table td{ width: 100%;}#payment #price .total p{ text-align: right;}</style>

Related

Change font color based on value retrieve from MySQL

I want the font to change its color at PHP based on value. its booking type value .. For example, Pending will change the font to Yellow, Approved to Green and Reject to Red.
booking type font color
<thead>
<tr>
<th><?php echo $this->lang->line('appointment') . " " . $this->lang->line('date'); ?></th>
<!-- <th><?php echo $this->lang->line('opd') . " " . $this->lang->line('id'); ?></th> -->
<th><?php echo $this->lang->line('patient') . " " . $this->lang->line('name'); ?></th>
<th><?php echo $this->lang->line('mobile_no'); ?></th>
<th><?php echo $this->lang->line('casualty'); ?></th>
<th><?php echo $this->lang->line('consultant') . " " . $this->lang->line('doctor'); ?></th>
<th><?php echo $this->lang->line('case'); ?></th>
<th><?php echo $this->lang->line('generated_by'); ?></th>
<th><?php echo $this->lang->line('generted_time'); ?></th>
</tr>
</thead>
<tbody>
<?php
if (empty($resultlist)) {
?>
<!-- <tr>
<td colspan="12" class="text-danger text-center"><?php echo $this->lang->line('no_record_found'); ?>
</td>
</tr> -->
<?php
} else {
$count = 1;
$total = 0;
foreach ($resultlist as $report) {
// echo "<pre>";
// print_r($report['generated_by']);
// echo die();
if (!empty($report['amount'])) {
$amount = $report['amount'] ;
$total += $amount ;
}
$paymentmode = $report['payment_mode'];
/* if($report['payment_mode'] == 'paid'){
$paymentmode = $this->lang->line('paid');
}else {
$paymentmode = $report['payment_mode'];
}*/
if($report['paytype'] == 'visit'){
$paymenttype = $this->lang->line('visit');
}elseif ($report['paytype'] == 'rechekup'){
$paymenttype = $this->lang->line('re_checkup');
}elseif ($report['paytype'] == 'payment'){
$paymenttype = $this->lang->line('payment');
}elseif ($report['paytype'] == 'bill'){
$paymenttype = $this->lang->line('bill');
}
?>
<tr>
<td><?php echo date($this->customlib->getSchoolDateFormat(true), strtotime($report['appointment_date'])) ?></td>
<!-- <td><?php echo $report['id']; ?></td> -->
<td>
<a href="<?php echo base_url(); ?>admin/patient/profile/<?php echo $report['pid']; ?>"><?php echo $report['patient_name'] ?>
</a>
</td>
<td><?php echo $report['mobileno']; ?></td>
<td><?php echo date('h:i a ', strtotime($report['casualty'])); ?></td>
<td><?php echo $report['name']." ".$report['surname']; ?></td>
<td><?php echo $report['case_type'];?>
</td>
<?php
$this->db->select('name');
$this->db->from('staff');
$this->db->where('id', $report['generated_by']);
$query = $this->db->get();
$generated_by = $query->row();
?>
<td><?php echo $generated_by->name; ?></td>
<td><?php echo $report['created_at'] ; ?></td>
</tr>
<?php
$count++;
}
?>
</tr>
</tbody>
" " its booking type value .. what i need to change its color at PHP based on value. its booking type value .. For example, Pending will change the font to Yellow, Approved to Green and Reject to Red
use css classes
<style>
.approved {
color: green;
}
.rejected {
color: red;
}
</style>
add class to you div by php
<div class="<?php echo $status ?>" >... </div>

Very heavy wordpress plugin and customization

i have a wordpress website and with customization (cache/minify/database), is really quick in frontend, and in backend, with one exception. I use a plugin where it stores and retrieves players stats, carreers, teams etc.
When saving the team's match player's statistics, it needs 5 minutes to show the page reloaded with the data.
Also when retrieving for example team's season data, it also needs a lot of time to show them.
From what i ve seen, it is related with two of my files that do all the work. tournament_match.php, and functions.php. From hosting they said that it gets all tha database and thats why it is so slow
Here is the tournament_match file
<?php
global $wpdb;
global $msg;
$page = $_GET['page'];
$tournament_id = $_GET['tid'];
$match_id = $_GET['mid'];
$league_type = leagueengine_fetch_data_from_id($tournament_id,'league_type');
if(isset($_POST['home_team_bonus']) or isset($_POST['away_team_bonus'])) {
if(isset($_POST['save_tournament_match'])) { leagueengine_save_tournament_match($tournament_id,$match_id,$_POST['date_alt'],$_POST['time_alt'],$_POST['home_team_id'],$_POST['away_team_id'],$_POST['home_team_score'],$_POST['away_team_score'],$_POST['home_team_bonus'],$_POST['away_team_bonus']); }
} else {
if(isset($_POST['save_tournament_match'])) { leagueengine_save_tournament_match($tournament_id,$match_id,$_POST['date_alt'],$_POST['time_alt'],$_POST['home_team_id'],$_POST['away_team_id'],$_POST['home_team_score'],$_POST['away_team_score']); }
}
if(isset($_POST['save_attributes'])) { leagueengine_save_attribute_values('tournament_match',NULL,NULL,$match_id,NULL,NULL,$tournament_id); }
if(isset($_POST['add_event_to_match'])) { error_reporting(0); leagueengine_add_event_to_tournament_match($tournament_id,$match_id,$_POST['new_event_id'],$_POST['new_event_time'],$_POST['timeline_text'],$_POST['new_event_count'],$_POST['new_event_player_id']); error_reporting(1); }
if(isset($_POST['save_events'])) { leagueengine_save_event_times('tournament_match',$_POST['event_time_id'],$_POST['event_time'],$_POST['event_text']); }
if(isset($_POST['add_home_event_to_match'])){
error_reporting(0);
foreach($_POST as $key=>$val){
$val=intval($val);
if(is_int($val)&&$val>0){
$data=explode('-',$key);
$playerid=$data[1];
$eventid=$data[2];
leagueengine_add_event_to_tournament_match2($tournament_id,$match_id,$eventid,$_POST['new_event_time'],$_POST['timeline_text'],$val,$playerid);
}
}
error_reporting(1);
}
if(isset($_POST['add_away_event_to_match'])){
error_reporting(0);
foreach($_POST as $key=>$val){
$val=intval($val);
if(is_int($val)&&$val>0){
$data=explode('-',$key);
$playerid=$data[1];
$eventid=$data[2];
leagueengine_add_event_to_tournament_match2($tournament_id,$match_id,$eventid,$_POST['new_event_time'],$_POST['timeline_text'],$val,$playerid);
}
}
error_reporting(1);
}
if(isset($_POST['save_tournament_match_lineups'])) {
if(isset($_POST['homeplayers'])) { $homeplayers = $_POST['homeplayers']; } else { $homeplayers = ''; }
if(isset($_POST['awayplayers'])) { $awayplayers = $_POST['awayplayers']; } else { $awayplayers = ''; }
if(isset($_POST['homesubs'])) { $homesubs = $_POST['homesubs']; } else { $homesubs = ''; }
if(isset($_POST['awaysubs'])) { $awaysubs = $_POST['awaysubs']; } else { $awaysubs = ''; }
leagueengine_save_tournament_match_lineups($tournament_id,$match_id,$homeplayers,$awayplayers,$homesubs,$awaysubs);
}
if(isset($_POST['delete_events'])) { leagueengine_delete_data('tournament_match_event',$_POST['delete_id'],'tournament',NULL,NULL,$tournament_id,$match_id); }
if(isset($_POST['save_match_statistics'])) { leagueengine_save_tournament_match_statistics($tournament_id,$match_id,$_POST['tournament_match_statistic'],$_POST['home_value'],$_POST['away_value'],$_POST['att_type']); }
if(isset($_POST['save_tournament_match_preview'])) { leagueengine_save_tournament_match_preview($tournament_id,$match_id,stripslashes_deep($_POST['match_preview'])); }
if(isset($_POST['save_tournament_match_report'])) { leagueengine_save_tournament_match_report($tournament_id,$match_id,stripslashes_deep($_POST['match_report'])); }
if(isset($_POST['tournament_match_swap'])) { leagueengine_tournament_match_swap($tournament_id,$match_id); }
$table = $wpdb->prefix . 'leagueengine_tournament_matches';
$match = $wpdb->get_row("SELECT * FROM $table WHERE tournament_id = '$tournament_id' AND id = '$match_id'");
$home_team_id = $match->home_team_id;
$away_team_id = $match->away_team_id;
$tournament = leagueengine_fetch_data_row('tournament',$tournament_id);
$table2 = $wpdb->prefix . 'leagueengine_tournaments';
$tournament_row = $wpdb->get_row("SELECT * FROM $table2 WHERE data_id = '$tournament_id'");
?>
<div id="leagueengine_admin" class="<?php echo $page; ?>">
<?php echo leagueengine_admin_header(); ?>
<div id="leagueengine_admin_content">
<?php if($msg) { echo $msg; } ?>
<ul class="breadcrumbs">
<li><?php _e('Competitions','leagueengine');?> <span class="divider">/</span></li>
<li><?php echo leagueengine_fetch_data_from_id($tournament_id,'data_value') ?> <span class="divider">/</span></li>
<?php if($match->round == 'GROUP') { ?>
<li><?php _e('Groups','leagueengine');?> <span class="divider">/</span></li>
<?php } else { ?>
<li><?php _e('Knockout','leagueengine');?> <span class="divider">/</span></li>
<?php } ?>
<li><?php _e('Match','leagueengine');?></li>
</ul>
<?php
if($league_type == 'players') {
$home_emblem = leagueengine_fetch_player_emblem($match->home_team_id,20);
$away_emblem = leagueengine_fetch_player_emblem($match->away_team_id,20,'right');
} else {
$home_emblem = leagueengine_fetch_team_emblem($match->home_team_id,20);
$away_emblem = leagueengine_fetch_team_emblem($match->away_team_id,20,'right');
}
?>
<div class="match_masthead">
<table>
<tr>
<td class="home_team" style="border-top: 5px solid <?php echo leagueengine_fetch_team_colour($match->home_team_id,'primary');?>; text-align:left;width:40%;"><?php echo $home_emblem . leagueengine_fetch_data_from_id($match->home_team_id,'data_value');?></td>
<td class="score" style="text-align:center;width:20%;"><span><?php echo $match->home_team_score;?> &dash; <?php echo $match->away_team_score;?></span></td>
<td class="away_team" style="border-top: 5px solid <?php echo leagueengine_fetch_team_colour($match->away_team_id,'primary');?>; text-align:right;width:40%;"><?php echo leagueengine_fetch_data_from_id($match->away_team_id,'data_value') . $away_emblem;?></td>
</tr>
<tr>
<td colspan="3" style="text-align:center;"><?php echo date(leagueengine_fetch_settings('date_format_php'),strtotime($match->match_date)) . ' ' . date(leagueengine_fetch_settings('time_format_php'),strtotime($match->match_time)); ?></td>
</tr>
<tr>
<td class="competition" colspan="3" style="text-align:center;"><?php echo '' . leagueengine_fetch_data_from_id($tournament_id,'data_value') . ''; ?></td>
</tr>
<tr><td colspan="100%" style="text-align:center;padding-bottom:20px;"><?php echo leagueengine_link('tournament_match&tid='.$tournament_id.'&mid='.$match->id,__('Go To Match','leagueengine'),'','','button-primary'); ?></td></tr>
</table>
</div>
<div id="leagueengine_tabs">
<ul>
<li><?php _e('Score','leagueengine');?></li>
<?php
$table = $wpdb->prefix . 'leagueengine_player_careers';
$homeplayers = $wpdb->get_results("SELECT * FROM $table WHERE tournament_id = '$tournament_id' AND team_id = '$home_team_id'");
$awayplayers = $wpdb->get_results("SELECT * FROM $table WHERE tournament_id = '$tournament_id' AND team_id = '$away_team_id'");
if($homeplayers or $awayplayers && $league_type != 'players') {
?>
<li><?php _e('Lineups','leagueengine');?></li>
<?php } ?>
<?php if(leagueengine_data_exists('event')) { echo '<li>' . __('Events','leagueengine') . '</li>'; } ?>
<?php if(leagueengine_statistics_exists('tournament_match')) { echo '<li>' . __('Statistics','leagueengine') . '</li>'; } ?>
<?php if(leagueengine_h2h_history($match->match_date,$home_team_id,$away_team_id)) { echo '<li>' . __('History','leagueengine') . '</li>'; } ?>
<li><?php _e('Report','leagueengine');?></li>
</ul>
<div id="score">
<form action="" method="POST">
<table class="form">
<tr>
<th style="width:20%;"><?php _e('Date/Time','leagueengine');?></th>
<th style="width:30%;text-align:center;"><?php _e('Home','leagueengine');?></th>
<th style="width:20%;text-align:center;"><?php _e('Score','leagueengine');?></th>
<th style="width:30%;text-align:center;"><?php _e('Away','leagueengine');?></th>
</tr>
<tr class="date">
<td><input type="text" class="leagueengine_datepicker" name="match_date" value="<?php echo date(leagueengine_fetch_settings('date_format_php'),strtotime($match->match_date));?>"></td>
<td colspan="3"></td>
</tr>
<input type="hidden" name="tournament_match_id" value="<?php echo $match->id;?>">
<input type="hidden" name="home_team_id" value="<?php echo $match->home_team_id;?>">
<input type="hidden" name="away_team_id" value="<?php echo $match->away_team_id;?>">
<input type="hidden" name="date_alt" class="leagueengine_datepicker_alt" value="<?php echo $match->match_date;?>">
<input type="hidden" name="time_alt" class="leagueengine_timepicker_alt" value="<?php echo $match->match_time;?>">
<tr>
<td><input type="text" class="leagueengine_timepicker" name="match_time" value="<?php echo date(leagueengine_fetch_settings('time_format_php'),strtotime($match->match_time));?>"></td>
<td style="text-align:center;"><?php echo leagueengine_fetch_data_from_id($match->home_team_id,'data_value') ;?></td>
<td style="text-align:center;">
<input style="width:48%;text-align:center;" type="text" name="home_team_score" value="<?php echo $match->home_team_score;?>">
<input style="width:48%;text-align:center;" type="text" name="away_team_score" value="<?php echo $match->away_team_score;?>">
</td>
<td style="text-align:center;"><?php echo leagueengine_fetch_data_from_id($match->away_team_id,'data_value') ;?></td>
</tr>
<?php if($tournament_row->pts_bonus == 'on') { ?>
<tr>
<td></td>
<td style="text-align:center;"><?php _e('Bonus Points','leagueengine');?></td>
<td style="text-align:center;">
<input style="width:48%;text-align:center;" type="text" name="home_team_bonus" value="<?php echo $match->home_team_bonus;?>">
<input style="width:48%;text-align:center;" type="text" name="away_team_bonus" value="<?php echo $match->away_team_bonus;?>">
</td>
<td style="text-align:center;"><?php _e('Bonus Points','leagueengine');?></td>
</tr>
<?php } ?>
</table>
<input style="margin-top:20px;" type="submit" name="save_tournament_match" class="button-primary" value="<?php _e('Save','leagueengine');?>" />
<input style="margin:20px 0 0 10px;" type="submit" name="tournament_match_swap" class="button" value="<?php _e('Swap Teams','leagueengine');?>" style="float:right;margin-right:10px;" />
</form>
</div>
<?php
$table = $wpdb->prefix . 'leagueengine_player_careers';
$homeplayers = $wpdb->get_results("SELECT * FROM $table WHERE tournament_id = '$tournament_id' AND team_id = '$home_team_id'");
$awayplayers = $wpdb->get_results("SELECT * FROM $table WHERE tournament_id = '$tournament_id' AND team_id = '$away_team_id'");
if($homeplayers or $awayplayers && $league_type != 'players') {
?>
<div id="lineups">
<?php echo leagueengine_tournament_match_lineups($tournament_id,$match_id);?>
</div>
<?php } ?>
<?php if(leagueengine_data_exists('event')) { ?>
<div id="events">
<?php echo leagueengine_tournament_match_events($tournament_id,$match_id);?>
</div>
<?php } ?>
<?php if(leagueengine_statistics_exists('tournament_match')) { ?>
<div id="statistics">
<?php echo leagueengine_fetch_statistics('tournament_match',NULL,NULL,$tournament_id,$match_id);?>
</div>
<?php } ?>
<?php if(leagueengine_h2h_history($match->match_date,$home_team_id,$away_team_id)) { ?>
<div id="history">
<?php echo leagueengine_fetch_h2h_history($match->match_date,$home_team_id,$away_team_id);?>
</div>
<?php } ?>
<div id="report">
<form action="" method="post">
<div class="setting">
<table class="form">
<tr><th><?php _e('Match Report','leagueengine');?></th></tr>
</table>
<?php wp_editor( stripslashes_deep($match->report), 'match_report', array( 'media_buttons' => true, 'tinymce' => true, 'quicktags' => true, 'textarea_rows' => 20 )); ?>
</div>
<input style="margin-top:20px;" type="submit" name="save_tournament_match_report" class="button-primary" value="<?php _e('Save','leagueengine'); ?>">
</form>
</div>
</div>
</div>
</div>
</div>

Small product issue on success page Magento

I try to get product details on my checkout success page in Magento 1.9, but I don't know why I get the same product for two times. This is what I add in the app/design/frontend/base/default/template/checkout/success.phtml file
<tbody>
<?php
foreach ($items as $item):
$_product = Mage::getModel('catalog/product')->load($item->getProductId());
$productType = $_product->getTypeId();
$entityId = $_product->getEntityId();
$options = $item->getProductOptions();
if ($productType == "bundle") {
$bundled_product = new Mage_Catalog_Model_Product();
$bundled_product->load($entityId);
$selectionCollection = $bundled_product->getTypeInstance(true)->getSelectionsCollection( $bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product );
$bundled_items = array();
foreach ($selectionCollection as $option) {
$bundled_items[] = $option->product_id;
}?>
<tr>
<td rowspan="1">
<img class="product_img" src="<?php echo Mage::helper('catalog/image')->init($_product, 'thumbnail')->resize(75); ?>" alt="product-img" />
<?php echo $item->getName();
$customOptions = $options['options'];
if (!empty($customOptions)) {
foreach ($customOptions as $option) {?>
<span class="bottom-align">
<?php
echo '<b>' . $option['label'] . '</b> :';
echo $optionValue = $option['value'];
?>
</span>
<?php
}
}
?>
</td>
<td><?php echo $this->helper('checkout')->formatPrice($item->getPrice()); ?></td>
<td><?php echo $item->getQtyOrdered(); ?></td>
<td><?php echo $item->getSku(); ?></td>
<td><?php echo $this->helper('checkout')->formatPrice($item->getRowTotal()); ?></td>
</tr>
<?php
} else if (in_array($entityId, $bundled_items)) {
} else {
?>
<tr>
<td>
<img class="product_img" src="<?php echo Mage::helper('catalog/image')->init($_product, 'thumbnail')->resize(75); ?>" alt="product-img" />
<?php
echo $item->getName();
$customOptions = $options['options'];
if (!empty($customOptions)) {
foreach ($customOptions as $option) {
?>
<span class="bottom-align">
<?php
echo '<b>' . $option['label'] . '</b> :';
echo $optionValue = $option['value'];
?></span>
<?php
}
}
?>
</td>
<td><?php echo $this->helper('checkout')->formatPrice($item->getPrice()); ?></td>
<td><?php echo $item->getQtyOrdered(); ?></td>
<td><?php echo $item->getSku(); ?></td>
<td><?php echo $this->helper('checkout')->formatPrice($item->getRowTotal()); ?></td>
</tr>
<?php
}
?>
<?php endforeach ?>
</tbody>
This is the expected behaviour. There are several rows inserted into database for composite products: bundles, configurables.
In your case first one is a bundle product himself, second one is a selected simple product.
You can replace } else { with } elseif (!$item->getParentId()) { in your template to skip child simple product.

Getting magento Attribute on item returns blank

I am trying to get some custom attributes to show in magento like Color, Delivery_Time...
I could call Some Attributes with :
<?php echo $item->getName();?>
<?php echo $item->getWeight();?>
But i could'nt call the most of the attributes. i've tried also :
<?php echo $this->htmlEscape($item->getData('luftkammern'));?>
<?php echo $item->getAttributeText('spannung'); ?>
Nothing works!!
Code of attributes :
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct()
?>
<?php if($_additional = $this->getAdditionalData()): ?>
<h2><?php echo $this->__('Additional Information') ?></h2>
<table class="data-table" id="product-attribute-specs-table">
<col width="25%" />
<col />
<tbody>
<?php foreach ($_additional as $_data): ?>
<tr>
<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product,$_data['value'], $_data['code']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
<?php endif;?>
code
echo $this->__('Additional Information');?>
<table class="data-table" id="product-attribute-specs-table">
<col width="25%" />
<col />
<tbody>
<?php foreach ($_additional as $_data): ?>
<tr>
<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
can anyone help please ?
If you need to get those attributes in checkout page, you can do like this :
$_product = $item->getProduct();
$pid = $_product->getId();
$product = Mage::getModel('catalog/product')->load($pid);
/* getting some attributes */
$color = $product->getData('color');
$manufacturer = $product->getData('manufacturer');
$delivery_date = $product->getData('delivery_date');
....
Hope it will help you.
You can get attributes from a product by calling the correct get function.
For example to receive the color use:
echo $item->getColor();
To receive the manufacturer use:
echo $item->getManufacturer();
Also you have to make sure that your product has been fully loaded. Try this:
print_r($item->getData());
Please check the following code:
$attributes = $product->getAttributes();
$additional_data = array();
foreach ($attributes as $attribute) {
if ($attribute->getIsVisibleOnFront() && $attribute->getIsUserDefined()) {
$value = $attribute->getFrontend()->getValue($product);
if (!$product->hasData($attribute->getAttributeCode())) {
$value = Mage::helper('catalog')->__('N/A');
} elseif ((string)$value == '') {
$value = Mage::helper('catalog')->__('No');
} elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
$value = Mage::app()->getStore()->convertPrice($value, true);
}
if (is_string($value) && strlen($value)) {
$additional_data[$attribute->getAttributeCode()] = array(
'label' => $attribute->getStoreLabel(),
'value' => $value,
'code' => $attribute->getAttributeCode()
);
}
}
}
/* Your code here */
<h2><?php echo $this->__('Additional Information') ?></h2>
...
<?php foreach ($additional_data as $_data): ?>
...

WordPress - Theme Options Page with Category List

I am trying to create an options page for my theme, where on the options page there is a dropdown list that displays all of the category names, with the option value as the ID number of the category, so that on the dropdown itself, it displays all of the category names, but then when you select your category, and echo this in the frontend, it echos the categories ID.
The code I have at the moment displays the list of category names, but also echos the name onto the frontend. I have tried to modify it for the ID number, but I've had no luck.
So just to summarize, on the options page, it needs to display the category names in the dropdown, but on the frontend it should echo the category's ID number.
EDIT: This is the complete code I am using to create the options page - this all sits inside functions.php:
<?php
$themename = "TGH 2012";
$shortname = "tgh";
$categories = get_categories('hide_empty=0&orderby=name');
$wp_cats = array();
foreach ($categories as $category_list ) {
$wp_cats[$category_list->cat_id] = $category_list->cat_name;
}
array_unshift($wp_cats, "Choose a category");
global $options;
$options = array (
array( "name" => "Homepage Options",
"type" => "title"),
array( "type" => "open"),
array( "name" => "Pick Categories",
"desc" => "Choose a category from the list to do some interesting stuff.",
"id" => $shortname."_categories",
"type" => "select",
"options" => $wp_cats,
"std" => ""),
array( "type" => "close")
);
function mytheme_add_admin() {
global $themename, $shortname, $options;
if ( $_GET['page'] == basename(__FILE__) ) {
if ( 'save' == $_REQUEST['action'] ) {
foreach ($options as $value) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
foreach ($options as $value) {
if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
header("Location: themes.php?page=functions.php&saved=true");
die;
} else if( 'reset' == $_REQUEST['action'] ) {
foreach ($options as $value) {
delete_option( $value['id'] ); }
header("Location: themes.php?page=functions.php&reset=true");
die;
}
}
add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
function mytheme_admin() {
global $themename, $shortname, $options;
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
?>
<div class="wrap">
<h2><?php echo $themename; ?> settings</h2>
<form method="post">
<?php foreach ($options as $value) {
switch ( $value['type'] ) {
case "open":
?>
<table width="100%" border="0" style="background-color:#eef5fb; padding:10px;">
<?php break;
case "close":
?>
</table>
<br />
<?php break;
case "title":
?>
<table width="100%" border="0" style="background-color:#dceefc; padding:5px 10px;">
<tr>
<td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
</tr>
<?php break;
case 'text':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" /></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr>
<tr>
<td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<?php
break;
case 'textarea':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:400px; height:200px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>
</textarea></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr>
<tr>
<td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<?php
break;
case 'select':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $option) { ?>
<option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr>
<tr>
<td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<?php
break;
case "checkbox":
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><? if(get_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> /></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr>
<tr>
<td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<?php break;
}
}
?>
<!--</table>-->
<p class="submit">
<input name="save" type="submit" value="Save changes" />
<input type="hidden" name="action" value="save" />
</p>
</form>
<form method="post">
<p class="submit">
<input name="reset" type="submit" value="Reset" />
<input type="hidden" name="action" value="reset" />
</p>
</form>
<?php
}
add_action('admin_menu', 'mytheme_add_admin'); ?>
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '',
'after_title' => '',
));
?>
The following code is then placed at the bottom of "header.php":
<?php global $options;
foreach ($options as $value) {
if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}
?>
And then, this is the code I am using to show the saved variable on the front-end:
<?php echo $tgh_categories; ?>
Is this how it really appears? If so, change cat_id to cat_ID
foreach ($categories as $category_list ) {
$wp_cats[$category_list->cat_id] = $category_list->cat_name;
}
EDIT
After this:
foreach ($categories as $category_list ) {
$wp_cats[$category_list->cat_ID] = $category_list->cat_name;
}
Add:
$wp_ids = array();
foreach ($categories as $category_list ) {
$wp_ids[$category_list->cat_ID] = $category_list->cat_ID;
}
Change this:
array( "name" => "Pick Categories",
"desc" => "Choose a category from the list to do some interesting stuff.",
"id" => $shortname."_categories",
"type" => "select",
"options" => $wp_cats,
"std" => ""),
To this:
array( "name" => "Pick Categories",
"desc" => "Choose a category from the list to do some interesting stuff.",
"id" => $shortname."_categories",
"cid" => wp_ids,
"type" => "select",
"options" => $wp_cats,
"std" => ""),
Also change this:
case 'select':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $option) { ?>
<option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr>
<tr>
<td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<?php
break;
To this:
case 'select':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $option) { ?>
<option value="<?php echo $value['cid']; ?>" <?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr>
<tr>
<td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<?php
break;
EDIT
My bad, I forgot a $
Change this:
"cid" => wp_ids,
To:
"cid" => $wp_ids,
NEW EDIT
Change this:
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $option) { ?>
<option value="<?php echo $value['cid']; ?>" <?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option>
<?php } ?>
</select></td>
</tr>
To this:
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php
$categories = get_categories('hide_empty=0&orderby=name');
foreach ($categories as $category_list ) {
?>
<option value="<?php echo $category_list->cat_ID; ?>" <?php if ( get_settings( $value['id'] ) == $category_list->cat_name) { echo ' selected="selected"'; } elseif ($category_list->cat_name == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $category_list->cat_name; ?></option>
<?php } ?>
</select></td>
</tr>
Have you looked at using the Options Framework?
It takes all the hassle out of making an admin panel. And as a bonus there are functions built in for category drop down lists.
I've been looking for the same thing, and have found no where which actually answers what you're trying to do, not even this thread. At least here they're close, but they still break some functionality in your question code provided. However, I have been working on this for a few hours, and per usual, the longer you work at it, the simpler the solution turns out to be.
I've made an assumption that you're trying to us WP_Query to choose and display posts from a category chosen in your new them options page, like I am. I've discovered that WP_Query doesn't like recursively sifting through categories if you are using a name, but will if you're using cat_ID...not even when using get_cat_ID. So first, here is my WP_Query that appears in my front-page.php
<?php
$feat1= get_option('twp_feat_cat'); //this is the id of your option in the mega array you setup in functions.php
$args=array('cat' => $feat1,'post_type' => 'post','post_status' => 'publish','posts_per_page' => 2,'caller_get_posts'=> 1);
$my_query = null;
$my_query = new WP_Query($args);
$post_counter = 0; //so I can style last post differently with css
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); $post_counter++; ?>
<article id="post-<?php the_ID(); ?>" <?php if ($post_counter == 1) post_class('fourcol first clearfix'); elseif ($post_counter == count( $posts )) post_class('fourcol last clearfix'); else post_class('fourcol clearfix'); ?> role="article">
<header class="article-header">
<h2><?php the_title(); ?></h2>
</header> <!-- end header section -->
<section class="entry-content clearfix">
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'original' );
$url = $thumb['0'];
echo do_shortcode( '[rimg src="' . $url . '"]' );
?>
<?php the_excerpt(); ?>
</section> <!-- end article section -->
<footer class="article-footer">
<p class="tags"><?php //the_tags('<span class="tags-title">' . __('Tags:', 'bonestheme') . '</span> ', ', ', ''); ?></p>
</footer> <!-- end article footer -->
</article>
<?php
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
This snippet takes the cat_ID from my theme options page and puts it into $feat1
The only two changes needed to your functions.php from the original are changing this:
$wp_cats[$category_list->cat_id] = $category_list->cat_name;
to this:
$wp_cats[$category_list->cat_ID] = $category_list->cat_ID;
and then modify your selection <option> tag from this:
<option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option>
to this:
<option value="<?php echo $option;?>" <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>><?php echo get_cat_name($option); ?></option>
I didn't have to put anything in my header.php to get this working. So what this does is instead of using the cat_name, it uses cat_ID, but fills in the user friendly cat_name in the drop down, while still associating each entry to the cat_ID, which I think it what you were looking for. I'm sorry if this was long, late, or not quite what you were looking for, but this is my very first time contributing to the site, and it was this post that got me started when I was looking for the solution.

Categories