E
E
Edward2020-11-17 11:12:33
WooCommerce
Edward, 2020-11-17 11:12:33

How to override Woocoomerce class-wc-cart?

Can't override class-wc-cart or add_to_cart method. Tried like this:
1.

add_action( 'woocommerce_add_to_cart', 'add_to_cart', 20, 0 );
function add_to_cart( $product_id = 0, $quantity = 1, $variation_id = 0, $variation = array(), $cart_item_data = array() ) {
//code
}

2. Make a folder in the theme includes/class-wc-cart.php
3. Override the method
function add_to_cart( $product_id = 0, $quantity = 1, $variation_id = 0, $variation = array(), $cart_item_data = array() ) {
//code
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question