diff --git a/TODO b/TODO index 624b22344d126c42667fe3aabe0871f6a9bda5a4..8b585feafe1658d16d4cb4e74a4ca5441771fee4 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,7 @@ OpenTools Advanced Ordernumbers for WooCommerce - Open TODOs ============================================================ -- Make sure the numbers are generated only for new orders, not for exsiting ones +- Make sure the numbers are generated only for new orders, not for existing ones - Check REST API - Would it make sense to configure the order password format? - Find out how multisite works and make the plugin work with it diff --git a/woocommerce-advanced-ordernumbers.php b/woocommerce-advanced-ordernumbers.php index b48c43614391262111778d3773204d2bf74349da..7a0d506a70355d70913d2e47761b29f79987d4d8 100644 --- a/woocommerce-advanced-ordernumbers.php +++ b/woocommerce-advanced-ordernumbers.php @@ -192,7 +192,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g // When a new order is created, we immediately assign the order number: add_action( 'wp_insert_post', array(&$this, 'check_create_ordernumber'), 10, 3); - add_action( 'save_post', array(&$this, 'check_create_ordernumber'), 10, 3); +// add_action( 'save_post', array(&$this, 'check_create_ordernumber'), 10, 3); // The filter to actually return the order number for the given order add_filter ('woocommerce_order_number', array(&$this, 'get_ordernumber'), 10, 2/*<= Also get the order object! */); } @@ -533,6 +533,20 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g return wp_parse_args ($custom, $columns); } + /** + * Add the "create new order number" action to the edit order page in the Backend + */ + public function add_order_action_new_number($actions) { + $actions['assign_new_ordernumber'] = self::__('Assign a new order number'); + } + /** + * Handle the "Assign a new order number" action from the edit order page in the backend + */ + public function order_action_assign_new_ordernumber( $order ) { + $number = $this->create_ordernumber($order->id, $order, 'ordernumber'); + } + + /** * Handle new posts created in the frontend. This action will be called for all posts, * not only for orders, so we need to check explicitly. Also, this function will be called @@ -884,7 +898,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g * The hook to assign a customized order number (unless the order already has one assigned) */ function assign_new_ordernumber($orderid, $order, $update=true) { - if ((!$update) && ($order->post_status == 'auto-draft')) { + if ((!$update) /*&& ($order->post_status == 'auto-draft')*/) { // New order => assign placeholder, which will later be overwritten the real order number update_post_meta( $orderid, $this->ordernumber_meta, $this->ordernumber_new_placeholder ); }