-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add options to customize WooCommerce thank you page (#890)
* Add option to customize the page's title and thank you message * Remove order details table * Add option to show the customer details, and set it to false
- Loading branch information
1 parent
488656e
commit e487f0b
Showing
5 changed files
with
283 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?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/ | ||
* @package WooCommerce/Templates | ||
* @version 3.2.0 | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
?> | ||
|
||
<div class="woocommerce-order"> | ||
|
||
<?php | ||
if ( $order ) : | ||
|
||
do_action( 'woocommerce_before_thankyou', $order->get_id() ); | ||
?> | ||
|
||
<?php if ( $order->has_status( 'failed' ) ) : ?> | ||
|
||
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed"> | ||
<?php esc_html_e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'newspack' ); ?> | ||
</p> | ||
|
||
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed-actions"> | ||
<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php esc_html_e( 'Pay', 'newspack' ); ?></a> | ||
<?php if ( is_user_logged_in() ) : ?> | ||
<a href="<?php echo esc_url( wc_get_page_permalink( 'myaccount' ) ); ?>" class="button pay"><?php esc_html_e( 'My account', 'newspack' ); ?></a> | ||
<?php endif; ?> | ||
</p> | ||
|
||
<?php else : ?> | ||
|
||
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"> | ||
<?php echo esc_html( apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'newspack' ), $order ) ); ?> | ||
</p> | ||
|
||
<h4><?php esc_html_e( 'Summary', 'newspack' ); ?></h4> | ||
|
||
<ul class="woocommerce-order-overview woocommerce-thankyou-order-details order_details"> | ||
|
||
<li class="woocommerce-order-overview__date date"> | ||
<?php esc_html_e( 'Date:', 'newspack' ); ?> | ||
<strong><?php echo wc_format_datetime( $order->get_date_created() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></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 esc_html_e( 'Email:', 'newspack' ); ?> | ||
<strong><?php echo $order->get_billing_email(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong> | ||
</li> | ||
<?php endif; ?> | ||
|
||
<li class="woocommerce-order-overview__total total"> | ||
<?php esc_html_e( 'Total:', 'newspack' ); ?> | ||
<strong><?php echo $order->get_formatted_order_total(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong> | ||
</li> | ||
|
||
<?php if ( $order->get_payment_method_title() ) : ?> | ||
<li class="woocommerce-order-overview__payment-method method"> | ||
<?php esc_html_e( 'Payment method:', 'newspack' ); ?> | ||
<strong><?php echo wp_kses_post( $order->get_payment_method_title() ); ?></strong> | ||
</li> | ||
<?php endif; ?> | ||
|
||
<li class="woocommerce-order-overview__order order"> | ||
<?php esc_html_e( 'Transaction:', 'newspack' ); ?> | ||
<strong><?php echo $order->get_order_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong> | ||
</li> | ||
|
||
</ul> | ||
|
||
<?php | ||
// Copied from templates/order/order-details.php | ||
$show_customer_details = is_user_logged_in() && $order->get_user_id() === get_current_user_id(); | ||
if ( false === get_theme_mod( 'thank_you_customer_details_display', false ) ) { | ||
$show_customer_details = false; | ||
} | ||
if ( $show_customer_details ) { | ||
wc_get_template( 'order/order-details-customer.php', array( 'order' => $order ) ); | ||
} | ||
?> | ||
<?php endif; ?> | ||
<?php else : ?> | ||
|
||
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"> | ||
<?php echo esc_html( apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'newspack' ), null ) ); ?> | ||
</p> | ||
|
||
<?php endif; ?> | ||
|
||
</div> |
66 changes: 66 additions & 0 deletions
66
newspack-theme/woocommerce/order/order-details-customer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* Order Customer Details | ||
* | ||
* This template can be overridden by copying it to yourtheme/woocommerce/order/order-details-customer.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/ | ||
* @package WooCommerce/Templates | ||
* @version 3.4.4 | ||
*/ | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
$show_shipping = ! wc_ship_to_billing_address_only() && $order->needs_shipping_address(); | ||
?> | ||
<section class="woocommerce-customer-details"> | ||
|
||
<h4><?php esc_html_e( 'Your Information', 'newspack' ); ?></h4> | ||
|
||
<?php if ( $show_shipping ) : ?> | ||
|
||
<section class="woocommerce-columns woocommerce-columns--2 woocommerce-columns--addresses col2-set addresses"> | ||
<div class="woocommerce-column woocommerce-column--1 woocommerce-column--billing-address col-1"> | ||
|
||
<?php endif; ?> | ||
|
||
<?php if ( $show_shipping ) : ?> | ||
<h5 class="woocommerce-column__title"><?php esc_html_e( 'Billing address', 'newspack' ); ?></h5> | ||
<?php endif; ?> | ||
|
||
<address> | ||
<?php echo wp_kses_post( $order->get_formatted_billing_address( esc_html__( 'N/A', 'newspack' ) ) ); ?> | ||
|
||
<?php if ( $order->get_billing_phone() ) : ?> | ||
<p class="woocommerce-customer-details--phone"><?php echo esc_html( $order->get_billing_phone() ); ?></p> | ||
<?php endif; ?> | ||
|
||
<?php if ( $order->get_billing_email() ) : ?> | ||
<p class="woocommerce-customer-details--email"><?php echo esc_html( $order->get_billing_email() ); ?></p> | ||
<?php endif; ?> | ||
</address> | ||
|
||
<?php if ( $show_shipping ) : ?> | ||
|
||
</div><!-- /.col-1 --> | ||
|
||
<div class="woocommerce-column woocommerce-column--2 woocommerce-column--shipping-address col-2"> | ||
<h5 class="woocommerce-column__title"><?php esc_html_e( 'Shipping address', 'newspack' ); ?></h5> | ||
<address> | ||
<?php echo wp_kses_post( $order->get_formatted_shipping_address( esc_html__( 'N/A', 'newspack' ) ) ); ?> | ||
</address> | ||
</div><!-- /.col-2 --> | ||
|
||
</section><!-- /.col2-set --> | ||
|
||
<?php endif; ?> | ||
|
||
<?php do_action( 'woocommerce_order_details_after_customer_details', $order ); ?> | ||
|
||
</section> |