ID, 'product_data', true) ); $featured = (string) get_post_meta( $post->ID, 'featured', true ); $visibility = (string) get_post_meta( $post->ID, 'visibility', true); if (!isset($data['weight'])) $data['weight'] = ''; if (!isset($data['regular_price'])) $data['regular_price'] = ''; if (!isset($data['sale_price'])) $data['sale_price'] = ''; $thepostid = $post->ID; ?>
slug; else $product_type = 'simple'; $field = array( 'id' => 'product-type', 'label' => __('Product Type', 'woothemes') ); echo '

'; // List Grouped products $posts_in = (array) get_objects_in_term( get_term_by( 'slug', 'grouped', 'product_type' )->term_id, 'product_type' ); $posts_in = array_unique($posts_in); $field = array( 'id' => 'parent_id', 'label' => __('Parent post', 'woothemes') ); echo '

'; // Ordering $menu_order = $post->menu_order; $field = array( 'id' => 'menu_order', 'label' => _x('Post Order', 'ordering', 'woothemes') ); echo ''; // Summary echo '

'; // SKU $field = array( 'id' => 'sku', 'label' => __('SKU', 'woothemes') ); $SKU = get_post_meta($thepostid, 'SKU', true); if( get_option('woocommerce_enable_sku', true) !== 'no' ) : echo '

' . __('Leave blank to use product ID', 'woothemes') . '

'; else: echo ''; endif; // Weight $field = array( 'id' => 'weight', 'label' => __('Weight', 'woothemes') . ' ('.get_option('woocommerce_weight_unit').'):' ); if( get_option('woocommerce_enable_weight', true) !== 'no' ) : echo '

'; else: echo ''; endif; // Featured $field = array( 'id' => 'featured', 'label' => __('Featured?', 'woothemes') ); echo '

'; // Visibility $field = array( 'id' => 'visibility', 'label' => __('Visibility', 'woothemes') ); echo '

'; ?>
'regular_price', 'label' => __('Regular Price', 'woothemes') . ' ('.get_woocommerce_currency_symbol().'):' ); echo '

'; // Special Price $field = array( 'id' => 'sale_price', 'label' => __('Sale Price', 'woothemes') . ' ('.get_woocommerce_currency_symbol().'):' ); echo '

'; // 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

'; // Tax $_tax = new woocommerce_tax(); $field = array( 'id' => 'tax_status', 'label' => __('Tax Status', 'woothemes') ); echo '

'; $field = array( 'id' => 'tax_class', 'label' => __('Tax Class', 'woothemes') ); echo '

'; ?>
'manage_stock', 'label' => __('Manage stock?', 'woothemes') ); echo '

'; // Stock status $field = array( 'id' => 'stock_status', 'label' => 'Stock status:' ); echo '

'; echo '
'; // Stock $field = array( 'id' => 'stock', 'label' => __('Stock Qty', 'woothemes') ); echo '

'; // Backorders? $field = array( 'id' => 'backorders', 'label' => __('Allow Backorders?', 'woothemes') ); echo '

'; echo '
'; ?>
ID, 'product_attributes', true) ); $i = -1; // Taxonomies if ( $attribute_taxonomies ) : foreach ($attribute_taxonomies as $tax) : $i++; $attribute_nicename = strtolower(sanitize_title($tax->attribute_name)); if (isset($attributes[$attribute_nicename])) $attribute = $attributes[$attribute_nicename]; if (isset($attribute['visible']) && $attribute['visible']=='yes') $checked = 'checked="checked"'; else $checked = ''; if (isset($attribute['variation']) && $attribute['variation']=='yes') $checked2 = 'checked="checked"'; else $checked2 = ''; $values = wp_get_post_terms( $thepostid, 'product_attribute_'.strtolower(sanitize_title($tax->attribute_name)) ); $value = array(); if (!is_wp_error($values) && $values) : foreach ($values as $v) : $value[] = $v->slug; endforeach; endif; ?>> 0) foreach ($attributes as $attribute) : if (isset($attribute['is_taxonomy']) && $attribute['is_taxonomy']=='yes') continue; $i++; if (isset($attribute['visible']) && $attribute['visible']=='yes') $checked = 'checked="checked"'; else $checked = ''; if (isset($attribute['variation']) && $attribute['variation']=='yes') $checked2 = 'checked="checked"'; else $checked2 = ''; ?>
attribute_name; ?> attribute_type=="select" || $tax->attribute_type=="multiselect") : ?> attribute_type=="text") : ?> name="attribute_visibility[]" value="1" /> name="attribute_variation[]" value="1" />
name="attribute_visibility[]" value="1" /> name="attribute_variation[]" value="1" />

    0) : $upsell_ids = $data['upsell_ids']; else : $upsell_ids = array(0); endif; woocommerce_product_selection_list_remove($upsell_ids, 'upsell_ids'); ?>

    0) : $crosssell_ids = $data['crosssell_ids']; else : $crosssell_ids = array(0); endif; woocommerce_product_selection_list_remove($crosssell_ids, 'crosssell_ids'); ?>
htmlspecialchars(stripslashes($attribute_names[$i])), 'value' => $attribute_values[$i], 'position' => $attribute_position[$i], 'visible' => $visible, 'variation' => $variation, 'is_taxonomy' => $is_taxonomy ); if ($is_taxonomy=='yes') : // Update post terms $tax = $attribute_names[$i]; $value = $attribute_values[$i]; if (taxonomy_exists('product_attribute_'.strtolower(sanitize_title($tax)))) : wp_set_object_terms( $post_id, $value, 'product_attribute_'.strtolower(sanitize_title($tax)) ); endif; 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'); // 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'); // visibility $visibility = stripslashes( $_POST['visibility'] ); update_post_meta( $post_id, 'visibility', $visibility ); // Featured $featured = stripslashes( $_POST['featured'] ); update_post_meta( $post_id, 'featured', $featured ); // Unique SKU $SKU = get_post_meta($post_id, 'SKU', true); $new_sku = stripslashes( $_POST['sku'] ); if ($new_sku!==$SKU) : if ($new_sku && !empty($new_sku)) : if ($wpdb->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; // 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 ($data['sale_price'] && $date_to == '' && $date_from == '') : update_post_meta( $post_id, 'price', $data['sale_price'] ); else : update_post_meta( $post_id, 'price', $data['regular_price'] ); endif; if ($date_from && strtotime($date_from) < strtotime('NOW')) : update_post_meta( $post_id, 'price', $data['sale_price'] ); endif; if ($date_to && strtotime($date_to) < strtotime('NOW')) : update_post_meta( $post_id, 'price', $data['regular_price'] ); update_post_meta( $post_id, 'sale_price_dates_from', ''); update_post_meta( $post_id, 'sale_price_dates_to', ''); endif; else : $data['sale_price'] = ''; $data['regular_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; // 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'] ); $data['manage_stock'] = 'yes'; $data['backorders'] = stripslashes( $_POST['backorders'] ); else : update_post_meta( $post_id, 'stock', '0' ); $data['manage_stock'] = 'no'; $data['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; $data['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; $data['crosssell_ids'] = $crosssells; endif; // Apply filters to data $data = apply_filters( 'process_product_meta', $data, $post_id ); // Apply filter to data for product type $data = apply_filters( 'filter_product_meta_' . $product_type, $data, $post_id ); // Do action for product type do_action( 'process_product_meta_' . $product_type, $data, $post_id ); // Save update_post_meta( $post_id, 'product_attributes', $attributes ); update_post_meta( $post_id, 'product_data', $data ); 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; ?>