• Resolved Michal Slepko

    (@mslepko)


    We are applying custom coupon codes on subscription renewals and due to the is_coupon_emails_allowed function introduced a couple of weeks ago we’ve started to get errors with subscription renewals.

    2024-05-01T11:01:13+00:00 Notice scheduled action XYZ (subscription payment) failed to finish processing due to the following exception: Call to a member function is_coupon_emails_allowed() on null  
    Additional context
    {
        "_legacy": true
    }
    
    2024-05-01T11:01:13+00:00 Notice action args: subscription_id: XYZ

    It looks like WC()->cart is null in this scenario

    [29-Apr-2024 09:51:25 UTC] PHP Fatal error:  Uncaught Error: Call to a member function is_coupon_emails_allowed() on null in /wp-content/plugins/woocommerce/includes/class-wc-discounts.php:979
    Stack trace:
    #0 /wp-content/plugins/woocommerce/includes/class-wc-discounts.php(1046): WC_Discounts->validate_coupon_allowed_emails(Object(WC_Coupon))
    #1 /wp-content/plugins/woocommerce/includes/class-wc-discounts.php(252): WC_Discounts->is_coupon_valid(Object(WC_Coupon))
    #2 /wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-order.php(1252): WC_Discounts->apply_coupon(Object(WC_Coupon))
    #3 /wp-content/themes/my_theme/custom/discount-on-renewal.php(132): WC_Abstract_Order->apply_coupon('renewal_couponXYZ')
    

    https://github.com/woocommerce/woocommerce/blob/release/8.8.0.20/plugins/woocommerce/includes/class-wc-discounts.php#L979

    My custom function is called using this filter

    add_filter( 'wcs_renewal_order_created', 'apply_discount_on_renewal_order_created', 10, 2 );

    I’ve already fixed the issue in my theme and wrapped the code in try/catch block but I’m wondering if this shouldn’t be fixed in WooCommerce code as well.

    If latter please let me know, and I can create an issue on GitHub.

    Thanks

    Michal

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Shameem – a11n

    (@shameemreza)

    Hi @mslepko

    We appreciate your detailed explanation of the issue you encountered with custom coupon codes on subscription renewals. It’s great to hear that you’ve already managed to fix the issue on your end with a try/catch block.

    We are always open to suggestions and improvements to our codebase. If you believe this is a bug or an improvement that could benefit other WooCommerce users, we encourage you to create an issue on our GitHub repo. This will allow our development team to review the issue and determine the best course of action.

    Thank you for bringing this to our attention and for your proactive approach in resolving this issue.

    I had the same problem after updating woocommerce to version 8.8

    Messages received:

    failed to finish processing due to the following exception: Call to a member function is_coupon_emails_allowed()

    failed to finish processing due to the following exception: Call to a member function get_subtotal() on null

    failed to finish processing due to the following exception: Call to a member function delete_meta_data()


    We downgraded the plugins, but the error persists

    • This reply was modified 1 year, 1 month ago by zehmatias.
    Plugin Support Shameem – a11n

    (@shameemreza)

    Hi @zehmatias

    Sorry to hear that you are experiencing the same issue.

    However, to align with forum best practices, please create a new topic so that we can address your issue(s) separately.

    You can create a new thread here: https://wordpress.org/support/plugin/woocommerce/#new-topic-0

    Thanks for understanding!

    Thread Starter Michal Slepko

    (@mslepko)

    Hello @mslepko,

    We appreciate you taking the time to report this. Our technical team is constantly monitoring the GitHub repository for any reported issues, and they will be checking your issue soon.

    Please keep an eye on the thread for updates or further questions from our team.

    We appreciate your patience and understanding.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Applying coupon on subscription renewal fails due to validate_coupon_allowed_ema’ is closed to new replies.