This repository has been archived by the owner on Aug 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
controller.php
70 lines (57 loc) · 2.76 KB
/
controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* WCTYController
*/
class WCTYController {
public function __construct() {
add_shortcode( 'woo_order_details', array( $this, 'woo_order_details_action' ) );
add_shortcode( 'woo_order_stub', array( $this, 'woo_order_stub_action' ) );
add_shortcode( 'woo_order_table', array( $this, 'woo_order_table_action' ) );
add_shortcode( 'woo_customer_details', array( $this, 'woo_customer_details_action' ) );
}
public function woo_order_details_action() {
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['order_id'] ) && isset( $_REQUEST['hash'] ) ) {
if ( 'thank_you_page' === $_REQUEST['action'] && (int) $_REQUEST['order_id'] > 0 ) {
$hask_key = get_transient( 'wcty_order_' . sanitize_text_field( wp_unslash( $_REQUEST['order_id'] ) ) );
if ( ! empty( $hask_key ) && $hask_key === $_REQUEST['hash'] ) {
$order = wc_get_order( sanitize_text_field( wp_unslash( $_REQUEST['order_id'] ) ) );
return wcty_view( 'thankyou', array( 'order' => $order ) );
}
}
}
}
public function woo_order_stub_action() {
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['order_id'] ) && isset( $_REQUEST['hash'] ) ) {
if ( 'thank_you_page' === $_REQUEST['action'] && (int) $_REQUEST['order_id'] > 0 ) {
$hask_key = get_transient( 'wcty_order_' . sanitize_text_field( wp_unslash( $_REQUEST['order_id'] ) ) );
if ( ! empty( $hask_key ) && $hask_key === $_REQUEST['hash'] ) {
$order = wc_get_order( sanitize_text_field( wp_unslash( $_REQUEST['order_id'] ) ) );
return wcty_view( 'order-stub', array( 'order' => $order ) );
}
}
}
}
public function woo_order_table_action() {
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['order_id'] ) && isset( $_REQUEST['hash'] ) ) {
if ( 'thank_you_page' === $_REQUEST['action'] && (int) $_REQUEST['order_id'] > 0 ) {
$hask_key = get_transient( 'wcty_order_' . sanitize_text_field( wp_unslash( $_REQUEST['order_id'] ) ) );
if ( ! empty( $hask_key ) && $hask_key === $_REQUEST['hash'] ) {
$order = wc_get_order( sanitize_text_field( wp_unslash( $_REQUEST['order_id'] ) ) );
return wcty_view( 'order-table', array( 'order' => $order ) );
}
}
}
}
public function woo_customer_details_action() {
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['order_id'] ) && isset( $_REQUEST['hash'] ) ) {
if ( 'thank_you_page' === $_REQUEST['action'] && (int) $_REQUEST['order_id'] > 0 ) {
$hask_key = get_transient( 'wcty_order_' . sanitize_text_field( wp_unslash( $_REQUEST['order_id'] ) ) );
if ( ! empty( $hask_key ) && $hask_key === $_REQUEST['hash'] ) {
$order = wc_get_order( sanitize_text_field( wp_unslash( $_REQUEST['order_id'] ) ) );
return wcty_view( 'customer-details', array( 'order' => $order ) );
}
}
}
}
}
new WCTYController();