• Resolved morvy

    (@morvy)


    Every refund initiated from the Stripe dashboard triggers a PHP warning on our site:

    Warning: Undefined array key "refund_total"
    /wp-content/plugins/woocommerce/includes/wc-order-functions.php:608

    Stack (top of the app frames down):

    POST /wp-json/wc-stripe/v1/webhook
    -> PaymentPlugins\Stripe\Rest\Routes\V1\Webhook::handle_post_request()
    -> wc_stripe_process_create_refund() (includes/wc-stripe-webhook-functions.php:180)
    -> wc_create_refund() (woocommerce/includes/wc-order-functions.php:608)

    At that line WooCommerce reads the key without a guard:

    $refund_total = $args['line_items'][ $item_id ]['refund_total'];

    while qty and refund_tax on the surrounding lines are isset()-checked. So it looks like the line_items array built in wc_stripe_process_create_refund() can contain entries without a refund_total key — probably when the refund comes from Stripe’s side and there is no per-line data.

    Not fatal, but it fires on every such webhook (38 occurrences here in 90 days) and pollutes the error log. Is refund_total supposed to always be set in that array?

Viewing 1 replies (of 1 total)
  • Plugin Author Clayton R

    (@mrclayton)

    Hi @morvy

    Thank you for contacting Payment Plugins.

    Is refund_total supposed to always be set in that array?

    The Stripe plugin sets the line items entry when the order has been fully refunded which requires restocking. The WooCommerce refund function will process the re-stocking if the refund arguments passed to the function contain line item info.

    In the past this just required the quantity for each line item but not needs the per line item total to avoid that PHP notice.

    We’ve added this as a development task for the next release.

    Kind Regards

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.