Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfiguredOptions.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 
16 {
25  public function getItemOptionsValue(float $basePrice, ItemInterface $item): float
26  {
27  $product = $item->getProduct();
28  $value = 0.;
29  $optionIds = $item->getOptionByCode('option_ids');
30  if ($optionIds) {
31  foreach (explode(',', $optionIds->getValue()) as $optionId) {
32  $option = $product->getOptionById($optionId);
33  if ($option !== null) {
34  $itemOption = $item->getOptionByCode('option_' . $option->getId());
36  $group = $option->groupFactory($option->getType())
37  ->setOption($option)
38  ->setConfigurationItem($item)
39  ->setConfigurationItemOption($itemOption);
40  $value += $group->getOptionPrice($itemOption->getValue(), $basePrice);
41  }
42  }
43  }
44 
45  return $value;
46  }
47 }
$group
Definition: sections.phtml:16
$value
Definition: gender.phtml:16