radio shipping methods

This commit is contained in:
Mike Jolley 2012-05-13 21:02:07 +01:00
parent c292060045
commit 26a8af2440
8 changed files with 92 additions and 30 deletions

View File

@ -884,6 +884,20 @@ $woocommerce_settings['shipping'] = apply_filters('woocommerce_shipping_settings
'type' => 'checkbox',
'checkboxgroup' => 'end'
),
array(
'name' => __( 'Shipping methods display format', 'woocommerce' ),
'desc' => __( 'This controls how multiple shipping methods are displayed on the frontend.', 'woocommerce' ),
'id' => 'woocommerce_shipping_method_format',
'css' => 'min-width:150px;',
'std' => '',
'type' => 'select',
'options' => array(
'' => __( 'Radio buttons', 'woocommerce' ),
'select' => __( 'Select box', 'woocommerce' ),
),
'desc_tip' => true,
),
array(
'name' => __( 'Shipping destination', 'woocommerce' ),

File diff suppressed because one or more lines are too long

View File

@ -20,6 +20,7 @@
.text_shadow( 0, 1px, 0, lighten( @secondary, 4 ) );
list-style:none outside;
.clearfix();
width: auto;
&:before {
content: "";
@ -379,7 +380,7 @@ span.onsale {
.clearfix();
ul.products, ul {
float:none;
li {
li.product {
width: 48%;
img {
width: 100%;
@ -390,7 +391,7 @@ span.onsale {
}
ul.products {
li {
li.product {
float:left;
margin: 0 3.8% 2.992em 0;
padding: 0;
@ -1062,7 +1063,7 @@ ul.cart_list, ul.product_list_widget {
}
}
td, th {
padding: 6px 12px;
padding: 6px 3px;
}
small {
display:block;
@ -1077,7 +1078,7 @@ ul.cart_list, ul.product_list_widget {
}
tr td, tr th {
border-top: 1px solid @secondary;
padding: 6px 24px;
padding: 6px 6px;
}
a.button.alt {
width: 193px;
@ -1157,6 +1158,21 @@ form.login, form.checkout_coupon {
.border_radius(5px);
}
ul#shipping_method {
list-style: none outside;
margin: 0;
padding: 0;
li {
margin: 0;
padding: .25em 0 .25em 22px;
text-indent: -22px;
list-style: none outside;
}
.amount {
font-weight: bold;
}
}
/* =Checkout
-------------------------------------------------------------- */

View File

@ -521,9 +521,9 @@ jQuery(document).ready(function($) {
if (woocommerce_params.is_cart==1) {
$('select#shipping_method').live('change', function() {
$('select#shipping_method, input[name=shipping_method]').live('change', function() {
var method = $('#shipping_method').val();
var method = $(this).val();
$('div.cart_totals').block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.plugin_url + '/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6}});
@ -553,7 +553,11 @@ jQuery(document).ready(function($) {
if (xhr) xhr.abort();
var method = $('#shipping_method').val();
if ( $('select#shipping_method').size() > 0 )
var method = $('select#shipping_method').val();
else
var method = $('input[name=shipping_method]:checked').val();
var payment_method = $('#order_review input[name=payment_method]:checked').val();
var country = $('#billing_country').val();
var state = $('#billing_state').val();
@ -651,7 +655,7 @@ jQuery(document).ready(function($) {
$('#order_review input[name=payment_method]:checked').click();
/* Update totals */
$('#shipping_method').live('change', function(){
$('select#shipping_method, input[name=shipping_method]').live('change', function(){
$('body').trigger('update_checkout');
});
$('input#billing_country, input#billing_state, #billing_postcode, input#shipping_country, input#shipping_state, #shipping_postcode').live('keydown', function(){

File diff suppressed because one or more lines are too long

View File

@ -148,9 +148,12 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
= 1.5.6 =
* Feature - Default display for shipping methods is radio buttons. Before, when methods were enabled/disabled based on coupons or customer, changed methods could go unnoticed. Radio options are always visible.
* Feature - Option to display shipping methods as a select box vs. radio buttons
* Tweak - When the count of available shipping methods changes, reset to default
* Tweak - Optimisations to monthly and product reports
* Tweak - Individually sold variation handling
* Tweak - Removed mdash; from shipping options
* Fix - Google Analytics options fix
* Fix - % discount rounding

View File

@ -45,7 +45,7 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
$method->full_label = esc_html( $method->label );
if ( $method->cost > 0 ) {
$method->full_label .= ' — ';
$method->full_label .= ': ';
// Append price to label using the correct tax settings
if ( $woocommerce->cart->display_totals_ex_tax || ! $woocommerce->cart->prices_include_tax ) {
@ -65,20 +65,32 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
// Print a single available shipping method as plain text
if ( 1 === count( $available_methods ) ) {
echo $method->full_label;
echo '<input type="hidden" name="shipping_method" id="shipping_method" value="'.esc_attr( $method->id ).'">';
echo $method->full_label . '<input type="hidden" name="shipping_method" id="shipping_method" value="' . esc_attr( $method->id ) . '" />';
// Show multiple shipping methods in a select list
// Show multiple shipping methods
} else {
if ( 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, $_SESSION['_chosen_shipping_method'], false).'>';
echo strip_tags( $method->full_label );
echo '</option>';
echo '<select name="shipping_method" id="shipping_method">';
foreach ( $available_methods as $method )
echo '<option value="' . esc_attr( $method->id ) . '" ' . selected( $method->id, $_SESSION['_chosen_shipping_method'], false ) . '>' . strip_tags( $method->full_label ) . '</option>';
echo '</select>';
} 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, $_SESSION['_chosen_shipping_method'], false) . ' /> <label for="shipping_method_' . sanitize_title( $method->id ) . '">' . $method->full_label . '</label></li>';
echo '</ul>';
}
echo '</select>';
}
// No shipping methods are available

View File

@ -49,7 +49,7 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
$method->full_label = esc_html( $method->label );
if ( $method->cost > 0 ) {
$method->full_label .= ' &mdash; ';
$method->full_label .= ': ';
// Append price to label using the correct tax settings
if ( $woocommerce->cart->display_totals_ex_tax || ! $woocommerce->cart->prices_include_tax ) {
@ -72,17 +72,30 @@ $available_methods = $woocommerce->shipping->get_available_shipping_methods();
echo $method->full_label;
echo '<input type="hidden" name="shipping_method" id="shipping_method" value="'.esc_attr( $method->id ).'">';
// Show multiple shipping methods in a select list
// Show multiple shipping methods
} else {
echo '<select name="shipping_method" id="shipping_method">';
foreach ( $available_methods as $method ) {
echo '<option value="'.esc_attr( $method->id ).'" '.selected( $method->id, $_SESSION['_chosen_shipping_method'], false).'>';
echo strip_tags( $method->full_label );
echo '</option>';
}
echo '</select>';
if ( 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, $_SESSION['_chosen_shipping_method'], false ) . '>' . strip_tags( $method->full_label ) . '</option>';
echo '</select>';
} 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, $_SESSION['_chosen_shipping_method'], false) . ' /> <label for="shipping_method_' . sanitize_title( $method->id ) . '">' . $method->full_label . '</label></li>';
echo '</ul>';
}
}
// No shipping methods are available