Created
July 29, 2012 18:37
Revisions
-
ChromeOrange revised this gist
Jul 29, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ function isi_write_panel() { 'multiple' => __('Multiple purchases allowed', 'woocommerce'), 'individual' => __('Individual Only', 'woocommerce') )), 'description' => __('Limit the product to one per order?', 'woocommerce') ) ); echo '</div>'; } -
ChromeOrange created this gist
Jul 29, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ <?php add_filter( 'woocommerce_is_sold_individually', 'cj_woocommerce_is_sold_individually', 10, 2 ); function cj_woocommerce_is_sold_individually( $value, $product ) { $isi = get_post_meta( $product->id, '_custom_sell_individually', TRUE ); if ( $isi == 'individual' ) : $return = true; endif; return $return; } if ( is_admin() ) : add_action( 'woocommerce_product_options_dimensions', 'isi_write_panel'); add_action( 'woocommerce_process_product_meta', 'isi_write_panel_save' ); function isi_write_panel() { echo '<div class="options_group">'; woocommerce_wp_select( array( 'id' => '_custom_sell_individually', 'label' => __('Sell Individually?', 'woocommerce'), 'options' => apply_filters('woocommerce_product_visibility_options', array( 'multiple' => __('Multiple purchases allowed', 'woocommerce'), 'individual' => __('Individual Only', 'woocommerce') )), 'description' => __('Define the loops this product should be visible in. It will still be accessible directly.', 'woocommerce') ) ); echo '</div>'; } function isi_write_panel_save( $post_id ) { $_custom_sell_individually = esc_attr($_POST['_custom_sell_individually']); update_post_meta($post_id, '_custom_sell_individually', $_custom_sell_individually); } endif; ?>