Hello,
We are also running into the same issue, but we noticed that it doesn’t always have to be a WooCommerce Subscription product. It can also happen on a regular product. Or, at least for us, that is what was happening.
For developers, we traced the issue to the Wcff_Negotiator::handle_custom_pricing() function. This function is applying pricing rules to the cart items, which we currently don’t use in our application.
It appears that the call to $citem["data"]->set_price() on line 72 is the culprit. WooCommerce will use the “changed” version of the price from the data store if it exists, which calling set_price() sets. We are not quite sure why the new price is being set to zero, but in our case we had to edit this plugin directly to fix the bug. We just skipped the pricing rules logic all together because we don’t currently use it. Note: It is not recommended to edit plugins directly because those edits will be lost when the plugin is updated. We needed to fix this fast, and this was one of our only options.
@mycholan: It would be helpful for developers if you could create instances of your classes/object inside variables or by using a singleton instance() function so that we can modify hooks as necessary. In our case, it would have been nice if we could have used remove_action( 'woocommerce_before_calculate_totals', array( $wcffProductFields, 'pricing_rules_handler' ), 99 ); or similar to remove this hook temporarily since we do not use pricing rules. Unfortunately with the way that classes/objects are currently instantiated in WooCommerce Fields Factory, they are “anonymous” so we cannot easily modify the hooks.
Here are a couple of resources that may help:
- https://tommcfarlin.com/instantiating-wordpress-plugins/
- https://maurobringolf.ch/2017/02/learning-the-singleton-design-pattern-for-wordpress-plugins/
Thank You,
Scott
I’ve run into this same issue, but instead of the price becoming $0, it would multiply. If quantity was 1, price was double. If quantity was 2, price would be 6 times as much.
This happened to be on a subscription product with a duration for 3 months, hence the 3x multiple.
Commenting out the line highlighted above fixed the issue for me, but the developer needs to release an update fixing this issue.
I have this plugin installed on my production site and I am not experiencing this issue. It is on my development site where the issue is occurring. The difference being that I am using a select field on my dev site, but not on my production site.
And again, I have no pricing rules set up.
Kudos to the developer!
For me, updating to 2.0.7 (just released) has resolved this issue.
Please update WCFF version 2.0.7