diff --git a/CHANGELOG.md b/CHANGELOG.md index d848324..645a55e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.8.4 + +- WooCommerce orders carry `order_id` and `placed_at`, so SendBeam stores each order once, attributes it to the email that led to it, and counts it in revenue. Orders reported by earlier versions cannot be attributed retroactively. + ## 1.8.3 - Connect SendBeam: one button connects the site and hands it a key with exactly the permissions you tick, and can add your sending domain at the same time. Pasting a key by hand still works. diff --git a/blocks/form/block.json b/blocks/form/block.json index 2fa8c25..4afa9d8 100644 --- a/blocks/form/block.json +++ b/blocks/form/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "sendbeam/form", - "version": "1.8.3", + "version": "1.8.4", "title": "SendBeam Form", "category": "widgets", "icon": "email-alt", diff --git a/blocks/form/index.asset.php b/blocks/form/index.asset.php index 4664653..0ac01cf 100644 --- a/blocks/form/index.asset.php +++ b/blocks/form/index.asset.php @@ -10,5 +10,5 @@ // editor renders a placeholder card now. Loading a script nothing uses is // how an editor gets slow one dependency at a time. 'dependencies' => array( 'wp-blocks', 'wp-element', 'wp-block-editor', 'wp-components', 'wp-i18n', 'wp-api-fetch' ), - 'version' => '1.8.3', + 'version' => '1.8.4', ); diff --git a/includes/ecommerce.php b/includes/ecommerce.php index 971ac53..cf1b360 100644 --- a/includes/ecommerce.php +++ b/includes/ecommerce.php @@ -275,9 +275,16 @@ function sendbeam_ecommerce_on_order_placed( $order_id ) { 'order_placed', $email, array( - 'name' => trim( $order->get_billing_first_name() . ' ' . $order->get_billing_last_name() ), - 'value' => (float) $order->get_total(), - 'currency' => $order->get_currency(), + 'name' => trim( $order->get_billing_first_name() . ' ' . $order->get_billing_last_name() ), + 'value' => (float) $order->get_total(), + 'currency' => $order->get_currency(), + // The order id is what lets SendBeam store the order, attribute it + // to the email that led to it, and treat a retried delivery as the + // same order rather than a second one. Without it the event fires + // automations and moves lifetime value but appears in no revenue + // figure. + 'order_id' => (string) $order->get_id(), + 'placed_at' => $order->get_date_created() ? $order->get_date_created()->format( DATE_ATOM ) : gmdate( DATE_ATOM ), ) ); } diff --git a/readme.txt b/readme.txt index 5d21286..54f2381 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: newsletter, email marketing, signup form, popup, contact form Requires at least: 6.1 Tested up to: 7.1 Requires PHP: 7.4 -Stable tag: 1.8.3 +Stable tag: 1.8.4 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -181,6 +181,9 @@ Yes. The form is an iframe and the pop-up is a script tag, both cache-safe. == Changelog == += 1.8.4 = +* WooCommerce orders now carry the order number and the time it was placed, so SendBeam stores each order once, attributes it to the email that led to it, and counts it in revenue. Orders reported by earlier versions fired automations and lifetime value but cannot be attributed after the fact. + = 1.8.3 = * Connect SendBeam: one button connects the site and hands it a key with exactly the permissions you tick, and can add your sending domain at the same time. Pasting a key by hand still works. * SendBeam has its own menu, with a page for each section: Overview, Forms, Pop-ups, Audience, Site email, E-commerce, Settings and Help. Old Settings → SendBeam links redirect. diff --git a/sendbeam.php b/sendbeam.php index c267f54..2d023b4 100644 --- a/sendbeam.php +++ b/sendbeam.php @@ -3,7 +3,7 @@ * Plugin Name: SendBeam * Plugin URI: https://sendbeam.io/docs/wordpress * Description: Newsletter signup forms, pop-ups, opt-ins at registration and checkout, and your site's own email, from your SendBeam account. - * Version: 1.8.3 + * Version: 1.8.4 * Requires at least: 6.1 * Requires PHP: 7.4 * Author: SendBeam @@ -17,7 +17,7 @@ defined( 'ABSPATH' ) || exit; -define( 'SENDBEAM_VERSION', '1.8.3' ); +define( 'SENDBEAM_VERSION', '1.8.4' ); define( 'SENDBEAM_FILE', __FILE__ ); define( 'SENDBEAM_DIR', plugin_dir_path( __FILE__ ) ); diff --git a/tests/smoke.php b/tests/smoke.php index 1011939..29681fe 100644 --- a/tests/smoke.php +++ b/tests/smoke.php @@ -572,6 +572,7 @@ function sb_log_reset() { sendbeam_ecommerce_on_order_placed( 501 ); ok( 1 === count( $stub['cron'] ) && SENDBEAM_ECOMMERCE_HOOK === $stub['cron'][0]['hook'], 'order placed: queued as a single cron event, like every other subscription' ); $sendbeam_order_job = $stub['cron'][0]['args'][0]; +ok( '501' === $sendbeam_order_job['order_id'] && ! empty( $sendbeam_order_job['placed_at'] ) && false !== strtotime( $sendbeam_order_job['placed_at'] ), 'order placed: carries the order id and the time it was placed, so SendBeam stores and attributes it (#105)' ); ok( 'order_placed' === $sendbeam_order_job['type'] && 'buyer@example.test' === $sendbeam_order_job['email'] && 'Ada Lovelace' === $sendbeam_order_job['name'] && 84.5 === $sendbeam_order_job['value'] && 'GBP' === $sendbeam_order_job['currency'], 'order placed: name, total and currency are read from the order' ); $stub['remote'] = array(); diff --git a/tests/woocommerce-stubs.php b/tests/woocommerce-stubs.php index ec0b9af..891a14f 100644 --- a/tests/woocommerce-stubs.php +++ b/tests/woocommerce-stubs.php @@ -27,6 +27,7 @@ public function get_billing_last_name() { return isset( $this->data['last_name'] public function get_total() { return isset( $this->data['total'] ) ? $this->data['total'] : 0; } public function get_currency() { return isset( $this->data['currency'] ) ? $this->data['currency'] : 'USD'; } public function get_id() { return isset( $this->data['id'] ) ? $this->data['id'] : 0; } + public function get_date_created() { return new DateTime( '2026-09-25T08:00:00+00:00' ); } // Order meta lives in the shared stub store, keyed by order id, so a // second WC_Order for the same id sees what the first one saved. public function get_meta( $key ) { $id = $this->get_id(); return isset( $GLOBALS['stub']['wc_order_meta'][ $id ][ $key ] ) ? $GLOBALS['stub']['wc_order_meta'][ $id ][ $key ] : ''; }