How to display WooCommerce cart items on the checkout page?

I'm going to answer my own question, since I solved it with some additional poking around. Hopefully it will help someone else later down the road.

I didn't find a shortcode to to simply add the cart to the top of the checkout page. I had to edit the template file directly.

So, I copied:

/wp-content/plugins/woocommerce/templates/checkout/form-checkout.php

to:

/wp-content/mytheme/woocommerce/checkout/form-checkout.php

to make my edits to that file directly so I wouldn't lose them when WooCommerce was upgraded. I then copied the form code from:

/wp-content/plugins/woocommerce/templates/cart/cart.php

And pasted it in the file I copied to my theme directory:

/wp-content/mytheme/woocommerce/checkout/form-checkout.php

where I wanted the form to appear.

There may be more elegant ways, but this fixed my issue.


You can also use a hook for this

// put this in functions.php, it will produce code before the form
add_action('woocommerce_before_checkout_form','show_cart_summary',9);

// gets the cart template and outputs it before the form
function show_cart_summary( ) {
  wc_get_template_part( 'cart/cart' );
}

I've created a cart-part.php template which contains jus the cart table and replaced the code with wc_get_template_part( 'cart/cart','part' );