R
R
RobertCody2019-04-04 18:17:45
WooCommerce
RobertCody, 2019-04-04 18:17:45

WOOCOMMERCE - where are the functions connected to the hook?

Hello. Most likely, I did not fully understand the principle of how hooks work.
Woocommerce cart has

apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );

But there are no more add_filters to this woocommerce_cart_item_product in any file. How does it work if no filters are connected to it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yanchevsky, 2019-04-04
@RobertCody

Hello.
The value $_productis written to the variable $cart_item['data'].
This behavior can be changed with add_filter. In the function that you connect to this filter, you will have three options available: $cart_item['data'], $cart_item, $cart_item_key. Based on which, you can customize your logic.
In your function, you will do return что-тоand this is what will be written in $_productinstead of $cart_item['data'].

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question