• Resolved clonemykey

    (@clonemykey)


    Hello,

    I thought I had this code pretty well generated but it’s throwing a critical error when I try to implement. Items in our orders have “service” tags that show several different levels of service, depending on what the customer selects.

    If a customer checks out with an item with a certain service (example below: mail-in) and the order is paid (goes from pending to processing) we need that status updated to waiting (wc-waiting).

    Important note, an order can have more than one item and more than one service tag. This function should change the status if the mail-in service is used in any of the items.

    Any help would be great. I’m not a coder by trade but I thought I had this.

    
    function woocommerce_order_status_change_for_waiting_for_key( $order ) {
    		$needs_mailin_instructions = false;
    
    		foreach ( $order->get_items() as $item ) {
    
    		if ( isset( $item['service'] ) && $item['service'] === 'mail-in' ) {
    		$needs_mailin_instructions = true;
    				}
    			}
    
                    if ( $needs_mailin_instructions )  
                        {if ($status == "wc-processing") {
    					$order->update_status( 'waiting', 'order_note' );
                    }
                }	
    		}
    add_action('woocommerce_order_status_changed', 'woocommerce_order_status_change_for_waiting_for_key');
    • This topic was modified 2 years, 10 months ago by clonemykey.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello there,

    * You can use a plugin like:
    WooCommerce Order Status Manager

    It allows you to create new statuses and integrate them into your order workflow.

    In case there is any pre-sales questions (it also has a 30 days money back refund policy) you can reach out at: WooCommerce.com > My Account > Support. You may need to create an account before you can access that page.

    * Also, an alternative solution to edit order status via custom code is provided in this blog.

    I hope this leads you in the right direction.

    Thread Starter clonemykey

    (@clonemykey)

    Hi @ihereira,

    We looked at plugins like this and it doesn’t appear that you can set logic conditions based on order item meta values like “mail-in” as described in the example above.

    I’ll take a look at the blog post you linked.

    Regards,

    B

    Mirko P.

    (@rainfallnixfig)

    Hey @clonemykey,

    I would recommend that you review the Business Bloomer article shared by Igor and try the PHP snippet. Hopefully, it will work for you. Please note that we do not take responsibility for issues arising using snippets found on the web. Make sure to have a full backup before adding custom code to your site.

    If that doesn’t help, you might want to consider consulting with a developer and you could reach out to some of the official WooCommerce development partners via this link below:

    https://woocommerce.com/customizations/

    Feel free to contact us back if you have any other questions.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution and the above resources for developers were helpful. If you have further questions, please feel free to open a new topic.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change status of order if conditions are met’ is closed to new replies.