Skip to content

Commit

Permalink
- Standardizing Event names sent to Intercom. New format: `order-[sta…
Browse files Browse the repository at this point in the history
…tus]`. See [Issue #19](#19).
  • Loading branch information
jaswsinc committed Nov 19, 2016
1 parent 976d9d2 commit c10691a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## [coming soon]

- Standardizing Event names sent to Intercom. New format: `order-[status]`. See [Issue #19](https://github.com/websharks/woocommerce-intercom-pro/issues/19).

- Adding `wp_site` and `wp_uri` fields to JS Snippet to make it easier for support representatives to identify the origin of a customer request; e.g., whenever a single Intercom account is being used to support more then one WordPress installation, or multiple child sites/domains in a Multisite Network. See [Issue #22](https://github.com/websharks/woocommerce-intercom-pro/issues/22).

- **Bug Fix:** Call to undefined method `WC_Order::get_currency()` should be `get_order_currency()`. Reported by @raamdev in [this GitHub issue](https://github.com/websharks/woocommerce-intercom-pro/issues/4).
Expand Down
11 changes: 6 additions & 5 deletions src/includes/classes/Utils/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @author @raamdev
* @copyright WP Sharks™
*/
declare (strict_types = 1);
declare(strict_types=1);
namespace WebSharks\WpSharks\WooCommerceIntercom\Pro\Classes\Utils;

use WebSharks\WpSharks\WooCommerceIntercom\Pro\Classes;
Expand Down Expand Up @@ -61,7 +61,7 @@ public function onWcOrderGiven($order_id)
public function onWcOrderStatusChanged($order_id, string $old_status, string $new_status)
{
if (in_array($new_status, ['processing', 'completed'], true)) {
$this->eventCreate((int) $order_id);
$this->eventCreate((int) $order_id, $new_status);
}
}

Expand All @@ -71,8 +71,9 @@ public function onWcOrderStatusChanged($order_id, string $old_status, string $ne
* @since 160909.7530 Initial release.
*
* @param string|int $order_id Order ID.
* @param string $status The new status.
*/
protected function eventCreate(int $order_id)
protected function eventCreate(int $order_id, string $status)
{
if (!($WC_Order = wc_get_order($order_id))) {
debug(0, c::issue(vars(), 'Missing order.'));
Expand Down Expand Up @@ -145,7 +146,7 @@ protected function eventCreate(int $order_id)
}
$_event_data = [ // For API call; this pulls everything together.
// See: <https://developers.intercom.io/reference#submitting-events>
'event_name' => 'purchased-item',
'event_name' => 'item-'.$status,
'created_at' => time(),
'user_id' => $user_id,
'metadata' => $_event_metadata,
Expand Down Expand Up @@ -184,7 +185,7 @@ protected function eventCreate(int $order_id)
}
$event_data = [ // For API call; this pulls everything together.
// See: <https://developers.intercom.io/reference#submitting-events>
'event_name' => 'placed-order',
'event_name' => 'order-'.$status,
'created_at' => time(),
'user_id' => $user_id,
'metadata' => $event_metadata,
Expand Down

0 comments on commit c10691a

Please sign in to comment.