Solution:
WooCommerce has a number of options for modifying the cart, and checkout pages. Here are the three I’d recomend:
Use WooCommerce Conditional Tags
is_cart()
and is_checkout()
functions return true on their page. Example:
if ( is_cart() || is_checkout() ) {
echo "This is the cart, or checkout page!";
}
Modify the template file
The main, cart template file is located at wp-content/themes/{current-theme}/woocommerce/cart/cart.php
The main, checkout template file is located at wp-content/themes/{current-theme}/woocommerce/checkout/form-checkout.php
To edit these, first copy them to your child theme.
Use wp-content/themes/{current-theme}/page-{slug}.php
page-{slug}.php
is the second template that will be used, coming after manually assigned ones through the WP dashboard.
This is safer than my other solutions, because if you remove WooCommerce, but forget to remove this file, the code inside (that may rely on WooCommerce functions) won’t break, because it’s never called (unless of cause you have a page with slug {slug}
).
For example:
wp-content/themes/{current-theme}/page-cart.php
wp-content/themes/{current-theme}/page-checkout.php