woothemes/woocommerce — pull request #6696 by HomAfromPTZ (2014-11-05 23:07:24+00:00)
Title: Filters added to $base_price

It would be great to have opportunity to change $base_price through filters if product price depends on the quantity, for example.
Say, if I ordered {x} units, then the base_price will be 5$. But if I ordered more than {y}, then it will be 3$.

The add_filter function might look like:

```php
add_filter( 'woocommerce_base_price', 'my_base_price', 10, 2);
function my_base_price($price, $cart_item) {
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item);
// x < y
$product_more_than_x = get_post_meta( $product_id, '_woo_more_than_x', true );
$product_more_than_y = get_post_meta( $product_id, '_woo_more_than_y', true );

if ($cart_item['quantity'] >= $product_more_than_y) {
return get_post_meta( $product_id, '_woo_big_price', true );
} elseif ($cart_item['quantity'] >= $product_more_than_x) {
return get_post_meta( $product_id, '_woo_medium_price', true );
} else {
return $price;
}
}
```