New Landing How can we help? Atelier Personalize Thank you page

Viewing 15 posts - 1 through 15 (of 17 total)
  • Posted in: Atelier
  • #215849
    huntingensemble
    Member
    Post count: 318

    Hi Guys,

    I would like to personalize my thank you page and to do so by using this code:

    <?php
    function rp4wp_title_order_received( $title, $id ) {
    	if ( is_order_received_page() && get_the_ID() === $id ) {
    		global $wp;
    		$order_id  = apply_filters( 'woocommerce_thankyou_order_id', absint( $wp->query_vars['order-received'] ) );
    		$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) );
    		if ( $order_id > 0 ) {
    			$order = wc_get_order( $order_id );
    			if ( $order->order_key != $order_key ) {
    				unset( $order );
    			}
    		}
    		if ( isset ( $order ) ) {
    			$title = sprintf( "Thank you, %s!", esc_html( $order->billing_first_name ) );
    		}
    	}
    	return $title;
    }
    add_filter( 'the_title', 'rp4wp_title_order_received', 10, 2 );

    I’ve added this code to the functions.php file (2nd rule) in my child theme folder (which is activated in wordpress) I tried a test order to see if it works but I still see the “old” thank you message. Am I doing something wrong? Or do I need to flush all cache to see changes?

    Thanks!
    Joost

    #215851
    David Martin – Support
    Moderator
    Post count: 20834

    Hi Joost,

    Please look at the file /woocommerce/checkout/thankyou.php. All the text is within that file.

    -David.

    #215854
    huntingensemble
    Member
    Post count: 318

    Hi David,

    Thanks for the swift 😉 response!
    Ok so delete this code in functions.php?

    Joost

    #215855
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    Yes I would look to the file first, what text are you looking to change?

    – David.

    #215858
    huntingensemble
    Member
    Post count: 318

    Hi David,

    I’ve found the file in my parent folder, thanks!
    Can I just change rule 45 & 84 from :

    <p class="thank-you"><?php _e( 'Thank you. Your order has been received.', 'swiftframework' ); ?></p>

    to:

    <p class="thank-you"><?php _e( "Thank you, %s!", esc_html( $order->billing_first_name ) ); ?></p>

    #215860
    huntingensemble
    Member
    Post count: 318

    If you would be the customer I would like change the thank you title from static Thank you. Your order has been received

    To: Thanks David! (dynamic).

    Joost

    #215874
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    Tested this and it will work. Please make sure you update both instances of the text. Line 45 & Line 84.

    – David.

    #215881
    huntingensemble
    Member
    Post count: 318
    This reply has been marked as private.
    #215888
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    Did you populate the first name field when testing the order?

    – David.

    #215900
    huntingensemble
    Member
    Post count: 318
    This reply has been marked as private.
    #216142
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    Here is a my tried and tested amended code:

    Please delete this: <p class="thank-you"><?php _e( "Thank you, %s!", esc_html( $order->billing_first_name ) ); ?></p>

    Replace with this new code, you will need to submit a test order for this work.

    <?php echo sprintf( __( 'Thank you, %s!', 'swiftframework' ), $order->billing_first_name ); ?>

    – David.

    #216305
    huntingensemble
    Member
    Post count: 318
    This reply has been marked as private.
    #216561
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Can you send us the link of that page order url so we can inspect the html and adjust the size with css?
    Thanks

    -Rui

    #216683
    huntingensemble
    Member
    Post count: 318
    This reply has been marked as private.
    #216802
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Yes I can see it.

    Guess it will be automatically sorted if you change the last solution that David send you
    from this

    <?php echo sprintf( __( 'Thank you, %s!', 'swiftframework' ), $order->billing_first_name ); ?>

    to this one

    <p class="thank-you"><?php echo sprintf( __( 'Thank you, %s!', 'swiftframework' ), $order->billing_first_name ); ?></p>

    Give a try and don’t revert the code so I can adjust if necessary.

    -Rui

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register