| @@ -141,12 +141,21 @@ | ||
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | 143 | * Check if the current page is the customer dashboard page. |
| 144 | 144 | * |
| 145 | + * Uses is_page() instead of a URL comparison so dashboard subviews | |
| 146 | + * with query args (?action=index&model=invoice) are also matched. | |
| 147 | + * | |
| 145 | 148 | * @return bool |
| 146 | 149 | */ |
| 147 | 150 | protected function isCustomerDashboardPage(): bool { |
| 148 | - return \SureCart::pages()->isCustomerDashboardPageByUrl(); | |
| 151 | + $dashboard_page_id = \SureCart::pages()->getId( 'dashboard' ); | |
| 152 | + | |
| 153 | + if ( empty( $dashboard_page_id ) ) { | |
| 154 | + return false; | |
| 155 | + } | |
| 156 | + | |
| 157 | + return is_page( $dashboard_page_id ); | |
| 149 | 158 | } |
| 150 | 159 | |
| 151 | 160 | /** |
| 152 | 161 | * Check if the current page is the checkout page. |
| @@ -180,13 +189,18 @@ | ||
| 180 | 189 | |
| 181 | 190 | /** |
| 182 | 191 | * Check if the current page is a buy page. |
| 183 | 192 | * |
| 193 | + * Pretty buy permalinks (/buy/{product-slug}/) rewrite to the | |
| 194 | + * sc_checkout_product_id query var; sc-buy covers legacy buy links. | |
| 195 | + * | |
| 184 | 196 | * @return bool |
| 185 | 197 | */ |
| 186 | 198 | protected function isBuyPage(): bool { |
| 187 | 199 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 188 | - return isset( $_GET['sc-buy'] ) || ! empty( get_query_var( 'sc-buy' ) ); | |
| 200 | + return isset( $_GET['sc-buy'] ) | |
| 201 | + || ! empty( get_query_var( 'sc-buy' ) ) | |
| 202 | + || ! empty( get_query_var( 'sc_checkout_product_id' ) ); | |
| 189 | 203 | } |
| 190 | 204 | |
| 191 | 205 | /** |
| 192 | 206 | * Get SureCart vary cookies. |