ID; $order = &new woocommerce_order( $thepostid ); add_action('admin_footer', 'woocommerce_meta_scripts'); wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' ); // Custom user $customer_user = (int) get_post_meta($post->ID, '_customer_user', true); // Order status $order_status = wp_get_post_terms($post->ID, 'shop_order_status'); if ($order_status) : $order_status = current($order_status); $order_status = $order_status->slug; else : $order_status = 'pending'; endif; if (!isset($post->post_title) || empty($post->post_title)) : $order_title = 'Order'; else : $order_title = $post->post_title; endif; ?>

()

formatted_billing_address) echo wpautop($order->formatted_billing_address); else echo '

' . __('No billing address set.', 'woothemes') . '

'; ?>

'_billing_first_name', 'label' => __('First Name', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_billing_last_name', 'label' => __('Last Name', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_billing_company', 'label' => __('Company', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_billing_address_1', 'label' => __('Address 1', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_billing_address_2', 'label' => __('Address 2', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_billing_city', 'label' => __('City', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_billing_postcode', 'label' => __('Postcode', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_billing_country', 'label' => __('Country', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_billing_state', 'label' => __('State/County', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_billing_email', 'label' => __('Email Address', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_billing_phone', 'label' => __('Tel', 'woothemes') ) ); ?>

()

formatted_shipping_address) echo wpautop($order->formatted_shipping_address); else echo '

' . __('No shipping address set.', 'woothemes') . '

'; ?>

'_shipping_first_name', 'label' => __('First Name', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_shipping_last_name', 'label' => __('Last Name', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_shipping_company', 'label' => __('Company', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_shipping_address_1', 'label' => __('Address 1', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_shipping_address_2', 'label' => __('Address 2', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_shipping_city', 'label' => __('City', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_shipping_postcode', 'label' => __('Postcode', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_shipping_country', 'label' => __('Country', 'woothemes') ) ); woocommerce_wp_text_input( array( 'id' => '_shipping_state', 'label' => __('State/County', 'woothemes') ) ); ?>
ID, '_order_items', true) ); ?>
0 && isset($order_items[0]['id'])) foreach ($order_items as $item) : if (isset($item['variation_id']) && $item['variation_id'] > 0) : $_product = &new woocommerce_product_variation( $item['variation_id'] ); else : $_product = &new woocommerce_product( $item['id'] ); endif; ?>
 [?]  [?]
sku) echo $_product->sku; else echo '-'; ?> variation_data)) echo '
' . woocommerce_get_formatted_variation( $_product->variation_data, true ); ?>
0) : foreach ($item['item_meta'] as $key => $meta) : // Backwards compatibility if (is_array($meta) && isset($meta['meta_name'])) : $meta_name = $meta['meta_name']; $meta_value = $meta['meta_value']; else : $meta_name = $key; $meta_value = $meta; endif; echo ''; endforeach; endif; ?>

ID ); ?>
add( $meta_name, $meta_value ); endif; endfor; // Add to array $order_items[] = apply_filters('update_order_item', array( 'id' => htmlspecialchars(stripslashes($item_id[$i])), 'variation_id' => (int) $item_variation[$i], 'name' => htmlspecialchars(stripslashes($item_name[$i])), 'qty' => (int) $item_quantity[$i], 'cost' => rtrim(rtrim(number_format(woocommerce_clean($item_cost[$i]), 4, '.', ''), '0'), '.'), 'base_cost' => rtrim(rtrim(number_format(woocommerce_clean($base_item_cost[$i]), 4, '.', ''), '0'), '.'), 'taxrate' => rtrim(rtrim(number_format(woocommerce_clean($item_tax_rate[$i]), 4, '.', ''), '0'), '.'), 'item_meta' => $item_meta->meta )); endfor; endif; update_post_meta( $post_id, '_order_items', $order_items ); // Give a password - not used, but can protect the content/comments from theme functions if ($post->post_password=='') : $order_post = array(); $order_post['ID'] = $post_id; $order_post['post_password'] = uniqid('order_'); wp_update_post( $order_post ); endif; // Order data saved, now get it so we can manipulate status $order = &new woocommerce_order( $post_id ); // Order status $order->update_status( $_POST['order_status'] ); // Handle button actions if (isset($_POST['reduce_stock']) && $_POST['reduce_stock'] && sizeof($order_items)>0) : $order->add_order_note( __('Manually reducing stock.', 'woothemes') ); foreach ($order_items as $order_item) : $_product = $order->get_product_from_item( $order_item ); if ($_product->exists) : if ($_product->managing_stock()) : $old_stock = $_product->stock; $new_quantity = $_product->reduce_stock( $order_item['qty'] ); $order->add_order_note( sprintf( __('Item #%s stock reduced from %s to %s.', 'woothemes'), $order_item['id'], $old_stock, $new_quantity) ); if ($new_quantity<0) : do_action('woocommerce_product_on_backorder_notification', $order_item['id'], $values['quantity']); endif; // stock status notifications if (get_option('woocommerce_notify_no_stock_amount') && get_option('woocommerce_notify_no_stock_amount')>=$new_quantity) : do_action('woocommerce_no_stock_notification', $order_item['id']); elseif (get_option('woocommerce_notify_low_stock_amount') && get_option('woocommerce_notify_low_stock_amount')>=$new_quantity) : do_action('woocommerce_low_stock_notification', $order_item['id']); endif; endif; else : $order->add_order_note( sprintf( __('Item %s %s not found, skipping.', 'woothemes'), $order_item['id'], $order_item['name'] ) ); endif; endforeach; $order->add_order_note( __('Manual stock reduction complete.', 'woothemes') ); elseif (isset($_POST['restore_stock']) && $_POST['restore_stock'] && sizeof($order_items)>0) : $order->add_order_note( __('Manually restoring stock.', 'woothemes') ); foreach ($order_items as $order_item) : $_product = $order->get_product_from_item( $order_item ); if ($_product->exists) : if ($_product->managing_stock()) : $old_stock = $_product->stock; $new_quantity = $_product->increase_stock( $order_item['qty'] ); $order->add_order_note( sprintf( __('Item #%s stock increased from %s to %s.', 'woothemes'), $order_item['id'], $old_stock, $new_quantity) ); endif; else : $order->add_order_note( sprintf( __('Item %s %s not found, skipping.', 'woothemes'), $order_item['id'], $order_item['name'] ) ); endif; endforeach; $order->add_order_note( __('Manual stock restore complete.', 'woothemes') ); elseif (isset($_POST['invoice']) && $_POST['invoice']) : // Mail link to customer woocommerce_pay_for_order_customer_notification( $order ); endif; // Error Handling if (sizeof($woocommerce_errors)>0) update_option('woocommerce_errors', $woocommerce_errors); }