Sorting items in Mini-cart type right menu

This topic has 2 replies, 2 voices, and was last updated 1 years, 11 months ago ago by Olga Barlow

  • Avatar: paulgor
    paulgor
    Participant
    June 17, 2022 at 12:19

    Hi, 8theme.
    How sorting items in Mini-cart type right menu from Z-A (reverse_cart_contents)? Use this code but after have issues with add quantity input products.

    revers items in cart and mini cart
    
    function reverse_cart_contents() {
      $cart_contents = WC()->cart->get_cart_contents();
    
      if($cart_contents) {
        $reversed_contents = array_reverse($cart_contents);
        WC()->cart->set_cart_contents($reversed_contents);
      }
    }
    add_action('woocommerce_before_mini_cart', 'reverse_cart_contents');
    add_action('woocommerce_after_mini_cart', 'reverse_cart_contents');
    add_action('woocommerce_before_cart', 'reverse_cart_contents');
    add_action('woocommerce_after_cart', 'reverse_cart_contents');
    add_action('woocommerce_review_order_before_cart_contents', 'reverse_cart_contents');
    add_action('woocommerce_review_order_after_cart_contents', 'reverse_cart_contents');

    Thanks

    Best, Paul

    Please, contact administrator
    for this information.
    1 Answer
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    June 17, 2022 at 13:13
  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.