To be more specific, to add a coupon code to an order we execute a PUT on the below endpoint with the below JSON payload:
Endpoint:
/wp-json/wc/v3/orders/<id>
Payload:
{“coupon_lines”:[{“code”:”[coupon code]”}]}
The error we receive when the Advanced Coupons for WooCommerce plugin is enabled is:
{
"code": "internal_server_error",
"message": "<p>There has been a critical error on this website.</p><p><a href=\"https://wordpress.org/support/article/faq-troubleshooting/\">Learn more about troubleshooting WordPress.</a></p>",
"data": {
"status": 500
},
"additional_errors": []
}
Hey @ssoper97470, thanks for the message and the clarification too!
We are aware of this problem and will have a fix out in a later release (not sure if it will be the next one or not at this stage as its already pretty full).
The issue is the cart conditions attempting to validate for API calls. There’s no cart object so it fails.
Here’s a code snippet to get around the problem in the meantime:
add_action('rest_api_init', 'acfwf_disable_features_in_rest_api');
function acfwf_disable_features_in_rest_api() {
// disable cart conditions.
if (function_exists('ACFWF') && is_object(\ACFWF()->Cart_Conditions)) {
remove_filter('woocommerce_coupon_is_valid', array(\ACFWF()->Cart_Conditions, 'implement_cart_conditions'), 10, 2);
}
}
Please install this on your functions.php or a code snippet plugin.
Thanks, I have forwarded that on to the client.
We did put in place a temporary work-around by passing the discounted price for items in the order which applies a generic discount. We are not attempting to apply any coupon codes, and we are also passing an identifier in the customer note to indicate that the order is coming from our call center for the client’s reporting purposes. That seems to be working in the meantime. I’m just noting that for anybody else viewing this thread for the same reasons.