ID; $product_custom_fields = get_post_custom( $thepostid ); ?>
'; // List Grouped products $post_parents = array(); $post_parents[''] = __('Choose a grouped product…', 'woothemes'); $posts_in = array_unique((array) get_objects_in_term( get_term_by( 'slug', 'grouped', 'product_type' )->term_id, 'product_type' )); if (sizeof($posts_in)>0) : $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'asc', 'post_parent' => 0, 'include' => $posts_in, ); $grouped_products = get_posts($args); $loop = 0; if ($grouped_products) : foreach ($grouped_products as $product) : if ($product->ID==$post->ID) continue; $post_parents[$product->ID] = $product->post_title; endforeach; endif; endif; woocommerce_wp_select( array( 'id' => 'parent_id', 'label' => __('Grouping', 'woothemes'), 'value' => $post->post_parent, 'options' => $post_parents ) ); // Ordering woocommerce_wp_text_input( array( 'id' => 'menu_order', 'label' => _x('Sort Order', 'ordering', 'woothemes'), 'value' => $post->menu_order ) ); do_action('woocommerce_product_options_grouping'); echo '
'; echo '
'; // SKU if( get_option('woocommerce_enable_sku', true) !== 'no' ) : woocommerce_wp_text_input( array( 'id' => 'sku', 'label' => __('SKU', 'woothemes'), 'placeholder' => $post->ID ) ); else: echo ''; endif; do_action('woocommerce_product_options_sku'); echo '
'; echo '
'; // Price woocommerce_wp_text_input( array( 'id' => 'regular_price', 'label' => __('Regular Price', 'woothemes') . ' ('.get_woocommerce_currency_symbol().'):', 'placeholder' => '0.00' ) ); // Special Price woocommerce_wp_text_input( array( 'id' => 'sale_price', 'label' => __('Sale Price', 'woothemes') . ' ('.get_woocommerce_currency_symbol().'):', 'placeholder' => '0.00' ) ); // Special Price date range $field = array( 'id' => 'sale_price_dates', 'label' => __('Sale Price Dates', 'woothemes') ); $sale_price_dates_from = get_post_meta($thepostid, 'sale_price_dates_from', true); $sale_price_dates_to = get_post_meta($thepostid, 'sale_price_dates_to', true); echo '

' . __('Date format', 'woothemes') . ': YYYY-MM-DD

'; do_action('woocommerce_product_options_pricing'); echo '
'; echo '
'; // Weight if( get_option('woocommerce_enable_weight', true) !== 'no' ) : woocommerce_wp_text_input( array( 'id' => 'weight', 'label' => __('Weight', 'woothemes') . ' ('.get_option('woocommerce_weight_unit').')', 'placeholder' => '0.00' ) ); else: echo ''; endif; do_action('woocommerce_product_options_weight'); echo '
'; do_action('woocommerce_product_options_general_product_data'); ?>
'tax_status', 'label' => __('Tax Status', 'woothemes'), 'options' => array( 'taxable' => __('Taxable', 'woothemes'), 'shipping' => __('Shipping only', 'woothemes'), 'none' => __('None', 'woothemes') ) ) ); $_tax = new woocommerce_tax(); $tax_classes = $_tax->get_tax_classes(); $classes_options = array(); $classes_options[''] = __('Standard', 'woothemes'); if ($tax_classes) foreach ($tax_classes as $class) : $classes_options[sanitize_title($class)] = $class; endforeach; woocommerce_wp_select( array( 'id' => 'tax_class', 'label' => __('Tax Class', 'woothemes'), 'options' => $classes_options ) ); do_action('woocommerce_product_options_tax'); ?>
'manage_stock', 'label' => __('Manage stock?', 'woothemes') ) ); // Stock status woocommerce_wp_select( array( 'id' => 'stock_status', 'label' => __('Stock status', 'woothemes'), 'options' => array( 'instock' => __('In stock', 'woothemes'), 'outofstock' => __('Out of stock', 'woothemes') ) ) ); do_action('woocommerce_product_options_stock'); echo '
'; // Stock woocommerce_wp_text_input( array( 'id' => 'stock', 'label' => __('Stock Qty', 'woothemes') ) ); // Backorders? woocommerce_wp_select( array( 'id' => 'backorders', 'label' => __('Allow Backorders?', 'woothemes'), 'options' => array( 'no' => __('Do not allow', 'woothemes'), 'notify' => __('Allow, but notify customer', 'woothemes'), 'yes' => __('Allow', 'woothemes') ) ) ); do_action('woocommerce_product_options_stock_fields'); echo '
'; ?>
get_attribute_taxonomies(); // Array of defined attribute taxonomies $attributes = maybe_unserialize( get_post_meta($thepostid, 'product_attributes', true) ); // Product attributes - taxonomies and custom, ordered, with visibility and variation attributes set $i = -1; // Taxonomies if ( $attribute_taxonomies ) : foreach ($attribute_taxonomies as $tax) : $i++; // Get name of taxonomy we're now outputting (pa_xxx) $attribute_taxonomy_name = $woocommerce->attribute_taxonomy_name($tax->attribute_name); // Ensure it exists if (!taxonomy_exists($attribute_taxonomy_name)) continue; // Get product data values for current taxonomy - this contains ordering and visibility data if (isset($attributes[$attribute_taxonomy_name])) $attribute = $attributes[$attribute_taxonomy_name]; $position = (isset($attribute['position'])) ? $attribute['position'] : 0; // Get terms of this taxonomy associated with current product $post_terms = wp_get_post_terms( $thepostid, $attribute_taxonomy_name ); // Any set? $has_terms = (is_wp_error($post_terms) || !$post_terms || sizeof($post_terms)==0) ? 0 : 1; ?>> 0) foreach ($attributes as $attribute) : if ($attribute['is_taxonomy']) continue; $i++; $position = (isset($attribute['position'])) ? $attribute['position'] : 0; ?>
 [?]  [?]  [?]
attribute_label) ? $tax->attribute_label : $tax->attribute_name; ?> attribute_type=="select") : ?> attribute_type=="text") : ?> name="attribute_visibility[]" value="1" /> name="attribute_variation[]" value="1" />
name="attribute_visibility[]" value="1" /> name="attribute_variation[]" value="1" />

get_var("SELECT * FROM $wpdb->postmeta WHERE meta_key='sku' AND meta_value='".$new_sku."';") || $wpdb->get_var("SELECT * FROM $wpdb->posts WHERE ID='".$new_sku."' AND ID!=".$post_id.";")) : $woocommerce_errors[] = __('Product SKU must be unique.', 'woothemes'); else : update_post_meta( $post_id, 'sku', $new_sku ); endif; else : update_post_meta( $post_id, 'sku', '' ); endif; endif; // Save Attributes $attributes = array(); if (isset($_POST['attribute_names'])) : $attribute_names = $_POST['attribute_names']; $attribute_values = $_POST['attribute_values']; if (isset($_POST['attribute_visibility'])) $attribute_visibility = $_POST['attribute_visibility']; if (isset($_POST['attribute_variation'])) $attribute_variation = $_POST['attribute_variation']; $attribute_is_taxonomy = $_POST['attribute_is_taxonomy']; $attribute_position = $_POST['attribute_position']; for ($i=0; $i htmlspecialchars(stripslashes($attribute_names[$i])), 'value' => '', 'position' => $attribute_position[$i], 'is_visible' => $is_visible, 'is_variation' => $is_variation, 'is_taxonomy' => $is_taxonomy ); else : // Format values $values = trim(htmlspecialchars(stripslashes($attribute_values[$i]))); // Custom attribute - Add attribute to array and set the values $attributes[ sanitize_title( $attribute_names[$i] ) ] = array( 'name' => htmlspecialchars(stripslashes($attribute_names[$i])), 'value' => $values, 'position' => $attribute_position[$i], 'is_visible' => $is_visible, 'is_variation' => $is_variation, 'is_taxonomy' => $is_taxonomy ); endif; endfor; endif; if (!function_exists('attributes_cmp')) { function attributes_cmp($a, $b) { if ($a['position'] == $b['position']) { return 0; } return ($a['position'] < $b['position']) ? -1 : 1; } } uasort($attributes, 'attributes_cmp'); update_post_meta( $post_id, 'product_attributes', $attributes ); // Product type $product_type = sanitize_title( stripslashes( $_POST['product-type'] ) ); if( !$product_type ) $product_type = 'simple'; wp_set_object_terms($post_id, $product_type, 'product_type'); // Sales and prices if ($product_type!=='grouped') : $date_from = (isset($_POST['sale_price_dates_from'])) ? $_POST['sale_price_dates_from'] : ''; $date_to = (isset($_POST['sale_price_dates_to'])) ? $_POST['sale_price_dates_to'] : ''; // Dates if ($date_from) : update_post_meta( $post_id, 'sale_price_dates_from', strtotime($date_from) ); else : update_post_meta( $post_id, 'sale_price_dates_from', '' ); endif; if ($date_to) : update_post_meta( $post_id, 'sale_price_dates_to', strtotime($date_to) ); else : update_post_meta( $post_id, 'sale_price_dates_to', '' ); endif; if ($date_to && !$date_from) : update_post_meta( $post_id, 'sale_price_dates_from', strtotime('NOW') ); endif; // Update price if on sale if ($_POST['sale_price'] && $date_to == '' && $date_from == '') : update_post_meta( $post_id, 'price', stripslashes($_POST['sale_price']) ); else : update_post_meta( $post_id, 'price', stripslashes($_POST['regular_price']) ); endif; if ($date_from && strtotime($date_from) < strtotime('NOW')) : update_post_meta( $post_id, 'price', stripslashes($_POST['sale_price']) ); endif; if ($date_to && strtotime($date_to) < strtotime('NOW')) : update_post_meta( $post_id, 'price', stripslashes($_POST['regular_price']) ); update_post_meta( $post_id, 'sale_price_dates_from', ''); update_post_meta( $post_id, 'sale_price_dates_to', ''); endif; else : update_post_meta( $post_id, 'regular_price', '' ); update_post_meta( $post_id, 'sale_price', '' ); update_post_meta( $post_id, 'sale_price_dates_from', '' ); update_post_meta( $post_id, 'sale_price_dates_to', '' ); update_post_meta( $post_id, 'price', '' ); endif; // Update parent if grouped so price sorting works if ($post->post_parent || $product_type=='grouped') : if ($post->post_parent) : $post_parent = $post->post_parent; else : $post_parent = $post_id; endif; $children_by_price = get_posts( array( 'post_parent' => $post_parent, 'orderby' => 'meta_value_num', 'order' => 'asc', 'meta_key' => 'price', 'posts_per_page' => 1, 'post_type' => 'product' )); if ($children_by_price) : $children_by_price = $children_by_price[0]; $child = $children_by_price->ID; update_post_meta( $post_parent, 'price', get_post_meta($child, 'price', true) ); endif; endif; // Stock Data if (get_option('woocommerce_manage_stock')=='yes') : // Manage Stock Checkbox if ($product_type!=='grouped' && isset($_POST['manage_stock']) && $_POST['manage_stock']) : update_post_meta( $post_id, 'stock', $_POST['stock'] ); update_post_meta( $post_id, 'manage_stock', 'yes' ); update_post_meta( $post_id, 'backorders', stripslashes( $_POST['backorders'] ) ); if ($product_type!=='variable' && $_POST['backorders']=='no' && $_POST['stock']<1) : update_post_meta( $post_id, 'stock_status', 'outofstock' ); endif; else : update_post_meta( $post_id, 'stock', '0' ); update_post_meta( $post_id, 'manage_stock', 'no' ); update_post_meta( $post_id, 'backorders', 'no' ); endif; endif; // Upsells if (isset($_POST['upsell_ids'])) : $upsells = array(); $ids = $_POST['upsell_ids']; foreach ($ids as $id) : if ($id && $id>0) $upsells[] = $id; endforeach; update_post_meta( $post_id, 'upsell_ids', $upsells ); endif; // Cross sells if (isset($_POST['crosssell_ids'])) : $crosssells = array(); $ids = $_POST['crosssell_ids']; foreach ($ids as $id) : if ($id && $id>0) $crosssells[] = $id; endforeach; update_post_meta( $post_id, 'crosssell_ids', $crosssells ); endif; // Do action do_action( 'process_product_meta', $post_id ); // Do action for product type do_action( 'process_product_meta_' . $product_type, $post_id ); // Save errors update_option('woocommerce_errors', $woocommerce_errors); } /** * Outputs product list in selection boxes **/ function woocommerce_product_selection_list_remove( $posts_to_display, $name ) { global $thepostid; $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'asc', 'include' => $posts_to_display, ); $related_posts = get_posts($args); $loop = 0; if ($related_posts) : foreach ($related_posts as $related_post) : if ($related_post->ID==$thepostid) continue; $SKU = get_post_meta($related_post->ID, 'sku', true); ?>
  • post_title; ?> – #ID; ?>
  • ID; echo '
    '; // Product Type if ($terms = wp_get_object_terms( $thepostid, 'product_type' )) $product_type = current($terms)->slug; else $product_type = 'simple'; woocommerce_wp_select( array( 'id' => 'product-type', 'label' => __('Product Type', 'woothemes'), 'value' => $product_type, 'options' => apply_filters('product_type_selector', array( 'simple' => __('Simple', 'woothemes') ), $product_type) ) ); // Visibility woocommerce_wp_select( array( 'id' => 'visibility', 'label' => __('Visibility', 'woothemes'), 'options' => array( 'visible' => __('Catalog & Search', 'woothemes'), 'catalog' => __('Catalog', 'woothemes'), 'search' => __('Search', 'woothemes'), 'hidden' => __('Hidden', 'woothemes') ) ) ); // Featured woocommerce_wp_checkbox( array( 'id' => 'featured', 'label' => __('Featured?', 'woothemes') ) ); echo '
    '; }