PluginProbe
WooCommerce / 11.1.0-rc.2
WooCommerce v11.1.0-rc.2
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / src / Internal / Orders / PointOfSaleOrderUtil.php
PointOfSaleOrderUtil.php
64 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PointOfSaleOrderUtil class file.
4 */
5
6 declare( strict_types = 1 );
7
8 namespace Automattic\WooCommerce\Internal\Orders;
9
10 use WC_Abstract_Order;
11
12 /**
13 * Helper class for POS order related functionality.
14 *
15 * @internal Just for internal use.
16 */
17 class PointOfSaleOrderUtil {
18 /**
19 * Check if the order is a POS (Point of Sale) order.
20 *
21 * This method determines if an order was created via the POS REST API
22 * by checking the 'created_via' property of the order.
23 *
24 * @param WC_Abstract_Order $order Order instance.
25 * @return bool True if the order is a POS order, false otherwise.
26 */
27 public static function is_pos_order( WC_Abstract_Order $order ): bool {
28 return 'pos-rest-api' === $order->get_created_via();
29 }
30
31 /**
32 * Check if the order was paid at POS, regardless of where it was created.
33 *
34 * An order is considered paid at POS if:
35 * - It was created via the POS REST API, OR
36 * - It was paid via card terminal, OR
37 * - It was paid via cash at POS.
38 *
39 * @param WC_Abstract_Order $order Order instance.
40 * @return bool
41 *
42 * @since 10.6.0
43 */
44 public static function is_order_paid_at_pos( WC_Abstract_Order $order ): bool {
45 if ( self::is_pos_order( $order ) ) {
46 return true;
47 }
48
49 if ( 'mobile_pos' === $order->get_meta( '_wcpay_ipp_channel' ) ) {
50 return true;
51 }
52
53 if ( 'mobile_pos' === $order->get_meta( '_stripe_ipp_channel' ) ) {
54 return true;
55 }
56
57 if ( '' !== $order->get_meta( '_cash_change_amount' ) ) {
58 return true;
59 }
60
61 return false;
62 }
63 }
64