Sage-woocommerce return error when try to override plugin template

Trying to override PW WooCommerce Gift Cards template. I added the file in the correct folder (woocommerce > single-product > add-to-cart), change file extension to .blade.php and change php syntax to blade syntax. But I got this error:

[27-May-2019 11:40:57 UTC] PHP Warning: array_merge(): Argument #3 is not an array in /srv/www/website/public_html/wp-content/themes/website/vendor/roots/sage-woocommerce/src/woocommerce.php on line 48
[27-May-2019 11:40:57 UTC] PHP Warning: array_merge(): Argument #2 is not an array in /srv/www/website/public_html/wp-content/themes/website/vendor/illuminate/view/Factory.php on line 110

Even if I left the file empty, this error appear.

I think I’ve run into this error in the past, although possibly not with WooCommerce, and although I don’t remember the exact solution(s) I eventually came up with, I think the problem is that something is causing a string to be passed to scripts mentioned in your errors instead of the expected array—I think because something is tapping into one of the template filters that Sage uses to pass data to views.

My approach to figuring these problems out was to dive into the scripts mentioned in the error (in your case vendor/roots/sage-woocommerce/src/woocommerce.php and vendor/illuminate/view/Factory.php and start directly examining the variables passing through them (i.e. w/ var_dump or something) until I could figure out what was passing bad arguments, and then trace that back to its source and fix it there.

1 Like

Hey @alwaysblank, I figured out! The problem is in the plugin. It pass the second argument of wc_get_template() as a string instead an array.

This topic was automatically closed after 42 days. New replies are no longer allowed.