Prepare submitted order components
@param array $submitted
433767
protected function prepareSubmittedOrderComponentsCheckout(array &$submitted)
    {
        foreach ($submitted['data']['components'] as $id => &$component) {

            if (!isset($component['price'])) {
                continue;
            }

            if (empty($component['price'])) {
                unset($submitted['data']['components'][$id]);
                continue;
            }

            $component['currency'] = $submitted['currency'];
            $component['price'] = $this->price->amount($component['price'], $submitted['currency']);
        }
    }
795476
public function trigger(array &$submitted, array $options)
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateTrigger();
        $this->validateBool('status');
        $this->validateName();
        $this->validateStoreId();
        $this->validateWeight();
        $this->validateConditionsTrigger();

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
836320
public function process($data, $form)
    {
        $submittedForm = SubmittedForm::create();
        $submittedForm->SubmittedByID = Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0;
        $submittedForm->ParentClass = get_class($this->data());
        $submittedForm->ParentID = $this->ID;

        // if saving is not disabled save now to generate the ID
        if (!$this->DisableSaveSubmissions) {
            $submittedForm->write();
        }

        $attachments = [];
        $submittedFields = ArrayList::create();

        foreach ($this->data()->Fields() as $field) {
            if (!$field->showInReports()) {
                continue;
            }

            $submittedField = $field->getSubmittedFormField();
            $submittedField->ParentID = $submittedForm->ID;
            $submittedField->Name = $field->Name;
            $submittedField->Title = $field->getField('Title');

            // save the value from the data
            if ($field->hasMethod('getValueFromData')) {
                $submittedField->Value = $field->getValueFromData($data);
            } else {
                if (isset($data[$field->Name])) {
                    $submittedField->Value = $data[$field->Name];
                }
            }

            if (!empty($data[$field->Name])) {
                if (in_array(EditableFileField::class, $field->getClassAncestry())) {
                    if (!empty($_FILES[$field->Name]['name'])) {
                        $foldername = $field->getFormField()->getFolderName();

                        // create the file from post data
                        $upload = Upload::create();
                        $file = File::create();
                        $file->ShowInSearch = 0;
                        try {
                            $upload->loadIntoFile($_FILES[$field->Name], $file, $foldername);
                        } catch (ValidationException $e) {
                            $validationResult = $e->getResult();
                            foreach ($validationResult->getMessages() as $message) {
                                $form->sessionMessage($message['message'], ValidationResult::TYPE_ERROR);
                            }
                            Controller::curr()->redirectBack();
                            return;
                        }

                        // write file to form field
                        $submittedField->UploadedFileID = $file->ID;

                        // attach a file only if lower than 1MB
                        if ($file->getAbsoluteSize() < 1024 * 1024 * 1) {
                            $attachments[] = $file;
                        }
                    }
                }
            }

            $submittedField->extend('onPopulationFromField', $field);

            if (!$this->DisableSaveSubmissions) {
                $submittedField->write();
            }

            $submittedFields->push($submittedField);
        }

        $emailData = [
            'Sender' => Security::getCurrentUser(),
            'HideFormData' => false,
            'Fields' => $submittedFields,
            'Body' => '',
        ];

        $this->extend('updateEmailData', $emailData, $attachments);

        // email users on submit.
        if ($recipients = $this->FilteredEmailRecipients($data, $form)) {
            foreach ($recipients as $recipient) {
                $email = Email::create()
                    ->setHTMLTemplate('email/SubmittedFormEmail')
                    ->setPlainTemplate('email/SubmittedFormEmailPlain');

                // Merge fields are used for CMS authors to reference specific form fields in email content
                $mergeFields = $this->getMergeFieldsMap($emailData['Fields']);

                if ($attachments) {
                    foreach ($attachments as $file) {
                        /** @var File $file */
                        if ((int) $file->ID === 0) {
                            continue;
                        }

                        $email->addAttachmentFromData(
                            $file->getString(),
                            $file->getFilename(),
                            $file->getMimeType()
                        );
                    }
                }

                if (!$recipient->SendPlain && $recipient->emailTemplateExists()) {
                    $email->setHTMLTemplate($recipient->EmailTemplate);
                }

                // Add specific template data for the current recipient
                $emailData['HideFormData'] =  (bool) $recipient->HideFormData;
                // Include any parsed merge field references from the CMS editor - this is already escaped
                $emailData['Body'] = SSViewer::execute_string($recipient->getEmailBodyContent(), $mergeFields);

                // Push the template data to the Email's data
                foreach ($emailData as $key => $value) {
                    $email->addData($key, $value);
                }

                // check to see if they are a dynamic reply to. eg based on a email field a user selected
                $emailFrom = $recipient->SendEmailFromField();
                if ($emailFrom && $emailFrom->exists()) {
                    $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailFromField()->Name);

                    if ($submittedFormField && is_string($submittedFormField->Value)) {
                        $email->setReplyTo(explode(',', $submittedFormField->Value));
                    }
                } elseif ($recipient->EmailReplyTo) {
                    $email->setReplyTo(explode(',', $recipient->EmailReplyTo));
                }

                // check for a specified from; otherwise fall back to server defaults
                if ($recipient->EmailFrom) {
                    $email->setFrom(explode(',', $recipient->EmailFrom));
                }

                // check to see if they are a dynamic reciever eg based on a dropdown field a user selected
                $emailTo = $recipient->SendEmailToField();
                if ($emailTo && $emailTo->exists()) {
                    $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailToField()->Name);

                    if ($submittedFormField && is_string($submittedFormField->Value)) {
                        $email->setTo(explode(',', $submittedFormField->Value));
                    } else {
                        $email->setTo(explode(',', $recipient->EmailAddress));
                    }
                } else {
                    $email->setTo(explode(',', $recipient->EmailAddress));
                }

                // check to see if there is a dynamic subject
                $emailSubject = $recipient->SendEmailSubjectField();
                if ($emailSubject && $emailSubject->exists()) {
                    $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailSubjectField()->Name);

                    if ($submittedFormField && trim($submittedFormField->Value)) {
                        $email->setSubject($submittedFormField->Value);
                    } else {
                        $email->setSubject(SSViewer::execute_string($recipient->EmailSubject, $mergeFields));
                    }
                } else {
                    $email->setSubject(SSViewer::execute_string($recipient->EmailSubject, $mergeFields));
                }

                $this->extend('updateEmail', $email, $recipient, $emailData);

                if ((bool)$recipient->SendPlain) {
                    $body = strip_tags($recipient->getEmailBodyContent()) . "\n";
                    if (isset($emailData['Fields']) && !$emailData['HideFormData']) {
                        foreach ($emailData['Fields'] as $field) {
                            $body .= $field->Title . ': ' . $field->Value . " \n";
                        }
                    }

                    $email->setBody($body);
                    $email->sendPlain();
                } else {
                    $email->send();
                }
            }
        }

        $submittedForm->extend('updateAfterProcess');

        $session = $this->getRequest()->getSession();
        $session->clear("FormInfo.{$form->FormName()}.errors");
        $session->clear("FormInfo.{$form->FormName()}.data");

        $referrer = (isset($data['Referrer'])) ? '?referrer=' . urlencode($data['Referrer']) : "";

        // set a session variable from the security ID to stop people accessing
        // the finished method directly.
        if (!$this->DisableAuthenicatedFinishAction) {
            if (isset($data['SecurityID'])) {
                $session->set('FormProcessed', $data['SecurityID']);
            } else {
                // if the form has had tokens disabled we still need to set FormProcessed
                // to allow us to get through the finshed method
                if (!$this->Form()->getSecurityToken()->isEnabled()) {
                    $randNum = rand(1, 1000);
                    $randHash = md5($randNum);
                    $session->set('FormProcessed', $randHash);
                    $session->set('FormProcessedNum', $randNum);
                }
            }
        }

        if (!$this->DisableSaveSubmissions) {
            $session->set('userformssubmission'. $this->ID, $submittedForm->ID);
        }

        return $this->redirect($this->Link('finished') . $referrer . $this->config()->get('finished_anchor'));
    }
557345
public function address(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateAddress();
        $this->validateCountryAddress();

        $this->validateStateAddress();
        $this->validateCityAddress();
        $this->validateTypeAddress();
        $this->validateFieldsAddress();
        $this->validateUserIdAddress();
        $this->validateData();

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
260246
public function store(array &$submitted, array $options)
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateStore();
        $this->validateBool('status');
        $this->validateDomainStore();
        $this->validateBasepathStore();
        $this->validateName();
        $this->validateDataStore();
        $this->validateImagesStore();
        $this->validateDefaultStore();

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
153804
public function required(array $submitted, array $options)
    {
        $options += array(
            'field' => null,
            'label' => null
        );

        $value = gplcart_array_get($submitted, $options['field']);

        if (empty($value)) {
            return $this->setErrorRequired($options['field'], $options['label']);
        }

        return true;
    }
92356
protected function submitAddProduct()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->setSubmitted('form', true); // Internal flag. Specifies that the product submitted manually
        $this->validateComponent('product');
        $this->addProduct();
    }
253188
protected function submitAddPage()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->validateComponent('page');
        $this->addPage();
    }
1025905
public function process()
    {
        if (
            $this->getForm()->getHiddenField($this->id . '_submitted') === null
        ) {
            return;
        }

        parent::process();

        foreach ($this->values as $option_value) {
            $this->getEntryWidget($option_value)->process();
        }
    }
555116
public function json(array $submitted, array $options)
    {
        $options += array(
            'field' => null,
            'label' => null
        );

        $value = gplcart_array_get($submitted, $options['field']);

        json_decode($value);

        if (json_last_error() === JSON_ERROR_NONE) {
            return true;
        }

        return $this->setErrorInvalid($options['field'], $options['label']);
    }
1133649
public function set_submit() {
		if ( ! $this->child['config']->is_submitted() ) {
			$data = $this->child['config']->get_data();
			$this->child['config']->struct['attributes']['data-default'] = wp_json_encode( $data );
			$data_template = $this->drill_in( $data );

			$this->child['config']->set_data( $data_template );
		}
	}
1025272
protected function prepareOrderCheckoutComplete(array &$order)
    {
        $this->setItemTotalFormatted($order, $this->price);
        $this->setItemTotalFormattedNumber($order, $this->price);
    }
1167545
protected function prepareOrderComponentsCheckout($calculated)
    {
        $component_types = $this->order->getComponentTypes();

        $components = array();
        foreach ($calculated['components'] as $type => $component) {

            $components[$type] = array(
                'price' => $component['price'],
                'price_decimal' => $this->price->decimal($component['price'], $calculated['currency']),
                'price_formatted' => $this->price->format($component['price'], $calculated['currency'])
            );

            if (empty($component['rule'])) {
                $components[$type]['name'] = $component_types[$type];
                continue;
            }

            $components[$type]['rule'] = $component['rule'];
            $components[$type]['name'] = $component['rule']['name'];
        }

        return $components;
    }
1192678
protected function submitAddCity()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->validateComponent('city');
        $this->addCity();
    }
129563
public function productBundle(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateProductProductBundle();
        $this->validateItemsProductBundle();

        return $this->getResult();
    }
689870
public function zone(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateZone();
        $this->validateBool('status');
        $this->validateTitle();

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
707624
public function setOrder(array $order)
    {
        // Check requirements
        if (
            in_array(self::LABEL, $order) === false ||
            in_array(self::COMPONENT, $order) === false ||
            in_array(self::MESSAGE, $order) === false
        ) {
            throw new Doozr_Form_Service_Exception(
                'Alda'
            );
        }

        $this->order = $order;
    }