BaseController.php
3 years ago
ChargeController.php
3 years ago
CustomerController.php
3 years ago
DownloadController.php
3 years ago
InvoiceController.php
3 years ago
OrderController.php
2 years ago
PaymentMethodController.php
2 years ago
SubscriptionController.php
2 years ago
UserController.php
3 years ago
OrderController.php
158 lines
| 1 | <?php |
| 2 | namespace SureCartBlocks\Controllers; |
| 3 | |
| 4 | use SureCart\Models\Component; |
| 5 | use SureCart\Models\User; |
| 6 | |
| 7 | /** |
| 8 | * The subscription controller. |
| 9 | */ |
| 10 | class OrderController extends BaseController { |
| 11 | /** |
| 12 | * Preview. |
| 13 | */ |
| 14 | public function preview( $attributes = [] ) { |
| 15 | if ( ! is_user_logged_in() ) { |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | return wp_kses_post( |
| 20 | Component::tag( 'sc-orders-list' ) |
| 21 | ->id( 'customer-orders-preview' ) |
| 22 | ->with( |
| 23 | [ |
| 24 | 'allLink' => add_query_arg( |
| 25 | [ |
| 26 | 'tab' => $this->getTab(), |
| 27 | 'model' => 'order', |
| 28 | 'action' => 'index', |
| 29 | ] |
| 30 | ), |
| 31 | 'isCustomer' => User::current()->isCustomer(), |
| 32 | 'query' => [ |
| 33 | 'customer_ids' => array_values( User::current()->customerIds() ), |
| 34 | 'status' => [ 'paid', 'processing', 'payment_failed', 'canceled', 'void' ], |
| 35 | 'page' => 1, |
| 36 | 'per_page' => 5, |
| 37 | ], |
| 38 | ] |
| 39 | )->render( $attributes['title'] ? "<span slot='heading'>" . $attributes['title'] . '</span>' : '' ) |
| 40 | ); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Index. |
| 45 | */ |
| 46 | public function index() { |
| 47 | if ( ! is_user_logged_in() ) { |
| 48 | return; |
| 49 | } |
| 50 | ob_start(); |
| 51 | ?> |
| 52 | |
| 53 | <sc-spacing style="--spacing: var(--sc-spacing-large)"> |
| 54 | <sc-breadcrumbs> |
| 55 | <sc-breadcrumb href="<?php echo esc_url( add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>"> |
| 56 | <?php esc_html_e( 'Dashboard', 'surecart' ); ?> |
| 57 | </sc-breadcrumb> |
| 58 | <sc-breadcrumb> |
| 59 | <?php esc_html_e( 'Orders', 'surecart' ); ?> |
| 60 | </sc-breadcrumb> |
| 61 | </sc-breadcrumbs> |
| 62 | |
| 63 | <?php |
| 64 | echo wp_kses_post( |
| 65 | Component::tag( 'sc-orders-list' ) |
| 66 | ->id( 'customer-orders-index' ) |
| 67 | ->with( |
| 68 | [ |
| 69 | 'heading' => __( 'Order History', 'surecart' ), |
| 70 | 'isCustomer' => User::current()->isCustomer(), |
| 71 | 'query' => [ |
| 72 | 'customer_ids' => array_values( User::current()->customerIds() ), |
| 73 | 'status' => [ 'paid', 'processing', 'payment_failed', 'canceled', 'void' ], |
| 74 | 'page' => 1, |
| 75 | 'per_page' => 10, |
| 76 | ], |
| 77 | ] |
| 78 | )->render() |
| 79 | ); |
| 80 | ?> |
| 81 | </sc-spacing> |
| 82 | |
| 83 | <?php |
| 84 | return ob_get_clean(); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Index. |
| 89 | */ |
| 90 | public function show() { |
| 91 | if ( ! is_user_logged_in() ) { |
| 92 | return; |
| 93 | } |
| 94 | ob_start(); |
| 95 | ?> |
| 96 | |
| 97 | <sc-spacing style="--spacing: var(--sc-spacing-large)"> |
| 98 | <sc-breadcrumbs> |
| 99 | |
| 100 | <sc-breadcrumb href="<?php echo esc_url( add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>"> |
| 101 | <?php esc_html_e( 'Dashboard', 'surecart' ); ?> |
| 102 | </sc-breadcrumb> |
| 103 | <sc-breadcrumb href=" |
| 104 | <?php |
| 105 | echo esc_url( |
| 106 | add_query_arg( |
| 107 | [ |
| 108 | 'tab' => $this->getTab(), |
| 109 | 'model' => 'order', |
| 110 | 'action' => 'index', |
| 111 | ], |
| 112 | remove_query_arg( array_keys( $_GET ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 113 | ) |
| 114 | ); |
| 115 | ?> |
| 116 | "> |
| 117 | <?php esc_html_e( 'Orders', 'surecart' ); ?> |
| 118 | </sc-breadcrumb> |
| 119 | <sc-breadcrumb> |
| 120 | <?php esc_html_e( 'Order', 'surecart' ); ?> |
| 121 | </sc-breadcrumb> |
| 122 | </sc-breadcrumbs> |
| 123 | |
| 124 | <div> |
| 125 | <?php |
| 126 | echo wp_kses_post( |
| 127 | Component::tag( 'sc-order' ) |
| 128 | ->id( 'sc-customer-order' ) |
| 129 | ->with( |
| 130 | [ |
| 131 | 'orderId' => $this->getId(), |
| 132 | 'customerIds' => array_values( (array) User::current()->customerIds() ), |
| 133 | ] |
| 134 | )->render() |
| 135 | ); |
| 136 | ?> |
| 137 | </div> |
| 138 | |
| 139 | <div> |
| 140 | <?php |
| 141 | echo wp_kses_post( |
| 142 | Component::tag( 'sc-fulfillments' ) |
| 143 | ->id( 'sc-customer-fulfillments' ) |
| 144 | ->with( |
| 145 | [ |
| 146 | 'orderId' => $this->getId(), |
| 147 | ] |
| 148 | )->render() |
| 149 | ); |
| 150 | ?> |
| 151 | </div> |
| 152 | </sc-spacing> |
| 153 | |
| 154 | <?php |
| 155 | return ob_get_clean(); |
| 156 | } |
| 157 | } |
| 158 |