From 843238e1bf686b97d4af20534a6718b0e97b7a1a Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Mon, 13 May 2024 12:50:19 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20use=20field=20from=20ww.merx.ca?= =?UTF-8?q?rt.fields=20option=20if=20$fieldName=20is=20provided?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #77 --- src/ProductList.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ProductList.php b/src/ProductList.php index a2f3dc8..b0e602f 100644 --- a/src/ProductList.php +++ b/src/ProductList.php @@ -123,14 +123,16 @@ public function __set(string $key, $value): void $value['uid'] = $page->uid(); } foreach (option('ww.merx.cart.fields', []) as $fieldName) { - $field = $page->{$fieldName}(); - if ( - $field === null || - is_scalar($field) || - is_string($field) || - (is_object($field) && method_exists($field, '__toString')) - ) { - $value[$fieldName] = (string)$field; + if (!array_key_exists($fieldName, $value)) { + $field = $page->{$fieldName}(); + if ( + $field === null || + is_scalar($field) || + is_string($field) || + (is_object($field) && method_exists($field, '__toString')) + ) { + $value[$fieldName] = (string)$field; + } } } }