Merge pull request #1673 from helgatheviking/feature/individual_product

allow any product to be sold individually
This commit is contained in:
Mike Jolley 2012-11-06 06:01:59 -08:00
commit 133d93c592
2 changed files with 18 additions and 2 deletions

View File

@ -103,6 +103,15 @@ function woocommerce_product_data_box() {
echo '</div>';
echo '<div class="options_group show_if_simple show_if_variable">';
// Individual product
woocommerce_wp_checkbox( array( 'id' => '_sold_individually', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __('Product Sold Individually?', 'woocommerce'), 'description' => __('For items of singular quantity.', 'woocommerce') ) );
do_action('woocommerce_product_options_sold_individually');
echo '</div>';
echo '<div class="options_group show_if_external">';
// External URL
@ -824,6 +833,13 @@ function woocommerce_process_product_meta( $post_id, $post ) {
$woocommerce->clear_product_transients( $post_parent );
}
// Sold Individuall
if ( ! empty( $_POST['_sold_individually'] ) ) {
update_post_meta( $post_id, '_sold_individually', 'yes' );
} else {
update_post_meta( $post_id, '_sold_individually', '' );
}
// Stock Data
if ( get_option('woocommerce_manage_stock') == 'yes' ) {

View File

@ -435,8 +435,8 @@ class WC_Product {
function is_sold_individually() {
$return = false;
// Sold individually if downloadable, virtual, and the option is enabled
if ( $this->is_downloadable() && $this->is_virtual() && get_option('woocommerce_limit_downloadable_product_qty') == 'yes' ) {
// Sold individually if downloadable, virtual, and the option is enabled OR if intentionally a singular item
if ( 'yes' == get_post_meta( $this->id, '_sold_individually', true ) || ( $this->is_downloadable() && $this->is_virtual() && get_option('woocommerce_limit_downloadable_product_qty') == 'yes' ) ) {
$return = true;
}