PluginProbe
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More / 2.2.0
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More v2.2.0
2.3.0 2.2.0 2.1.1 2.1.0 2.0.0 1.10.0 1.9.1 1.9.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 All 59 releases
storeengine / includes / classes / order-status / auto-draft.php

auto-draft.php in StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More 2.2.0, at includes/classes/order-status/auto-draft.php

61 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 namespace StoreEngine\Classes\OrderStatus;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 use StoreEngine\Classes\Exceptions\StoreEngineInvalidArgumentException;
10 use StoreEngine\Classes\OrderContext;
11 use StoreEngine\Interfaces\OrderStatus;
12
13 class AutoDraft implements OrderStatus {
14 const STATUS = 'auto-draft';
15
16 public function proceed_to_next_status( OrderContext $context, string $trigger = '' ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
17 switch ( $trigger ) {
18 case 'update_checkout':
19 $context->set_order_status( new Draft() );
20 break;
21 case 'finalized_order': // for admin stat-update.
22 case 'order_placed':
23 $context->set_order_status( new PendingPayment() );
24 break;
25 default:
26 throw new StoreEngineInvalidArgumentException(
27 sprintf(
28 /* translators: %1$s. Requested status transition, %2$s. Current Status */
29 esc_html__( 'Invalid trigger (%1$s) for next status from %2$s', 'storeengine' ),
30 esc_html( self::STATUS ),
31 esc_html( $trigger )
32 ),
33 'invalid-trigger'
34 );
35 }
36 }
37
38 public function get_status(): string {
39 return self::STATUS;
40 }
41
42 public function get_status_title(): string {
43 return __( 'Admin Draft', 'storeengine' );
44 }
45
46 public function get_possible_next_statuses(): array {
47 return [
48 Draft::STATUS,
49 PendingPayment::STATUS,
50 ];
51 }
52
53 public function get_possible_triggers(): array {
54 return [
55 'update_checkout',
56 'finalized_order',
57 'order_placed',
58 ];
59 }
60 }
61