Created
October 18, 2019 15:22
-
-
Save bporcelli/a96285f629d400335fe060119d03b8c1 to your computer and use it in GitHub Desktop.
Simple Sales Tax: Charge tax on composite products
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Sets the taxable price for all Composite Products to the product price. | |
| * This overrides the default behavior of Simple Sales Tax, which is to tax | |
| * the components of a Composite Product and not the product itself. | |
| * | |
| * This hook MUST run with priority 11 or later to work properly. | |
| * | |
| * @see SST_Composite_Products::filter_composite_product_price() | |
| * | |
| * @param float $price Product price for tax calculation purposes. | |
| * @param WC_Product $product Product. | |
| * | |
| * @return float | |
| */ | |
| function sst_set_composite_product_price( $price, $product ) { | |
| if ( is_a( $product, 'WC_Product_Composite' ) ) { | |
| $price = $product->get_price(); | |
| } | |
| return $price; | |
| } | |
| add_filter( 'wootax_product_price', 'sst_set_composite_product_price', 20, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment