cart->get_cart(); $values = array(); $cart_updated = false; if ( ! empty( $cart[ $cart_item_key ] ) ) { $values = $cart[ $cart_item_key ]; } $passed_validation = apply_filters( 'woocommerce_update_cart_validation', true, $cart_item_key, $values, $quantity ); if ( $passed_validation && $quantity ) { WC()->cart->set_quantity( $cart_item_key, $quantity, false ); $cart_updated = true; } elseif ( ! $quantity ) { WC()->cart->remove_cart_item( $cart_item_key ); } // Trigger action - let 3rd parties update the cart if they need to and update the $cart_updated variable. $cart_updated = apply_filters( 'woocommerce_update_cart_action_cart_updated', $cart_updated ); if ( $cart_updated ) { WC()->cart->calculate_totals(); } wp_send_json( WC()->cart->get_cart_item( $cart_item_key ) ); } /** * Before empty message html. * * @return void */ public function before_empty_message_html() { ?>
0 ) : ?>

' . esc_html_x( 'Add', 'mini cart add to cart button label', 'flatsome' ); return preg_replace( '/().*?(<\/a>)/', '$1' . $insert . '$2', $link ); } /** * Renders the quantity html. * * @param string $markup The markup. * @param array $cart_item The cart item. * @param string $cart_item_key The cart item key. */ public function quantity_html( $markup, $cart_item, $cart_item_key ) { $header_cart_qty = get_theme_mod( 'header_cart_qty' ); $product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $product_name = apply_filters( 'woocommerce_cart_item_name', $product->get_name(), $cart_item, $cart_item_key ); ob_start(); ?>
is_purchasable() && apply_filters( 'flatsome_show_mini_cart_item_quantity', true, $cart_item_key ) ) { if ( $product->is_sold_individually() ) { $min_quantity = 1; $max_quantity = 1; } else { $min_quantity = 0; $max_quantity = $product->get_max_purchase_quantity(); } $product_quantity = woocommerce_quantity_input( array( 'input_name' => "cart[{$cart_item_key}][qty]", 'input_value' => $cart_item['quantity'], 'min_value' => $min_quantity, 'max_value' => $max_quantity, 'product_name' => $product_name, ), $product, false ); echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput } if ( $header_cart_qty ) { ?> cart->get_product_subtotal( $product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
cart->get_cross_sells() ), 'wc_products_array_filter_visible' ); $cross_sells = array_filter( array_map( function ( $product ) { if ( ! $product->is_in_stock() ) return false; return $product; }, $cross_sells ) ); $cross_sells_orderby = apply_filters( 'woocommerce_cross_sells_orderby', 'date' ); $cross_sells_orderby = apply_filters( 'flatsome_mini_cart_cross_sells_orderby', $cross_sells_orderby ); $cross_sells_order = apply_filters( 'woocommerce_cross_sells_order', 'desc' ); $cross_sells_order = apply_filters( 'flatsome_mini_cart_cross_sells_order', $cross_sells_order ); $cross_sells = wc_products_array_orderby( $cross_sells, $cross_sells_orderby, $cross_sells_order ); $limit = intval( apply_filters( 'flatsome_mini_cart_cross_sells_total', 5 ) ); $cross_sells = $limit > 0 ? array_slice( $cross_sells, 0, $limit ) : $cross_sells; wc_get_template( 'cart/mini-cart/cross-sells.php', array( 'cross_sells' => $cross_sells ) ); } /** * Refresh mini cart on customizer open. * * @return void */ public function refresh_on_customizer_open() { if ( is_customize_preview() ) { do_action( 'wc_cart_fragments_refresh' ); } } }