@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | function wpinv_can_checkout() { |
33 | - $can_checkout = true; // Always true for now |
|
33 | + $can_checkout = true; // Always true for now |
|
34 | 34 | |
35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
35 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | function wpinv_get_success_page_uri() { |
39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | - $page_id = absint( $page_id ); |
|
39 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | + $page_id = absint( $page_id ); |
|
41 | 41 | |
42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
42 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | function wpinv_get_history_page_uri() { |
46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | - $page_id = absint( $page_id ); |
|
46 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | + $page_id = absint( $page_id ); |
|
48 | 48 | |
49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
49 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | function wpinv_is_success_page() { |
53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
53 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | + $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
55 | 55 | |
56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
56 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_invoice_history_page() { |
60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | - $ret = $ret ? is_page( $ret ) : false; |
|
62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
60 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | + $ret = $ret ? is_page( $ret ) : false; |
|
62 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | function wpinv_is_subscriptions_history_page() { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | function wpinv_send_to_success_page( $args = null ) { |
72 | - $redirect = wpinv_get_success_page_uri(); |
|
72 | + $redirect = wpinv_get_success_page_uri(); |
|
73 | 73 | |
74 | 74 | if ( !empty( $args ) ) { |
75 | 75 | // Check for backward compatibility |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | function wpinv_send_to_failed_page( $args = null ) { |
92 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
92 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
93 | 93 | |
94 | 94 | if ( !empty( $args ) ) { |
95 | 95 | // Check for backward compatibility |
@@ -109,72 +109,72 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | function wpinv_get_checkout_uri( $args = array() ) { |
112 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
113 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
112 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
113 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
114 | 114 | |
115 | - if ( !empty( $args ) ) { |
|
116 | - // Check for backward compatibility |
|
117 | - if ( is_string( $args ) ) |
|
118 | - $args = str_replace( '?', '', $args ); |
|
115 | + if ( !empty( $args ) ) { |
|
116 | + // Check for backward compatibility |
|
117 | + if ( is_string( $args ) ) |
|
118 | + $args = str_replace( '?', '', $args ); |
|
119 | 119 | |
120 | - $args = wp_parse_args( $args ); |
|
120 | + $args = wp_parse_args( $args ); |
|
121 | 121 | |
122 | - $uri = add_query_arg( $args, $uri ); |
|
123 | - } |
|
122 | + $uri = add_query_arg( $args, $uri ); |
|
123 | + } |
|
124 | 124 | |
125 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
125 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
126 | 126 | |
127 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
127 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
128 | 128 | |
129 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
130 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
131 | - } |
|
129 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
130 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
131 | + } |
|
132 | 132 | |
133 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
133 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | function wpinv_send_back_to_checkout( $args = array() ) { |
137 | - $redirect = wpinv_get_checkout_uri(); |
|
137 | + $redirect = wpinv_get_checkout_uri(); |
|
138 | 138 | |
139 | - if ( ! empty( $args ) ) { |
|
140 | - // Check for backward compatibility |
|
141 | - if ( is_string( $args ) ) |
|
142 | - $args = str_replace( '?', '', $args ); |
|
139 | + if ( ! empty( $args ) ) { |
|
140 | + // Check for backward compatibility |
|
141 | + if ( is_string( $args ) ) |
|
142 | + $args = str_replace( '?', '', $args ); |
|
143 | 143 | |
144 | - $args = wp_parse_args( $args ); |
|
144 | + $args = wp_parse_args( $args ); |
|
145 | 145 | |
146 | - $redirect = add_query_arg( $args, $redirect ); |
|
147 | - } |
|
146 | + $redirect = add_query_arg( $args, $redirect ); |
|
147 | + } |
|
148 | 148 | |
149 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
150 | - exit; |
|
149 | + wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
150 | + exit; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | function wpinv_get_success_page_url( $query_string = null ) { |
154 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
155 | - $success_page = get_permalink( $success_page ); |
|
154 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
155 | + $success_page = get_permalink( $success_page ); |
|
156 | 156 | |
157 | - if ( $query_string ) |
|
158 | - $success_page .= $query_string; |
|
157 | + if ( $query_string ) |
|
158 | + $success_page .= $query_string; |
|
159 | 159 | |
160 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
160 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
164 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
165 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
164 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
165 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
166 | 166 | |
167 | - if ( $extras ) |
|
168 | - $uri .= $extras; |
|
167 | + if ( $extras ) |
|
168 | + $uri .= $extras; |
|
169 | 169 | |
170 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
170 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | function wpinv_is_failed_transaction_page() { |
174 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
175 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
174 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
175 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
176 | 176 | |
177 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
177 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | } |
701 | 701 | |
702 | 702 | function wpinv_get_payment_key( $invoice_id = 0 ) { |
703 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
703 | + $invoice = new WPInv_Invoice( $invoice_id ); |
|
704 | 704 | return $invoice->get_key(); |
705 | 705 | } |
706 | 706 | |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | return false; |
951 | 951 | } |
952 | 952 | $invoice = wpinv_get_invoice_cart(); |
953 | - if ( empty( $invoice ) ) { |
|
953 | + if ( empty( $invoice ) ) { |
|
954 | 954 | return false; |
955 | 955 | } |
956 | 956 | |
@@ -1247,20 +1247,20 @@ discard block |
||
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | function wpinv_checkout_get_cc_info() { |
1250 | - $cc_info = array(); |
|
1251 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
1252 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
1253 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
1254 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
1255 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
1256 | - $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
1257 | - $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
1258 | - $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
1259 | - $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
1260 | - $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
1261 | - |
|
1262 | - // Return cc info |
|
1263 | - return $cc_info; |
|
1250 | + $cc_info = array(); |
|
1251 | + $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
1252 | + $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
1253 | + $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
1254 | + $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
1255 | + $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
1256 | + $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
1257 | + $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
1258 | + $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
1259 | + $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
1260 | + $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
1261 | + |
|
1262 | + // Return cc info |
|
1263 | + return $cc_info; |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | $required_fields = wpinv_checkout_required_fields(); |
1468 | 1468 | |
1469 | 1469 | // Loop through required fields and show error messages |
1470 | - if ( !empty( $required_fields ) ) { |
|
1470 | + if ( !empty( $required_fields ) ) { |
|
1471 | 1471 | foreach ( $required_fields as $field_name => $value ) { |
1472 | 1472 | if ( in_array( $value, $required_fields ) && empty( $_POST[ $field_name ] ) ) { |
1473 | 1473 | wpinv_set_error( $value['error_id'], $value['error_message'] ); |
@@ -1570,7 +1570,7 @@ discard block |
||
1570 | 1570 | } |
1571 | 1571 | |
1572 | 1572 | function wpinv_get_checkout_session() { |
1573 | - global $wpi_session; |
|
1573 | + global $wpi_session; |
|
1574 | 1574 | |
1575 | 1575 | return $wpi_session->get( 'wpinv_checkout' ); |
1576 | 1576 | } |
@@ -1651,7 +1651,7 @@ discard block |
||
1651 | 1651 | $response['data']['taxf'] = $invoice->get_tax( true ); |
1652 | 1652 | $response['data']['total'] = $invoice->get_total(); |
1653 | 1653 | $response['data']['totalf'] = $invoice->get_total( true ); |
1654 | - $response['data']['free'] = $invoice->is_free() && ( ! ( (float) $response['data']['total'] > 0 ) || $invoice->is_free_trial() ) ? true : false; |
|
1654 | + $response['data']['free'] = $invoice->is_free() && ( ! ( (float) $response['data']['total'] > 0 ) || $invoice->is_free_trial() ) ? true : false; |
|
1655 | 1655 | |
1656 | 1656 | wp_send_json( $response ); |
1657 | 1657 | } |
@@ -1936,57 +1936,57 @@ discard block |
||
1936 | 1936 | } |
1937 | 1937 | |
1938 | 1938 | function wpinv_get_invoice_id_by_key( $key ) { |
1939 | - global $wpdb; |
|
1939 | + global $wpdb; |
|
1940 | 1940 | |
1941 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1941 | + $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1942 | 1942 | |
1943 | - if ( $invoice_id != NULL ) |
|
1944 | - return $invoice_id; |
|
1943 | + if ( $invoice_id != NULL ) |
|
1944 | + return $invoice_id; |
|
1945 | 1945 | |
1946 | - return 0; |
|
1946 | + return 0; |
|
1947 | 1947 | } |
1948 | 1948 | |
1949 | 1949 | function wpinv_can_view_receipt( $invoice_key = '' ) { |
1950 | - $return = false; |
|
1950 | + $return = false; |
|
1951 | 1951 | |
1952 | - if ( empty( $invoice_key ) ) { |
|
1953 | - return $return; |
|
1954 | - } |
|
1952 | + if ( empty( $invoice_key ) ) { |
|
1953 | + return $return; |
|
1954 | + } |
|
1955 | 1955 | |
1956 | - global $wpinv_receipt_args; |
|
1956 | + global $wpinv_receipt_args; |
|
1957 | 1957 | |
1958 | - $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
1959 | - if ( isset( $_GET['invoice-id'] ) ) { |
|
1960 | - $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
1961 | - } |
|
1958 | + $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
1959 | + if ( isset( $_GET['invoice-id'] ) ) { |
|
1960 | + $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
1961 | + } |
|
1962 | 1962 | |
1963 | - if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
1964 | - return $return; |
|
1965 | - } |
|
1963 | + if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
1964 | + return $return; |
|
1965 | + } |
|
1966 | 1966 | |
1967 | - $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
1968 | - if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
1969 | - return $return; |
|
1970 | - } |
|
1967 | + $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
1968 | + if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
1969 | + return $return; |
|
1970 | + } |
|
1971 | 1971 | |
1972 | - if ( is_user_logged_in() ) { |
|
1973 | - if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
1974 | - $return = true; |
|
1975 | - } |
|
1976 | - } |
|
1972 | + if ( is_user_logged_in() ) { |
|
1973 | + if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
1974 | + $return = true; |
|
1975 | + } |
|
1976 | + } |
|
1977 | 1977 | |
1978 | - $session = wpinv_get_checkout_session(); |
|
1979 | - if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) { |
|
1980 | - $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
1978 | + $session = wpinv_get_checkout_session(); |
|
1979 | + if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) { |
|
1980 | + $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
1981 | 1981 | |
1982 | - if ( wpinv_require_login_to_checkout() ) { |
|
1983 | - $return = $return && $check_key === $invoice_key; |
|
1984 | - } else { |
|
1985 | - $return = $check_key === $invoice_key; |
|
1986 | - } |
|
1987 | - } |
|
1982 | + if ( wpinv_require_login_to_checkout() ) { |
|
1983 | + $return = $return && $check_key === $invoice_key; |
|
1984 | + } else { |
|
1985 | + $return = $check_key === $invoice_key; |
|
1986 | + } |
|
1987 | + } |
|
1988 | 1988 | |
1989 | - return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
1989 | + return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
1990 | 1990 | } |
1991 | 1991 | |
1992 | 1992 | function wpinv_pay_for_invoice() { |
@@ -2296,14 +2296,14 @@ discard block |
||
2296 | 2296 | |
2297 | 2297 | if ( isset( $_GET['invoice_key'] ) || is_singular( 'wpi_invoice' ) || is_singular( 'wpi_quote' ) ) { |
2298 | 2298 | $invoice_key = isset( $_GET['invoice_key'] ) ? urldecode($_GET['invoice_key']) : ''; |
2299 | - global $post; |
|
2299 | + global $post; |
|
2300 | 2300 | |
2301 | 2301 | if(!empty($invoice_key)){ |
2302 | - $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
2302 | + $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
2303 | 2303 | } else if(!empty( $post ) && ($post->post_type == 'wpi_invoice' || $post->post_type == 'wpi_quote')) { |
2304 | - $invoice_id = $post->ID; |
|
2304 | + $invoice_id = $post->ID; |
|
2305 | 2305 | } else { |
2306 | - return; |
|
2306 | + return; |
|
2307 | 2307 | } |
2308 | 2308 | |
2309 | 2309 | $invoice = new WPInv_Invoice($invoice_id); |
@@ -2312,17 +2312,17 @@ discard block |
||
2312 | 2312 | return; |
2313 | 2313 | } |
2314 | 2314 | |
2315 | - if ( is_user_logged_in() ) { |
|
2316 | - if ( (int)$invoice->get_user_id() === get_current_user_id() ) { |
|
2317 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
2318 | - } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2319 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
2320 | - } |
|
2321 | - } else { |
|
2322 | - if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2323 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
2324 | - } |
|
2325 | - } |
|
2315 | + if ( is_user_logged_in() ) { |
|
2316 | + if ( (int)$invoice->get_user_id() === get_current_user_id() ) { |
|
2317 | + update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
2318 | + } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2319 | + update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
2320 | + } |
|
2321 | + } else { |
|
2322 | + if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2323 | + update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
2324 | + } |
|
2325 | + } |
|
2326 | 2326 | } |
2327 | 2327 | |
2328 | 2328 | } |