• Resolved Pavel Mares

    (@pavelmares)


    So my client has special flow, when the site creates 3 separate orders but they are connected via ACF (custom fields) and then in frontend presented as one order with different options.

    This flow is needed for our purpose.

    Point is, these orders has custom status and WooSMS is reacting when this status is added – correct behaviour.

    But problem is, that it’s firing 3 times for 1 order – as I explained before. I didn’t fined any solution to something like conditions.

    E.g.: If order status (this is normal plugin function) AND has CATEGORY (send sms) then it would send SMS.

    I would be able to add category to only one order and if plugin would have some more logic beside “status change”, e.g. the category selection, it would be nice.

    Or is there any other way?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author BulkGate

    (@woosms)

    Hi @pavelmares,

    You can’t do this without any modification of the plugin.

    Please, see the following line:
    https://github.com/BulkGate/woosms/blob/master/woosms-sms-module-for-woocommerce.php#L97

    You can propose a solution to your problem and send a pull request.

    Thread Starter Pavel Mares

    (@pavelmares)

    Well, there could be this simple line, that should be able to stop the hook from running.

    And now, when order has post_meta key with specific status, hook won’t run. I believe you can write it better than me, but you sure get the point.

    You doesn’t have to make big changes, most of it is on developer part – aka me.

    
    <?php
        if( get_post_meta( $order_id, 'woosms_forbid_wc-'.$order->get_status(), true) ) return;
    ?>
    

    And would put this somewhere here – https://github.com/BulkGate/woosms/blob/master/woosms-sms-module-for-woocommerce.php#L96

    • This reply was modified 2 years, 5 months ago by Pavel Mares.
    Thread Starter Pavel Mares

    (@pavelmares)

    Of course, this is just for now quick solution. If you would want to, you can add metabox in orders detail in admin with checkboxes to add this.

    Or make a rule metabox in settings of SMS updates, where could be “add custom meta key, which prevent order from sending SMS”. Which would need to add hook for my code line I presented in previous comment.

    There are multiple solutions how to take advantage of that function and preventing it. Depends how much time you can spend to do it.

    My solution is quick for my specific purpose, if you don’t want to make some big changes to the plugin.

    Thread Starter Pavel Mares

    (@pavelmares)

    Or there could be hook that would round in that function. This would be some normal code for WordPress hook like “proceed_send_woo” with order_id and if there was action for that, that would return false, it would forbid.

    I could add action to that hook, and run SQL / PHP to control, if for this specific order should be allow to send SMS (aka proceed with WooSMS functions).

    Plugin Author BulkGate

    (@woosms)

    Hi @pavelmares,

    sorry for the late reply.

    Try to implement the hook “proceed_send_woo” and send the pull request on github.

    Plugin Author BulkGate

    (@woosms)

    Hi @pavelmares,

    your pull request was accepted and we released version 2.0.25.

    Thread Starter Pavel Mares

    (@pavelmares)

    Yes, already updated. Thanks.

    • This reply was modified 2 years, 5 months ago by Pavel Mares.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Conditions’ is closed to new replies.