Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Not working correctly since Woo v4
- This topic has 11 replies, 2 voices, and was last updated 3 years, 8 months ago by Phil Whitwell.
-
AuthorPosts
-
April 4, 2020 at 12:40 pm #15317Phil WhitwellParticipant
Hi,
we are getting an issue not with the plugin itself but with a product that has only a signup fee, the fee is not added to the total. With help from Woo support, your plugin was found to be responsible, ie with the plugin disabled the issue goes away.
We have upgraded to PRO but still have the same issue. Happy to give access for you to have a look…We get this error message in WP logs…
[Sat Apr 04 12:07:20.684216 2020] [php7:notice] [pid 9564] [client 51.6.112.249:42880] id was called incorrectly. Product properties should not be accessed directly. Backtrace: require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’), WP_Hook->do_action, WP_Hook->apply_filters, WC_AJAX::do_wc_ajax, do_action(‘wc_ajax_update_order_review’), WP_Hook->do_action, WP_Hook->apply_filters, WC_AJAX::update_order_review, woocommerce_checkout_payment, WC_Payment_Gateways->get_available_payment_gateways, apply_filters(‘woocommerce_available_payment_gateways’), WP_Hook->apply_filters, payment_gateway_disable_direct_debit, WC_Product_Subscription->__get, WC_Abstract_Legacy_Product->__get, wc_doing_it_wrong. This message was added in version 3.0., referer: https://batchdistillery.co.uk/checkout/April 4, 2020 at 6:58 pm #15318Soft79KeymasterWell, the error message is not caused by our plugin, because our plugin does not call ‘id’ on products. But maybe the error message is not related to the problem that you are having.
Can you please provide steps to reproduce the issue in your store? If you wish you can send the details privately to admin at soft79.nl
April 4, 2020 at 8:11 pm #15320Phil WhitwellParticipantOk,
i have sent you credentials to have a look.
To recreate the problem
https://stagingbatch2.wpengine.com/become-a-member/
Click sign up for either 6 month or 12 month productsNote checkout total does not include signup fee.
I had a quick look at the debug
It is something to do with call to woocommerce_after_calculate_totals
I guess it appears as a free product but it is not free just with sign up cost onlyApril 5, 2020 at 10:47 am #15321Phil WhitwellParticipantNot sure if you have checked credentials yet but should be added now.
April 5, 2020 at 11:08 am #15322Soft79KeymasterI’ve did some tests on your site.
When our plugins adds the auto-coupon to the cart; it immediately is removed from the cart somehow. I think (but am not sure) that the Subscriptions plugin resets the cart during calculate_totals. Long story short; auto-coupons of our plugin and subscriptions plugin can’t work together… feel free to ask for a refund.
April 5, 2020 at 1:15 pm #15323Phil WhitwellParticipantThat’s giving up a bit easily.
It is only since v4, unless you fix it, you cannot say that it is compatible with v4 of WooCommerce.
It was the WooCommerce support team that pointed me in your direction.We rely on your plugin and subscriptions so would like a fix
April 5, 2020 at 1:31 pm #15324Soft79KeymasterOur plugin is compatible with WC 4; it’s possibly not compatible with the subscriptions plugin. Unfortunately we can’t guarantee compatibility with every single plugin. Normally we do try to apply fixes/workarounds if possible; but it’s outside of our hands if our plugin applies a coupon which then immediately gets removed by another plugin (probably the subscription plugin in this case). If you wish us to investigate this further you can hire us but not free of charge; please contact us by email then.
April 5, 2020 at 2:50 pm #15326Phil WhitwellParticipantI can understand if it was a random plugin but Woo Subscriptions is a core plugin.
The issue is not related to the coupon being removed it is that it sets the Total to £0, so subscribers get it for free!
This is a bug not something that can be worked around.April 5, 2020 at 2:51 pm #15327Phil WhitwellParticipantI found this code which is setting the total to £0
// Must be AFTER hook of Auto Coupon (5) but BEFORE WC_Cart_Session::set_session (10)
WJECF()->safe_add_action( ‘woocommerce_after_calculate_totals’, array( $this, ‘update_free_products_in_cart’ ), 8 );//Set price to 0.00 for free products
add_filter( ‘woocommerce_add_cart_item’, array( $this, ‘filter_woocommerce_add_cart_item’ ), PHP_INT_MAX, 6 ); // mark the free products as such
add_filter( ‘woocommerce_get_cart_item_from_session’, array( $this, ‘filter_woocommerce_get_cart_item_from_session’ ), PHP_INT_MAX, 3 ); // mark the free products as such// overwrite values (price 0.00) if it’s a free product
add_filter( ‘woocommerce_product_get_price’, array( $this, ‘filter_woocommerce_product_get_price’ ), PHP_INT_MAX, 2 );
add_filter( ‘woocommerce_product_variation_get_price’, array( $this, ‘filter_woocommerce_product_get_price’ ), PHP_INT_MAX, 2 );// overwrite subtotal of 0.00
add_filter( ‘woocommerce_coupon_discount_amount_html’, array( $this, ‘filter_woocommerce_coupon_discount_amount_html’ ), 8, 2 );//A free product coupon always has a value (for Auto coupon)
add_filter( ‘wjecf_coupon_has_a_value’, array( $this, ‘filter_wjecf_coupon_has_a_value’ ), 10, 2 ); // if coupon grants free products, it has a value! Required for Auto Coupons
add_filter( ‘woocommerce_coupon_is_valid_for_product’, array( $this, ‘filter_woocommerce_coupon_is_valid_for_product’ ), 10, 4 ); //don’t count the free items for coupon restrictionsadd_action( ‘woocommerce_cart_emptied’, array( $this, ‘woocommerce_cart_emptied’ ) );
April 6, 2020 at 7:19 am #15331Soft79KeymasterThat code is not related. The product price is 0.00, but Subscriptions plugin changes this to 185.
I have an idea which might work, but I need the subscriptions plugin to test this locally, can you send it to admin at soft79.nl?
April 6, 2020 at 5:06 pm #15337Soft79KeymasterSimply changing the discount type from “Percentage Discount” to “Sign Up Fee % Discount” seems to solve the issue.
The subscriptions plugin gets confused when calculate_totals gets called multiple times. Somehow it mixes up the Subscription price and the sign-up fee. Also internally it throws an “Sorry, this coupon is only valid for an initial payment and the subscription already has a free trial.”-exception when the discount type is not one of the Subscriptions-discount types. Changing the discount type to “Sign Up Fee % Discount” fixes this, but I don’t know why.
April 6, 2020 at 5:17 pm #15339Phil WhitwellParticipantThanks for the workaround.
The only thing now is it does not show the notification that the coupon is being applied but only minor and can live with that. -
AuthorPosts
- You must be logged in to reply to this topic.