Home › Forums › Lorina Pro › Cart Icon – Number of items › Reply To: Cart Icon – Number of items
April 19, 2020 at 1:12 pm
#10248
Andy
Keymaster
The theme only displays the cart quantity provided by the WooCommerce get_cart_contents_count
function.
Looking at the WooCommerce php files, this is the full function:
public function get_cart_contents_count() {
return apply_filters( 'woocommerce_cart_contents_count', array_sum( wp_list_pluck( $this->get_cart(), 'quantity' ) ) );
}
This function is filterable with the woocommerce_cart_contents_count
filter, which means that you can create your own function to output a number based on your own formula, like so:
function tronds_cart_quantity() {
/* your formula/calculations of cart quantity here */
}
add_filter( 'woocommerce_cart_contents_count', 'tronds_cart_quantity' );
Any php functions such as this should be added to the functions.php file of a child theme.