Skip to content

Commit 8a77523

Browse files
authored
Merge pull request #99 from bold-commerce/400-html-tags-show-up-on-cart-summary-on-bold-checkout-for-configurable-products-with-configurations
400-html-tags-show-up-on-cart-summary-on-bold-checkout-for-configurab…
2 parents aa390f0 + 870eeac commit 8a77523

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

Model/Quote/Result/Builder/ExtractCartTotals.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Bold\Checkout\Model\Quote\Result\Builder;
55

6+
use Bold\Checkout\Model\Quote\Result\Builder\ExtractCartTotals\UpdateProductOptionValues;
67
use Magento\Framework\Api\DataObjectHelper;
78
use Magento\Framework\Api\ExtensibleDataInterface;
89
use Magento\Framework\Exception\NoSuchEntityException;
@@ -43,25 +44,33 @@ class ExtractCartTotals
4344
*/
4445
private $totalsConverter;
4546

47+
/**
48+
* @var UpdateProductOptionValues
49+
*/
50+
private $updateProductOptionValues;
51+
4652
/**
4753
* @param TotalsInterfaceFactory $totalsFactory
4854
* @param DataObjectHelper $dataObjectHelper
4955
* @param ItemConverter $itemConverter
5056
* @param CouponManagementInterface $couponService
5157
* @param TotalsConverter $totalsConverter
58+
* @param UpdateProductOptionValues $updateProductOptionValues
5259
*/
5360
public function __construct(
5461
TotalsInterfaceFactory $totalsFactory,
5562
DataObjectHelper $dataObjectHelper,
5663
ItemConverter $itemConverter,
5764
CouponManagementInterface $couponService,
58-
TotalsConverter $totalsConverter
65+
TotalsConverter $totalsConverter,
66+
UpdateProductOptionValues $updateProductOptionValues
5967
) {
6068
$this->totalsFactory = $totalsFactory;
6169
$this->dataObjectHelper = $dataObjectHelper;
6270
$this->itemConverter = $itemConverter;
6371
$this->couponService = $couponService;
6472
$this->totalsConverter = $totalsConverter;
73+
$this->updateProductOptionValues = $updateProductOptionValues;
6574
}
6675

6776
/**
@@ -83,6 +92,7 @@ public function extract(CartInterface $quote): TotalsInterface
8392
TotalsInterface::class
8493
);
8594
$items = array_map([$this->itemConverter, 'modelToDataObject'], $quote->getAllVisibleItems());
95+
$this->updateProductOptionValues->updateValues($items);
8696
$calculatedTotals = $this->totalsConverter->process($addressTotals);
8797
$quoteTotals->setTotalSegments($calculatedTotals);
8898
$amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Bold\Checkout\Model\Quote\Result\Builder\ExtractCartTotals;
6+
7+
use Magento\Framework\Serialize\Serializer\Json;
8+
use Magento\Quote\Model\Cart\Totals\Item;
9+
10+
/**
11+
* Update product option names to full if needed.
12+
*/
13+
class UpdateProductOptionValues
14+
{
15+
/**
16+
* @var Json
17+
*/
18+
private $serializer;
19+
20+
/**
21+
* @param Json $serializer
22+
*/
23+
public function __construct(
24+
Json $serializer
25+
) {
26+
$this->serializer = $serializer;
27+
}
28+
29+
/**
30+
* Update product option names to full if needed.
31+
*
32+
* @param Item[] $items
33+
* @return void
34+
*/
35+
public function updateValues(array $items): void
36+
{
37+
foreach ($items as $item) {
38+
$changed = false;
39+
$options = $this->serializer->unserialize($item->getOptions());
40+
foreach ($options as $index => $option) {
41+
if (isset($option['full_view'])) {
42+
$options[$index]['value'] = $option['full_view'];
43+
$changed = true;
44+
}
45+
}
46+
if ($changed) {
47+
$item->setOptions($this->serializer->serialize($options));
48+
}
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)