-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwoocommerce.php
49 lines (45 loc) · 2.44 KB
/
woocommerce.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Check if WooCommerce is active
**/
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
// the woocommerce_new_order callback
function notify_woosms_action_woocommerce_new_order($order_id) {
$order = wc_get_order( $order_id );
$options = get_option( 'notify_woosms_settings' );
$customerphonenumber = $order->get_billing_phone();
$smsbody = $options['notify_woosms_template_order_placed'];
$smsbody = str_replace("{{ordernumber}}", $order_id, $smsbody);
$smsbody = str_replace("{{customername}}", $order->get_billing_first_name(), $smsbody);
if ($options['notify_woosms_enable_sms'] == 1 && $options['notify_woosms_check_order_placed'] == 1) {
notify_woosms_send_sms($customerphonenumber, $smsbody);
}
};
add_action( 'woocommerce_new_order', 'notify_woosms_action_woocommerce_new_order', 10, 3 );
// the woocommerce_order_processing callback
function notify_woosms_action_woocommerce_order_processing($order_id) {
$order = wc_get_order( $order_id );
$options = get_option( 'notify_woosms_settings' );
$customerphonenumber = $order->get_billing_phone();
$smsbody = $options['notify_woosms_template_order_processing'];
$smsbody = str_replace("{{ordernumber}}", $order_id, $smsbody);
$smsbody = str_replace("{{customername}}", $order->get_billing_first_name(), $smsbody);
if ($options['notify_woosms_enable_sms'] == 1 && $options['notify_woosms_check_order_processing'] == 1) {
notify_woosms_send_sms($customerphonenumber, $smsbody);
}
};
add_action( 'woocommerce_order_status_processing', 'notify_woosms_action_woocommerce_order_processing', 10, 3 );
// the woocommerce_ordercompleted callback
function notify_woosms_action_woocommerce_order_completed($order_id) {
$order = wc_get_order( $order_id );
$options = get_option( 'notify_woosms_settings' );
$customerphonenumber = $order->get_billing_phone();
$smsbody = $options['notify_woosms_template_order_completed'];
$smsbody = str_replace("{{ordernumber}}", $order_id, $smsbody);
$smsbody = str_replace("{{customername}}", $order->get_billing_first_name(), $smsbody);
if ($options['notify_woosms_enable_sms'] == 1 && $options['notify_woosms_check_order_completed'] == 1) {
notify_woosms_send_sms($customerphonenumber, $smsbody);
}
};
add_action( 'woocommerce_order_status_completed', 'notify_woosms_action_woocommerce_order_completed', 10, 3 );
}