Woocommerce Hook woocommerce_get_price how to used in product list?

woocommerce, wordpress

Solution

When i test your code, all prices in my listing change. Maybe you got a problem with sales prices. The `WC_PRODUCT` class has different functions (including filter to get a price depending on it's sales status). The `get_price_html` uses the `get_regular_price` or `get_price_suffix` function, etc.

Try:

add_filter('woocommerce_get_price','change_price_regular_member', 10, 2);
add_filter('woocommerce_get_regular_price','change_price_regular_member', 10, 2);
add_filter('woocommerce_get_sale_price','change_price_regular_member', 10, 2);

You could also try an extension like http://club.orbisius.com/products/wordpress-plugins/woocommerce-extensions/orbisius-flex-price-woocommerce/.

update

Your Code is not working every where when i place order through paypal

It seems the paypal gateway use the order class instead of the product class to calculate prices. In `./includes/class-wc-order.php` you will find functions such as `get_item_subtotal()` which has a filter `apply_filters( 'woocommerce_order_amount_item_subtotal', $price, $this );`. Try to use these, for instance:

          add_filter('woocommerce_order_amount_item_subtotal','change_price_regular_member', 10, 2);

Problem

i used the Woocommerce for shopping cart. i want to change price of product in listing page. i used this hook for change product price. ``` woocommerce_get_price ``` This is my function. ``` add_action('woocommerce_get_price','change_price_regular_member', 10, 2); function change_price_regular_member($price, $productd){ return $price*2/100; } ``` i want to change price of all product in listing page. But this function is not working is return first product price in every product price. how can i used this hook to change every product price perfect? Thank You.

Original source