Skip to content

Commit

Permalink
Fix 'Test Slack' feature
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorbicewebdesign committed Oct 17, 2018
1 parent c92112c commit 1341118
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions woocommerce-slack.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,19 @@ public function get_last_order_id(){
global $wpdb;
$statuses = array_keys(wc_get_order_statuses());
$statuses = implode( "','", $statuses );

// Getting last Order ID (max value)
$results = $wpdb->get_col( "
$query = "
SELECT MAX(ID) FROM {$wpdb->prefix}posts
WHERE post_type LIKE 'shop_order'
AND post_status IN ('$statuses')
" );
";
// Getting last Order ID (max value)
$results = $wpdb->get_col($query);
return reset($results);
}
public static function test_slack() {
$order = wc_get_order( self::get_last_order_id() );

$order_id = self::get_last_order_id();
$order = wc_get_order( $order_id );
if($order->status=='processing' || $order->status=='completed'){
$icon = get_option( 'wc_settings_tab_slack_woocommerce_slack_icon_completed' );
$status = "completed";
Expand All @@ -357,7 +359,7 @@ public static function test_slack() {
$channel = "#".get_option( 'wc_settings_tab_slack_woocommerce_channel' );


$this->slack_message($message, "Marketplace Purchase", $channel, $icon);
self::slack_message($message, "Order ".ucfirst($order->status). " TEST", $channel, $icon);

wp_die();
}
Expand Down

0 comments on commit 1341118

Please sign in to comment.