• My client is running the Canvas theme. I have created a child theme within that fraework.

    Here are the versions for WooCommerce, WooFramework and Canvas:
    WooFramework v6.0.4
    Canvas v5.9.0
    WooCommerce v2.2.10

    I’ve been asked to add some widgets to the checkout page. I’m developing locally using Xampp and the PayPal Sandbox.

    A screenshot for WooCommerce Checkout settings
    https://screencast.com/t/a2jsqSp5gSi

    A screenshot for WooCommerce PayPal Settings:
    https://screencast.com/t/Mg4lHClq5

    I have copied the thankyou.php script from the WooCommerce Plugin into this folder structure for the child theme:

    childtheme/woocommerce/templates/checkout

    Before commencing with my code edits, I wanted to make sure that I had the right template so I put a simple echo into the copied file that lets me know I’ve arrived at the right template. It isn’t working.

    This method has worked in the past. What am I doing wrong?

    https://www.ads-software.com/plugins/woocommerce/

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.

    Thread Starter Marj Wyatt

    (@marjwyatt)

    Thank you terrytsang. I could have sworn I had it that way before and it didn’t work.

    Thread Starter Marj Wyatt

    (@marjwyatt)

    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: https://docs.woothemes.com/document/conditional-tags/

    I don’t see a conditional tag for the thankyou.page.

    I reviewed this link: https://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?

    Thread Starter Marj Wyatt

    (@marjwyatt)

    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>',
    	) );
        }
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Customizing the ThankYou.php page’ is closed to new replies.