I'm looking for some help getting customize the attribute table on WooCommerce.
<table>
<?php foreach (array_chunk($product_attributes, 2) as $product_attribute_key => $product_attribute) :{ ?>
<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item--<?php echo esc_attr( $product_attribute_key ); ?>">
<?php foreach ($product_attribute as $value) :{ ?>
<th class="woocommerce-product-attributes-item__label"><?php echo wp_kses_post( $value['label'] ); ?></th>
<td class="woocommerce-product-attributes-item__value"><?php echo wp_kses_post( $value['value'] ); ?></td>
<?php } endforeach; ?>
</tr>
<?php } endforeach; ?>
</table>
I tried modify the above snippet in order to break line between Attribute Name and Attribute Value to display the attributes like it is in the below picture.
attributes
Is there any easy hook to get this work?
Thanks in Advance.
Create child-theme in case of theme update to not lose your settings.
Create in child-theme folders /woocommerce/single-product/ and copy from woocommerce/templates/single-product the file product-attributes.php.
Change:
defined( 'ABSPATH' ) || exit;
if ( ! $product_attributes ) {
return;
}
?>
<table class="woocommerce-product-attributes shop_attributes">
<?php foreach ( $product_attributes as $product_attribute_key => $product_attribute ) : ?>
<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item--<?php echo esc_attr( $product_attribute_key ); ?>">
<th class="woocommerce-product-attributes-item__label"><?php echo wp_kses_post( $product_attribute['label'] ); ?></th>
<td class="woocommerce-product-attributes-item__value"><?php echo wp_kses_post( $product_attribute['value'] ); ?></td>
</tr>
<?php endforeach; ?>
</table>
to
defined( 'ABSPATH' ) || exit;
if ( ! $product_attributes ) {
return;
}
$i = 0;
?>
<div class="woocommerce-product-attributes shop_attributes">
<?php foreach ( $product_attributes as $product_attribute_key => $product_attribute ) : ?>
<div class="woocommerce-product-attributes-item woocommerce-product-attributes-item--<?php echo esc_attr( $product_attribute_key ); ?>">
<div class="woocommerce-product-attributes-item__label"><?php echo wp_kses_post( $product_attribute['label'] ); ?></div>
<div class="woocommerce-product-attributes-item__value"><?php echo wp_kses_post( $product_attribute['value'] ); ?></div>
</div>
<?php
if ($i % 2 != 0){
echo '<div class="clear"></div>';
}
$i++;
endforeach; ?>
</div>
add CSS
/*2 Columnt style on product attributes*/
.woocommerce-product-attributes.shop_attributes .woocommerce-product-attributes-item {
float: left;
width: 50%;
margin-bottom: 8px;
padding-right:10px;
}
Related
So, in settings of Woocommerce weight and other metric system in Russian language.
But in product page for example it still in English (g - gramm).
I have copied file in to my theme: /wp-content/themes/my_theme/woocommerce/single-product/product-attributes.php
What should I do in this file to display right Weight metric system in Russian language? This code did not help:
<td class="product_weight"><?php echo wc_format_localized_decimal( $product->get_weight() ) . ' ' . __(esc_attr( get_option( 'woocommerce_weight_unit' ) ), 'woocommerce'); ?></td>
Code of /product-attributes.php:
defined( 'ABSPATH' ) || exit;
if ( ! $product_attributes ) {
return;
}
?>
<table class="woocommerce-product-attributes shop_attributes">
<?php foreach ( $product_attributes as $product_attribute_key => $product_attribute ) : ?>
<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item--<?php echo esc_attr( $product_attribute_key ); ?>">
<th class="woocommerce-product-attributes-item__label"><?php echo wp_kses_post( $product_attribute['label'] ); ?></th>
<td class="woocommerce-product-attributes-item__value"><?php echo wp_kses_post( $product_attribute['value'] ); ?></td>
</tr>
<?php endforeach; ?>
</table>
Thank you!
Done, just posted this code in theme's functions.php
function localize_weight_units($weight) {
return str_replace('g', 'г', $weight);
}
add_filter('woocommerce_format_weight', 'localize_weight_units');
I am trying to change the Shipping field order in WooCommerce new order emails,
However, modifying the Shipping field in email-addresses.php will break the checkout page. How can I modify this?
This is how I am modifying:
0.Source code:
$text_align = is_rtl() ? 'right' : 'left';
$address = $order->get_formatted_billing_address();
$shipping = $order->get_formatted_shipping_address();
?><table id="addresses" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top; margin-bottom: 40px; padding:0;" border="0">
<tr>
<td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; border:0; padding:0;" valign="top" width="50%">
<h2><?php esc_html_e( 'Billing address', 'woocommerce' ); ?></h2>
<address class="address">
<?php echo wp_kses_post( $address ? $address : esc_html__( 'N/A', 'woocommerce' ) ); ?>
<?php if ( $order->get_billing_phone() ) : ?>
<br/><?php echo esc_html( $order->get_billing_phone() ); ?>
<?php endif; ?>
<?php if ( $order->get_billing_email() ) : ?>
<br/><?php echo esc_html( $order->get_billing_email() ); ?>
<?php endif; ?>
</address>
</td>
<?php if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && $shipping ) : ?>
<td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; padding:0;" valign="top" width="50%">
<h2><?php esc_html_e( 'Shipping address', 'woocommerce' ); ?></h2>
<address class="address"><?php echo wp_kses_post( $shipping ); ?></address>
</td>
<?php endif; ?>
</tr>
</table>
1.Successfully modified the Billing field:
<address class="address">
<?php //echo wp_kses_post( $address ? $address : esc_html__( 'N/A', 'woocommerce' ) ); ?>
Name: <?php echo $order->billing_first_name; ?><?php echo $order->billing_last_name; ?><br>
Address:<?php echo $order->billing_country; ?><?php echo $order->billing_postcode; ?><?php echo $order->billing_city; ?><?php echo $order->billing_state; ?><?php echo $order->billing_address_1; ?>
<?php if ( $order->get_billing_phone() ) : ?>
<br/>Phone:<?php echo esc_html( $order->get_billing_phone() ); ?>
<?php endif; ?>
<?php if ( $order->get_billing_email() ) : ?>
<br/>Email:<?php echo esc_html( $order->get_billing_email() ); ?>
<?php endif; ?>
</address>
</td>
2.This is I want to change shipping field, but not work:
<td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; padding:0;" valign="top" width="50%">
<h2><?php esc_html_e( 'Shipping address', 'woocommerce' ); ?></h2>
<address class="address">
<?php //echo wp_kses_post( $shipping ); ?>
Shipping Name:<?php echo esc_html($order->get_shipping_first_name() ); ?><?php echo esc_html($order->get_shipping_last_name() ); ?><br>
Shipping Address:<?php echo $order->esc_html(get_shipping_country() ); ?><?php echo esc_html($order->get_shipping_postcode() ); ?><?php echo esc_html($order->get_shipping_city() ); ?><?php echo esc_html($order->get_shipping_state() ); ?><?php echo esc_html($order->get_shipping_address_1() );?>
<?php if ( $order->get_shipping_phone() ) : ?>
<br/>Shipping Phone:<?php echo esc_html( $order->get_shipping_phone() ); ?>
<?php endif; ?>
<?php if ( $order->get_shipping_email() ) : ?>
<br/>Shipping Email:<?php echo esc_html( $order->get_shipping_email() ); ?>
<?php endif; ?>
</address>
Any help Where can i get and change it?
Thanks
Hey there your code is perfect except the following lines
1> if ( $order->get_shipping_phone() )
2> if ( $order->get_shipping_email() )
in above lines get_shipping_phone and get_shipping_email are the methods which are not available in the woocommerce itself so you can use get_billing_email and get_billing_phone instead of them if you want.
I am trying to add up all of my added coupons to get a discount total in the checkout. I tried adding a variable at the top of the checkout template file and doing ++ for each entry but I throws errors.
Any ideas how to add the values to a variable to get a total?
The checkout totals regenerate if you alter a value so I found my answer being outputted each time the loop runs.
My code:
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php $helloworld = wc_cart_totals_coupon_html( $coupon )++; ?></td>
</tr>
<?php endforeach; ?>
This can be done easily using some existing WC_Cart methods.
So in the template checkout/oreder-review.php, just after this:
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
You will insert the following code (after line 69):
<?php
$discount_excl_tax_total = WC()->cart->get_cart_discount_total();
$discount_tax_total = WC()->cart->get_cart_discount_tax_total();
$discount_total = $discount_excl_tax_total + $discount_tax_total;
if( ! empty($discount_total) ): ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php _e('Discount total','woocommerce'); ?></th>
<td><?php echo wc_price(-$discount_total) ?></td>
</tr>
<?php endif; ?>
Tested and works.
I've been trying for ages to simply calculate the "weight" field we have added to an invoice plugin called sliced invoices. All I need is for it to total the weight based on the value in the table.
The weight field has the div class, "adjust". Here's a link to the forms PDF and you'll see the empty table field - Weight. http://cavcon.co.za/sliced_quote/346-2/?create=pdf&id=346&print_pdf=8d39bfe988
Here's the code I'm working with:
<?php
$count = 0;
$items = sliced_get_invoice_line_items(); // gets quote and invoice
if( !empty( $items ) ) :
foreach ( $items[0] as $item ) {
$class = ($count % 2 == 0) ? 'even' : 'odd';
$item_tax = isset( $item['tax'] ) ? $item['tax'] : 0;
$line_total = $shared->get_line_item_sub_total( $item['qty'], $item['amount']);
?>
<tr class="row_<?php echo $class; ?> sliced-item">
<td class="qty"><?php echo esc_html( $item['qty'] ); ?></td>
<td class="service"><?php echo esc_html( isset( $item['title'] ) ? $item['title'] : '' ); ?>
<?php if ( isset( $item['description'] ) ) : ?>
<br/><span class="description"><?php echo esc_html( $item['description']); ?></span>
<?php endif; ?>
</td>
<td class="rate"><?php echo esc_html( $shared->get_formatted_currency( $item['amount'] ) ); ?></td>
<?php if ( sliced_hide_adjust_field() === false) { ?>
<td class="adjust"><?php echo esc_html( $item_tax ? $item['tax'] . 'kg' : '-' ); ?></td>
<?php } ?>
<td class="total"><?php echo esc_html( $shared->get_formatted_currency( $line_total ) ); ?></td>
</tr>
<?php $count++;
}
endif; ?>
</tbody>
</table>
<?php
}
endif;
if ( ! function_exists( 'sliced_display_invoice_totals' ) ) :
function sliced_display_invoice_totals() { ?>
<table class="table table-sm table-bordered" id="new-table">
<tbody>
<?php do_action( 'sliced_invoice_before_totals' ); ?>
<tr class="row-sub-total">
<td class="rate"><?php echo _e( 'Total Weight', 'sliced-invoices' ); ?></td>
<td class="total-weight"><?php echo esc_html( $item['weight'] ); ?>
</td>
</tr>
<tr class="row-sub-total">
<td class="rate"><?php echo _e( 'Sub Total', 'sliced-invoices' ); ?></td>
<td class="total"><?php echo esc_html( sliced_get_invoice_sub_total() ); ?></td>
</tr>
<tr class="row-tax">
<td class="rate"><?php echo esc_html( sliced_get_tax_name() ); ?></td>
<td class="total"><?php echo esc_html( sliced_get_invoice_tax() ); ?></td>
</tr>
<tr class="table-active row-total">
<td class="rate"><strong><?php echo _e( 'Total', 'sliced-invoices' ); ?></strong></td>
<td class="total"><strong><?php echo esc_html( sliced_get_invoice_total() ); ?></strong></td>
</tr>
<?php do_action( 'sliced_invoice_after_totals' ); ?>
</tbody>
</table>
<?php
}
endif;
THIS IS WHERE I'M AT
if ( ! function_exists( 'sliced_display_invoice_totals' ) ) :
$total_weight = 0;
foreach ( $items[0] as $item ) {
$total_weight = $total_weight + $item['tax'];
}
function sliced_display_invoice_totals() { ?>
<table class="table table-sm table-bordered" id="new-table">
<tbody>
<?php do_action( 'sliced_invoice_before_totals' ); ?>
<tr class="row-sub-total">
<td class="rate"><?php echo _e( 'Total Weight', 'sliced-
invoices' ); ?></td>
<td class="total-weight"><?php echo esc_html(
$total_weight . 'kg') ?>
</td>
If you run PHP version 5.5 or above, you can sum the weights in this way:
if( !empty( $items ) ) :
foreach ( $items[0] as $item ) {
(...)
}
$total_weight = array_sum( array_column( $items, 'tax' ) );
endif; ?>
Otherwise, you have to increment $total_weight inside foreach loop:
$total_weight = 0;
foreach ( $items[0] as $item ) {
$total_weight = $total_weight + $item['tax'];
(...)
}
If you output total weight in the same scope of above script, simply put echo $total_weight; where you want to print it (or echo esc_html( $total_weight . 'kg');, according with your other prints).
But maybe your totals is output through sliced_display_invoice_totals function (although I don't see any call to this function in your code); in this case, the $total_weight variable is not directly available in the function, due to different scope. You have to print it in this way:
function sliced_display_invoice_totals() { ?>
(...)
echo $GLOBALS['total_weight']; // or echo esc_html( $GLOBALS['total_weight'] . 'kg');
(...)
}
Pleae careful note:
In your code, the function sliced_display_invoice_totals declaration is prepended by condition if ( ! function_exists( 'sliced_display_invoice_totals' ) ): this means that, if the function is already defined, your function modification will be ignored: in this case, you have to modify the already declare function instead.
To see if the function is already declared, place this temporary code before if condition:
if( function_exists( 'sliced_display_invoice_totals' ) )
{
$reflFunc = new ReflectionFunction( 'sliced_display_invoice_totals' );
die( $reflFunc->getFileName() . ':' . $reflFunc->getStartLine() );
}
In this way you can see the filePath and line in which the function is defined and modify it.
See more about array_sum
See more about array_column
See more about Variables scope
See more about Reflection class
Here is a list of things to change:
1. Unpaired HTML tags
The code in your question does not include the <table> nor <tbody> tags which you later close. I assume they are present in your original code.
2. Unpaired braces
Maybe also just an error while drafting your question, but after the </table> there is a closing PHP } and endif which have no matching opening statements.
3. Use of _e
According to the documentation of _e() on wordpress.org:
Displays the returned translated text from translate()
[...]
This function does not return a value.
So you are not supposed to write echo _e(...), you should just write _e(...) instead.
4. Function sliced_display_invoice_totals
You define this function that displays the totals, but you never call it. If you intend to display that table then do just that, without function definition.
5. When $items is empty
You have a condition so that the first table is only produced when $items is not empty. However, the totals table is produced outside that context, so it would also be produced when $items is empty. This might not be what you want. Consider moving the code for the second table inside that if block.
6. Mixed use of normal and alternative syntax
You use often the : ... endif syntax, which can indeed be helpful to read code that is interrupted by HTML code. But you don't use it consistently. I suggest using it for all if statements and for the foreach construct as well.
7. Calculate and display the $total_weight
Inside your existing foreach loop, add the weight of each line to $total_weight. You must also initialise this value just before starting the loop with 0.
Then in the second table display that $total_weight with the same format as you display the individual weights in the first table.
Here is the code that has all of the above applied:
<table class="table table-sm table-bordered" id="detail-table">
<tbody>
<?php
$count = 0;
$items = sliced_get_invoice_line_items(); // gets quote and invoice
// *** add this line ***
$total_weight = 0;
if( !empty( $items ) ) :
foreach ( $items[0] as $item ) :
$class = ($count % 2 == 0) ? 'even' : 'odd';
$item_tax = isset( $item['tax'] ) ? $item['tax'] : 0;
// *** add this line ***
$total_weight += $item_tax;
$line_total = $shared->get_line_item_sub_total( $item['qty'], $item['amount']);
?>
<tr class="row_<?php echo $class; ?> sliced-item">
<td class="qty"><?php echo esc_html( $item['qty'] ); ?></td>
<td class="service"><?php echo esc_html( isset( $item['title'] ) ? $item['title'] : '' ); ?>
<?php if ( isset( $item['description'] ) ) :
?> <br/><span class="description"><?php echo esc_html( $item['description']); ?></span>
<?php endif;
?> </td>
<td class="rate"><?php echo esc_html( $shared->get_formatted_currency( $item['amount'] ) ); ?></td>
<?php if ( sliced_hide_adjust_field() === false) :
?> <td class="adjust"><?php echo esc_html( $item_tax ? $item['tax'] . 'kg' : '-' ); ?></td>
<?php endif;
?>
<td class="total"><?php echo esc_html( $shared->get_formatted_currency( $line_total ) ); ?></td>
</tr>
<?php $count++;
endforeach; // use consistent syntax (alternative)
?>
</tbody>
</table>
<?php
// **** Remove the IF and the FUNCTION. You want to execute this now. ***
?>
<table class="table table-sm table-bordered" id="new-table">
<tbody>
<?php do_action( 'sliced_invoice_before_totals' ); ?>
<tr class="row-sub-total">
<td class="rate"><?php _e( 'Total Weight', 'sliced-invoices' ); ?></td>
<td class="total-weight"><?php echo esc_html( $total_weight ? $total_weight . 'kg' : '-' ); ?></td>
</tr>
<tr class="row-sub-total">
<td class="rate"><?php _e( 'Sub Total', 'sliced-invoices' ); ?></td>
<td class="total"><?php echo esc_html( sliced_get_invoice_sub_total() ); ?></td>
</tr>
<tr class="row-tax">
<td class="rate"><?php echo esc_html( sliced_get_tax_name() ); ?></td>
<td class="total"><?php echo esc_html( sliced_get_invoice_tax() ); ?></td>
</tr>
<tr class="table-active row-total">
<td class="rate"><strong><?php _e( 'Total', 'sliced-invoices' ); ?></strong></td>
<td class="total"><strong><?php echo esc_html( sliced_get_invoice_total() ); ?></strong></td>
</tr>
<?php do_action( 'sliced_invoice_after_totals' ); ?>
</tbody>
</table>
<?php
// **** Consider closing the if (!empty($items)) here ***
endif;
?>
You did not specify the code for the many functions you call, like sliced_get_tax_name, sliced_get_invoice_tax,... etc. Unless there is a problem with any of these functions, the above code should work.
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>