При добавлении товара Woocommerce со страницы карточки – обновляет страницу, а с категории – нет

При добавлении товара Woocommerce со страницы карточки – обновляет страницу и добавляет товар (есть уведомление “Вы отложили….”)
А вот при добавлении товара в корзину из архива (категории) ничего не происходит (при обновлении цена возле иконки корзины меняется)
Как сделать обновление страницы из категории

Я заменил кнопку < a в категории на < button
в файле /public_html/wp-content/plugins/woocommerce/templates/loop/add-to-cart.php

замени на :

<?php
/**
 * Loop Add to Cart — <form> + <button>, отправка на текущую страницу
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

global $product;

if ( ! $product || ! $product->is_type('simple') || ! $product->is_purchasable() || ! $product->is_in_stock() ) {
	echo '<a href="' . esc_url( get_permalink() ) . '" class="button">' . esc_html__( 'Подробнее', 'woocommerce' ) . '</a>';
	return;
}

$product_id = $product->get_id();
$quantity   = 1;
$text       = $product->add_to_cart_text();

// Текущая страница (например, /catalog)
$current_url = strtok($_SERVER['REQUEST_URI'], '?'); // убираем GET-параметры

echo apply_filters(
	'woocommerce_loop_add_to_cart_link',
	sprintf(
		'<form action="%s" method="post" style="display:inline-block;">
			<input type="hidden" name="quantity" value="%s" />
			<input type="hidden" name="add-to-cart" value="%s" />
			<button type="submit" class="button product_type_simple add_to_cart_button">%s</button>
		</form>',
		esc_url( $current_url ),
		esc_attr( $quantity ),
		esc_attr( $product_id ),
		esc_html( $text )
	),
	$product,
	[]
);

guest
Другие сообщения форума
Закрыть меню
ZAPLATA.RU | Магазин готовых блогов Wordpress с автонаполнением
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.