• Resolved mishaml

    (@mishaml)


    Hi! I’m using coupon when creating an order using rest api, which causes fatal error.

    2024-03-29T15:22:34+01:00 CRITICAL Uncaught Error: Call to a member function get_applied_coupons() on null in /home/shypelyk/ninesquares.studio/sushijo/wp-content/plugins/advanced-coupons-for-woocommerce-free/Models/BOGO/Frontend.php:99
    Stack trace:
    #0 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/class-wp-hook.php(326): ACFWF\Models\BOGO\Frontend->restrict_cart_to_only_one_bogo_deal(true, Object(WC_Coupon))
    #1 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/plugin.php(205): WP_Hook->apply_filters(true, Array)
    #2 /home/shypelyk/ninesquares.studio/sushijo/wp-content/plugins/woocommerce/includes/class-wc-discounts.php(1002): apply_filters('woocommerce_cou...', true, Object(WC_Coupon), Object(WC_Discounts))
    #3 /home/shypelyk/ninesquares.studio/sushijo/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-orders-controller.php(75): WC_Discounts->is_coupon_valid(Object(WC_Coupon))
    #4 /home/shypelyk/ninesquares.studio/sushijo/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-orders-controller.php(243): WC_REST_Orders_Controller->calculate_coupons(Object(WP_REST_Request), Object(WC_Order))
    #5 /home/shypelyk/ninesquares.studio/sushijo/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-crud-controller.php(238): WC_REST_Orders_Controller->save_object(Object(WP_REST_Request), false)
    #6 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/rest-api/class-wp-rest-server.php(1193): WC_REST_CRUD_Controller->update_item(Object(WP_REST_Request))
    #7 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/rest-api/class-wp-rest-server.php(1041): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wc/v3/orders/(...', Array, NULL)
    #8 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/rest-api/class-wp-rest-server.php(431): WP_REST_Server->dispatch(Object(WP_REST_Request))
    #9 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/rest-api.php(424): WP_REST_Server->serve_request('/wc/v3/orders/2...')
    #10 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/class-wp-hook.php(324): rest_api_loaded(Object(WP))
    #11 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
    #12 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
    #13 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array)
    #14 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/class-wp.php(813): WP->parse_request('')
    #15 /home/shypelyk/ninesquares.studio/sushijo/wp-includes/functions.php(1336): WP->main('')
    #16 /home/shypelyk/ninesquares.studio/sushijo/wp-blog-header.php(16): wp()
    #17 /home/shypelyk/ninesquares.studio/sushijo/index.php(17): require('/home/shypelyk/...')
    #18 {main}
      thrown v /home/shypelyk/ninesquares.studio/sushijo/wp-content/plugins/advanced-coupons-for-woocommerce-free/Models/BOGO/Frontend.php na ?ádku 99
    • This topic was modified 8 months ago by mishaml.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Jeff Alvarez

    (@superlemon1998)

    Hi @mishaml,

    We currently do not support the use of Advanced Coupon-related coupons with Woocommerce’s REST API.

    You can find more information about our rest api here: REST API | Advanced Coupons API (gitbook.io)

    As we currently do not support the feature, I’ll raise a feature request for the use of coupons via Rest API.

    In the meantime, if you have other questions feel free to create another post.

    Thread Starter mishaml

    (@mishaml)

    However, may you fix this case so there will be no fatal error at least, even if the coupon wouldn’t work. As far as I understand, you have to check whether WC()->cart exists or whether it is not rest request

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fatal error while using coupon using rest api’ is closed to new replies.