J
J
Jack London2016-11-10 16:40:04
CMS
Jack London, 2016-11-10 16:40:04

How to change cart appearance in storefront (wordpress) theme?

In general, there is a site on wordpress + woocommerce and the storefront theme, it is not possible to change the appearance of the basket that is in the header, swap elements, etc., there is such code in the storefront theme, you can help figure out what it is responsible for:

function storefront_cart_link_fragment( $fragments ) {
  global $woocommerce;

  ob_start();
  storefront_cart_link();
  $fragments['a.cart-contents'] = ob_get_clean();
  ob_start();
  storefront_handheld_footer_bar_cart_link();
  $fragments['a.footer-cart-contents'] = ob_get_clean();

  return $fragments;
}
function storefront_cart_link() {
  ?>
    <a class="cart-contents" href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" title="<?php esc_attr_e( 'View your shopping cart', 'storefront' ); ?>">
      <span class="amount"><?php echo wp_kses_data( WC()->cart->get_cart_subtotal() ); ?></span> <span class="count"><?php echo wp_kses_data( sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'storefront' ), WC()->cart->get_cart_contents_count() ) );?></span>
    </a>
  <?php
}

It is interesting that when the storefront_cart_link() function is removed, the cart disappears, but the code cannot be edited, adding, removing or swapping spans in the function does nothing, many thanks in advance to those who respond!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gleb Kemarsky, 2017-03-26
@Windhack

  1. storefront_cart_link()sets the html code of the cart. We change it to the one we need.

A
Alexey Golyagin, 2016-12-01
@webrevenue

In general, the appearance is usually changed using CSS, your spans have classes, due to which the appearance is configured

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question