ItemLabel = __("Item", "all-in-one-forms"); $this->QuantityLabel = __("Quantity", "all-in-one-forms"); $this->PriceLabel = __("Price", "all-in-one-forms"); $this->TotalLabel = __("Total", "all-in-one-forms"); $options = $this->GetAttributeValue('Options'); $this->ShowPrice = Sanitizer::GetBooleanValueFromPath($options, ['ShowPrice'], true); $this->ShowQuantity = Sanitizer::GetBooleanValueFromPath($options, ['ShowQuantity'], true); $this->ShowTotal = Sanitizer::GetBooleanValueFromPath($options, ['ShowTotal'], true); $fields = $this->FormBuilder->GetFields(true, true); $this->PricingFields = []; if($this->FormBuilder->GetRootForm()->IsTest) { $this->PricingFields[] = [ 'Label' => '[Test Field]', 'Quantity' => 2, 'Price' => 200 ]; }else foreach($fields as $field) { if($field->IsUsed() && $field->GetPrice() > 0 && !$field->IsFieldContainer()) { $parentQuantity = $field->GetForm()->GetQuantity();; if($field instanceof FBMultipleOptionsField) { $options = $field->GetSelectedOptions(); foreach($options as $currentOption) { if($currentOption->Price * $parentQuantity > 0) { $this->PricingFields[] = [ 'Label' => $currentOption->Label, 'Quantity' => $currentOption->Quantity * $parentQuantity, 'Price' => $currentOption->Price * $parentQuantity ]; } } }else{ if($field->GetPrice() * $parentQuantity > 0) { $this->PricingFields[] = [ 'Label' => $field->GetLabel(), 'Quantity' => $field->GetQuantity() * $parentQuantity, 'Price' => $field->GetPrice() * $parentQuantity ]; } } } } $this->FooterSpan = 1; if($this->ShowPrice) $this->FooterSpan++; if($this->ShowQuantity) $this->FooterSpan++; $this->Total = 0; $this->TotalQuantity = 0; foreach($this->PricingFields as $pricingField) { $this->Total += $pricingField['Price']; $this->TotalQuantity += $pricingField['Quantity']; } return $this; } public function FormatCurrency($amount) { return $this->FormBuilder->GetRootForm()->FormatCurrency($amount); } protected function GetTemplateName() { return 'core/Managers/HTMLGenerator/HTMLParsers/Templates/FieldSummaryTemplate/PriceBreakdownTemplate.twig'; } }