diff --git a/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig b/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig index d0822a51e..7b2851abc 100644 --- a/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig +++ b/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig @@ -2,7 +2,7 @@ {% block buy_widget_buy_button %} - {% if mollie_subscriptions_enabled and product.customFields.mollie_payments_product_subscription_enabled %} + {% if mollie_subscriptions_enabled and product.translated.customFields.mollie_payments_product_subscription_enabled %}
diff --git a/src/Struct/Product/ProductAttributes.php b/src/Struct/Product/ProductAttributes.php index 6d2b27ff9..ca098f353 100644 --- a/src/Struct/Product/ProductAttributes.php +++ b/src/Struct/Product/ProductAttributes.php @@ -143,7 +143,7 @@ private function getCustomFieldValue(ProductEntity $product, string $keyName) $foundValue = ''; - $customFields = $product->getCustomFields(); + $customFields = $product->getTranslated()['customFields']; # --------------------------------------------------------------------------- # search in new structure diff --git a/tests/PHPUnit/Service/Cart/Voucher/VoucherServiceTest.php b/tests/PHPUnit/Service/Cart/Voucher/VoucherServiceTest.php index 193716597..eeeb67190 100644 --- a/tests/PHPUnit/Service/Cart/Voucher/VoucherServiceTest.php +++ b/tests/PHPUnit/Service/Cart/Voucher/VoucherServiceTest.php @@ -77,7 +77,7 @@ public function testProductHasMealVoucher() $foundProduct->setCustomFields([ 'mollie_payments_product_voucher_type' => VoucherType::TYPE_MEAL, ]); - + $foundProduct->setTranslated(['customFields'=>$foundProduct->getCustomFields()]); # build a repo that would return nothing...just in case ;) $fakeRepoProducts = new FakeProductRepository(null, $foundProduct); @@ -99,8 +99,10 @@ public function testUnknownParentThrowsException() $this->expectException(ProductNotFoundException::class); $foundProduct = new ProductEntity(); + $foundProduct->setId('ID-123'); $foundProduct->setParentId('PARENT-123'); + $foundProduct->setTranslated(['customFields'=>$foundProduct->getCustomFields()]); $fakeRepoProducts = new FakeProductRepository(null, $foundProduct); @@ -121,12 +123,14 @@ public function testVoucherOfParent() $foundProduct = new ProductEntity(); $foundProduct->setId('ID-123'); $foundProduct->setParentId('PARENT-123'); + $foundProduct->setTranslated(['customFields'=>$foundProduct->getCustomFields()]); $foundParentProduct = new ProductEntity(); $foundParentProduct->setId('ID-456'); $foundParentProduct->setCustomFields([ 'mollie_payments_product_voucher_type' => VoucherType::TYPE_GIFT, ]); + $foundParentProduct->setTranslated(['customFields'=>$foundParentProduct->getCustomFields()]); $fakeRepoProducts = new FakeProductRepository($foundParentProduct, $foundProduct); diff --git a/tests/PHPUnit/Struct/Product/ProductAttributesTest.php b/tests/PHPUnit/Struct/Product/ProductAttributesTest.php index 2e7c597b0..02001ecb3 100644 --- a/tests/PHPUnit/Struct/Product/ProductAttributesTest.php +++ b/tests/PHPUnit/Struct/Product/ProductAttributesTest.php @@ -15,10 +15,14 @@ class ProductAttributesTest extends TestCase */ public function testEmptyCustomFields() { - $method = new ProductEntity(); - $method->setCustomFields([]); + $product = new ProductEntity(); + $product->setCustomFields([]); + $product->setTranslated([ + 'customFields' => $product->getCustomFields() + ]); + - $attributes = new ProductAttributes($method); + $attributes = new ProductAttributes($product); $this->assertEquals('', $attributes->getVoucherType()); } @@ -30,15 +34,18 @@ public function testEmptyCustomFields() */ public function testVoucherType() { - $method = new ProductEntity(); - $method->setCustomFields([ + $product = new ProductEntity(); + $product->setCustomFields([ 'mollie_payments_product_voucher_type' => VoucherType::TYPE_ECO, 'mollie_payments' => [ 'voucher_type' => VoucherType::TYPE_MEAL ] ]); + $product->setTranslated([ + 'customFields' => $product->getCustomFields() + ]); - $attributes = new ProductAttributes($method); + $attributes = new ProductAttributes($product); $this->assertEquals(VoucherType::TYPE_ECO, $attributes->getVoucherType()); } @@ -49,12 +56,15 @@ public function testVoucherType() */ public function testUnknownVoucherType() { - $method = new ProductEntity(); - $method->setCustomFields([ + $product = new ProductEntity(); + $product->setCustomFields([ 'mollie_payments_product_voucher_type' => '5', ]); + $product->setTranslated([ + 'customFields' => $product->getCustomFields() + ]); - $attributes = new ProductAttributes($method); + $attributes = new ProductAttributes($product); $this->assertEquals(VoucherType::TYPE_NOTSET, $attributes->getVoucherType()); }