Answer the question
In order to leave comments, you need to log in
Can html be cached in php Wordpress functions?
Good evening, I add carts to the woocommerce f-th woocommerce_cart_link()
, my own html
, call the f-th in html <?php woocommerce_cart_link(); ?>
-> everything is fine, my html is displayed from the f-th.
Next, I return my html from the f-ii to its original place, the call to the f-ii lags behind in place. As a result, on the screen is my html of the basket and the one that is БЫЛ
in f-ii, but I removed it .... is this my handwriting or am I not understanding something?)
<?php nlo_woocommerce_cart_link(); ?>
<button type="button" class="menu_cart_button">
<span class="floating-cart__all-sum">
<span class="money">
<span class="value">0 </span>
<span class="currency currency_on-the-right">₽</span>
</span>
</span>
<span class="floating-cart__amount-info">
<span class="floating-cart__drop-down-icon"></span>
<span class="floating-cart__amount-goods">0 товаров</span>
</span>
</button>
<a class="floating-cart__to-cart-button button button_primary" href="cart.php">Корзина</a>
function nlo_woocommerce_cart_link() {
?>
<a class="cart-contents" href="<?php echo esc_url( wc_get_cart_url() ); ?>" title="<?php esc_attr_e( 'View your shopping cart', 'nlo' ); ?>">
<?php
$item_count_text = sprintf(
/* translators: number of items in the mini cart. */
_n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'nlo' ),
WC()->cart->get_cart_contents_count()
);
?>
<span class="amount"><?php echo wp_kses_data( WC()->cart->get_cart_subtotal() ); ?></span> <span class="count"><?php echo esc_html( $item_count_text ); ?></span>
</a>
<?php
}
Answer the question
In order to leave comments, you need to log in
Woo has such a feature, yes. The state of the cart and its html markup are saved in the user's session.
In order to see changes in the cart code, change the number of items in it. When you change the number of items in the cart, it is reloaded from the server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question