Check a specific custom field value before changing the order status by the plugin

Top WooCommerce & WordPress Plugins Forums Order Status Rules for WooCommerce Check a specific custom field value before changing the order status by the plugin

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #85558
    Miroslav Hrncir
    Guest

    Hi, I would love to check a specific custom field value before changing the order status by your plugin.

    I mean like combinations of these conditions:

    1. order is in specific state for 1 hour
    AND
    2. value of my specific customfield is equal to true / false / etc.

    So the order status will be changed after the 1 hour only in case, if value of my cusfom field is equal to something.

    Is this possible for example via any hooks etc. ?

    Thank you, regards Mirek

    #85559
    Tom Anbinder
    Moderator
    Plugin Support

    Hi Mirek,

    I could definitely add a hook, but maybe I could do more? This custom field – is it order’s? Or maybe order product’s or customer’s?

    #85560
    Miroslav Hrncir
    Guest

    Yes, it is order’s custom field … this would be AWESOME btw!! 🙂

    #85561
    Tom Anbinder
    Moderator
    Plugin Support

    Hi Mirek,

    As promised, we’ve just released a new plugin version 2.0.0, where I’ve added “Order meta” options to each rule’s settings (e.g. in “WooCommerce > Settings > Order Status Rules > Rule #1”). You need to set meta key and meta value there. They will be required for the rule to be executed on an order.

    Also, I’ve added alg_wc_order_status_rules_do_apply_rule filter. You probably won’t need it, but just in case, here is an example:

    if ( ! function_exists( 'my_alg_wc_order_status_rules_do_apply_rule' ) ) {
        add_filter( 'alg_wc_order_status_rules_do_apply_rule', 'my_alg_wc_order_status_rules_do_apply_rule', 10, 4 );
        function my_alg_wc_order_status_rules_do_apply_rule( $do_apply, $order, $rule_num, $args ) {
            if ( $do_apply && 1 == $rule_num && 'my_required_meta_value' !== get_post_meta( $order->get_id(), '_my_awesome_meta_key', true ) ) {
                return false;
            }
            return $do_apply;
        }
    }
    

    Please give it a try and let me know if something is not working as expected, or if you have any questions.

    And if you like the plugin, please consider leaving me a rating here or here.

    #85562
    Miroslav Hrncir
    Guest

    Oh Tom! You are a GOD!

    Thank you! Gonna test it and let you know!

    #85563
    Tom Anbinder
    Moderator
    Plugin Support

    Hi Mirek,

    I’m definitely not, but thank you 😉

    Yes, please let me know how did the testing go.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.