Change default order statuses of cash and cheque.
-
I am trying to figure out a lightweight upgrade-safe way to change the default order statuses of cash and cheque payments. Currently cash (COD) defaults to ‘Processing’ and Cheque defaults to ‘On Hold’. The following code is taken from the woocommerce core gateway files.
COD Gateway Relevant code:
/** * Process the payment and return the result * * @param int $order_id * @return array */ public function process_payment( $order_id ) { $order = wc_get_order( $order_id ); // Mark as processing (payment won't be taken until delivery) $order->update_status( 'processing', __( 'Payment to be made upon delivery.', 'woocommerce' ) ); // Reduce stock levels $order->reduce_order_stock(); // Remove cart WC()->cart->empty_cart(); // Return thankyou redirect return array( 'result' => 'success', 'redirect' => $this->get_return_url( $order ) ); }
Cheque Gateway Relevant Code
/** * Add content to the WC emails. * * @access public * @param WC_Order $order * @param bool $sent_to_admin * @param bool $plain_text */ public function email_instructions( $order, $sent_to_admin, $plain_text = false ) { if ( $this->instructions && ! $sent_to_admin && 'cheque' === $order->payment_method && $order->has_status( 'on-hold' ) ) { echo wpautop( wptexturize( $this->instructions ) ) . PHP_EOL; } } /** * Process the payment and return the result * * @param int $order_id * @return array */ public function process_payment( $order_id ) { $order = wc_get_order( $order_id ); // Mark as on-hold (we're awaiting the cheque) $order->update_status( 'on-hold', __( 'Awaiting cheque payment', 'woocommerce' ) ); // Reduce stock levels $order->reduce_order_stock(); // Remove cart WC()->cart->empty_cart(); // Return thankyou redirect return array( 'result' => 'success', 'redirect' => $this->get_return_url( $order ) ); } }
I am fairly sure I can just change ‘processing’ and ‘on-hold’ to pending. How can I do this in my theme functions. Also could I have automatic emails sent by the pending status? Thanks in advance!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Change default order statuses of cash and cheque.’ is closed to new replies.