Answer the question
In order to leave comments, you need to log in
How to do checkout on WooCommerce cart page?
Woocommerce has a notices folder where notifications are divided into files. error, success and notice.
So, I want to show a certain notification on certain pages, and the standard one on the rest.
For example, when returning a successful result, show some text on the cart page, and standard text on others.
I wrote the following code in success.php with a check: (but it doesn't work)
<?php
/**
* Show messages
*
* This template can be overridden by copying it to yourtheme/woocommerce/notices/success.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.9.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! $notices ) {
return;
}
?>
<?php if(is_cart()) { ?>
<?php echo esc_html__('Тут текст, например', 'skazkaMini') ?>
<?php } else { ?>
<?php foreach ( $notices as $notice ) : ?>
<div class="woocommerce-message test"<?php echo wc_get_notice_data_attr( $notice ); ?> role="alert">
<?php echo wc_kses_notice( $notice['notice'] ); ?>
</div>
<?php endforeach; ?>
<?php } ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question