questions

How to get the checkout object in Woocommerce custom template

Rate this post

For WooCommerce I create an own checkout page but I have an Issue.

The code $checkout->get_value( 'billing_first_name' ); does not work in my template file.

My file is called with `get_template_part( ‘temp-parts/content/pages/checkout-billing’); in the file woocommerce/checkout/form-billing.php

This generate an error

Call to a member function get_value() on null

If I use this code directly in the file woocommerce/checkout/form-billing.php the code does work.

Is it possible to get the checkout information in my own template?

 

✔️Solution:

As $checkout variable is not defined, you should use instead:

WC()->checkout->get_value( 'billing_first_name' );

Now it will work.

Leave a Reply

Your email address will not be published.

Back to top button