CardIcons
1 year ago
CouponsController.php
7 months ago
IppFunctions.php
1 year ago
MobileMessagingHandler.php
2 years ago
OrderActionsRestController.php
3 months ago
OrderAttributionBlocksController.php
1 year ago
OrderAttributionController.php
5 months ago
OrderNoteGroup.php
3 months ago
OrderStatusRestController.php
5 months ago
PaymentInfo.php
10 months ago
PointOfSaleEmailHandler.php
3 months ago
PointOfSaleOrderUtil.php
1 month ago
TaxesController.php
3 years ago
PointOfSaleOrderUtil.php
64 lines
| 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 |