Last active
January 14, 2021 14:06
-
-
Save mfMeds/af09797e0863248c30271b5a0f3e1f0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (TYPO3_MODE === 'FE') { | |
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['showCartActionAfterCartWasLoaded'][] = \MyVendor\MyExtension\Hooks\FrontendUserHook::class . '->showCartActionAfterCartWasLoaded'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Für neuere Versionen der Extension hat sich das NameSpace geändert: | |
\Extcode\Cart\Domain\Model\Order\Address- >\Extcode\Cart\Domain\Model\Order\BillingAddress | |
<?php | |
namespace MyVendor\MyExtension\Hooks; | |
use DmitryDulepov\Realurl\Configuration\ConfigurationReader; | |
/** | |
* FrontendUserHook | |
* | |
* @author Daniel Lorenz <[email protected]> | |
*/ | |
class FrontendUserHook | |
{ | |
/** | |
* @param array &$parameters | |
*/ | |
public function showCartActionAfterCartWasLoaded(&$parameters, $refObj) | |
{ | |
$billingAddress = $parameters['billingAddress']; | |
$request = $parameters['request']; | |
if ($billingAddress instanceof \Extcode\Cart\Domain\Model\Order\BillingAddress) { | |
return; | |
} | |
if ($request && $request->getOriginalRequest() && $request->getOriginalRequest()->getArguments()) { | |
return; | |
} | |
$feUserUid = (int)$GLOBALS['TSFE']->fe_user->user['uid']; | |
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( | |
\TYPO3\CMS\Extbase\Object\ObjectManager::class | |
); | |
$frontendUserRepository = $objectManager->get( | |
\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository::class | |
); | |
$frontenUser = $frontendUserRepository->findByUid($feUserUid); | |
if ($frontenUser instanceof \TYPO3\CMS\Extbase\Domain\Model\FrontendUser) { | |
$billingAddress = $objectManager->get( | |
\Extcode\Cart\Domain\Model\Order\BillingAddress::class | |
); | |
$billingAddress->setEmail($frontenUser->getEmail()); | |
$billingAddress->setTitle($frontenUser->getTitle()); | |
$billingAddress->setFirstName($frontenUser->getFirstName()); | |
$billingAddress->setLastName($frontenUser->getLastName()); | |
$billingAddress->setCompany($frontenUser->getCompany()); | |
$billingAddress->setStreet($frontenUser->getAddress()); | |
$billingAddress->setZip($frontenUser->getZip()); | |
$billingAddress->setCity($frontenUser->getCity()); | |
} | |
$parameters['billingAddress'] = $billingAddress; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a version for TYPO 10.4:
https://gist.github.com/martinlipp/83a145b1b3faa0ed6f6f5d74462cbc37