Make WordPress Core

Opened 6 months ago

Closed 6 months ago

Last modified 6 months ago

#63794 closed defect (bug) (invalid)

PHP notice: Array to string conversion in general-template.php

Reported by: balvantk's profile balvantk Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.8.2
Component: General Keywords:
Focuses: Cc:

Description (last modified by sabernhardt)

Test Case: PHP Notice - Array to String Conversion with Multiple Coupons

Environment:

  • Cart/Checkout: Classic and Block tested
  • WooCommerce version: (assumed to be recent, e.g., 9.x)
Step No. Action Expected Result
1 Login as a registered user. Login successful
2 Add a product to the cart. Product is added successfully
3 Go to the Cart page. Both coupons are auto/applied manually and reflected correctly
4 Proceed to Checkout and place the order. Order is placed successfully
5 Check the debug.log (or other PHP error logs). PHP Notice: Array to string conversion appears if improper coupon formatting or output exists.

This error show in log file

[07-Aug-2025 05:33:32 UTC] $helper: free_gift
[07-Aug-2025 05:33:32 UTC] $current: smart_coupon
[07-Aug-2025 05:33:32 UTC] $helper: smart_coupon
[07-Aug-2025 05:33:32 UTC] $current: smart_coupon
[07-Aug-2025 05:33:32 UTC] $helper: no
[07-Aug-2025 05:33:32 UTC] $current: yes
[07-Aug-2025 05:33:32 UTC] $helper: Array
(
    [0] => 
)

[07-Aug-2025 05:33:32 UTC] $current: yes
**[07-Aug-2025 05:33:32 UTC] PHP Notice:  Array to string conversion in C:\laragon\www\StoreApps\wp-includes\general-template.php on line 5313**
[07-Aug-2025 05:33:32 UTC] $helper: no
[07-Aug-2025 05:33:32 UTC] $current: yes
[07-Aug-2025 05:33:32 UTC] $helper: no
[07-Aug-2025 05:33:32 UTC] $current: yes

Attachments (2)

general-template.php (168.7 KB) - added by balvantk 6 months ago.
Patch uploaded to fix array to string conversion warning. Please review.
fix-array-conversion.patch (943 bytes) - added by balvantk 6 months ago.
Patch to fix PHP array to string conversion notice added. Please review.

Download all attachments as: .zip

Change History (6)

@balvantk
6 months ago

Patch uploaded to fix array to string conversion warning. Please review.

@balvantk
6 months ago

Patch to fix PHP array to string conversion notice added. Please review.

#1 @balvantk
6 months ago

  • Keywords has-patch added; needs-patch removed

#2 @rollybueno
6 months ago

  • Keywords needs-testing has-patch removed
  • Resolution set to invalid
  • Status changed from new to closed

Hey @balvantk - thanks for the patch and welcome to WP Core trac. WooCommerce is maintained separately and not part of the WordPress Core. Can you submit this issue on https://wordpress.org/support/plugin/woocommerce/

#3 follow-up: @SirLouen
6 months ago

@balvantk, where did you find that general-template.php file?

Those two lines do not exist in the original code

#4 in reply to: ↑ 3 @sabernhardt
6 months ago

  • Description modified (diff)
  • Milestone Awaiting Review deleted

I think fix-array-conversion.patch was supposed to add the two lines, not remove them.

However, I agree that the WooCommerce support forum should be a better place to discuss this (at least for now).

Note: See TracTickets for help on using tickets.