{"id":19015259,"date":"2026-09-09T08:32:56","date_gmt":"2026-09-09T08:32:56","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/undefined-array-key-refund_total\/"},"modified":"2026-09-09T08:32:56","modified_gmt":"2026-09-09T08:32:56","slug":"undefined-array-key-refund_total","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/undefined-array-key-refund_total\/","title":{"rendered":"Undefined array key &#8220;refund_total&#8221;"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Every refund initiated from the Stripe dashboard triggers a PHP warning on our site:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Warning: Undefined array key \"refund_total\"<br \/>\/wp-content\/plugins\/woocommerce\/includes\/wc-order-functions.php:608<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Stack (top of the app frames down):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>POST \/wp-json\/wc-stripe\/v1\/webhook<br \/> -&gt; PaymentPlugins\\Stripe\\Rest\\Routes\\V1\\Webhook::handle_post_request()<br \/> -&gt; wc_stripe_process_create_refund()  (includes\/wc-stripe-webhook-functions.php:180)<br \/> -&gt; wc_create_refund()                 (woocommerce\/includes\/wc-order-functions.php:608)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">At that line WooCommerce reads the key without a guard:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$refund_total = $args&#091;'line_items']&#091; $item_id ]&#091;'refund_total'];<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">while <code>qty<\/code> and <code>refund_tax<\/code> on the surrounding lines are <code>isset()<\/code>-checked. So it looks like the <code>line_items<\/code> array built in <code>wc_stripe_process_create_refund()<\/code> can contain entries without a <code>refund_total<\/code> key \u2014 probably when the refund comes from Stripe&#8217;s side and there is no per-line data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Not fatal, but it fires on every such webhook (38 occurrences here in 90 days) and pollutes the error log. Is <code>refund_total<\/code> supposed to always be set in that array?<\/p>\n","protected":false},"template":"","class_list":["post-19015259","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19015259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19015259\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19015259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}