Ask your WordPress questions! Pay money and get answers fast! (more info)

custom order status

  • SOLVED

I have custom order status created with a plugin. All status updated with email notifications sent no problem. Status updated through woo admin could trigger SMS working fine. However, cannot find anyway to trigger the SMS through PHP.

So looking for snippet that is able trigger SMS. Any ideas?

Current code:
$new_status = 'x';
$order = new WC_Order($order_id);
$order->update_status($new_status);

I need to trigger SMS custom order status, test it your self
https://wordpress.org/plugins/woocommerce-apg-sms-notifications/

Answers (3)

2016-11-09

Reigel Gallarde answers:

upon reading the code, I believe you are not allowed to do that based on the codes...
That plugin is requiring another plugin to be able to use custom order status... this plugin https://codecanyon.net/item/woocommerce-advance-order-status/6222931

you might be able to get away with it by editing apg-sms.php on lines 132 - 136...
but then you need to edit inludes\formulario.php too... on lines 330 - 357...

basically what it's currently doing is that if the order status is not in the defaults, it will check if that plugin B created it, otherwise it ignores the order status...

You might want to try this or ask the author himself for clarifications as to why your custom order status is not working..


Reigel Gallarde comments:

I'm not sure if my comment above should work because I have not tried it...

before doing above, you might want to try adding this code in your functions.php, to see if this works..

add_action( 'woocommerce_order_status_x', 'apg_sms_procesa_estados', 10 );

assuming your status is 'x'


email889 comments:

How do I limit only apply "add_action" below If there is apg?
add_action( 'woocommerce_order_status_x', 'apg_sms_procesa_estados', 10 );


Reigel Gallarde comments:

try to check if function exist...

if(function_exists('apg_sms_procesa_estados')){
add_action( 'woocommerce_order_status_x', 'apg_sms_procesa_estados', 10 );
}


email889 comments:

Great! it works. Solved!

2016-11-09

Arnav Joy answers:

I am not sure but I think this function will work

wp_remote_get( "https://www.voipstunt.com/myaccount/sendsms.php?username=xxxxxx&password=xxxxxx&from=xxxxxx&to=xxxxxx&text=xxxxxx" );


email889 comments:

sorry it's different sms.

2016-11-09

dimadin answers:

It should probably be something like

add_action( 'woocommerce_order_status_custom', 'apg_sms_procesa_estados', 10 );

where custom is name of your status.

See plugin's code on https://github.com/artprojectgroup/woocommerce-apg-sms-notifications/blob/master/apg-sms.php#L201 and WooCommerce's code that triggers it https://github.com/woocommerce/woocommerce/blob/2de494e105ba88b135ebf6ba9767c9f6a9299fce/includes/class-wc-order.php#L474