Merge branch 'revised-single-variation-cart-template'

Conflicts:
	includes/admin/views/html-admin-page-status-report.php
This commit is contained in:
Mike Jolley 2015-11-02 11:26:49 +00:00
commit 7fdb93329c
12 changed files with 1330 additions and 1406 deletions

File diff suppressed because one or more lines are too long

View File

@ -383,10 +383,13 @@ p.demo_store {
.variations {
margin-bottom: 1em;
border: 0;
width: 100%;
td,
th {
border: 0;
vertical-align: top;
line-height: 2em;
}
label {
@ -394,17 +397,15 @@ p.demo_store {
}
select {
width: 100%;
float: left;
max-width: 100%;
min-width: 75%;
display: inline-block;
margin-right: 1em;
}
td.label {
padding-right: 1em;
}
td {
vertical-align: top;
}
}
.woocommerce-variation-description {
@ -415,6 +416,7 @@ p.demo_store {
.reset_variations {
visibility: hidden;
font-size: 0.83em;
}
.wc-no-matching-variations {

View File

@ -1,18 +1,21 @@
/*global wc_add_to_cart_variation_params */
/*global wc_cart_fragments_params */
/*global wc_add_to_cart_variation_params, wc_cart_fragments_params */
/*!
* Variations Plugin
*/
;(function ( $, window, document, undefined ) {
$.fn.wc_variation_form = function() {
var $form = this;
var $product = $form.closest('.product');
var $product_id = parseInt( $form.data( 'product_id' ), 10 );
var $product_variations = $form.data( 'product_variations' );
var $use_ajax = $product_variations === false;
var $xhr = false;
var $reset_variations = $form.find( '.reset_variations' );
var $form = this,
$single_variation = $form.find( '.single_variation' ),
$product = $form.closest( '.product' ),
$product_id = parseInt( $form.data( 'product_id' ), 10 ),
$product_variations = $form.data( 'product_variations' ),
$use_ajax = $product_variations === false,
$xhr = false,
$reset_variations = $form.find( '.reset_variations' ),
template = wp.template( 'variation-template' ),
unavailable_template = wp.template( 'unavailable-variation-template' ),
$single_variation_wrap = $form.find( '.single_variation_wrap' );
// Unbind any existing events
$form.unbind( 'check_variations update_variation_values found_variation' );
@ -29,6 +32,22 @@
return false;
} )
// When the variation is hidden
.on( 'hide_variation', function() {
$form.find( '.single_add_to_cart_button' ).attr( 'disabled', 'disabled' ).attr( 'title', wc_add_to_cart_variation_params.i18n_make_a_selection_text );
return false;
} )
// When the variation is revealed
.on( 'show_variation', function( event, variation, purchasable ) {
if ( purchasable ) {
$form.find( '.single_add_to_cart_button' ).removeAttr( 'disabled' ).removeAttr( 'title' );
} else {
$form.find( '.single_add_to_cart_button' ).attr( 'disabled', 'disabled' ).attr( 'title', wc_add_to_cart_variation_params.i18n_unavailable_text );
}
return false;
} )
// Reload product variations data
.on( 'reload_product_variations', function() {
$product_variations = $form.data( 'product_variations' );
@ -37,44 +56,16 @@
// Reset product data
.on( 'reset_data', function() {
var to_reset = {
'.sku': 'o_sku',
'.product_weight': 'o_weight',
'.product_dimensions': 'o_dimensions'
};
$.each( to_reset, function( selector, data_attribute ) {
var $el = $product.find( selector );
if ( $el.attr( 'data-' + data_attribute ) ) {
$el.text( $el.attr( 'data-' + data_attribute ) );
}
});
$form.wc_variations_description_update( '' );
$('.sku').wc_reset_content();
$('.product_weight').wc_reset_content();
$('.product_dimensions').wc_reset_content();
$form.trigger( 'reset_image' );
$form.find( '.single_variation_wrap' ).slideUp( 200 ).trigger( 'hide_variation' );
$single_variation.slideUp( 200 ).trigger( 'hide_variation' );
} )
// Reset product image
.on( 'reset_image', function() {
var $product_img = $product.find( 'div.images img:eq(0)' ),
$product_link = $product.find( 'div.images a.zoom:eq(0)' ),
o_src = $product_img.attr( 'data-o_src' ),
o_title = $product_img.attr( 'data-o_title' ),
o_alt = $product_img.attr( 'data-o_title' ),
o_href = $product_link.attr( 'data-o_href' );
if ( o_src !== undefined ) {
$product_img.attr( 'src', o_src );
}
if ( o_href !== undefined ) {
$product_link.attr( 'href', o_href );
}
if ( o_title !== undefined ) {
$product_img.attr( 'title', o_title );
$product_link.attr( 'title', o_title );
}
if ( o_alt !== undefined ) {
$product_img.attr( 'alt', o_alt );
}
$form.wc_variations_image_update( false );
} )
// On changing an attribute
@ -113,13 +104,10 @@
data: data,
success: function( variation ) {
if ( variation ) {
$form.find( 'input[name="variation_id"], input.variation_id' )
.val( variation.variation_id )
.change();
$form.trigger( 'found_variation', [ variation ] );
} else {
$form.trigger( 'reset_data' );
$form.find( '.single_variation_wrap' ).after( '<p class="wc-no-matching-variations woocommerce-info">' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>' );
$form.find( '.single_variation' ).after( '<p class="wc-no-matching-variations woocommerce-info">' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>' );
$form.find( '.wc-no-matching-variations' ).slideDown( 200 );
}
}
@ -159,149 +147,69 @@
// Show single variation details (price, stock, image)
.on( 'found_variation', function( event, variation ) {
var $product_img = $product.find( 'div.images img:eq(0)' ),
$product_link = $product.find( 'div.images a.zoom:eq(0)' ),
o_src = $product_img.attr( 'data-o_src' ),
o_title = $product_img.attr( 'data-o_title' ),
o_alt = $product_img.attr( 'data-o_alt' ),
o_href = $product_link.attr( 'data-o_href' ),
variation_image = variation.image_src,
variation_link = variation.image_link,
variation_caption = variation.image_caption,
variation_title = variation.image_title;
$form.find( '.single_variation' ).html( variation.price_html + variation.availability_html );
if ( o_src === undefined ) {
o_src = ( ! $product_img.attr( 'src' ) ) ? '' : $product_img.attr( 'src' );
$product_img.attr( 'data-o_src', o_src );
}
if ( o_href === undefined ) {
o_href = ( ! $product_link.attr( 'href' ) ) ? '' : $product_link.attr( 'href' );
$product_link.attr( 'data-o_href', o_href );
}
if ( o_title === undefined ) {
o_title = ( ! $product_img.attr( 'title' ) ) ? '' : $product_img.attr( 'title' );
$product_img.attr( 'data-o_title', o_title );
}
if ( o_alt === undefined ) {
o_alt = ( ! $product_img.attr( 'alt' ) ) ? '' : $product_img.attr( 'alt' );
$product_img.attr( 'data-o_alt', o_alt );
}
if ( variation_image && variation_image.length > 1 ) {
$product_img
.attr( 'src', variation_image )
.attr( 'alt', variation_title )
.attr( 'title', variation_title );
$product_link
.attr( 'href', variation_link )
.attr( 'title', variation_caption );
} else {
$product_img
.attr( 'src', o_src )
.attr( 'alt', o_alt )
.attr( 'title', o_title );
$product_link
.attr( 'href', o_href )
.attr( 'title', o_title );
}
var $single_variation_wrap = $form.find( '.single_variation_wrap' ),
$sku = $product.find( '.product_meta' ).find( '.sku' ),
$weight = $product.find( '.product_weight' ),
$dimensions = $product.find( '.product_dimensions' );
if ( ! $sku.attr( 'data-o_sku' ) ) {
$sku.attr( 'data-o_sku', $sku.text() );
}
if ( ! $weight.attr( 'data-o_weight' ) ) {
$weight.attr( 'data-o_weight', $weight.text() );
}
if ( ! $dimensions.attr( 'data-o_dimensions' ) ) {
$dimensions.attr( 'data-o_dimensions', $dimensions.text() );
}
var $sku = $product.find( '.product_meta' ).find( '.sku' ),
$weight = $product.find( '.product_weight' ),
$dimensions = $product.find( '.product_dimensions' ),
$qty = $single_variation_wrap.find( '.quantity' ),
purchasable = true;
// Display SKU
if ( variation.sku ) {
$sku.text( variation.sku );
$sku.wc_set_content( variation.sku );
} else {
$sku.text( $sku.attr( 'data-o_sku' ) );
$sku.wc_reset_content();
}
// Display weight
if ( variation.weight ) {
$weight.text( variation.weight );
$weight.wc_set_content( variation.weight );
} else {
$weight.text( $weight.attr( 'data-o_weight' ) );
$weight.wc_reset_content();
}
// Display dimensions
if ( variation.dimensions ) {
$dimensions.text( variation.dimensions );
$dimensions.wc_set_content( variation.dimensions );
} else {
$dimensions.text( $dimensions.attr( 'data-o_dimensions' ) );
$dimensions.wc_reset_content();
}
var hide_qty = false;
var hide_qty_button = false;
if ( ! variation.is_purchasable || ! variation.is_in_stock || ! variation.variation_is_visible ) {
hide_qty_button = true;
}
// Show images
$form.wc_variations_image_update( variation );
// Output correct templates
if ( ! variation.variation_is_visible ) {
$form.find( '.single_variation' ).html( '<p>' + wc_add_to_cart_variation_params.i18n_unavailable_text + '</p>' );
}
if ( variation.min_qty !== '' ) {
$single_variation_wrap.find( '.quantity input.qty' ).attr( 'min', variation.min_qty ).val( variation.min_qty );
$single_variation.html( unavailable_template );
$form.find( 'input[name="variation_id"], input.variation_id' ).val( '' ).change();
} else {
$single_variation_wrap.find( '.quantity input.qty' ).removeAttr( 'min' );
}
if ( variation.max_qty !== '' ) {
$single_variation_wrap.find( '.quantity input.qty' ).attr( 'max', variation.max_qty );
} else {
$single_variation_wrap.find( '.quantity input.qty' ).removeAttr( 'max' );
$single_variation.html( template( {
price: variation.price_html,
availability: variation.availability_html,
description: variation.variation_description
} ) );
$form.find( 'input[name="variation_id"], input.variation_id' ).val( variation.variation_id ).change();
}
// Hide or show qty input
if ( variation.is_sold_individually === 'yes' ) {
$single_variation_wrap.find( '.quantity input.qty' ).val( '1' );
hide_qty = true;
}
// Show/hide qty container
if ( hide_qty ) {
$single_variation_wrap.find( '.quantity' ).hide();
$qty.find( 'input.qty' ).val( '1' ).attr( 'min', '1' ).attr( 'max', '' );
$qty.hide();
} else {
// No need to hide it when hiding its container
if ( ! hide_qty_button ) {
$single_variation_wrap.find( '.quantity' ).show();
}
$qty.find( 'input.qty' ).attr( 'min', variation.min_qty ).attr( 'max', variation.max_qty );
$qty.show();
}
// Show/hide qty & button container
if ( hide_qty_button ) {
if ( $single_variation_wrap.is( ':visible' ) ) {
$form.find( '.variations_button' ).slideUp( 200 );
} else {
$form.find( '.variations_button' ).hide();
}
// Enable or disable the add to cart button
if ( ! variation.is_purchasable || ! variation.is_in_stock || ! variation.variation_is_visible ) {
purchasable = false;
}
// Reveal
if ( $.trim( $single_variation.text() ) ) {
$single_variation.slideDown( 200 ).trigger( 'show_variation', [ variation, purchasable ] );
} else {
if ( $single_variation_wrap.is( ':visible' ) ) {
$form.find( '.variations_button' ).slideDown( 200 );
} else {
$form.find( '.variations_button' ).show();
}
$single_variation.show().trigger( 'show_variation', [ variation, purchasable ] );
}
// Refresh variation description
$form.wc_variations_description_update( variation.variation_description );
$single_variation_wrap.slideDown( 200 ).trigger( 'show_variation', [ variation ] );
})
// Check variations
@ -310,11 +218,11 @@
return;
}
var all_attributes_chosen = true,
var all_attributes_chosen = true,
some_attributes_chosen = false,
current_settings = {},
$form = $( this ),
$reset_variations = $form.find( '.reset_variations' );
current_settings = {},
$form = $( this ),
$reset_variations = $form.find( '.reset_variations' );
$form.find( '.variations select' ).each( function() {
var attribute_name = $( this ).data( 'attribute_name' ) || $( this ).attr( 'name' );
@ -341,9 +249,6 @@
var variation = matching_variations.shift();
if ( variation ) {
$form.find( 'input[name="variation_id"], input.variation_id' )
.val( variation.variation_id )
.change();
$form.trigger( 'found_variation', [ variation ] );
} else {
// Nothing found - reset fields
@ -365,7 +270,7 @@
}
if ( ! exclude ) {
$form.find( '.single_variation_wrap' ).slideUp( 200 ).trigger( 'hide_variation' );
$single_variation.slideUp( 200 ).trigger( 'hide_variation' );
}
}
if ( some_attributes_chosen ) {
@ -496,44 +401,64 @@
};
/**
* Performs animated variation description refreshes
* Stores the default text for an element so it can be reset later
*/
$.fn.wc_variations_description_update = function( variation_description ) {
var $form = this;
var $variations_description = $form.find( '.woocommerce-variation-description' );
$.fn.wc_set_content = function( content ) {
if ( undefined === this.attr( 'data-o_content' ) ) {
this.attr( 'data-o_content', this.text() );
}
this.text( content );
};
if ( $variations_description.length === 0 ) {
if ( variation_description ) {
// add transparent border to allow correct height measurement when children have top/bottom margins
$form.find( '.single_variation_wrap' ).prepend( $( '<div class="woocommerce-variation-description" style="border:1px solid transparent;">' + variation_description + '</div>' ).hide() );
$form.find( '.woocommerce-variation-description' ).slideDown( 200 );
}
/**
* Stores the default text for an element so it can be reset later
*/
$.fn.wc_reset_content = function() {
if ( undefined !== this.attr( 'data-o_content' ) ) {
this.text( this.attr( 'data-o_content' ) );
}
};
/**
* Stores a default attribute for an element so it can be reset later
*/
$.fn.wc_set_variation_attr = function( attr, value ) {
if ( undefined === this.attr( 'data-o_' + attr ) ) {
this.attr( 'data-o_' + attr, ( ! this.attr( attr ) ) ? '' : this.attr( attr ) );
}
this.attr( attr, value );
};
/**
* Reset a default attribute for an element so it can be reset later
*/
$.fn.wc_reset_variation_attr = function( attr ) {
if ( undefined !== this.attr( 'data-o_' + attr ) ) {
this.attr( attr, this.attr( 'data-o_' + attr ) );
}
};
/**
* Sets product images for the chosen variation
*/
$.fn.wc_variations_image_update = function( variation ) {
var $form = this,
$product = $form.closest('.product'),
$product_img = $product.find( 'div.images img:eq(0)' ),
$product_link = $product.find( 'div.images a.zoom:eq(0)' );
if ( variation && variation.image_src && variation.image_src.length > 1 ) {
$product_img.wc_set_variation_attr( 'src', variation.image_src );
$product_img.wc_set_variation_attr( 'title', variation.image_title );
$product_img.wc_set_variation_attr( 'alt', variation.image_title );
$product_link.wc_set_variation_attr( 'href', variation.image_link );
$product_link.wc_set_variation_attr( 'title', variation.image_caption );
} else {
var load_height = $variations_description.outerHeight( true );
var new_height = 0;
var animate_height = false;
// lock height
$variations_description.css( 'height', load_height );
// replace html
$variations_description.html( variation_description );
// measure height
$variations_description.css( 'height', 'auto' );
new_height = $variations_description.outerHeight( true );
if ( Math.abs( new_height - load_height ) > 1 ) {
animate_height = true;
// lock height
$variations_description.css( 'height', load_height );
}
// animate height
if ( animate_height ) {
$variations_description.animate( { 'height' : new_height }, { duration: 200, queue: false, always: function() {
$variations_description.css( { 'height' : 'auto' } );
} } );
}
$product_img.wc_reset_variation_attr( 'src' );
$product_img.wc_reset_variation_attr( 'title' );
$product_img.wc_reset_variation_attr( 'alt' );
$product_link.wc_reset_variation_attr( 'href' );
$product_link.wc_reset_variation_attr( 'title' );
}
};

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
jQuery(function(a){return"undefined"==typeof wc_add_to_cart_params?!1:void a(document).on("click",".add_to_cart_button",function(){var b=a(this);if(b.is(".product_type_simple")){if(!b.attr("data-product_id"))return!0;b.removeClass("added"),b.addClass("loading");var c={};return a.each(b.data(),function(a,b){c[a]=b}),a(document.body).trigger("adding_to_cart",[b,c]),a.post(wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart"),c,function(c){if(c){var d=window.location.toString();if(d=d.replace("add-to-cart","added-to-cart"),c.error&&c.product_url)return void(window.location=c.product_url);if("yes"===wc_add_to_cart_params.cart_redirect_after_add)return void(window.location=wc_add_to_cart_params.cart_url);b.removeClass("loading");var e=c.fragments,f=c.cart_hash;e&&a.each(e,function(b){a(b).addClass("updating")}),a(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}}),b.addClass("added"),wc_add_to_cart_params.is_cart||0!==b.parent().find(".added_to_cart").size()||b.after(' <a href="'+wc_add_to_cart_params.cart_url+'" class="added_to_cart wc-forward" title="'+wc_add_to_cart_params.i18n_view_cart+'">'+wc_add_to_cart_params.i18n_view_cart+"</a>"),e&&a.each(e,function(b,c){a(b).replaceWith(c)}),a(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock(),a(".shop_table.cart").load(d+" .shop_table.cart:eq(0) > *",function(){a(".shop_table.cart").stop(!0).css("opacity","1").unblock(),a(document.body).trigger("cart_page_refreshed")}),a(".cart_totals").load(d+" .cart_totals:eq(0) > *",function(){a(".cart_totals").stop(!0).css("opacity","1").unblock()}),a(document.body).trigger("added_to_cart",[e,f,b])}}),!1}return!0})});
jQuery(function(a){return"undefined"==typeof wc_add_to_cart_params?!1:void a(document).on("click",".add_to_cart_button",function(){var b=a(this);if(b.is(".ajax_add_to_cart")){if(!b.attr("data-product_id"))return!0;b.removeClass("added"),b.addClass("loading");var c={};return a.each(b.data(),function(a,b){c[a]=b}),a(document.body).trigger("adding_to_cart",[b,c]),a.post(wc_add_to_cart_params.wc_ajax_url.toString().replace("%%endpoint%%","add_to_cart"),c,function(c){if(c){var d=window.location.toString();if(d=d.replace("add-to-cart","added-to-cart"),c.error&&c.product_url)return void(window.location=c.product_url);if("yes"===wc_add_to_cart_params.cart_redirect_after_add)return void(window.location=wc_add_to_cart_params.cart_url);b.removeClass("loading");var e=c.fragments,f=c.cart_hash;e&&a.each(e,function(b){a(b).addClass("updating")}),a(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{opacity:.6}}),b.addClass("added"),wc_add_to_cart_params.is_cart||0!==b.parent().find(".added_to_cart").size()||b.after(' <a href="'+wc_add_to_cart_params.cart_url+'" class="added_to_cart wc-forward" title="'+wc_add_to_cart_params.i18n_view_cart+'">'+wc_add_to_cart_params.i18n_view_cart+"</a>"),e&&a.each(e,function(b,c){a(b).replaceWith(c)}),a(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock(),a(".shop_table.cart").load(d+" .shop_table.cart:eq(0) > *",function(){a(".shop_table.cart").stop(!0).css("opacity","1").unblock(),a(document.body).trigger("cart_page_refreshed")}),a(".cart_totals").load(d+" .cart_totals:eq(0) > *",function(){a(".cart_totals").stop(!0).css("opacity","1").unblock()}),a(document.body).trigger("added_to_cart",[e,f,b])}}),!1}return!0})});

File diff suppressed because it is too large Load Diff

View File

@ -166,7 +166,7 @@ class WC_Frontend_Scripts {
self::register_script( 'jquery-payment', $assets_path . 'js/jquery-payment/jquery.payment' . $suffix . '.js', array( 'jquery' ), '1.2.4' );
self::register_script( 'jquery-cookie', $assets_path . 'js/jquery-cookie/jquery.cookie' . $suffix . '.js', array( 'jquery' ), '1.4.1' );
self::register_script( 'wc-credit-card-form', $frontend_script_path . 'credit-card-form' . $suffix . '.js', array( 'jquery', 'jquery-payment' ) );
self::register_script( 'wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js' );
self::register_script( 'wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js', array( 'jquery', 'wp-util' ) );
self::register_script( 'wc-single-product', $frontend_script_path . 'single-product' . $suffix . '.js' );
self::register_script( 'wc-country-select', $frontend_script_path . 'country-select' . $suffix . '.js' );
self::register_script( 'wc-address-i18n', $frontend_script_path . 'address-i18n' . $suffix . '.js' );
@ -315,6 +315,7 @@ class WC_Frontend_Scripts {
case 'wc-add-to-cart-variation' :
return array(
'i18n_no_matching_variations_text' => esc_attr__( 'Sorry, no products matched your selection. Please choose a different combination.', 'woocommerce' ),
'i18n_make_a_selection_text' => esc_attr__( 'Select product options before adding this product to your cart.', 'woocommerce' ),
'i18n_unavailable_text' => esc_attr__( 'Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce' ),
);
break;

View File

@ -1923,7 +1923,7 @@ if ( ! function_exists( 'woocommerce_single_variation' ) ) {
* Output placeholders for the single variation.
*/
function woocommerce_single_variation() {
echo '<div class="single_variation"></div>';
wc_get_template( 'single-product/add-to-cart/variation.php' );
}
}
@ -1933,16 +1933,7 @@ if ( ! function_exists( 'woocommerce_single_variation_add_to_cart_button' ) ) {
* Output the add to cart button for variations.
*/
function woocommerce_single_variation_add_to_cart_button() {
global $product;
?>
<div class="variations_button">
<?php woocommerce_quantity_input( array( 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( $_POST['quantity'] ) : 1 ) ); ?>
<button type="submit" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
<input type="hidden" name="add-to-cart" value="<?php echo absint( $product->id ); ?>" />
<input type="hidden" name="product_id" value="<?php echo absint( $product->id ); ?>" />
<input type="hidden" name="variation_id" class="variation_id" value="" />
</div>
<?php
wc_get_template( 'single-product/add-to-cart/variation-add-to-cart-button.php' );
}
}

View File

@ -12,12 +12,13 @@
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.1.0
* @version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<div class="quantity"><input type="number" step="<?php echo esc_attr( $step ); ?>" <?php if ( is_numeric( $min_value ) ) : ?>min="<?php echo esc_attr( $min_value ); ?>"<?php endif; ?> <?php if ( is_numeric( $max_value ) ) : ?>max="<?php echo esc_attr( $max_value ); ?>"<?php endif; ?> name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="input-text qty text" size="4" /></div>
<div class="quantity">
<input type="number" step="<?php echo esc_attr( $step ); ?>" min="<?php echo esc_attr( $min_value ); ?>" max="<?php echo esc_attr( $max_value ); ?>" name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="input-text qty text" size="4" />
</div>

View File

@ -39,7 +39,7 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>
<?php
$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
echo end( $attribute_keys ) === $attribute_name ? '<a class="reset_variations" href="#" style="visibility: hidden;">' . __( 'Clear selection', 'woocommerce' ) . '</a>' : '';
echo end( $attribute_keys ) === $attribute_name ? '<a class="reset_variations" href="#">' . __( 'Clear', 'woocommerce' ) . '</a>' : '';
?>
</td>
</tr>

View File

@ -0,0 +1,22 @@
<?php
/**
* Single variation cart button
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $product;
?>
<div class="woocommerce-variation-add-to-cart variations_button">
<?php woocommerce_quantity_input( array( 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( $_POST['quantity'] ) : 1 ) ); ?>
<button type="submit" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
<input type="hidden" name="add-to-cart" value="<?php echo absint( $product->id ); ?>" />
<input type="hidden" name="product_id" value="<?php echo absint( $product->id ); ?>" />
<input type="hidden" name="variation_id" class="variation_id" value="0" />
</div>

View File

@ -0,0 +1,35 @@
<?php
/**
* Single variation display
*
* This is a javascript-based template for single variations (see https://codex.wordpress.org/Javascript_Reference/wp.template).
* The values will be dynamically replaced after selecting attributes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="woocommerce-variation single_variation">
<script type="text/template" id="tmpl-variation-template">
<div class="woocommerce-variation-description">
{{{ data.description }}}
</div>
<div class="woocommerce-variation-price">
{{{ data.price }}}
</div>
<div class="woocommerce-variation-availability">
{{{ data.availability }}}
</div>
</script>
<script type="text/template" id="tmpl-unavailable-variation-template">
<p><?php _e( 'Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce' ); ?></p>
</script>
</div>