Source of file OrderFormAddressValidator.php
Size: 1,916 Bytes - Last Modified: 2021-12-23T10:39:35+00:00
/var/www/docs.ssmods.com/process/src/src/Forms/Validation/OrderFormAddressValidator.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 | <?php namespace Sunnysideup\Ecommerce\Forms\Validation; use SilverStripe\Security\Member; /** * @Description: allows customer to make additional payments for their order * * @package: ecommerce * @authors: Silverstripe, Jeremy, Nicolaas */ class OrderFormAddressValidator extends ShopAccountFormValidator { /** * Ensures member unique id stays unique and other basic stuff... * * @param array $data = Form Data * @param mixed $allowExistingEmail * * @return bool */ public function php($data, $allowExistingEmail = false) { $this->form->saveDataToSession(); $allowExistingEmail = ! (bool) Member::currentUserID(); if (! isset($data['UseShippingAddress']) || ! $data['UseShippingAddress']) { foreach (array_keys($this->required) as $key) { if ('Shipping' === substr($key, 0, 8)) { unset($this->required[$key]); } } } $valid = parent::php($data, $allowExistingEmail); if ($this->form->uniqueMemberFieldCanBeUsed($data)) { //do nothing } else { $uniqueFieldName = Member::config()->get('unique_identifier_field'); $this->validationError( $uniqueFieldName, _t( 'OrderForm.EMAILFROMOTHERUSER', 'Sorry, an account with that email is already in use by another customer. If this is your email address then please log in first before placing your order.' ), 'required' ); $valid = false; } if (! $valid) { $this->form->sessionError( _t('OrderForm.ERRORINFORM', 'We could not proceed with your order, please check your errors below.'), 'error' ); } return $valid; } } |