PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 3.4.1
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v3.4.1
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / packages / blocks / Controllers / InvoiceController.php
InvoiceController.php
94 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SureCartBlocks\Controllers;
4
5 use SureCart\Models\Component;
6 use SureCart\Models\User;
7
8 /**
9 * The invoice controller.
10 */
11 class InvoiceController extends BaseController {
12 /**
13 * Preview.
14 */
15 public function preview( $attributes = [] ) {
16 if ( ! is_user_logged_in() ) {
17 return;
18 }
19
20 return wp_kses_post(
21 Component::tag( 'sc-invoices-list' )
22 ->id( 'customer-invoices-preview' )
23 ->with(
24 [
25 'allLink' => add_query_arg(
26 [
27 'tab' => $this->getTab(),
28 'model' => 'invoice',
29 'action' => 'index',
30 ]
31 ),
32 'isCustomer' => User::current()->isCustomer(),
33 'query' => apply_filters(
34 'surecart/dashboard/invoice_list/query',
35 [
36 'customer_ids' => array_values( User::current()->customerIds() ),
37 'status' => [ 'paid', 'open' ],
38 'page' => 1,
39 'per_page' => 5,
40 ]
41 ),
42 ]
43 )->render( $attributes['title'] ? "<span slot='heading'>" . $attributes['title'] . '</span>' : '' )
44 );
45 }
46
47 /**
48 * Index.
49 */
50 public function index() {
51 if ( ! is_user_logged_in() ) {
52 return;
53 }
54 ob_start();
55 ?>
56
57 <sc-spacing style="--spacing: var(--sc-spacing-large)">
58 <sc-breadcrumbs>
59 <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 ?>">
60 <?php esc_html_e( 'Dashboard', 'surecart' ); ?>
61 </sc-breadcrumb>
62 <sc-breadcrumb>
63 <?php esc_html_e( 'Invoices', 'surecart' ); ?>
64 </sc-breadcrumb>
65 </sc-breadcrumbs>
66
67 <?php
68 echo wp_kses_post(
69 Component::tag( 'sc-invoices-list' )
70 ->id( 'customer-invoices-index' )
71 ->with(
72 [
73 'heading' => __( 'Invoices', 'surecart' ),
74 'isCustomer' => User::current()->isCustomer(),
75 'query' => apply_filters(
76 'surecart/dashboard/invoice_list/query',
77 [
78 'customer_ids' => array_values( User::current()->customerIds() ),
79 'status' => [ 'paid', 'open' ],
80 'page' => 1,
81 'per_page' => 10,
82 ]
83 ),
84 ]
85 )->render()
86 );
87 ?>
88 </sc-spacing>
89
90 <?php
91 return ob_get_clean();
92 }
93 }
94