I'm trying to use the WordPress do_shortcode function for the WooCommerce One Page Checkout Plugin which uses shortcode like this: [woocommerce_one_page_checkout template="product-table" product_ids="product, ids, here"]. I can ONLY use this shortcode IF it's in the content editor and it won't allow me to add this to a page template using the do_shortcode function.

Their documentation here says:

If you wish to display the One Page Checkout Shortcode using WordPress’ do_shortcode() function instead of including the shortcode in a post or page’s content, you will also need to attach custom code to the 'is_wcopc_checkout' filter and make sure a boolean true value is returned.

So I tried adding the following to the functions.php file:

add_filter( 'is_wcopc_checkout', '__return_true' );

I also tried

add_filter( 'is_wcopc_checkout', function(){ return true; } );

and it didn't work either.

I also tried:

add_filter( 'is_wcopc_checkout', 'my_one_page_checkout' );
function my_one_page_checkout(){
  return true;
add_filter( 'is_wcopc_checkout', 'true' );

That didn't seem to do it either.

Am I adding this code to the functions.php wrong? I don't seem to see that there is a filter named is_wcopc_checkout in the code of WooCommerce one page checkout version 1.0.2

Any help on how I can get the One Page Checkout Plugin to work using do_shortcode?

Here's my full code in the page template for reference:

echo do_shortcode('[woocommerce_one_page_checkout template="product-table" product_ids="62, 122, 438, 52, 433, 435, 512, 514"]');

Thanks for your help.

(I tried contacting WooCommerce support and they were no help saying that this is custom code and they can't do anything to help.)

1 Answer 1


Here's a partial solution that has worked for me so far:

If you use the full do_shortcode() as in your example, and you also put the basic [woocommerce_one_page_checkout] shortcode (even without any attributes) into the content field, that seems to be enough to load the missing scripts and load the checkout form.

Not ideal but better than nothing because at least you can still programatically build out the do_shortcode() function in PHP to do whatever you need.

This probably works because of what is stated in this part of the documentation:

To display a working checkout form, One Page Checkout needs to enqueue a variety of scripts and styles prior to outputting the content on the page. In order to do this, it will check if the current post content to determine if it contains the One Page Checkout shortcode, and only add the require styles and scripts when it does (to avoid loading them on all pages)

  • I tried this out and didn't seem to work.
    – Jason
    May 18, 2022 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.