So I want to remove the billing address from the thank you page. I am using wordpress and have the theme Impreza.
I have targeted the .woocommerce-customer-details and set to display: none; which worked on the google inspector mode but saved and refreshed and it still shows up. And I have checked the woo-commerce template files and found the order-details-customer.php is generating the information. I added a class to remove that section but it still shows up.
Woocommerce thank you page
In theme find a folder named woocommerce if not exist then Create folder:
Copy this file
/wp-content/plugins/woocommerce/templates/checkout/thankyou.php
and paste it into your active theme directory something like this
/wp-content/themes/activetheme/woocommerce/checkout/thankyou.php
And remove this
<ul class="woocommerce-thankyou-order-details order_details">
<li class="order">
<?php _e( 'Order Number:', 'woocommerce' ); ?>
<strong><?php echo $order->get_order_number(); ?></strong>
</li>
<li class="date">
<?php _e( 'Date:', 'woocommerce' ); ?>
<strong><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></strong>
</li>
<li class="total">
<?php _e( 'Total:', 'woocommerce' ); ?>
<strong><?php echo $order->get_formatted_order_total(); ?></strong>
</li>
<?php if ( $order->payment_method_title ) : ?>
<li class="method">
<?php _e( 'Payment Method:', 'woocommerce' ); ?>
<strong><?php echo $order->payment_method_title; ?></strong>
</li>
<?php endif; ?>
</ul>
<div class="clear"></div>
and also remove this
<?php do_action( 'woocommerce_thankyou_' . $order->payment_method, $order->id ); ?>
<?php do_action( 'woocommerce_thankyou', $order->id ); ?>
Related
I have a WordPress "tube" theme. When I click on a thumbnail, it opens a new page which is my homepage! (It is supposed to take me to the post page) but I can type in the post page address to go there manually. How can I fix this in code? Here's a piece of code in image.php. i know some PHP but not very fluent so i can't quite connect the dots.
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
<div class="entry-meta">
<span class="entry-date"><time class="entry-date" datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>"><?php echo esc_html( get_the_date() ); ?></time></span>
<span class="full-size-link"><?php echo esc_html( $metadata['width'] ); ?> × <?php echo esc_html( $metadata['height'] ); ?></span>
<span class="parent-post-link"><?php echo get_the_title( $post->post_parent ); ?></span>
<?php edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-meta -->
</header><!-- .entry-header -->
You need to link to the actual post link.
maybe try to replace
post->post_parent
with:
post->ID
We are using woocommerce order tracking shortcode.This is my woocommerce order tracking.php file. We track the order of guest users by order id and email.
can we add cancel order button here which can cancel the order of guest user.
<?php if ( $notes ) : ?>
<h2><?php esc_html_e( 'Order updates', 'woocommerce' ); ?></h2>
<ol class="commentlist notes">
<?php foreach ( $notes as $note ) : ?>
<li class="comment note">
<div class="comment_container">
<div class="comment-text">
<p class="meta"><?php echo date_i18n( esc_html__( 'l jS \o\f F Y, h:ia', 'woocommerce' ), strtotime( $note->comment_date ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<div class="description">
<?php echo wpautop( wptexturize( $note->comment_content ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</li>
<?php endforeach; ?>
</ol>
<?php
endif; ?>
<?php do_action( 'woocommerce_view_order', $order->get_id() ); ?>
This is the view of order details page.
Here i want to add cancel order button for guest users
Use woocommerce wc_get_account_orders_actions() function to get all woocommerce actions.
Add the following link in you tracking.php file and that's it
echo '<a href="'.$string.'" id="custom-cancel" class="woocommerce-button button' . sanitize_html_class( $key ) . '" >' .esc_html( $actions['cancel']['name'] ). '</a>';
I am new to Wordpress development and am trying to install a traffic junky tracking code on the thankyou.php page.
My attempt has failed so far and I think it boils down to not understanding PHP well enough.
The two tracking codes from trafficjunky that were available were HTML or PHP
HTML:
<img id="1000143661_tester" src="https://ads.trafficjunky.net/tj_ads_pt?a=1000143661&member_id=1000734841&cb=[RANDOM_NUMBER]&cti=[TRANSACTION_UNIQ_ID]&ctv=[VALUE_OF_THE_TRANSACTION]&ctd=[TRANSACTION_DESCRIPTION]" width="1" height="1" border="0" />
PHP:
<?php
$randomNumber = time() . mt_rand(1000, 9999999);
$currentPage = substr($_SERVER["REQUEST_URI"], 0, 255);
?>
<img id="1000143661_tester" src="https://ads.trafficjunky.net/tj_ads_pt?a=1000143661&member_id=1000734841&cb=<?=$randomNumber ?>&epu=<?=$currentPage ?>&cti=[TRANSACTION_UNIQ_ID]&ctv=[VALUE_OF_THE_TRANSACTION]&ctd=[TRANSACTION_DESCRIPTION]" width="1" height="1" border="0" />
I tried to install the HTML version after the order processes under some PHP code on the thankyou.php WooCommerce template:
**<?php else : ?>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); ?></p>
<ul class="woocommerce-order-overview woocommerce-thankyou-order-details order_details">
<li class="woocommerce-order-overview__order order">
<?php _e( 'Order number:', 'woocommerce' ); ?>
<strong><?php echo $order->get_order_number(); ?></strong>
</li>
<li class="woocommerce-order-overview__date date">
<?php _e( 'Date:', 'woocommerce' ); ?>
<strong><?php echo wc_format_datetime( $order->get_date_created() ); ?></strong>
</li>
<?php if ( is_user_logged_in() && $order->get_user_id() === get_current_user_id() && $order->get_billing_email() ) : ?>
<li class="woocommerce-order-overview__email email">
<?php _e( 'Email:', 'woocommerce' ); ?>
<strong><?php echo $order->get_billing_email(); ?></strong>
</li>
<?php endif; ?>
<li class="woocommerce-order-overview__total total">
<?php _e( 'Total:', 'woocommerce' ); ?>
<strong><?php echo $order->get_formatted_order_total(); ?></strong>
</li>
<?php if ( $order->get_payment_method_title() ) : ?>
<li class="woocommerce-order-overview__payment-method method">
<?php _e( 'Payment method:', 'woocommerce' ); ?>
<strong><?php echo wp_kses_post( $order->get_payment_method_title() ); ?></strong>
</li>
<?php endif; ?>
</ul>
<img id="1000143661_tester" src="https://ads.trafficjunky.net/tj_ads_pt?a=1000143661&member_id=1000734841&cb=[RANDOM_NUMBER]&cti=[TRANSACTION_UNIQ_ID]&ctv=[VALUE_OF_THE_TRANSACTION]&ctd=[TRANSACTION_DESCRIPTION]" width="1" height="1" border="0" />
<?php endif; ?>
<?php do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() ); ?>
<?php do_action( 'woocommerce_thankyou', $order->get_id() ); ?>
<?php else : ?>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), null ); ?></p>
<?php endif; ?>
</div>**
This led to order errors so i am trying to figure out how to add the PHP version of the tracking code safely without throwing errors.
Any help would be appreciated.
Thank you for the replies, I have set up the function in functions.php as instructed but I am still having trouble getting the tracking code to fire. Here is my current code:
add_action( 'woocommerce_thankyou', 'tracking_code_thankyou', 10, 1 );
function tracking_code_thankyou($order_id){
$random_number = time() . mt_rand(1000, 9999999);
$current_page = substr($_SERVER["REQUEST_URI"], 0, 255);
?>
<em>Your tracking code just below (for testing)</em>
<img id="1000145711_cpa_testing" src="https://ads.trafficjunky.net/tj_ads_pt?a=1000145711&member_id=1000785411&cb=<?=$randomNumber ?>&epu=<?=$currentPage ?>&cti=[TRANSACTION_UNIQ_ID]&ctv=[VALUE_OF_THE_TRANSACTION]&ctd=[TRANSACTION_DESCRIPTION]" width="1" height="1" border="0" />
<?php
}
}
You can try adding the php tracking code inside the header.php (before the end of the head tag) or footer.php (before the end of the body tag). You need to get the id of the page if you want it to run exclusively on that page only.
Do something like this
if(is_page(yourpageidhere)):
//paste the tracking code here
endif;
UPDATED
Instead of overriding the thankyou.php template as you can see its source code there is this line:
<?php do_action( 'woocommerce_thankyou', $order->get_id() ); ?>
Which means that you can use this woocommerce_thankyou action hook with a custom function, to output anything in this template line. First get the template clean of your code...
Also I have corrected your code in the image link, as it was not correct. You should use the following code in the function.php file of your active child theme or active theme:
add_action( 'woocommerce_thankyou', 'tracking_code_thankyou', 10, 1 );
function tracking_code_thankyou( $order_id ) {
$random_number = time() . mt_rand(1000, 9999999);
$current_page = substr($_SERVER["REQUEST_URI"], 0, 255);
$url = "https://ads.trafficjunky.net/tj_ads_pt?a=1000145711&member_id=1000785411&cb=$randomNumber&epu=$currentPage&cti=[TRANSACTION_UNIQ_ID]&ctv=[VALUE_OF_THE_TRANSACTION]&ctd=[TRANSACTION_DESCRIPTION]";
echo '<em>Your tracking code just below (for testing)</em>
<img id="1000143661_tester" src="'.$url.'" width="1" height="1" border="0" />';
}
It will output your code just after customers details at the end of the order-received page…
I don't have much experience with PHP and was wondering if anyone could help me uncomment a few lines from the Woocommerce thankyou.php template that can be found here: https://github.com/woocommerce/woocommerce/blob/master/templates/checkout/thankyou.php . I need to remove the order details starting line 43-77:
<ul class="woocommerce-order-overview woocommerce-thankyou-order-details order_details">
<li class="woocommerce-order-overview__order order">
<?php _e( 'Order number:', 'woocommerce' ); ?>
<strong><?php echo $order->get_order_number(); ?></strong>
</li>
<li class="woocommerce-order-overview__date date">
<?php _e( 'Date:', 'woocommerce' ); ?>
<strong><?php echo wc_format_datetime( $order->get_date_created() ); ?></strong>
</li>
<li class="woocommerce-order-overview__total total">
<?php _e( 'Total:', 'woocommerce' ); ?>
<strong><?php echo $order->get_formatted_order_total(); ?></strong>
</li>
<?php if ( $order->get_payment_method_title() ) : ?>
<li class="woocommerce-order-overview__payment-method method">
<?php _e( 'Payment method:', 'woocommerce' ); ?>
<strong><?php echo wp_kses_post( $order->get_payment_method_title() ); ?></strong>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
<?php do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() ); ?>
<?php do_action( 'woocommerce_thankyou', $order->get_id() ); ?>
Thanks for your help!
This question is not clear. I think you want us to help you commenting a portion of code on that checkout/thankyou.php template, to remove some info from line 43 to 77…
So your template code will be:
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="woocommerce-order">
<?php if ( $order ) : ?>
<?php if ( $order->has_status( 'failed' ) ) : ?>
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed"><?php _e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'woocommerce' ); ?></p>
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed-actions">
<?php _e( 'Pay', 'woocommerce' ) ?>
<?php if ( is_user_logged_in() ) : ?>
<?php _e( 'My account', 'woocommerce' ); ?>
<?php endif; ?>
</p>
<?php endif; /* else: ?>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); ?></p>
<ul class="woocommerce-order-overview woocommerce-thankyou-order-details order_details">
<li class="woocommerce-order-overview__order order">
<?php _e( 'Order number:', 'woocommerce' ); ?>
<strong><?php echo $order->get_order_number(); ?></strong>
</li>
<li class="woocommerce-order-overview__date date">
<?php _e( 'Date:', 'woocommerce' ); ?>
<strong><?php echo wc_format_datetime( $order->get_date_created() ); ?></strong>
</li>
<li class="woocommerce-order-overview__total total">
<?php _e( 'Total:', 'woocommerce' ); ?>
<strong><?php echo $order->get_formatted_order_total(); ?></strong>
</li>
<?php if ( $order->get_payment_method_title() ) : ?>
<li class="woocommerce-order-overview__payment-method method">
<?php _e( 'Payment method:', 'woocommerce' ); ?>
<strong><?php echo wp_kses_post( $order->get_payment_method_title() ); ?></strong>
</li>
<?php endif; */ ?>
</ul>
<?php endif; ?>
<?php do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() ); ?>
<?php do_action( 'woocommerce_thankyou', $order->get_id() ); ?>
<?php else : ?>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), null ); ?></p>
<?php endif; ?>
</div>
I hope that is simply that…
Official Documentation: Template Structure + Overriding Templates via a Theme
Overriding templates in WooCommerce is quite simple, you just have to copy the template file you want to edit into the YOUR_THEME/woocommerce/ directory and edit/add/delete anything you want.
In your case you just have to copy the template file located in wp-content/plugins/woocommerce/templates/checkout/thankyou.php into wp-content/themes/YOUR_THEME/woocommerce/checkout and you're ready to go.
Be aware that you override the template files in child theme, otherwise after updating theme you will lose you changes.
Child theme creation procedure:
create a folder in themes directory and name it yourthemename-child
creat a style.css file and put this comment inside it
/*
Theme Name: Twenty Fifteen Child
Description: Twenty Fifteen Child Theme
Template: parent_theme_name
you can add other attributes here as well
*/
I've tried to edit the thankyou.php file in woocommerce to include some new text, but it keeps on showing the default message. I am not familiar with what anything means in php, but this is what I've been trying:
<?php
/**
* Thankyou page
*
* #author WooThemes
* #package WooCommerce/Templates
* #version 2.2.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( $order ) : ?>
<?php if ( $order->has_status( 'failed' ) ) : ?>
<p><?php _e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction.', 'woocommerce' ); ?></p>
<p><?php
if ( is_user_logged_in() )
_e( 'Please attempt your purchase again or go to your account page.', 'woocommerce' );
else
_e( 'Please attempt your purchase again.', 'woocommerce' );
?></p>
<p>
<?php _e( 'Pay', 'woocommerce' ) ?>
<?php if ( is_user_logged_in() ) : ?>
<?php _e( 'My Account', 'woocommerce' ); ?>
<?php endif; ?>
</p>
<?php else : ?>
<p><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Your shirt order has been received and will be at your doorstep in approximately 4 weeks. Thanks again for your support (and general badassery)!', 'woocommerce' ), $order ); ?></p>
<ul class="order_details">
<li class="order">
<?php _e( 'Order:', 'woocommerce' ); ?>
<strong><?php echo $order->get_order_number(); ?></strong>
</li>
<li class="date">
<?php _e( 'Date:', 'woocommerce' ); ?>
<strong><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></strong>
</li>
<li class="total">
<?php _e( 'Total:', 'woocommerce' ); ?>
<strong><?php echo $order->get_formatted_order_total(); ?></strong>
</li>
<?php if ( $order->payment_method_title ) : ?>
<li class="method">
<?php _e( 'Payment method:', 'woocommerce' ); ?>
<strong><?php echo $order->payment_method_title; ?></strong>
</li>
<?php endif; ?>
</ul>
<div class="clear"></div>
<?php endif; ?>
<?php do_action( 'woocommerce_thankyou_' . $order->payment_method, $order->id ); ?>
<?php do_action( 'woocommerce_thankyou', $order->id ); ?>
<p><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Your shirt order has been received and will be at your doorstep in approximately 4 weeks. Thanks again for your support (and general badassery)!', 'woocommerce' ), null ); ?></p>
The best way to do this would be to filter the WC thank you message:
add_filter( 'woocommerce_thankyou_order_received_text', 'd4tw_custom_ty_msg' );
function d4tw_custom_ty_msg ( $thank_you_msg ) {
$thank_you_msg = 'This is your new thank you message';
return $thank_you_msg;
}
Perhaps your theme is overriding your thank you template file. As a general rule you should never edit the plugin directly. Instead move the thankyou.php to your theme. Move this file to wp-content/themes/yourtheme/woocommerce/checkout/thankyou.php. More information it the documentation here.