Hi @marj Wyatt, you should put into the folder “/childtheme/woocommerce/checkout/”, remove”templates” should work this time.
You can refer here as official documentation.
Thank you terrytsang. I could have sworn I had it that way before and it didn’t work.
Would anyone happen to know what hook to use to add a widget to the WooCommerce thankyou.php script?
This is the code in the child theme’s functions.php
/** Widgets for WooCommerce thankyou.php **/
add_action( 'widgets_init', 'wc_thankyou_text' );
function wc_thankyou_text() {
register_sidebar( array(
'name' => 'WC Thank You Text',
'id' => 'wc-thankyou-text',
'description' => 'Custom Text for WooCommerce Thank You page',
) );
}
//add_action( 'woo_post_inside_before', 'render_wc_thankyou_text' ); // Didn't work
add_action( 'woocommerce_thankyou', 'render_wc_thankyou_widget' ); // Doesn't work
function render_wc_thankyou_widget() {
if ( ( is_active_sidebar( 'wc-thankyou-text' ) && is_woocommerce() ) ) {
dynamic_sidebar('wc-thankyou-text', array(
'before' => '<div class="before-post">',
'after' => '</div>',
) );
}
}
The sidebar is available and I’ve loaded a text widget and saved it.
I reviewed this link: http://docs.woothemes.com/document/conditional-tags/
I don’t see a conditional tag for the thankyou.page.
I reviewed this link: http://docs.woothemes.com/document/hooks/
woocommerce_thankyou seems to be the hook but I must confess that the documentation on what this hook actually does is very difficult to find.
I added this code to thankyou.php (moved to child theme folder)
<?php echo '<p>This is the custom thank you script</p>';
get_sidebar('wc-thankyou-text'); ?>
The paragraph I added is showing but not the sidebar.
Has anyone tried to do this? Is it possible?
Okay. I figured out my own issue and I’m posting it here for others.
The action that I needed to hook into was woocommerce_sidebar. Here’s the new and working code:
add_action('woocommerce_sidebar', 'render_wc_thankyou', 40);
function render_wc_thankyou() {
if ( ( is_active_sidebar( 'wc-thankyou-text' ) && is_woocommerce() ) ) {
dynamic_sidebar('wc-thankyou-text', array(
'before' => '<div class="before-post">',
'after' => '</div>',
) );
}
}