Changeset 3755233
- Timestamp:
- 10/19/2026 04:51:59 PM (40 hours ago)
- Location:
- onetrace-for-woocommerce
- Files:
-
- 2 added
- 20 edited
- 1 copied
-
tags/1.9.0 (copied) (copied from onetrace-for-woocommerce/trunk )
-
tags/1.9.0/languages/onetrace-for-woocommerce-ru_RU.mo (modified) ( previous)
-
tags/1.9.0/languages/onetrace-for-woocommerce-ru_RU.po (modified) (1 diff)
-
tags/1.9.0/languages/onetrace-for-woocommerce.pot (modified) (2 diffs)
-
tags/1.9.0/onetrace-woocommerce.php (modified) (2 diffs)
-
tags/1.9.0/readme.txt (modified) (6 diffs)
-
tags/1.9.0/src/Admin.php (modified) (1 diff)
-
tags/1.9.0/src/Orders.php (modified) (1 diff)
-
tags/1.9.0/src/Plugin.php (modified) (1 diff)
-
tags/1.9.0/src/Shipments.php (added)
-
tags/1.9.0/vendor/onetrace-php/src/Client.php (modified) (1 diff)
-
tags/1.9.0/vendor/onetrace-php/src/Commerce/Messages.php (modified) (3 diffs)
-
trunk/languages/onetrace-for-woocommerce-ru_RU.mo (modified) ( previous)
-
trunk/languages/onetrace-for-woocommerce-ru_RU.po (modified) (1 diff)
-
trunk/languages/onetrace-for-woocommerce.pot (modified) (2 diffs)
-
trunk/onetrace-woocommerce.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (6 diffs)
-
trunk/src/Admin.php (modified) (1 diff)
-
trunk/src/Orders.php (modified) (1 diff)
-
trunk/src/Plugin.php (modified) (1 diff)
-
trunk/src/Shipments.php (added)
-
trunk/vendor/onetrace-php/src/Client.php (modified) (1 diff)
-
trunk/vendor/onetrace-php/src/Commerce/Messages.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
onetrace-for-woocommerce/tags/1.9.0/languages/onetrace-for-woocommerce-ru_RU.po
r3753316 r3755233 108 108 109 109 #: src/Admin.php:82 110 msgid "Placed, paid, cancelled and refunded orders with the customer data"111 msgstr "Оформленные, оплаченные, от менённые заказы и возвраты с данными покупателя"110 msgid "Placed, paid, shipped, delivered, cancelled and refunded orders with the customer data" 111 msgstr "Оформленные, оплаченные, отправленные, доставленные, отменённые заказы и возвраты с данными покупателя" 112 112 113 113 #: src/Admin.php:83 -
onetrace-for-woocommerce/tags/1.9.0/languages/onetrace-for-woocommerce.pot
r3753316 r3755233 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: OneTrace for WooCommerce 1. 8.0\n"5 "Project-Id-Version: OneTrace for WooCommerce 1.9.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/onetrace-woocommerce\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 114 114 115 115 #: src/Admin.php:82 116 msgid "Placed, paid, cancelled and refunded orders with the customer data"116 msgid "Placed, paid, shipped, delivered, cancelled and refunded orders with the customer data" 117 117 msgstr "" 118 118 -
onetrace-for-woocommerce/tags/1.9.0/onetrace-woocommerce.php
r3753316 r3755233 4 4 * Plugin URI: https://wordpress.org/plugins/onetrace-for-woocommerce/ 5 5 * Description: Connects the store to OneTrace.pro, the customer data platform: orders, customers and consents from the server, the website tracker, the product catalog with stock, wishlists, recommendation widgets and Web Push. 6 * Version: 1. 8.06 * Version: 1.9.0 7 7 * Requires at least: 6.6 8 8 * Requires PHP: 7.4 … … 43 43 } 44 44 45 define('ONETRACE_WC_VERSION', '1. 8.0');45 define('ONETRACE_WC_VERSION', '1.9.0'); 46 46 define('ONETRACE_WC_FILE', __FILE__); 47 47 -
onetrace-for-woocommerce/tags/1.9.0/readme.txt
r3753316 r3755233 7 7 WC requires at least: 9.0 8 8 WC tested up to: 11.2 9 Stable tag: 1. 8.09 Stable tag: 1.9.0 10 10 License: GPLv2 or later 11 11 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 20 20 21 21 * Orders and their statuses from the server, through a queue with retries — not lost to ad blockers, and the store never waits for the platform. 22 * Shipments with the carrier, tracking number and link from WooCommerce Shipment Tracking, Advanced Shipment Tracking and TrackShip, and delivered orders — for "where is my order?" in the online chat and shipping journeys. 22 23 * Customers and newsletter consents from registration, the account page and the checkout (classic and block). 23 24 * Cart events for abandoned cart journeys; wishlist events from YITH WooCommerce Wishlist and TI WooCommerce Wishlist. … … 35 36 = External service = 36 37 37 The plugin sends data to the OneTrace.pro platform at the address you enter in the settings (your own brand domain or cdp.onetrace.pro): customer data (email, phone, name, city, country, language), consents, orders , cart and wishlist events and the product catalog with stock from the server; with the loyalty program — the customer id and the cart amount to show and hold bonus points, the friend's referral code on registration; with promo codes the plugin reads the codes of the bound pools; page and product views from the visitor's browser. Terms of service: https://onetrace.pro/en/legal/terms, privacy policy: https://onetrace.pro/en/legal/privacy.38 The plugin sends data to the OneTrace.pro platform at the address you enter in the settings (your own brand domain or cdp.onetrace.pro): customer data (email, phone, name, city, country, language), consents, orders with their shipments (carrier, tracking number and link), cart and wishlist events and the product catalog with stock from the server; with the loyalty program — the customer id and the cart amount to show and hold bonus points, the friend's referral code on registration; with promo codes the plugin reads the codes of the bound pools; page and product views from the visitor's browser. Terms of service: https://onetrace.pro/en/legal/terms, privacy policy: https://onetrace.pro/en/legal/privacy. 38 39 39 40 == Installation == … … 48 49 49 50 YITH WooCommerce Wishlist and TI WooCommerce Wishlist: adding and removing products is sent from the server (setting "Wishlist"). With another wishlist, put `data-cdp-wishlist="{product id}"` on the "Add to wishlist" button of the theme and `data-cdp-wishlist-remove="{product id}"` on the "Remove" button — the OneTrace tracker (1.13.0 and later) sends the events on click. The product id is the one of the catalog: the post ID, or the SKU with "Product id → SKU". 51 52 = Which shipment tracking plugins are supported? = 53 54 WooCommerce Shipment Tracking, Advanced Shipment Tracking and TrackShip: every tracking item added to the order is sent as order_shipped with the carrier, the tracking number and the link; the "Delivered" status of AST and TrackShip is order_delivered. Without a tracking plugin the "Completed" status is one order_shipped without tracking. Other tracking plugins can pass their parcels with the onetrace_woocommerce_order_shipments filter (see the README on GitHub). 50 55 51 56 = How does "Notify when available" work? = … … 69 74 70 75 == Changelog == 76 77 = 1.9.0 = 78 * Shipments: order_shipped with the carrier, tracking number and tracking link for every tracking item of WooCommerce Shipment Tracking, Advanced Shipment Tracking and TrackShip — once per parcel, a second parcel is a new event. Without tracking, the "Completed" or "Shipped" status is one order_shipped without tracking when no parcel was sent. 79 * Delivered orders: order_delivered from the "Delivered" status of AST and TrackShip, or when TrackShip reports every parcel of the order delivered. 80 * Other tracking plugins: the onetrace_woocommerce_order_shipments filter and the onetrace_woocommerce_sync_shipments action. 71 81 72 82 = 1.8.0 = … … 120 130 == Upgrade Notice == 121 131 132 = 1.9.0 = 133 Shipped and delivered orders with tracking numbers from WooCommerce Shipment Tracking, Advanced Shipment Tracking and TrackShip. 134 122 135 = 1.8.0 = 123 136 Stock in the catalog, wishlist events of YITH and TI wishlists, the "Notify when available" form on products out of stock. -
onetrace-for-woocommerce/tags/1.9.0/src/Admin.php
r3753316 r3755233 80 80 $field('tracker', ['type' => 'checkbox', 'title' => __('Tracker', 'onetrace-for-woocommerce'), 'desc' => __('Page and product views on the storefront', 'onetrace-for-woocommerce')]), 81 81 $field('wait_for_consent', ['type' => 'checkbox', 'title' => __('Cookie consent', 'onetrace-for-woocommerce'), 'desc' => __('Load the tracker after the visitor agrees to statistics cookies (with a consent plugin that supports the WP Consent API)', 'onetrace-for-woocommerce')]), 82 $field('orders', ['type' => 'checkbox', 'title' => __('Orders', 'onetrace-for-woocommerce'), 'desc' => __('Placed, paid, cancelled and refunded orders with the customer data', 'onetrace-for-woocommerce')]),82 $field('orders', ['type' => 'checkbox', 'title' => __('Orders', 'onetrace-for-woocommerce'), 'desc' => __('Placed, paid, shipped, delivered, cancelled and refunded orders with the customer data', 'onetrace-for-woocommerce')]), 83 83 $field('cart', ['type' => 'checkbox', 'title' => __('Cart', 'onetrace-for-woocommerce'), 'desc' => __('Adding to and removing from the cart, opening the checkout — for abandoned cart journeys', 'onetrace-for-woocommerce')]), 84 84 $field('wishlist', ['type' => 'checkbox', 'title' => __('Wishlist', 'onetrace-for-woocommerce'), 'desc' => __('Adding to and removing from the wishlist of YITH WooCommerce Wishlist or TI WooCommerce Wishlist — for wishlist journeys', 'onetrace-for-woocommerce')]), -
onetrace-for-woocommerce/tags/1.9.0/src/Orders.php
r3738426 r3755233 169 169 170 170 foreach ($order->get_items() as $item) { 171 if (!$item instanceof \WC_Order_Item_Product ) {171 if (!$item instanceof \WC_Order_Item_Product || $refund && abs((float) $item->get_total()) === 0.0) { 172 172 continue; 173 173 } 174 174 175 $quantity = abs((int) $item->get_quantity()); 176 $total = abs((float) $item->get_total()); 177 178 if ($quantity === 0 || $refund && $total === 0.0) { 179 continue; 175 $line = self::line($item); 176 177 if ($line !== null) { 178 $lines[] = $line; 180 179 } 181 182 $product = $item->get_product();183 $variation = $item->get_variation_id() ? wc_get_product($item->get_variation_id()) : null;184 $lines[] = new LineItem(185 Products::id($item->get_product_id()) ?: (string) $item->get_product_id(),186 $item->get_name(),187 $total / max(1, $quantity),188 max(1, $quantity),189 $variation instanceof \WC_Product ? Products::variantId($variation) : ($item->get_variation_id() ?: null),190 $product instanceof \WC_Product ? Catalog::categoryId($product) : null191 );192 180 } 193 181 194 182 return $lines; 183 } 184 185 /** 186 * A product line of the order; $quantity — a part of it (a parcel of a partial shipment). 187 */ 188 public static function line(\WC_Order_Item_Product $item, ?int $quantity = null): ?LineItem 189 { 190 $ordered = abs((int) $item->get_quantity()); 191 192 if ($ordered === 0) { 193 return null; 194 } 195 196 $product = $item->get_product(); 197 $variation = $item->get_variation_id() ? wc_get_product($item->get_variation_id()) : null; 198 199 return new LineItem( 200 Products::id($item->get_product_id()) ?: (string) $item->get_product_id(), 201 $item->get_name(), 202 abs((float) $item->get_total()) / $ordered, 203 $quantity !== null ? max(1, min($quantity, $ordered)) : $ordered, 204 $variation instanceof \WC_Product ? Products::variantId($variation) : ($item->get_variation_id() ?: null), 205 $product instanceof \WC_Product ? Catalog::categoryId($product) : null 206 ); 195 207 } 196 208 -
onetrace-for-woocommerce/tags/1.9.0/src/Plugin.php
r3753316 r3755233 45 45 Customers::register(); 46 46 Orders::register(); 47 Shipments::register(); 47 48 Cart::register(); 48 49 Wishlist::register(); -
onetrace-for-woocommerce/tags/1.9.0/vendor/onetrace-php/src/Client.php
r3753316 r3755233 45 45 final class Client 46 46 { 47 public const VERSION = '1.1 0.0';47 public const VERSION = '1.11.0'; 48 48 49 49 /** -
onetrace-for-woocommerce/tags/1.9.0/vendor/onetrace-php/src/Commerce/Messages.php
r3753316 r3755233 31 31 public const ORDER_REFUNDED = 'order_refunded'; 32 32 33 public const ORDER_SHIPPED = 'order_shipped'; 34 35 public const ORDER_DELIVERED = 'order_delivered'; 36 33 37 /** @var string */ 34 38 private $platform; … … 133 137 134 138 return $this->order($order, self::ORDER_REFUNDED, $properties, $at ?? $order->placedAt, $refundId !== null ? (string) $refundId : null); 139 } 140 141 /** 142 * The order (or a part of it) is handed over to delivery. Each parcel is sent once: $shipmentId (the tracking 143 * number by default) tells several parcels of one order apart. The platform shows the carrier, the tracking 144 * number and the link to the customer and to the AI of the online chat ("where is my order"). 145 * 146 * @param string|int|null $shipmentId 147 * @param list<LineItem> $lines shipped products of a partial shipment, if known 148 * 149 * @return array<string, mixed> 150 */ 151 public function orderShipped( 152 Order $order, 153 ?string $carrier = null, 154 ?string $trackingNumber = null, 155 ?string $trackingUrl = null, 156 ?\DateTimeInterface $estimatedDelivery = null, 157 ?\DateTimeInterface $at = null, 158 $shipmentId = null, 159 array $lines = [] 160 ): array { 161 $properties = array_filter([ 162 'order_id' => $order->id, 163 'carrier' => self::text($carrier, 100), 164 'tracking_number' => self::text($trackingNumber, 100), 165 'tracking_url' => $trackingUrl !== null && filter_var($trackingUrl, FILTER_VALIDATE_URL) !== false ? $trackingUrl : null, 166 'estimated_delivery' => $estimatedDelivery !== null ? $estimatedDelivery->format('Y-m-d') : null, 167 ], static function ($value): bool { 168 return $value !== null; 169 }); 170 171 if ($lines !== []) { 172 $properties['products'] = array_map(static function (LineItem $line): array { 173 return $line->toArray(); 174 }, $lines); 175 } 176 177 $suffix = $shipmentId !== null ? (string) $shipmentId : ($properties['tracking_number'] ?? null); 178 179 return $this->order($order, self::ORDER_SHIPPED, $properties, $at ?? new \DateTimeImmutable(), $suffix !== null ? preg_replace('/[^A-Za-z0-9_-]/', '', $suffix) : null); 180 } 181 182 /** 183 * The customer received the order. 184 * 185 * @return array<string, mixed> 186 */ 187 public function orderDelivered(Order $order, ?\DateTimeInterface $at = null): array 188 { 189 return $this->order($order, self::ORDER_DELIVERED, ['order_id' => $order->id], $at ?? new \DateTimeImmutable()); 135 190 } 136 191 … … 250 305 } 251 306 307 private static function text(?string $value, int $max): ?string 308 { 309 $value = $value !== null ? trim($value) : ''; 310 311 if ($value === '') { 312 return null; 313 } 314 315 return function_exists('mb_substr') ? mb_substr($value, 0, $max) : substr($value, 0, $max); 316 } 317 252 318 private static function time(\DateTimeInterface $at): string 253 319 { -
onetrace-for-woocommerce/trunk/languages/onetrace-for-woocommerce-ru_RU.po
r3753316 r3755233 108 108 109 109 #: src/Admin.php:82 110 msgid "Placed, paid, cancelled and refunded orders with the customer data"111 msgstr "Оформленные, оплаченные, от менённые заказы и возвраты с данными покупателя"110 msgid "Placed, paid, shipped, delivered, cancelled and refunded orders with the customer data" 111 msgstr "Оформленные, оплаченные, отправленные, доставленные, отменённые заказы и возвраты с данными покупателя" 112 112 113 113 #: src/Admin.php:83 -
onetrace-for-woocommerce/trunk/languages/onetrace-for-woocommerce.pot
r3753316 r3755233 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: OneTrace for WooCommerce 1. 8.0\n"5 "Project-Id-Version: OneTrace for WooCommerce 1.9.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/onetrace-woocommerce\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 114 114 115 115 #: src/Admin.php:82 116 msgid "Placed, paid, cancelled and refunded orders with the customer data"116 msgid "Placed, paid, shipped, delivered, cancelled and refunded orders with the customer data" 117 117 msgstr "" 118 118 -
onetrace-for-woocommerce/trunk/onetrace-woocommerce.php
r3753316 r3755233 4 4 * Plugin URI: https://wordpress.org/plugins/onetrace-for-woocommerce/ 5 5 * Description: Connects the store to OneTrace.pro, the customer data platform: orders, customers and consents from the server, the website tracker, the product catalog with stock, wishlists, recommendation widgets and Web Push. 6 * Version: 1. 8.06 * Version: 1.9.0 7 7 * Requires at least: 6.6 8 8 * Requires PHP: 7.4 … … 43 43 } 44 44 45 define('ONETRACE_WC_VERSION', '1. 8.0');45 define('ONETRACE_WC_VERSION', '1.9.0'); 46 46 define('ONETRACE_WC_FILE', __FILE__); 47 47 -
onetrace-for-woocommerce/trunk/readme.txt
r3753316 r3755233 7 7 WC requires at least: 9.0 8 8 WC tested up to: 11.2 9 Stable tag: 1. 8.09 Stable tag: 1.9.0 10 10 License: GPLv2 or later 11 11 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 20 20 21 21 * Orders and their statuses from the server, through a queue with retries — not lost to ad blockers, and the store never waits for the platform. 22 * Shipments with the carrier, tracking number and link from WooCommerce Shipment Tracking, Advanced Shipment Tracking and TrackShip, and delivered orders — for "where is my order?" in the online chat and shipping journeys. 22 23 * Customers and newsletter consents from registration, the account page and the checkout (classic and block). 23 24 * Cart events for abandoned cart journeys; wishlist events from YITH WooCommerce Wishlist and TI WooCommerce Wishlist. … … 35 36 = External service = 36 37 37 The plugin sends data to the OneTrace.pro platform at the address you enter in the settings (your own brand domain or cdp.onetrace.pro): customer data (email, phone, name, city, country, language), consents, orders , cart and wishlist events and the product catalog with stock from the server; with the loyalty program — the customer id and the cart amount to show and hold bonus points, the friend's referral code on registration; with promo codes the plugin reads the codes of the bound pools; page and product views from the visitor's browser. Terms of service: https://onetrace.pro/en/legal/terms, privacy policy: https://onetrace.pro/en/legal/privacy.38 The plugin sends data to the OneTrace.pro platform at the address you enter in the settings (your own brand domain or cdp.onetrace.pro): customer data (email, phone, name, city, country, language), consents, orders with their shipments (carrier, tracking number and link), cart and wishlist events and the product catalog with stock from the server; with the loyalty program — the customer id and the cart amount to show and hold bonus points, the friend's referral code on registration; with promo codes the plugin reads the codes of the bound pools; page and product views from the visitor's browser. Terms of service: https://onetrace.pro/en/legal/terms, privacy policy: https://onetrace.pro/en/legal/privacy. 38 39 39 40 == Installation == … … 48 49 49 50 YITH WooCommerce Wishlist and TI WooCommerce Wishlist: adding and removing products is sent from the server (setting "Wishlist"). With another wishlist, put `data-cdp-wishlist="{product id}"` on the "Add to wishlist" button of the theme and `data-cdp-wishlist-remove="{product id}"` on the "Remove" button — the OneTrace tracker (1.13.0 and later) sends the events on click. The product id is the one of the catalog: the post ID, or the SKU with "Product id → SKU". 51 52 = Which shipment tracking plugins are supported? = 53 54 WooCommerce Shipment Tracking, Advanced Shipment Tracking and TrackShip: every tracking item added to the order is sent as order_shipped with the carrier, the tracking number and the link; the "Delivered" status of AST and TrackShip is order_delivered. Without a tracking plugin the "Completed" status is one order_shipped without tracking. Other tracking plugins can pass their parcels with the onetrace_woocommerce_order_shipments filter (see the README on GitHub). 50 55 51 56 = How does "Notify when available" work? = … … 69 74 70 75 == Changelog == 76 77 = 1.9.0 = 78 * Shipments: order_shipped with the carrier, tracking number and tracking link for every tracking item of WooCommerce Shipment Tracking, Advanced Shipment Tracking and TrackShip — once per parcel, a second parcel is a new event. Without tracking, the "Completed" or "Shipped" status is one order_shipped without tracking when no parcel was sent. 79 * Delivered orders: order_delivered from the "Delivered" status of AST and TrackShip, or when TrackShip reports every parcel of the order delivered. 80 * Other tracking plugins: the onetrace_woocommerce_order_shipments filter and the onetrace_woocommerce_sync_shipments action. 71 81 72 82 = 1.8.0 = … … 120 130 == Upgrade Notice == 121 131 132 = 1.9.0 = 133 Shipped and delivered orders with tracking numbers from WooCommerce Shipment Tracking, Advanced Shipment Tracking and TrackShip. 134 122 135 = 1.8.0 = 123 136 Stock in the catalog, wishlist events of YITH and TI wishlists, the "Notify when available" form on products out of stock. -
onetrace-for-woocommerce/trunk/src/Admin.php
r3753316 r3755233 80 80 $field('tracker', ['type' => 'checkbox', 'title' => __('Tracker', 'onetrace-for-woocommerce'), 'desc' => __('Page and product views on the storefront', 'onetrace-for-woocommerce')]), 81 81 $field('wait_for_consent', ['type' => 'checkbox', 'title' => __('Cookie consent', 'onetrace-for-woocommerce'), 'desc' => __('Load the tracker after the visitor agrees to statistics cookies (with a consent plugin that supports the WP Consent API)', 'onetrace-for-woocommerce')]), 82 $field('orders', ['type' => 'checkbox', 'title' => __('Orders', 'onetrace-for-woocommerce'), 'desc' => __('Placed, paid, cancelled and refunded orders with the customer data', 'onetrace-for-woocommerce')]),82 $field('orders', ['type' => 'checkbox', 'title' => __('Orders', 'onetrace-for-woocommerce'), 'desc' => __('Placed, paid, shipped, delivered, cancelled and refunded orders with the customer data', 'onetrace-for-woocommerce')]), 83 83 $field('cart', ['type' => 'checkbox', 'title' => __('Cart', 'onetrace-for-woocommerce'), 'desc' => __('Adding to and removing from the cart, opening the checkout — for abandoned cart journeys', 'onetrace-for-woocommerce')]), 84 84 $field('wishlist', ['type' => 'checkbox', 'title' => __('Wishlist', 'onetrace-for-woocommerce'), 'desc' => __('Adding to and removing from the wishlist of YITH WooCommerce Wishlist or TI WooCommerce Wishlist — for wishlist journeys', 'onetrace-for-woocommerce')]), -
onetrace-for-woocommerce/trunk/src/Orders.php
r3738426 r3755233 169 169 170 170 foreach ($order->get_items() as $item) { 171 if (!$item instanceof \WC_Order_Item_Product ) {171 if (!$item instanceof \WC_Order_Item_Product || $refund && abs((float) $item->get_total()) === 0.0) { 172 172 continue; 173 173 } 174 174 175 $quantity = abs((int) $item->get_quantity()); 176 $total = abs((float) $item->get_total()); 177 178 if ($quantity === 0 || $refund && $total === 0.0) { 179 continue; 175 $line = self::line($item); 176 177 if ($line !== null) { 178 $lines[] = $line; 180 179 } 181 182 $product = $item->get_product();183 $variation = $item->get_variation_id() ? wc_get_product($item->get_variation_id()) : null;184 $lines[] = new LineItem(185 Products::id($item->get_product_id()) ?: (string) $item->get_product_id(),186 $item->get_name(),187 $total / max(1, $quantity),188 max(1, $quantity),189 $variation instanceof \WC_Product ? Products::variantId($variation) : ($item->get_variation_id() ?: null),190 $product instanceof \WC_Product ? Catalog::categoryId($product) : null191 );192 180 } 193 181 194 182 return $lines; 183 } 184 185 /** 186 * A product line of the order; $quantity — a part of it (a parcel of a partial shipment). 187 */ 188 public static function line(\WC_Order_Item_Product $item, ?int $quantity = null): ?LineItem 189 { 190 $ordered = abs((int) $item->get_quantity()); 191 192 if ($ordered === 0) { 193 return null; 194 } 195 196 $product = $item->get_product(); 197 $variation = $item->get_variation_id() ? wc_get_product($item->get_variation_id()) : null; 198 199 return new LineItem( 200 Products::id($item->get_product_id()) ?: (string) $item->get_product_id(), 201 $item->get_name(), 202 abs((float) $item->get_total()) / $ordered, 203 $quantity !== null ? max(1, min($quantity, $ordered)) : $ordered, 204 $variation instanceof \WC_Product ? Products::variantId($variation) : ($item->get_variation_id() ?: null), 205 $product instanceof \WC_Product ? Catalog::categoryId($product) : null 206 ); 195 207 } 196 208 -
onetrace-for-woocommerce/trunk/src/Plugin.php
r3753316 r3755233 45 45 Customers::register(); 46 46 Orders::register(); 47 Shipments::register(); 47 48 Cart::register(); 48 49 Wishlist::register(); -
onetrace-for-woocommerce/trunk/vendor/onetrace-php/src/Client.php
r3753316 r3755233 45 45 final class Client 46 46 { 47 public const VERSION = '1.1 0.0';47 public const VERSION = '1.11.0'; 48 48 49 49 /** -
onetrace-for-woocommerce/trunk/vendor/onetrace-php/src/Commerce/Messages.php
r3753316 r3755233 31 31 public const ORDER_REFUNDED = 'order_refunded'; 32 32 33 public const ORDER_SHIPPED = 'order_shipped'; 34 35 public const ORDER_DELIVERED = 'order_delivered'; 36 33 37 /** @var string */ 34 38 private $platform; … … 133 137 134 138 return $this->order($order, self::ORDER_REFUNDED, $properties, $at ?? $order->placedAt, $refundId !== null ? (string) $refundId : null); 139 } 140 141 /** 142 * The order (or a part of it) is handed over to delivery. Each parcel is sent once: $shipmentId (the tracking 143 * number by default) tells several parcels of one order apart. The platform shows the carrier, the tracking 144 * number and the link to the customer and to the AI of the online chat ("where is my order"). 145 * 146 * @param string|int|null $shipmentId 147 * @param list<LineItem> $lines shipped products of a partial shipment, if known 148 * 149 * @return array<string, mixed> 150 */ 151 public function orderShipped( 152 Order $order, 153 ?string $carrier = null, 154 ?string $trackingNumber = null, 155 ?string $trackingUrl = null, 156 ?\DateTimeInterface $estimatedDelivery = null, 157 ?\DateTimeInterface $at = null, 158 $shipmentId = null, 159 array $lines = [] 160 ): array { 161 $properties = array_filter([ 162 'order_id' => $order->id, 163 'carrier' => self::text($carrier, 100), 164 'tracking_number' => self::text($trackingNumber, 100), 165 'tracking_url' => $trackingUrl !== null && filter_var($trackingUrl, FILTER_VALIDATE_URL) !== false ? $trackingUrl : null, 166 'estimated_delivery' => $estimatedDelivery !== null ? $estimatedDelivery->format('Y-m-d') : null, 167 ], static function ($value): bool { 168 return $value !== null; 169 }); 170 171 if ($lines !== []) { 172 $properties['products'] = array_map(static function (LineItem $line): array { 173 return $line->toArray(); 174 }, $lines); 175 } 176 177 $suffix = $shipmentId !== null ? (string) $shipmentId : ($properties['tracking_number'] ?? null); 178 179 return $this->order($order, self::ORDER_SHIPPED, $properties, $at ?? new \DateTimeImmutable(), $suffix !== null ? preg_replace('/[^A-Za-z0-9_-]/', '', $suffix) : null); 180 } 181 182 /** 183 * The customer received the order. 184 * 185 * @return array<string, mixed> 186 */ 187 public function orderDelivered(Order $order, ?\DateTimeInterface $at = null): array 188 { 189 return $this->order($order, self::ORDER_DELIVERED, ['order_id' => $order->id], $at ?? new \DateTimeImmutable()); 135 190 } 136 191 … … 250 305 } 251 306 307 private static function text(?string $value, int $max): ?string 308 { 309 $value = $value !== null ? trim($value) : ''; 310 311 if ($value === '') { 312 return null; 313 } 314 315 return function_exists('mb_substr') ? mb_substr($value, 0, $max) : substr($value, 0, $max); 316 } 317 252 318 private static function time(\DateTimeInterface $at): string 253 319 {
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)