S
S
Sergey2018-05-09 22:49:19
WordPress
Sergey, 2018-05-09 22:49:19

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
  }

5af3508854251569631717.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mr Crabbz, 2018-05-09
@1Sergey1

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 question

Ask a Question

731 491 924 answers to any question