|
216 | 216 | ?> |
217 | 217 | </td> |
218 | 218 | <td><?php echo esc_html( $item->get_quantity() ); ?></td> |
219 | | - <td><?php echo \is_object( $product ) && method_exists( $product, 'get_price' ) ? wp_kses_post( wc_price( $product->get_price() ) ) : ''; ?></td> |
220 | | - <td><?php echo wp_kses_post( wc_price( $item->get_total() ) ); ?></td> |
| 219 | + <td><?php |
| 220 | + $tax_display = get_option( 'woocommerce_tax_display_cart' ); |
| 221 | + if ( 'excl' === $tax_display ) { |
| 222 | + echo wp_kses_post( wc_price( $item->get_subtotal() / $item->get_quantity() ) ); |
| 223 | + } else { |
| 224 | + echo wp_kses_post( wc_price( $item->get_subtotal_tax() / $item->get_quantity() + $item->get_subtotal() / $item->get_quantity() ) ); |
| 225 | + } |
| 226 | + ?></td> |
| 227 | + <td><?php |
| 228 | + $tax_display = get_option( 'woocommerce_tax_display_cart' ); |
| 229 | + if ( 'excl' === $tax_display ) { |
| 230 | + echo wp_kses_post( wc_price( $item->get_total() ) ); |
| 231 | + } else { |
| 232 | + echo wp_kses_post( wc_price( $item->get_total() + $item->get_total_tax() ) ); |
| 233 | + } |
| 234 | + ?></td> |
221 | 235 | </tr> |
222 | 236 | <?php } ?> |
223 | 237 | </tbody> |
224 | 238 | <tfoot> |
225 | 239 | <tr> |
226 | 240 | <th colspan="3"><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th> |
227 | | - <td><?php echo wp_kses_post( wc_price( $order->get_subtotal() ) ); ?></td> |
| 241 | + <td><?php |
| 242 | + $tax_display = get_option( 'woocommerce_tax_display_cart' ); |
| 243 | + if ( 'excl' === $tax_display ) { |
| 244 | + echo wp_kses_post( wc_price( $order->get_subtotal() ) ); |
| 245 | + } else { |
| 246 | + echo wp_kses_post( wc_price( $order->get_subtotal() + $order->get_subtotal_tax() ) ); |
| 247 | + } |
| 248 | + ?></td> |
228 | 249 | </tr> |
229 | 250 | <?php if ( $order->get_shipping_total() > 0 ) { ?> |
230 | 251 | <tr> |
231 | 252 | <th colspan="3"><?php esc_html_e( 'Shipping', 'woocommerce' ); ?></th> |
232 | | - <td><?php echo wp_kses_post( wc_price( $order->get_shipping_total() ) ); ?></td> |
| 253 | + <td><?php |
| 254 | + if ( 'excl' === $tax_display ) { |
| 255 | + echo wp_kses_post( wc_price( $order->get_shipping_total() ) ); |
| 256 | + } else { |
| 257 | + echo wp_kses_post( wc_price( $order->get_shipping_total() + $order->get_shipping_tax() ) ); |
| 258 | + } |
| 259 | + ?></td> |
233 | 260 | </tr> |
234 | 261 | <?php } ?> |
235 | 262 | <?php foreach ( $order->get_fees() as $fee ) { ?> |
236 | 263 | <tr> |
237 | 264 | <th colspan="3"><?php echo esc_html( $fee->get_name() ); ?></th> |
238 | | - <td><?php echo wp_kses_post( wc_price( $fee->get_total() ) ); ?></td> |
| 265 | + <td><?php |
| 266 | + if ( 'excl' === $tax_display ) { |
| 267 | + echo wp_kses_post( wc_price( $fee->get_total() ) ); |
| 268 | + } else { |
| 269 | + echo wp_kses_post( wc_price( $fee->get_total() + $fee->get_total_tax() ) ); |
| 270 | + } |
| 271 | + ?></td> |
239 | 272 | </tr> |
240 | 273 | <?php } ?> |
241 | 274 | <?php if ( $order->get_total_discount() > 0 ) { ?> |
242 | 275 | <tr> |
243 | 276 | <th colspan="3"><?php esc_html_e( 'Discount', 'woocommerce' ); ?></th> |
244 | | - <td><?php echo wp_kses_post( wc_price( $order->get_total_discount() ) ); ?></td> |
| 277 | + <td><?php |
| 278 | + // Discounts are always displayed as positive numbers |
| 279 | + if ( 'excl' === $tax_display ) { |
| 280 | + echo wp_kses_post( wc_price( $order->get_total_discount( false ) ) ); |
| 281 | + } else { |
| 282 | + echo wp_kses_post( wc_price( $order->get_total_discount( true ) ) ); |
| 283 | + } |
| 284 | + ?></td> |
245 | 285 | </tr> |
246 | 286 | <?php } ?> |
247 | | - <?php if ( wc_tax_enabled() ) { ?> |
248 | | - <?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) { ?> |
249 | | - <?php foreach ( $order->get_tax_totals() as $code => $tax ) { ?> |
| 287 | + <?php |
| 288 | + // Only show tax rows if we're showing prices excluding tax |
| 289 | + if ( 'excl' === $tax_display && wc_tax_enabled() ) { |
| 290 | + if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) { |
| 291 | + foreach ( $order->get_tax_totals() as $code => $tax ) { ?> |
250 | 292 | <tr> |
251 | 293 | <th colspan="3"><?php echo esc_html( $tax->label ); ?></th> |
252 | 294 | <td><?php echo wp_kses_post( wc_price( $tax->amount ) ); ?></td> |
253 | 295 | </tr> |
254 | | - <?php } ?> |
255 | | - <?php } else { ?> |
| 296 | + <?php } |
| 297 | + } else { ?> |
256 | 298 | <tr> |
257 | 299 | <th colspan="3"><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></th> |
258 | 300 | <td><?php echo wp_kses_post( wc_price( $order->get_total_tax() ) ); ?></td> |
259 | 301 | </tr> |
260 | | - <?php } ?> |
261 | | - <?php } ?> |
| 302 | + <?php } |
| 303 | + } ?> |
262 | 304 | <tr> |
263 | 305 | <th colspan="3"><?php esc_html_e( 'Total', 'woocommerce' ); ?></th> |
264 | 306 | <td><?php echo wp_kses_post( wc_price( $order->get_total() ) ); ?></td> |
|
0 commit comments