Tidied up settings, removed some un-needed settings, and made some settings automatic e.g. coupons disabled if no coupons exist

This commit is contained in:
Mike Jolley 2013-02-10 23:02:52 +00:00
parent 2aeb555a9f
commit 7a84ddd6c1
13 changed files with 142 additions and 159 deletions

View File

@ -33,10 +33,10 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
array( 'title' => __( 'General Options', 'woocommerce' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ), array( 'title' => __( 'General Options', 'woocommerce' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ),
array( array(
'title' => __( 'Base Country/Region', 'woocommerce' ), 'title' => __( 'Base Location', 'woocommerce' ),
'desc' => __( 'This is the base country for your business. Tax rates will be based on this country.', 'woocommerce' ), 'desc' => __( 'This is the base location for your business. Tax rates will be based on this country.', 'woocommerce' ),
'id' => 'woocommerce_default_country', 'id' => 'woocommerce_default_country',
'css' => 'min-width:300px;', 'css' => 'min-width:350px;',
'default' => 'GB', 'default' => 'GB',
'type' => 'single_select_country', 'type' => 'single_select_country',
'desc_tip' => true, 'desc_tip' => true,
@ -44,9 +44,9 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
array( array(
'title' => __( 'Currency', 'woocommerce' ), 'title' => __( 'Currency', 'woocommerce' ),
'desc' => __("This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.", 'woocommerce' ), 'desc' => __( "This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.", 'woocommerce' ),
'id' => 'woocommerce_currency', 'id' => 'woocommerce_currency',
'css' => 'min-width:300px;', 'css' => 'min-width:350px;',
'default' => 'GBP', 'default' => 'GBP',
'type' => 'select', 'type' => 'select',
'class' => 'chosen_select', 'class' => 'chosen_select',
@ -61,7 +61,7 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
'default' => 'all', 'default' => 'all',
'type' => 'select', 'type' => 'select',
'class' => 'chosen_select', 'class' => 'chosen_select',
'css' => 'min-width:300px;', 'css' => 'min-width:350px;',
'desc_tip' => true, 'desc_tip' => true,
'options' => array( 'options' => array(
'all' => __( 'All Countries', 'woocommerce' ), 'all' => __( 'All Countries', 'woocommerce' ),
@ -80,9 +80,26 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
$localisation_setting, $localisation_setting,
array(
'title' => __( 'Store Notice', 'woocommerce' ),
'desc' => __( 'Enable site-wide store notice text', 'woocommerce' ),
'id' => 'woocommerce_demo_store',
'default' => 'no',
'type' => 'checkbox'
),
array(
'title' => __( 'Store Notice Text', 'woocommerce' ),
'desc' => '',
'id' => 'woocommerce_demo_store_notice',
'default' => __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' ),
'type' => 'text',
'css' => 'min-width:300px;',
),
array( 'type' => 'sectionend', 'id' => 'general_options'), array( 'type' => 'sectionend', 'id' => 'general_options'),
array( 'title' => __( 'Checkout and Accounts', 'woocommerce' ), 'type' => 'title','desc' => __( 'The following options control the behaviour of the checkout process and customer accounts.', 'woocommerce' ), 'id' => 'checkout_account_options' ), array( 'title' => __( 'Checkout and Accounts', 'woocommerce' ), 'type' => 'title', 'id' => 'checkout_account_options' ),
array( array(
'title' => __( 'Checkout', 'woocommerce' ), 'title' => __( 'Checkout', 'woocommerce' ),
@ -94,20 +111,19 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
), ),
array( array(
'desc' => __( 'Show order comments section', 'woocommerce' ), 'desc' => __( 'Enable customer note field on checkout', 'woocommerce' ),
'id' => 'woocommerce_enable_order_comments', 'id' => 'woocommerce_enable_order_comments',
'default' => 'yes', 'default' => 'yes',
'type' => 'checkbox', 'type' => 'checkbox',
'checkboxgroup' => 'end' 'checkboxgroup' => ''
), ),
array( array(
'title' => __( 'Security', 'woocommerce' ),
'desc' => __( 'Force secure checkout', 'woocommerce' ), 'desc' => __( 'Force secure checkout', 'woocommerce' ),
'id' => 'woocommerce_force_ssl_checkout', 'id' => 'woocommerce_force_ssl_checkout',
'default' => 'no', 'default' => 'no',
'type' => 'checkbox', 'type' => 'checkbox',
'checkboxgroup' => 'start', 'checkboxgroup' => '',
'show_if_checked' => 'option', 'show_if_checked' => 'option',
'desc_tip' => __( 'Force SSL (HTTPS) on the checkout pages (an SSL Certificate is required)', 'woocommerce' ), 'desc_tip' => __( 'Force SSL (HTTPS) on the checkout pages (an SSL Certificate is required)', 'woocommerce' ),
), ),
@ -121,34 +137,6 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
'show_if_checked' => 'yes', 'show_if_checked' => 'yes',
), ),
array(
'title' => __( 'Coupons', 'woocommerce' ),
'desc' => __( 'Enable coupons', 'woocommerce' ),
'id' => 'woocommerce_enable_coupons',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'show_if_checked' => 'option'
),
array(
'desc' => __( 'Enable coupon form on cart', 'woocommerce' ),
'id' => 'woocommerce_enable_coupon_form_on_cart',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => '',
'show_if_checked' => 'yes'
),
array(
'desc' => __( 'Enable coupon form on checkout', 'woocommerce' ),
'id' => 'woocommerce_enable_coupon_form_on_checkout',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
'show_if_checked' => 'yes'
),
array( array(
'title' => __( 'Registration', 'woocommerce' ), 'title' => __( 'Registration', 'woocommerce' ),
'desc' => __( 'Allow registration on the checkout page', 'woocommerce' ), 'desc' => __( 'Allow registration on the checkout page', 'woocommerce' ),
@ -192,7 +180,7 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
), ),
array( array(
'desc' => __( 'Allow customers to repurchase past orders', 'woocommerce' ), 'desc' => __( 'Allow customers to repurchase orders from their account page', 'woocommerce' ),
'id' => 'woocommerce_allow_customers_to_reorder', 'id' => 'woocommerce_allow_customers_to_reorder',
'default' => 'no', 'default' => 'no',
'type' => 'checkbox', 'type' => 'checkbox',
@ -201,7 +189,7 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
array( 'type' => 'sectionend', 'id' => 'checkout_account_options'), array( 'type' => 'sectionend', 'id' => 'checkout_account_options'),
array( 'title' => __( 'Styles and Scripts', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect the styling of your store, as well as how certain features behave.', 'woocommerce' ), 'id' => 'script_styling_options' ), array( 'title' => __( 'Styles and Scripts', 'woocommerce' ), 'type' => 'title', 'id' => 'script_styling_options' ),
array( array(
'title' => __( 'Styling', 'woocommerce' ), 'title' => __( 'Styling', 'woocommerce' ),
@ -215,39 +203,13 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
'type' => 'frontend_styles' 'type' => 'frontend_styles'
), ),
array(
'title' => __( 'Store Notice', 'woocommerce' ),
'desc' => __( 'Enable the "Demo Store" notice on your site', 'woocommerce' ),
'id' => 'woocommerce_demo_store',
'default' => 'no',
'type' => 'checkbox'
),
array(
'title' => __( 'Store Notice Text', 'woocommerce' ),
'desc' => '',
'id' => 'woocommerce_demo_store_notice',
'default' => __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' ),
'type' => 'text',
'css' => 'min-width:300px;',
),
array(
'title' => __( 'Scripts', 'woocommerce' ),
'desc' => __( 'Enable AJAX add to cart buttons on product archives', 'woocommerce' ),
'id' => 'woocommerce_enable_ajax_add_to_cart',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start'
),
array( array(
'desc' => __( 'Enable WooCommerce lightbox', 'woocommerce' ), 'desc' => __( 'Enable WooCommerce lightbox', 'woocommerce' ),
'id' => 'woocommerce_enable_lightbox', 'id' => 'woocommerce_enable_lightbox',
'default' => 'yes', 'default' => 'yes',
'desc_tip' => __( 'On the product details page, product gallery images will open in a lightbox. The Add Review form will open in a modal window', 'woocommerce' ), 'desc_tip' => __( 'On the product details page, product gallery images will open in a lightbox. The Add Review form will also open in a modal window.', 'woocommerce' ),
'type' => 'checkbox', 'type' => 'checkbox',
'checkboxgroup' => '' 'checkboxgroup' => 'start'
), ),
array( array(
@ -260,7 +222,7 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
array( 'type' => 'sectionend', 'id' => 'script_styling_options'), array( 'type' => 'sectionend', 'id' => 'script_styling_options'),
array( 'title' => __( 'Digital Downloads', 'woocommerce' ), 'type' => 'title','desc' => __( 'The following options are specific to downloadable products.', 'woocommerce' ), 'id' => 'digital_download_options' ), array( 'title' => __( 'Downloadable Products', 'woocommerce' ), 'type' => 'title', 'id' => 'digital_download_options' ),
array( array(
'title' => __( 'File Download Method', 'woocommerce' ), 'title' => __( 'File Download Method', 'woocommerce' ),
@ -279,12 +241,12 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
), ),
array( array(
'title' => __( 'Access Restrictions', 'woocommerce' ), 'title' => __( 'Access Restriction', 'woocommerce' ),
'desc' => __( 'Must be logged in to download files', 'woocommerce' ), 'desc' => __( 'Downloads require login', 'woocommerce' ),
'id' => 'woocommerce_downloads_require_login', 'id' => 'woocommerce_downloads_require_login',
'type' => 'checkbox', 'type' => 'checkbox',
'default' => 'no', 'default' => 'no',
'desc_tip' => __( 'This setting does not apply to guest downloads.', 'woocommerce' ), 'desc_tip' => __( 'This setting does not apply to guest purchases.', 'woocommerce' ),
'checkboxgroup' => 'start' 'checkboxgroup' => 'start'
), ),
@ -297,14 +259,6 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
'checkboxgroup' => 'end' 'checkboxgroup' => 'end'
), ),
array(
'title' => __( 'Limit Quantity', 'woocommerce' ),
'desc' => __( 'Limit the purchasable quantity of downloadable-virtual items to 1', 'woocommerce' ),
'id' => 'woocommerce_limit_downloadable_product_qty',
'default' => 'yes',
'type' => 'checkbox'
),
array( 'type' => 'sectionend', 'id' => 'digital_download_options' ), array( 'type' => 'sectionend', 'id' => 'digital_download_options' ),
)); // End general settings )); // End general settings
@ -360,14 +314,6 @@ $woocommerce_settings['pages'] = apply_filters('woocommerce_page_settings', arra
'desc_tip' => true, 'desc_tip' => true,
), ),
array(
'title' => __( 'Logout link', 'woocommerce' ),
'desc' => sprintf(__( 'Append a logout link to menus containing "My Account"', 'woocommerce' ), $base_slug),
'id' => 'woocommerce_menu_logout_link',
'default' => 'yes',
'type' => 'checkbox',
),
array( 'type' => 'sectionend', 'id' => 'page_options' ), array( 'type' => 'sectionend', 'id' => 'page_options' ),
array( 'title' => __( 'Shop Pages', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following pages need selecting so that WooCommerce knows where they are. These pages should have been created upon installation of the plugin, if not you will need to create them.', 'woocommerce' ) ), array( 'title' => __( 'Shop Pages', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following pages need selecting so that WooCommerce knows where they are. These pages should have been created upon installation of the plugin, if not you will need to create them.', 'woocommerce' ) ),
@ -460,6 +406,17 @@ $woocommerce_settings['pages'] = apply_filters('woocommerce_page_settings', arra
'desc_tip' => true, 'desc_tip' => true,
), ),
array(
'title' => __( 'Logout Page', 'woocommerce' ),
'desc' => __( 'Parent: "My Account"', 'woocommerce' ),
'id' => 'woocommerce_logout_page_id',
'type' => 'single_select_page',
'default' => '',
'class' => 'chosen_select_nostd',
'css' => 'min-width:300px;',
'desc_tip' => true,
),
array( array(
'title' => __( 'Lost Password Page', 'woocommerce' ), 'title' => __( 'Lost Password Page', 'woocommerce' ),
'desc' => __( 'Page contents: [woocommerce_lost_password] Parent: "My Account"', 'woocommerce' ), 'desc' => __( 'Page contents: [woocommerce_lost_password] Parent: "My Account"', 'woocommerce' ),
@ -529,8 +486,8 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings',
), ),
array( array(
'title' => __( 'Redirects', 'woocommerce' ), 'title' => __( 'Add to cart', 'woocommerce' ),
'desc' => __( 'Redirect to cart after adding a product to the cart (on single product pages)', 'woocommerce' ), 'desc' => __( 'Redirect to the cart page after successful addition', 'woocommerce' ),
'id' => 'woocommerce_cart_redirect_after_add', 'id' => 'woocommerce_cart_redirect_after_add',
'default' => 'no', 'default' => 'no',
'type' => 'checkbox', 'type' => 'checkbox',
@ -538,9 +495,9 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings',
), ),
array( array(
'desc' => __( 'Redirect to the product page on a single matching search result', 'woocommerce' ), 'desc' => __( 'Enable AJAX add to cart buttons on archives', 'woocommerce' ),
'id' => 'woocommerce_redirect_on_single_search_result', 'id' => 'woocommerce_enable_ajax_add_to_cart',
'default' => 'no', 'default' => 'yes',
'type' => 'checkbox', 'type' => 'checkbox',
'checkboxgroup' => 'end' 'checkboxgroup' => 'end'
), ),
@ -551,7 +508,7 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings',
array( array(
'title' => __( 'Product Fields', 'woocommerce' ), 'title' => __( 'Product Fields', 'woocommerce' ),
'desc' => __( 'Enable the SKU field for products', 'woocommerce' ), 'desc' => __( 'Enable the <strong>SKU</strong> field for products', 'woocommerce' ),
'id' => 'woocommerce_enable_sku', 'id' => 'woocommerce_enable_sku',
'default' => 'yes', 'default' => 'yes',
'type' => 'checkbox', 'type' => 'checkbox',
@ -559,7 +516,7 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings',
), ),
array( array(
'desc' => __( 'Enable the weight field for products', 'woocommerce' ), 'desc' => __( 'Enable the <strong>weight</strong> field for products (some shipping methods may require this)', 'woocommerce' ),
'id' => 'woocommerce_enable_weight', 'id' => 'woocommerce_enable_weight',
'default' => 'yes', 'default' => 'yes',
'type' => 'checkbox', 'type' => 'checkbox',
@ -567,7 +524,7 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings',
), ),
array( array(
'desc' => __( 'Enable the dimension fields for products', 'woocommerce' ), 'desc' => __( 'Enable the <strong>dimension</strong> fields for products (some shipping methods may require this)', 'woocommerce' ),
'id' => 'woocommerce_enable_dimensions', 'id' => 'woocommerce_enable_dimensions',
'default' => 'yes', 'default' => 'yes',
'type' => 'checkbox', 'type' => 'checkbox',
@ -575,7 +532,7 @@ $woocommerce_settings['catalog'] = apply_filters('woocommerce_catalog_settings',
), ),
array( array(
'desc' => __( 'Show weight and dimension fields in product attributes tab', 'woocommerce' ), 'desc' => __( 'Show <strong>weight and dimension</strong> values on the <strong>Additional Information</strong> tab', 'woocommerce' ),
'id' => 'woocommerce_enable_dimension_product_attributes', 'id' => 'woocommerce_enable_dimension_product_attributes',
'default' => 'yes', 'default' => 'yes',
'type' => 'checkbox', 'type' => 'checkbox',

View File

@ -931,7 +931,7 @@ jQuery( function($){
$('.show_if_virtual').show(); $('.show_if_virtual').show();
} }
$('.show_if_'+product_type).show(); $('.show_if_' + product_type).show();
// Hide rules // Hide rules
if ( is_downloadable ) { if ( is_downloadable ) {
@ -941,7 +941,9 @@ jQuery( function($){
$('.hide_if_virtual').hide(); $('.hide_if_virtual').hide();
} }
$('.hide_if_'+product_type).hide(); $('.hide_if_' + product_type).hide();
$('input#_manage_stock').change();
} }

File diff suppressed because one or more lines are too long

View File

@ -33,56 +33,65 @@ jQuery(document).ready(function($) {
this_page = this_page.replace( 'add-to-cart', 'added-to-cart' ); this_page = this_page.replace( 'add-to-cart', 'added-to-cart' );
$thisbutton.removeClass('loading');
if ( response.error && response.product_url ) { if ( response.error && response.product_url ) {
window.location = response.product_url; window.location = response.product_url;
return; return;
} }
fragments = response.fragments; // Redirect to cart option
cart_hash = response.cart_hash; if ( woocommerce_params.cart_redirect_after_add == 'yes' ) {
// Block fragments class window.location = woocommerce_params.cart_url;
if ( fragments ) { return;
$.each(fragments, function(key, value) {
$(key).addClass('updating'); } else {
$thisbutton.removeClass('loading');
fragments = response.fragments;
cart_hash = response.cart_hash;
// Block fragments class
if ( fragments ) {
$.each(fragments, function(key, value) {
$(key).addClass('updating');
});
}
// Block widgets and fragments
$('.shop_table.cart, .updating, .cart_totals').fadeTo('400', '0.6').block({message: null, overlayCSS: {background: 'transparent url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } } );
// Changes button classes
if ( $thisbutton.parent().find('.added_to_cart').size() == 0 )
$thisbutton.addClass('added').after( ' <a href="' + woocommerce_params.cart_url + '" class="added_to_cart" title="' + woocommerce_params.i18n_view_cart + '">' + woocommerce_params.i18n_view_cart + '</a>' );
// Replace fragments
if ( fragments ) {
$.each(fragments, function(key, value) {
$(key).replaceWith(value);
});
}
// Unblock
$('.widget_shopping_cart, .updating').stop(true).css('opacity', '1').unblock();
// Cart page elements
$('.shop_table.cart').load( this_page + ' .shop_table.cart:eq(0) > *', function() {
$("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass('buttons_added').append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');
$('.shop_table.cart').stop(true).css('opacity', '1').unblock();
$('body').trigger('cart_page_refreshed');
}); });
}
// Block widgets and fragments $('.cart_totals').load( this_page + ' .cart_totals:eq(0) > *', function() {
$('.shop_table.cart, .updating, .cart_totals').fadeTo('400', '0.6').block({message: null, overlayCSS: {background: 'transparent url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6 } } ); $('.cart_totals').stop(true).css('opacity', '1').unblock();
// Changes button classes
if ( $thisbutton.parent().find('.added_to_cart').size() == 0 )
$thisbutton.addClass('added').after( ' <a href="' + woocommerce_params.cart_url + '" class="added_to_cart" title="' + woocommerce_params.i18n_view_cart + '">' + woocommerce_params.i18n_view_cart + '</a>' );
// Replace fragments
if ( fragments ) {
$.each(fragments, function(key, value) {
$(key).replaceWith(value);
}); });
// Trigger event so themes can refresh other areas
$('body').trigger( 'added_to_cart', [ fragments, cart_hash ] );
} }
// Unblock
$('.widget_shopping_cart, .updating').stop(true).css('opacity', '1').unblock();
// Cart page elements
$('.shop_table.cart').load( this_page + ' .shop_table.cart:eq(0) > *', function() {
$("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass('buttons_added').append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');
$('.shop_table.cart').stop(true).css('opacity', '1').unblock();
$('body').trigger('cart_page_refreshed');
});
$('.cart_totals').load( this_page + ' .cart_totals:eq(0) > *', function() {
$('.cart_totals').stop(true).css('opacity', '1').unblock();
});
// Trigger event so themes can refresh other areas
$('body').trigger( 'added_to_cart', [ fragments, cart_hash ] );
}); });
return false; return false;

View File

@ -1 +1 @@
jQuery(document).ready(function(e){e(document).on("click",".add_to_cart_button",function(){var t=e(this);if(t.is(".product_type_simple, .product_type_downloadable, .product_type_virtual")){if(!t.attr("data-product_id"))return!0;t.removeClass("added");t.addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:t.attr("data-product_id"),quantity:t.attr("data-quantity"),security:woocommerce_params.add_to_cart_nonce};e("body").trigger("adding_to_cart",[t,n]);e.post(woocommerce_params.ajax_url,n,function(n){if(!n)return;var r=window.location.toString();r=r.replace("add-to-cart","added-to-cart");t.removeClass("loading");if(n.error&&n.product_url){window.location=n.product_url;return}fragments=n.fragments;cart_hash=n.cart_hash;fragments&&e.each(fragments,function(t,n){e(t).addClass("updating")});e(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+woocommerce_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});t.parent().find(".added_to_cart").size()==0&&t.addClass("added").after(' <a href="'+woocommerce_params.cart_url+'" class="added_to_cart" title="'+woocommerce_params.i18n_view_cart+'">'+woocommerce_params.i18n_view_cart+"</a>");fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock();e(".shop_table.cart").load(r+" .shop_table.cart:eq(0) > *",function(){e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');e(".shop_table.cart").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_page_refreshed")});e(".cart_totals").load(r+" .cart_totals:eq(0) > *",function(){e(".cart_totals").stop(!0).css("opacity","1").unblock()});e("body").trigger("added_to_cart",[fragments,cart_hash])});return!1}return!0})}); jQuery(document).ready(function(e){e(document).on("click",".add_to_cart_button",function(){var t=e(this);if(t.is(".product_type_simple, .product_type_downloadable, .product_type_virtual")){if(!t.attr("data-product_id"))return!0;t.removeClass("added");t.addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:t.attr("data-product_id"),quantity:t.attr("data-quantity"),security:woocommerce_params.add_to_cart_nonce};e("body").trigger("adding_to_cart",[t,n]);e.post(woocommerce_params.ajax_url,n,function(n){if(!n)return;var r=window.location.toString();r=r.replace("add-to-cart","added-to-cart");if(n.error&&n.product_url){window.location=n.product_url;return}if(woocommerce_params.cart_redirect_after_add=="yes"){window.location=woocommerce_params.cart_url;return}t.removeClass("loading");fragments=n.fragments;cart_hash=n.cart_hash;fragments&&e.each(fragments,function(t,n){e(t).addClass("updating")});e(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+woocommerce_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});t.parent().find(".added_to_cart").size()==0&&t.addClass("added").after(' <a href="'+woocommerce_params.cart_url+'" class="added_to_cart" title="'+woocommerce_params.i18n_view_cart+'">'+woocommerce_params.i18n_view_cart+"</a>");fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock();e(".shop_table.cart").load(r+" .shop_table.cart:eq(0) > *",function(){e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');e(".shop_table.cart").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_page_refreshed")});e(".cart_totals").load(r+" .cart_totals:eq(0) > *",function(){e(".cart_totals").stop(!0).css("opacity","1").unblock()});e("body").trigger("added_to_cart",[fragments,cart_hash])});return!1}return!0})});

View File

@ -332,8 +332,7 @@ abstract class WC_Product {
function is_sold_individually() { function is_sold_individually() {
$return = false; $return = false;
// Sold individually if downloadable, virtual, and the option is enabled OR if intentionally a singular item if ( 'yes' == $this->sold_individually || ( ! $this->backorders_allowed() && $this->get_stock_quantity() == 1 ) ) {
if ( 'yes' == $this->sold_individually || ( $this->is_downloadable() && $this->is_virtual() && get_option('woocommerce_limit_downloadable_product_qty') == 'yes' ) || ( ! $this->backorders_allowed() && $this->get_stock_quantity() == 1 ) ) {
$return = true; $return = true;
} }

View File

@ -122,10 +122,8 @@ class WC_Cart {
global $woocommerce; global $woocommerce;
// Load the coupons // Load the coupons
if ( get_option( 'woocommerce_enable_coupons' ) == 'yes' ) { $this->applied_coupons = ( empty( $woocommerce->session->coupon_codes ) ) ? array() : array_filter( (array) $woocommerce->session->coupon_codes );
$this->applied_coupons = ( empty( $woocommerce->session->coupon_codes ) ) ? array() : array_filter( (array) $woocommerce->session->coupon_codes ); $this->coupon_discount_amounts = ( empty( $woocommerce->session->coupon_amounts ) ) ? array() : array_filter( (array) $woocommerce->session->coupon_amounts );
$this->coupon_discount_amounts = ( empty( $woocommerce->session->coupon_amounts ) ) ? array() : array_filter( (array) $woocommerce->session->coupon_amounts );
}
// Load the cart // Load the cart
if ( isset( $woocommerce->session->cart ) && is_array( $woocommerce->session->cart ) ) { if ( isset( $woocommerce->session->cart ) && is_array( $woocommerce->session->cart ) ) {
@ -290,6 +288,20 @@ class WC_Cart {
/* Cart Data Functions */ /* Cart Data Functions */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/**
* If there are no coupons, return false to disable coupon forms. Filterable.
*
* @access public
* @return void
*/
public function coupons_enabled() {
$coupon_count = wp_count_posts( 'shop_coupon' );
$coupons_enabled = $coupon_count->publish > 0 ? true : false;
return apply_filters( 'woocommerce_coupons_enabled', $coupons_enabled );
}
/** /**
* Get number of items in the cart. * Get number of items in the cart.
* *
@ -1742,7 +1754,8 @@ class WC_Cart {
global $woocommerce; global $woocommerce;
// Coupons are globally disabled // Coupons are globally disabled
if ( get_option('woocommerce_enable_coupons') == 'no' ) return false; if ( ! $woocommerce->cart->coupons_enabled() )
return false;
$the_coupon = new WC_Coupon( $coupon_code ); $the_coupon = new WC_Coupon( $coupon_code );

View File

@ -214,6 +214,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Templating - Renamed empty.php to cart-empty.php to make clearer. * Templating - Renamed empty.php to cart-empty.php to make clearer.
* Templating - Renamed sorting.php to orderby.php to better reflect contained hooks and code. * Templating - Renamed sorting.php to orderby.php to better reflect contained hooks and code.
* Templating - Product tabs rewritten - new filter to define tab titles, priorities, and display callbacks. * Templating - Product tabs rewritten - new filter to define tab titles, priorities, and display callbacks.
* Templating - loop/no-products-found.php template added.
* Tweak - Sorting uses GET to make it cache friendly * Tweak - Sorting uses GET to make it cache friendly
* Tweak - Optimised class loading (autoload). Reduced memory consumption. * Tweak - Optimised class loading (autoload). Reduced memory consumption.

View File

@ -117,7 +117,7 @@ global $woocommerce;
<tr> <tr>
<td colspan="6" class="actions"> <td colspan="6" class="actions">
<?php if ( get_option( 'woocommerce_enable_coupons' ) == 'yes' && get_option( 'woocommerce_enable_coupon_form_on_cart' ) == 'yes') { ?> <?php if ( $woocommerce->cart->coupons_enabled() ) { ?>
<div class="coupon"> <div class="coupon">
<label for="coupon_code"><?php _e( 'Coupon', 'woocommerce' ); ?>:</label> <input name="coupon_code" class="input-text" id="coupon_code" value="" /> <input type="submit" class="button" name="apply_coupon" value="<?php _e( 'Apply Coupon', 'woocommerce' ); ?>" /> <label for="coupon_code"><?php _e( 'Coupon', 'woocommerce' ); ?>:</label> <input name="coupon_code" class="input-text" id="coupon_code" value="" /> <input type="submit" class="button" name="apply_coupon" value="<?php _e( 'Apply Coupon', 'woocommerce' ); ?>" />

View File

@ -9,7 +9,8 @@
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( get_option( 'woocommerce_enable_coupons' ) == 'no' || get_option( 'woocommerce_enable_coupon_form_on_checkout' ) == 'no' ) return; if ( ! $woocommerce->cart->coupons_enabled() )
return;
$info_message = apply_filters('woocommerce_checkout_coupon_message', __( 'Have a coupon?', 'woocommerce' )); $info_message = apply_filters('woocommerce_checkout_coupon_message', __( 'Have a coupon?', 'woocommerce' ));
?> ?>

View File

@ -262,6 +262,11 @@ function woocommerce_ajax_add_to_cart() {
do_action( 'woocommerce_ajax_added_to_cart', $product_id ); do_action( 'woocommerce_ajax_added_to_cart', $product_id );
if ( get_option( 'woocommerce_cart_redirect_after_add' ) == 'yes' ) {
woocommerce_add_to_cart_message( $product_id );
$woocommerce->set_messages();
}
// Return fragments // Return fragments
woocommerce_get_refreshed_fragments(); woocommerce_get_refreshed_fragments();

View File

@ -207,13 +207,6 @@ add_action( 'template_redirect', 'woocommerce_template_redirect' );
add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_item_classes', 2, 20 ); add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_item_classes', 2, 20 );
add_filter( 'wp_list_pages', 'woocommerce_list_pages' ); add_filter( 'wp_list_pages', 'woocommerce_list_pages' );
/**
* Logout link
*
* @see woocommerce_nav_menu_items()
*/
add_filter( 'wp_nav_menu_items', 'woocommerce_nav_menu_items', 10, 2 );
/** /**
* Clear the cart * Clear the cart
* *

View File

@ -726,6 +726,7 @@ class Woocommerce {
* @return void * @return void
*/ */
public function wp_head() { public function wp_head() {
if ( is_woocommerce() ) { if ( is_woocommerce() ) {
$this->add_body_class( 'woocommerce' ); $this->add_body_class( 'woocommerce' );
$this->add_body_class( 'woocommerce-page' ); $this->add_body_class( 'woocommerce-page' );
@ -749,6 +750,7 @@ class Woocommerce {
$this->add_body_class( 'woocommerce-page' ); $this->add_body_class( 'woocommerce-page' );
return; return;
} }
} }
@ -1204,6 +1206,7 @@ class Woocommerce {
'update_shipping_method_nonce' => wp_create_nonce( "update-shipping-method" ), 'update_shipping_method_nonce' => wp_create_nonce( "update-shipping-method" ),
'add_to_cart_nonce' => wp_create_nonce( "add-to-cart" ), 'add_to_cart_nonce' => wp_create_nonce( "add-to-cart" ),
'cart_url' => get_permalink( woocommerce_get_page_id( 'cart' ) ), 'cart_url' => get_permalink( woocommerce_get_page_id( 'cart' ) ),
'cart_redirect_after_add' => get_option( 'woocommerce_cart_redirect_after_add' )
); );
if ( is_checkout() || is_cart() ) if ( is_checkout() || is_cart() )