-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hook): woocommerce order new (#17)
* feat(hook): woocommerce order new * feat: add more details to woocommerce order new * chore: update label for woocommerce new order callback * chore: translate woocommerce order new
- Loading branch information
Showing
7 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* @package Telelog | ||
*/ | ||
|
||
namespace Telelog\Inc\Telegram\WooCommerce; | ||
|
||
use Telelog\Inc\Telegram\Telegram; | ||
|
||
class WooCommerceOrderNew extends Telegram | ||
{ | ||
private $onWooCommerceOrderNew; | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->onWooCommerceOrderNew = get_option('telelog_on_woocommerce_order_new'); | ||
} | ||
public function register() | ||
{ | ||
if ($this->onWooCommerceOrderNew === '1' && in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) | ||
add_action('woocommerce_new_order', array($this, 'woocommerce_order_new'), 10, 1); | ||
} | ||
public function woocommerce_order_new($order_id) | ||
{ | ||
$order = wc_get_order( $order_id ); | ||
$ip = $order->customer_ip_address; | ||
$order_id = $order->get_id(); | ||
|
||
$site_url = get_site_url(); | ||
$order_url = $site_url . '/wp-admin/post.php?post=' . $order_id . '&action=edit'; | ||
|
||
$author = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name(); | ||
$email = $order->get_billing_email(); | ||
|
||
$title = __('New WooCommerce order', 'telelog') . ": <a href='$order_url'>$order_id</a>"; | ||
$this->alert($title, null, __FUNCTION__, $author, $ip, $email); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters