– Note: if you edit quantities or remove items from the order you will need to manually change the item\'s stock levels.', 'jigoshop'), 'jigoshop_order_items_meta_box', 'shop_order', 'normal', 'high'); add_meta_box( 'jigoshop-order-totals', __('Order Totals', 'jigoshop'), 'jigoshop_order_totals_meta_box', 'shop_order', 'side', 'default'); add_meta_box( 'jigoshop-order-actions', __('Order Actions', 'jigoshop'), 'jigoshop_order_actions_meta_box', 'shop_order', 'side', 'default'); remove_meta_box( 'commentstatusdiv', 'shop_order' , 'normal' ); remove_meta_box( 'slugdiv', 'shop_order' , 'normal' ); } /** * Save meta boxes * * Runs when a post is saved and does an action which the write panel save scripts can hook into. * * @since 1.0 */ add_action( 'save_post', 'jigoshop_meta_boxes_save', 1, 2 ); function jigoshop_meta_boxes_save( $post_id, $post ) { global $wpdb; if ( !$_POST ) return $post_id; if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id; if ( !isset($_POST['jigoshop_meta_nonce']) || (isset($_POST['jigoshop_meta_nonce']) && !wp_verify_nonce( $_POST['jigoshop_meta_nonce'], 'jigoshop_save_data' ))) return $post_id; if ( !current_user_can( 'edit_post', $post_id )) return $post_id; if ( $post->post_type != 'product' && $post->post_type != 'shop_order' ) return $post_id; do_action( 'jigoshop_process_'.$post->post_type.'_meta', $post_id, $post ); } /** * Product data * * Forces certain product data based on the product's type, e.g. grouped products cannot have a parent. * * @since 1.0 */ add_filter('wp_insert_post_data', 'jigoshop_product_data'); function jigoshop_product_data( $data ) { global $post; if ($data['post_type']=='product' && isset($_POST['product-type'])) { $product_type = stripslashes( $_POST['product-type'] ); switch($product_type) : case "grouped" : case "variable" : $data['post_parent'] = 0; break; endswitch; } return $data; } /** * Order data * * Forces the order posts to have a title in a certain format (containing the date) * * @since 1.0 */ add_filter('wp_insert_post_data', 'jigoshop_order_data'); function jigoshop_order_data( $data ) { global $post; if ($data['post_type']=='shop_order' && isset($data['post_date'])) { $order_title = 'Order'; if ($data['post_date']) $order_title.= ' – '.date('F j, Y @ h:i A', strtotime($data['post_date'])); $data['post_title'] = $order_title; } return $data; } /** * Save errors * * Stores error messages in a variable so they can be displayed on the edit post screen after saving. * * @since 1.0 */ add_action( 'admin_notices', 'jigoshop_meta_boxes_save_errors' ); function jigoshop_meta_boxes_save_errors() { $jigoshop_errors = maybe_unserialize(get_option('jigoshop_errors')); if ($jigoshop_errors && sizeof($jigoshop_errors)>0) : echo '
'.$error.'
'; endforeach; echo '"; $html .= ""; $html .= ""; if ( $desc ) { $html .= "$desc"; } $html .= "
"; return $html; } public static function select( $ID, $label, $options, $selected = false, $desc = FALSE, $class = 'select short' ) { global $post; $selected = ($selected) ? $selected : get_post_meta($post->ID, $ID, true); $desc = ($desc) ? esc_html($desc) : false; $label = __($label, 'jigoshop'); $html = ''; $html .= ""; $html .= ""; $html .= ""; if ( $desc ) { $html .= "$desc"; } $html .= "
"; return $html; } public static function checkbox( $ID, $label, $value = FALSE, $desc = FALSE, $class = 'checkbox' ) { global $post; $value = ($value) ? $value : get_post_meta($post->ID, $ID, true); $desc = ($desc) ? esc_html($desc) : false; $label = __($label, 'jigoshop'); $html = ''; $mark = ''; if( $value ) { $mark = 'checked="checked"'; } $html .= ""; $html .= ""; $html .= ""; if ( $desc ) { $html .= ""; } $html .= "
"; return $html; } }