Merge pull request #24435 from strayobject/fix-show-error-in-myaccount-when-order-missing

fix: show error message in myaccount if order does not exist.
This commit is contained in:
Rodrigo Primo 2019-08-21 16:29:10 -03:00 committed by GitHub
commit 9c9715ac8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -133,7 +133,7 @@ class WC_Shortcode_My_Account {
public static function view_order( $order_id ) {
$order = wc_get_order( $order_id );
if ( ! current_user_can( 'view_order', $order_id ) ) {
if ( ! $order || ! current_user_can( 'view_order', $order_id ) ) {
echo '<div class="woocommerce-error">' . esc_html__( 'Invalid order.', 'woocommerce' ) . ' <a href="' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '" class="wc-forward">' . esc_html__( 'My account', 'woocommerce' ) . '</a></div>';
return;