WPprodigy / woocommerce-product-fees

Add additional fees at checkout based on products that are in the cart.
https://wordpress.org/plugins/woocommerce-product-fees/
Other
26 stars 19 forks source link

WooCommerce Chained Products #29

Closed cwuensche closed 7 years ago

cwuensche commented 7 years ago

This plugin doesn't play nicely with the Chained Products plugin. Basically, when you add a product fee, and the plugin bundles the product in, it adds the fee even though it's bundled.

I fixed this on my own end by adding a checkbox option, and I added an if statement to check for the existence of the Chained product IDs, and if it's not empty, and the box is checked, the fee gets ignored.

I don't know if anyone else even wants this code, but I might upload a forked version with this code.

screen shot 2017-06-15 at 3 17 05 pm
WPprodigy commented 7 years ago

it adds the fee even though it's bundled.

That could be what some people want though, so it's kind of a trade off.

Are there any hooks or filters you need in the plugin to make this work without editing core files?

cwuensche commented 7 years ago

I made it work by editing the file class-wcpf-product-fee.php. It uses the get_product_fee_data function. I also had to do another quick edit today to allow for a 100% off coupon to also discount the product fees. I had to do these hacks quickly because the website I wrote it for needed it today. The owners of the website wanted to be able to have only one parent service charge, and have the bundled products be included in that.

So here are the features I think would be good for you to do officially, make it so in the WooCommerce coupon section, add a checkbox for a coupon to discount the service charges also, and make it so they can ignore the bundled product service fees.

The other option is for me to just make a more elegant solution some day and release this. I don't know what you want though.

WPprodigy commented 7 years ago

See here for the coupon feature: https://github.com/WPprodigy/woocommerce-product-fees/issues/14. About to look into that.

I've decided not to do anything special for chained products though. It's quite likely that some people want the fees to still be added for chained items. The wcpf_indivual_product_fee_data filter in the get_product_fee_data method you mentioned passes along all of the data you could need. Just use that filter to externally alter how the plugin treats chained products. You can return false with the filter to prevent the fee from being added.