Skip to content
This repository

allow any product to be sold individually #1673

Merged
merged 1 commit into from over 1 year ago

2 participants

Kathy Mike Jolley
Kathy

Re pull for #1602

Mike Jolley mikejolley merged commit 133d93c into from November 06, 2012
Mike Jolley mikejolley closed this November 06, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
16  admin/post-types/writepanels/writepanel-product_data.php
@@ -103,6 +103,15 @@ function woocommerce_product_data_box() {
103 103
 
104 104
 			echo '</div>';
105 105
 
  106
+			echo '<div class="options_group show_if_simple show_if_variable">';
  107
+
  108
+				// Individual product
  109
+				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') ) );
  110
+
  111
+				do_action('woocommerce_product_options_sold_individually');
  112
+
  113
+			echo '</div>';
  114
+
106 115
 			echo '<div class="options_group show_if_external">';
107 116
 
108 117
 				// External URL
@@ -824,6 +833,13 @@ function attributes_cmp( $a, $b ) {
824 833
 		$woocommerce->clear_product_transients( $post_parent );
825 834
 	}
826 835
 
  836
+	// Sold Individuall
  837
+	if ( ! empty( $_POST['_sold_individually'] ) ) {
  838
+		update_post_meta( $post_id, '_sold_individually', 'yes' );
  839
+	} else {
  840
+		update_post_meta( $post_id, '_sold_individually', '' );
  841
+	}
  842
+	
827 843
 	// Stock Data
828 844
 	if ( get_option('woocommerce_manage_stock') == 'yes' ) {
829 845
 
4  classes/class-wc-product.php
@@ -435,8 +435,8 @@ function needs_shipping() {
435 435
 	function is_sold_individually() {
436 436
 		$return = false;
437 437
 
438  
-		// Sold individually if downloadable, virtual, and the option is enabled
439  
-		if ( $this->is_downloadable() && $this->is_virtual() && get_option('woocommerce_limit_downloadable_product_qty') == 'yes' ) {
  438
+		// Sold individually if downloadable, virtual, and the option is enabled OR if intentionally a singular item
  439
+		if ( 'yes' == get_post_meta( $this->id, '_sold_individually', true ) || ( $this->is_downloadable() && $this->is_virtual() && get_option('woocommerce_limit_downloadable_product_qty') == 'yes'  ) ) {
440 440
 			$return = true;
441 441
 		}
442 442
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.