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.
Related
I cant add or edit the billing and shipping addresses in my account in woocommerce.
I've deleted the wp rocket cache but it didnt work. And I removed the country from address. Non of these solutions seems working. What should I do?
This is my woocomerce form-edit-address php
defined( 'ABSPATH' ) || exit;
$page_title = ( 'billing' === $load_address ) ? esc_html__( 'Billing address', 'woocommerce' ) : esc_html__( 'Shipping address', 'woocommerce' );
do_action( 'woocommerce_before_edit_account_address_form' ); ?>
<?php if ( ! $load_address ) : ?>
<?php wc_get_template( 'myaccount/my-address.php' ); ?>
<?php else : ?>
<form method="post">
<h3><?php echo apply_filters( 'woocommerce_my_account_edit_address_title', $page_title, $load_address ); ?></h3><?php // #codingStandardsIgnoreLine ?>
<div class="woocommerce-address-fields">
<?php do_action( "woocommerce_before_edit_address_form_{$load_address}" ); ?>
<div class="woocommerce-address-fields__field-wrapper">
<?php
foreach ( $address as $key => $field ) {
woocommerce_form_field( $key, $field, wc_get_post_data_by_key( $key, $field['value'] ) );
}
?>
</div>
<?php do_action( "woocommerce_after_edit_address_form_{$load_address}" ); ?>
<p>
<button type="submit" class="button" name="save_address" value="<?php esc_attr_e( 'Save address', 'woocommerce' ); ?>"><?php esc_html_e( 'Save address', 'woocommerce' ); ?></button>
<?php wp_nonce_field( 'woocommerce-edit_address', 'woocommerce-edit-address-nonce' ); ?>
<input type="hidden" name="action" value="edit_address" />
</p>
</div>
</form>
<?php endif; ?>
<?php do_action( 'woocommerce_after_edit_account_address_form' ); ?>
I've deleted the wp rocket cache but it didnt work. And I removed the country from address. Non of these solutions seems working. What should I do?
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 ); ?>
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 have changed the customer details label for customer notes but it does not change the label in the "new order" email. How can I change this?
Here is how I changed the way it appears on the invoice page after order is submitted:
<header><h2><?php _e( 'Customer Details', 'woocommerce' ); ?></h2></header>
<table class="shop_table customer_details">
<?php if ( $order->customer_note ) : ?>
<tr>
<th><?php _e( 'Requested Dates:', 'woocommerce' ); ?></th>
<td><?php echo wptexturize( $order->customer_note ); ?></td>
</tr>
<?php endif; ?>
This does nothing to the email. Here is a screenshot of how it appears in the email:
I found this code in the email-customer-details.php file:
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<ul>
<?php foreach ( $fields as $field ) : ?>
<li><strong><?php echo wp_kses_post( $field['label'] ); ?>: </strong>
<span class="text"><?php echo wp_kses_post( $field['value'] ); ?></span></li>
<?php endforeach; ?>
</ul>
It might help to figure this problem out.
You can filter woocommerce_email_customer_details_fields which is the array of info passed to the email-customer-details.php template.
function so_41986388_email_customer_details_fields( $fields, $sent_to_admin, $order ){
if( isset( $fields['customer_note'] ) ) {
$fields['customer_note']['label'] = __( 'Requested Dates:', 'your-text-domain' );
}
return $fields;
}
add_filter( 'woocommerce_email_customer_details_fields', 'so_41986388_email_customer_details_fields', 10, 3 );
why the ordered items doesn't appear in my thankyou pages? there is no invoice detail as usual.. i don't know why, now it's only a message only.. several weeks ago, invoice detail appears and can work properly..
i think the error code is at thankyou.php at woocommerce/checkout
i find that variable $order cannot be read, so the if clause is skipped to the else one.. then it only shows the messages in the bottom of codes in thankyou.php (below is the codes)
my goal is to show the invoice detail in my woocommerce thank you pages, not only the messages.
<?php
/**
* Thankyou page
*
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/thankyou.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* #see https://docs.woocommerce.com/document/template-structure/
* #author WooThemes
* #package WooCommerce/Templates
* #version 2.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( $order ) : ?>
<?php if ( $order->has_status( 'failed' ) ) : ?>
<p class="woocommerce-thankyou-order-failed"><?php _e( 'Pesaan Anda belum dapat kami proses sehubungan BANK Anda telah menolak transaksi. Silahkan coba melakukan pemesanan ulang.', 'woocommerce' ); ?></p>
<p class="woocommerce-thankyou-order-failed-actions">
<?php _e( 'Pay', 'woocommerce' ) ?>
<?php if ( is_user_logged_in() ) : ?>
<?php _e( 'My Account', 'woocommerce' ); ?>
<?php endif; ?>
</p>
<?php else : ?>
<p class="woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Terima kasih, Pemesanan Anda baru saja kami terima. Anda juga bisa melihat detail pemesanan melalui email yang kami kirimkan.', 'woocommerce' ), $order ); ?></p>
<ul class="woocommerce-thankyou-order-details order_details">
<li class="order">
<?php _e( 'Nomor Pesanan:', 'woocommerce' ); ?>
<strong><?php echo $order->get_order_number(); ?></strong>
</li>
<li class="date">
<?php _e( 'Tanggal Pesan:', 'woocommerce' ); ?>
<strong><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></strong>
</li>
<li class="total">
<?php _e( 'Total Bayar:', 'woocommerce' ); ?>
<strong><?php echo $order->get_formatted_order_total(); ?></strong>
</li>
<?php if ( $order->payment_method_title ) : ?>
<li class="method">
<?php _e( 'Cara Bayar:', '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 ); ?>
<?php else : ?>
<p class="woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Terima kasih. Pemesanan Anda baru saja Kami terima. Detail pemesanan dapat Anda lihat melalui email yang baru saja kami kirimkan. Anda bisa cek email sekarang. Bila tidak menemukan email, silahkan cek folder spam dan pindahkan ke bukan spam.', 'woocommerce' ), null ); ?></p>
<?php endif; ?>