Skip to content

Commit

Permalink
Merge pull request #298 from franzholz/develop
Browse files Browse the repository at this point in the history
fix for voucher
  • Loading branch information
franzholz authored Oct 2, 2024
2 parents f6795d5 + 7c690c2 commit c358a27
Show file tree
Hide file tree
Showing 22 changed files with 94 additions and 70 deletions.
40 changes: 25 additions & 15 deletions Classes/Api/ActivityApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

use JambageCom\TtProducts\Api\ParameterApi;

class ActivityApi implements SingletonInterface
{
Expand All @@ -66,12 +67,17 @@ public function init($codes = []): void
if (empty($codes)) {
return;
}
$parameterApi = GeneralUtility::makeInstance(ParameterApi::class);
// $request = $parameterApi->getRequest();

$activityArray = [];
$subActivity = $this->subActivity;
$update = GeneralUtility::_POST('products_update') || GeneralUtility::_POST('products_update_x');
$info = GeneralUtility::_POST('products_info') || GeneralUtility::_POST('products_info_x');
$payment = GeneralUtility::_POST('products_payment') || GeneralUtility::_POST('products_payment_x');
$gpVars = GeneralUtility::_GP(TT_PRODUCTS_EXT);
$update = $parameterApi->getParameter('products_update') || $parameterApi->getParameter('products_update_x');
$info = $parameterApi->getParameter('products_info') || $parameterApi->getParameter('products_info_x');
$payment = $parameterApi->getParameter('products_payment') || $parameterApi->getParameter('products_payment_x');

$gpVars = $parameterApi->getParameter(TT_PRODUCTS_EXT);
debug($gpVars, '$gpVars');

if (
!$update &&
Expand All @@ -98,31 +104,35 @@ public function init($codes = []): void
}
}

if (GeneralUtility::_GP('products_clear_basket') || GeneralUtility::_GP('products_clear_basket_x')) {
if ($parameterApi->getParameter('products_clear_basket') || $parameterApi->getParameter('products_clear_basket_x')) {
$activityArray['products_clear_basket'] = true;
}
if (GeneralUtility::_GP('products_overview') || GeneralUtility::_GP('products_overview_x')) {

if ($parameterApi->getParameter('products_overview') || $parameterApi->getParameter('products_overview_x')) {
$activityArray['products_overview'] = true;
}

if (!$update) {
if (GeneralUtility::_GP('products_payment') || GeneralUtility::_GP('products_payment_x')) {
if ($parameterApi->getParameter('products_payment') || $parameterApi->getParameter('products_payment_x')) {
$activityArray['products_payment'] = true;
} elseif (GeneralUtility::_GP('products_info') || GeneralUtility::_GP('products_info_x')) {
} elseif ($parameterApi->getParameter('products_info') || $parameterApi->getParameter('products_info_x')) {
$activityArray['products_info'] = true;
}
}

if (GeneralUtility::_GP('products_customized_payment') || GeneralUtility::_GP('products_customized_payment_x')) {
if ($parameterApi->getParameter('products_customized_payment') || $parameterApi->getParameter('products_customized_payment_x')) {
$activityArray['products_customized_payment'] = true;
}
if (GeneralUtility::_GP('products_verify') || GeneralUtility::_GP('products_verify_x')) {

if ($parameterApi->getParameter('products_verify') || $parameterApi->getParameter('products_verify_x')) {
$activityArray['products_verify'] = true;
}
if (GeneralUtility::_GP('products_finalize') || GeneralUtility::_GP('products_finalize_x')) {

if ($parameterApi->getParameter('products_finalize') || $parameterApi->getParameter('products_finalize_x')) {
$activityArray['products_finalize'] = true;
}


$codeActivityArray = [];
$isBasketCode = false;
if (is_array($codes)) {
Expand All @@ -132,7 +142,7 @@ public function init($codes = []): void
$codeActivityArray['products_basket'] = true;
$isBasketCode = true;
break;
case 'INFO':
case 'INFO': // neu
if (
!(
!empty($activityArray['products_verify']) ||
Expand All @@ -158,7 +168,7 @@ public function init($codes = []): void
}

if (!empty($activityArray['products_verify'])) {
$isBasketCode = true;
$isBasketCode = true; // neu, damit verify gesetzt bleibt, wenn vorhanden
}
break;
case 'FINALIZE':
Expand Down Expand Up @@ -218,8 +228,7 @@ public function fixCountry($infoObj, $basketExtra, $conf): void
) {
$overwrite =
ControlApi::isOverwriteMode($infoArray);
$needsDeliveryAddress =
\tx_ttproducts_control_basket::needsDeliveryAddresss($basketExtra);
$needsDeliveryAddress = \tx_ttproducts_control_basket::needsDeliveryAddresss($basketExtra);
$infoObj->mapPersonIntoDelivery(
$basketExtra,
$overwrite,
Expand Down Expand Up @@ -276,6 +285,7 @@ public function transformActivities($activities)
$codeActivities['products_basket'] = false;
}
}

$sortedCodeActivities = [];
foreach ($codeActivityArray as $activity) { // You must keep the order of activities.
if (isset($codeActivities[$activity])) {
Expand Down
14 changes: 14 additions & 0 deletions Classes/Api/ParameterApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ public function getParameter($param)
return $value;
}

public function getPostParameter($param)
{
$request = $this->getRequest();
$value = $request->getParsedBody()[$param] ?? null;
return $value;
}

public function getGetParameter($param)
{
$request = $this->getRequest();
$value = $request->getQueryParams()[$param] ?? null;
return $value;
}

public function getParameterMerged($param)
{
$request = $this->getRequest();
Expand Down
6 changes: 4 additions & 2 deletions Classes/Controller/ActivityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ public function getErrorLabel(
$languageKey = '';
$context = GeneralUtility::makeInstance(Context::class);
$languageSubpath = '/Resources/Private/Language/';
$parameterApi = GeneralUtility::makeInstance(ParameterApi::class);

if ($checkRequired || $checkAllowed) {
$check = ($checkRequired ?: $checkAllowed);
Expand Down Expand Up @@ -444,7 +445,7 @@ public function getErrorLabel(
} elseif (
$pidagb &&
empty($_REQUEST['recs']['personinfo']['agb']) &&
empty(GeneralUtility::_GET('products_payment')) &&
empty($parameterApi->getGetParameter('products_payment')) &&
empty($infoArray['billing']['agb'])
) {
// so AGB has not been accepted
Expand Down Expand Up @@ -519,6 +520,7 @@ public function getContent(
$config = $cnf->getConfig();
$paymentScript = false;
$feUserRecord = CustomerApi::getFeUserRecord();
$parameterApi = GeneralUtility::makeInstance(ParameterApi::class);

if ($checkBasket && !$basketEmpty) {
$basketConf = $cnf->getBasketConf('minPrice'); // check the basket limits
Expand Down Expand Up @@ -662,7 +664,7 @@ public function getContent(
(
empty($pidagb) ||
!empty($_REQUEST['recs']['personinfo']['agb']) ||
($isPayment && GeneralUtility::_GET('products_payment')) ||
($isPayment && $parameterApi->getGetParameter('products_payment')) ||
!empty($infoArray['billing']['agb'])
)
) {
Expand Down
3 changes: 2 additions & 1 deletion api/class.tx_ttproducts_ts.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ public function processMemo(): void
{
$funcTablename = 'tt_products';
$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? [];
$piVars = GeneralUtility::_GPmerged('tt_products');
$parameterApi = GeneralUtility::makeInstance(ParameterApi::class);
$piVars = $parameterApi->getParameterMerged('tt_products');

tx_ttproducts_control_memo::process($funcTablename, $piVars, $conf);
}
Expand Down
10 changes: 7 additions & 3 deletions control/class.tx_ttproducts_control_access.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

use JambageCom\TtProducts\Api\ParameterApi;

class tx_ttproducts_control_access implements SingletonInterface
{
public static function getVariables(
Expand All @@ -53,7 +55,8 @@ public static function getVariables(
throw new Exception('ERROR in tt_products: The setup "update_code" must not be empty');
}

$updateCode = GeneralUtility::_GP('update_code') ?? '';
$parameterApi = GeneralUtility::makeInstance(ParameterApi::class);
$updateCode = $parameterApi->getParameter('update_code') ?? '';
$bRequireBEAdmin = ($conf['shopAdmin'] == 'BE');
$bIsAllowed = self::isAllowed($bRequireBEAdmin);

Expand All @@ -68,7 +71,7 @@ public static function getVariables(
$updateCode = ''; // the update code must not be used if it is wrong
}

$trackingCode = GeneralUtility::_GP('tracking') ?? '';
$trackingCode = $parameterApi->getParameter('tracking');
}

public static function isAllowed($bRequireBEAdmin)
Expand All @@ -90,7 +93,8 @@ public static function isValidUpdateCode($bRequireBEAdmin, $password, &$updateCo
$result = false;

if (self::isAllowed($bRequireBEAdmin)) {
$updateCode = GeneralUtility::_GP('update_code') ?? '';
$parameterApi = GeneralUtility::makeInstance(ParameterApi::class);
$updateCode = $parameterApi->getParameter('update_code');

if ($updateCode == $password) {
$result = true; // Means that the administrator of the website is authenticated.
Expand Down
2 changes: 1 addition & 1 deletion control/class.tx_ttproducts_control_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function doProcessing(
$pidListObj->setPageArray();

$postVar = self::getCommandVar();
$cmdData = GeneralUtility::_GP($postVar);
$cmdData = $parameterApi->getParameter($postVar) ?? [];

switch ($theCode) {
case 'DOWNLOAD':
Expand Down
2 changes: 1 addition & 1 deletion control/class.tx_ttproducts_control_product.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static function getPresetVariantArray(

$basketVar = $parameterApi->getBasketVar();
$presetVariantArray = [];
$basketArray = GeneralUtility::_GP($basketVar);
$basketArray = $parameterApi->getParameter($basketVar);

if (
isset($basketArray) && is_array($basketArray) &&
Expand Down
2 changes: 1 addition & 1 deletion control/class.tx_ttproducts_control_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function init(&$content, &$conf, &$config, $cObj, $pibaseClass, &$error_c
$markerObj = GeneralUtility::makeInstance('tx_ttproducts_marker');
$markerObj->init(
$conf,
$piVars
$piVars['backPID'] ?? $parameterApi->getParameter('backPID')
);

$searchViewObj = GeneralUtility::makeInstance('tx_ttproducts_search_view');
Expand Down
2 changes: 1 addition & 1 deletion control/class.tx_ttproducts_javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function set(
$code .= '
';
foreach ($ajaxConf as $k => $actConf) {
$pVar = GeneralUtility::_GP($k);
$pVar = $parameterApi->getParameter($k);
if (isset($pVar) && is_array($actConf[$pVar . '.'])) {
foreach ($actConf[$pVar . '.'] as $k2 => $v2) {
$code .= 'conf[' . $k2 . '] = ' . $v2 . '; ';
Expand Down
12 changes: 6 additions & 6 deletions control/class.tx_ttproducts_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function init(
if (count($requiredArray)) {
foreach ($requiredArray as $k => $pivar) {
if ($pivar && $pivar != 'empty') {
$gpVar = GeneralUtility::_GP($pivar);
$gpVar = $parameterApi->getParameter($pivar);
if (
!isset($piVars[$pivar]) &&
!isset($gpVar)
Expand Down Expand Up @@ -399,7 +399,7 @@ public function run(&$cObj, $pibaseClass, &$errorCode, $content = '', $bRunAjax
}
}
$updateMode = 0;
if (GeneralUtility::_GP('mode_update')) {
if ($parameterApi->getParameter('mode_update')) {
$updateMode = 1;
}

Expand Down Expand Up @@ -468,7 +468,7 @@ public function run(&$cObj, $pibaseClass, &$errorCode, $content = '', $bRunAjax
$voucher = $tablesObj->get('voucher');
if (is_object($voucher) && $voucher->isEnabled()) {
$recs = tx_ttproducts_control_basket::getRecs();
$voucher->doProcessing($recs);
$voucher->doProcessing($recs, $basketObj->getCalculatedArray(), $feUserRecord);
}

if (!empty($voucher)) {
Expand Down Expand Up @@ -1165,7 +1165,7 @@ public function products_tracking(
$templateSuffix,
$theCode,
$conf
) { // GeneralUtility::_GP('tracking')
) {
$cnf = GeneralUtility::makeInstance('tx_ttproducts_config');
$urlObj = GeneralUtility::makeInstance('tx_ttproducts_url_view');
$updateCode = '';
Expand Down Expand Up @@ -1206,7 +1206,7 @@ public function products_tracking(
$tracking->init(
$cObj
);
$orderRecord = GeneralUtility::_GP('orderRecord');
$orderRecord = $parameterApi->getParameter('orderRecord');
if (
!empty($_REQUEST['userNotification']) &&
isset($orderRecord) &&
Expand Down Expand Up @@ -1349,7 +1349,7 @@ public function products_display(
$bSingleFromList
) {
$extVars = $piVars['variants'] ?? '';
$extVars = ($extVars ?: GeneralUtility::_GP('ttp_extvars'));
$extVars = ($extVars ?? $parameterApi->getParameter('ttp_extvars'));
$showAmount = $cnf->getBasketConf('view', 'showAmount');

if (!count($this->tt_product_single)) {
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'title' => 'Shop System',
'description' => 'Advanced versions at ttproducts.de. Documented in the E-Book "Der TYPO3-Webshop" - Shop with listing in multiple languages, with order tracking, product variants, support for transactor extension, bill, creditpoint and voucher system.',
'state' => 'stable',
'version' => '2.15.15',
'version' => '2.15.16',
'manual' => true,
'author' => 'Franz Holzinger',
'author_company' => 'jambage.com',
Expand Down
4 changes: 3 additions & 1 deletion hooks/class.tx_ttproducts_ws_flexslider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use WapplerSystems\WsFlexslider\Controller\FlexsliderController;
use JambageCom\TtProducts\Api\ParameterApi;

class tx_ttproducts_ws_flexslider
{
Expand All @@ -48,7 +49,8 @@ public function getUid(
) {
$uid = 0;

$params = GeneralUtility::_GP('tt_products');
$parameterApi = GeneralUtility::makeInstance(ParameterApi::class);
$params = $parameterApi->getParameter('tt_products');
if (isset($params) && is_array($params)) {
$uid = $params['cat'];
}
Expand Down
2 changes: 1 addition & 1 deletion lib/class.tx_ttproducts_tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function getTrackingInformation(
$recipient,
$status_log_element,
$statusCodeArray,
GeneralUtility::_GP('tracking'),
$parameterApi->getParameter('tracking'),
$orderRow,
$orderData,
$templateCode,
Expand Down
19 changes: 5 additions & 14 deletions marker/class.tx_ttproducts_marker.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class tx_ttproducts_marker implements SingletonInterface
*
* @param array array urls which should be overridden with marker key as index
*/
public function init($conf, $piVars)
public function init($conf, $backPID)
{
$this->markerArray = ['CATEGORY', 'PRODUCT', 'ARTICLE'];
$markerFile = $conf['markerFile'] ?? '';
Expand Down Expand Up @@ -104,7 +104,7 @@ public function init($conf, $piVars)
}
$locallang = $languageObj->getLocallang();
$LLkey = $languageObj->getLocalLangKey();
$this->setGlobalMarkerArray($conf, $piVars, $locallang, $LLkey);
$this->setGlobalMarkerArray($conf, $backPID, $locallang, $LLkey);
$errorCode = $this->getErrorCode();

return !is_array($errorCode) || (count($errorCode) == 0) ? true : false;
Expand Down Expand Up @@ -148,7 +148,7 @@ public function replaceGlobalMarkers(&$content, $markerArray = [])
/**
* getting the global markers.
*/
public function setGlobalMarkerArray($conf, $piVars, $locallang, $LLkey): void
public function setGlobalMarkerArray($conf, $backPID, $locallang, $LLkey): void
{
$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$markerArray = [];
Expand Down Expand Up @@ -184,20 +184,11 @@ public function setGlobalMarkerArray($conf, $piVars, $locallang, $LLkey): void
$markerArray['###PID_' . strtoupper($function) . '###'] = intval($conf['PID' . $function] ?? 0);
}
$markerArray['###SHOPADMIN_EMAIL###'] = $conf['orderEmail_from'] ?? 'undefined';
$lang = GeneralUtility::_GET('L');

if ($lang != '') {
$markerArray['###LANGPARAM###'] = '&L=' . $lang;
} else {
$markerArray['###LANGPARAM###'] = '';
}
$markerArray['###LANG###'] = $lang;
$markerArray['###LANG###'] = '';
$markerArray['###LANGUAGE###'] = $GLOBALS['TSFE']->config['config']['language'] ?? '';
$markerArray['###LOCALE_ALL###'] = $GLOBALS['TSFE']->config['config']['locale_all'] ?? '';

$backPID = $piVars['backPID'] ?? '';
$backPID = ($backPID ?: GeneralUtility::_GP('backPID'));
$backPID = ($backPID ?: (!empty($conf['PIDlistDisplay']) ? $conf['PIDlistDisplay'] : $GLOBALS['TSFE']->id ?? 0));
$backPID = ($backPID ?: $conf['PIDlistDisplay'] ?? ($GLOBALS['TSFE']->id ?? 0));
$markerArray['###BACK_PID###'] = $backPID;

// Call all addGlobalMarkers hooks at the end of this method
Expand Down
Loading

0 comments on commit c358a27

Please sign in to comment.