2012-11-27 16:22:47 +00:00
< ? php
2012-11-09 21:15:15 +00:00
/**
* Shipping Methods Display
*
* @ author WooThemes
* @ package WooCommerce / Templates
2012-12-03 19:19:58 +00:00
* @ version 2.0 . 0
2012-11-09 21:15:15 +00:00
*/
2012-11-27 16:22:47 +00:00
2012-11-09 21:15:15 +00:00
global $woocommerce ;
// If at least one shipping method is available
if ( $available_methods ) {
// Prepare text labels with price for each shipping method
foreach ( $available_methods as $method ) {
$method -> full_label = $method -> label ;
if ( $method -> cost > 0 ) {
2012-12-03 16:36:54 +00:00
if ( $woocommerce -> cart -> tax_display_cart == 'excl' ) {
2012-11-09 21:15:15 +00:00
$method -> full_label .= ': ' . woocommerce_price ( $method -> cost );
if ( $method -> get_shipping_tax () > 0 && $woocommerce -> cart -> prices_include_tax ) {
2012-12-16 16:28:54 +00:00
$method -> full_label .= ' <small>' . $woocommerce -> countries -> ex_tax_or_vat () . '</small>' ;
2012-11-09 21:15:15 +00:00
}
} else {
$method -> full_label .= ': ' . woocommerce_price ( $method -> cost + $method -> get_shipping_tax () );
if ( $method -> get_shipping_tax () > 0 && ! $woocommerce -> cart -> prices_include_tax ) {
2012-12-16 16:28:54 +00:00
$method -> full_label .= ' <small>' . $woocommerce -> countries -> inc_tax_or_vat () . '</small>' ;
2012-11-09 21:15:15 +00:00
}
}
2012-11-27 16:57:35 +00:00
} elseif ( $method -> id !== 'free_shipping' ) {
$method -> full_label .= ' (' . __ ( 'Free' , 'woocommerce' ) . ')' ;
2012-11-09 21:15:15 +00:00
}
2013-02-02 17:50:53 +00:00
$method -> full_label = apply_filters ( 'woocommerce_cart_shipping_method_full_label' , $method -> full_label , $method );
2012-11-09 21:15:15 +00:00
}
// Print a single available shipping method as plain text
if ( 1 === count ( $available_methods ) ) {
echo wp_kses_post ( $method -> full_label ) . '<input type="hidden" name="shipping_method" id="shipping_method" value="' . esc_attr ( $method -> id ) . '" />' ;
// Show select boxes for methods
} elseif ( get_option ( 'woocommerce_shipping_method_format' ) == 'select' ) {
echo '<select name="shipping_method" id="shipping_method">' ;
foreach ( $available_methods as $method )
echo '<option value="' . esc_attr ( $method -> id ) . '" ' . selected ( $method -> id , $woocommerce -> session -> chosen_shipping_method , false ) . '>' . wp_kses_post ( $method -> full_label ) . '</option>' ;
echo '</select>' ;
2012-11-27 16:22:47 +00:00
2012-11-09 21:15:15 +00:00
// Show radio buttons for methods
} else {
echo '<ul id="shipping_method">' ;
foreach ( $available_methods as $method )
echo '<li><input type="radio" name="shipping_method" id="shipping_method_' . sanitize_title ( $method -> id ) . '" value="' . esc_attr ( $method -> id ) . '" ' . checked ( $method -> id , $woocommerce -> session -> chosen_shipping_method , false ) . ' /> <label for="shipping_method_' . sanitize_title ( $method -> id ) . '">' . wp_kses_post ( $method -> full_label ) . '</label></li>' ;
echo '</ul>' ;
}
// No shipping methods are available
} else {
if ( ! $woocommerce -> customer -> get_shipping_country () || ! $woocommerce -> customer -> get_shipping_state () || ! $woocommerce -> customer -> get_shipping_postcode () ) {
echo '<p>' . __ ( 'Please fill in your details to see available shipping methods.' , 'woocommerce' ) . '</p>' ;
} else {
echo '<p>' . __ ( 'Sorry, it seems that there are no available shipping methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.' , 'woocommerce' ) . '</p>' ;
}
}