Делаем недоступным нажатие кнопки "Оформить заказ" в WooCommerce

Все просто. За кнопку "Оформить заказ" отвечает файл proceed-to-checkout-button.php. Поэтому внеся в него изменения, мы можем запретить нажатие кнопки.

Вот так он выглядит изначально:

proceed-to-checkout-button.php

<?php
/**
 * Proceed to checkout button
 *
 * Contains the markup for the proceed to checkout button on the cart.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/cart/proceed-to-checkout-button.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 2.4.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}
?>

<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="checkout-button button alt wc-forward">
	<?php esc_html_e( 'Proceed to checkout', 'woocommerce' ); ?>
</a>

И для отмены нажатия мы всего лишь добавляем несколько параметров.

Изменённый proceed-to-checkout-button.php

<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" onclick="return false" class="checkout-button button alt wc-forward" title="Оформление заказа пока не доступно">
	<?php esc_html_e( 'Proceed to checkout', 'woocommerce' ); ?>
</a>

 Все. А что бы сделать вид недоступной кнопки, стилизуем ее.

Так же с моим портфолио можно ознакомиться на любой из представленной социальной сети, на своих страницах я публикую посты о своих работах, заданиях и целях.

Для связи со мной можно воспользоваться любой социальной сетью,
или написать на почту:

С моим резюме можно ознакомиться по ссылке:

© 2020-2024 Портфолио Юдина Александра г.Пенза. Все права защищены