Skip to content
Code-Schnipsel Gruppen Projekte
Bestätigt Commit 53cd7010 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

refactor: code style

Übergeordneter 8e6d6642
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -2,6 +2,7 @@
namespace QUI\ERP\Coupons;
use Exception;
use QUI;
use QUI\ERP\Accounting\Calc as ErpCalc;
use QUI\ERP\Coupons\Handler as CouponsHandler;
......@@ -17,6 +18,15 @@
use QUI\ERP\Products\Interfaces\ProductInterface;
use Quiqqer\Engine\Collector;
use function array_merge;
use function array_search;
use function array_unique;
use function in_array;
use function is_array;
use function is_string;
use function json_decode;
use function json_encode;
/**
* Class Events
*
......@@ -34,7 +44,7 @@ public static function onPackageSetup(QUI\Package\Package $Package)
{
try {
self::createProductFields();
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
}
......@@ -69,7 +79,7 @@ public static function templateOrderProcessBasketEnd(Collector $Collector, $Bask
$CouponCode = Handler::getCouponCodeByCode($code);
$CouponCode->checkRedemption(QUI::getUserBySession());
$CouponCode->addToOrder($Order);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
}
}
......@@ -94,11 +104,11 @@ public static function onOrderProcess(QUI\ERP\Order\OrderProcess $OrderProcess)
$coupons = QUI::getSession()->get('quiqqer-coupons');
if (\is_string($coupons)) {
$coupons = \json_decode($coupons, true);
if (is_string($coupons)) {
$coupons = json_decode($coupons, true);
}
if (!\is_array($coupons)) {
if (!is_array($coupons)) {
$coupons = [];
}
......@@ -106,7 +116,7 @@ public static function onOrderProcess(QUI\ERP\Order\OrderProcess $OrderProcess)
$coupons[] = $_GET['coupon'];
}
$coupons = \array_unique($coupons);
$coupons = array_unique($coupons);
if (empty($coupons)) {
return;
......@@ -163,8 +173,8 @@ public static function onQuiqqerOrderBasketRemovePos(
// custom data has code params, so article is an coupon code
// we need to delete it
if (\in_array($articleCouponCode, $orderCoupons)) {
$pos = \array_search($articleCouponCode, $orderCoupons);
if (in_array($articleCouponCode, $orderCoupons)) {
$pos = array_search($articleCouponCode, $orderCoupons);
unset($orderCoupons[$pos]);
$Order->setData('quiqqer-coupons', $orderCoupons);
......@@ -179,15 +189,15 @@ public static function onQuiqqerOrderBasketRemovePos(
// we need to delete it
$coupons = QUI::getSession()->get('quiqqer-coupons');
if (\is_string($coupons)) {
$coupons = \json_decode($coupons, true);
if (is_string($coupons)) {
$coupons = json_decode($coupons, true);
}
if (!\is_array($coupons) || empty($coupons)) {
if (!is_array($coupons) || empty($coupons)) {
return;
}
if (!\in_array($customData['code'], $coupons)) {
if (!in_array($customData['code'], $coupons)) {
return;
}
......@@ -204,7 +214,7 @@ public static function onQuiqqerOrderBasketRemovePos(
if (empty($newCouponList)) {
QUI::getSession()->remove('quiqqer-coupons');
} else {
QUI::getSession()->set('quiqqer-coupons', \json_encode($newCouponList));
QUI::getSession()->set('quiqqer-coupons', json_encode($newCouponList));
}
}
......@@ -223,18 +233,18 @@ public static function onQuiqqerOrderBasketToOrder(
$coupons = $Order->getDataEntry('quiqqer-coupons');
$sessionCoupons = QUI::getSession()->get('quiqqer-coupons');
if (!\is_array($coupons)) {
if (!is_array($coupons)) {
$coupons = [];
}
if (\is_string($sessionCoupons)) {
$sessionCoupons = \json_decode($sessionCoupons, true);
if (is_string($sessionCoupons)) {
$sessionCoupons = json_decode($sessionCoupons, true);
if (\is_array($sessionCoupons)) {
$coupons = \array_merge($coupons, $sessionCoupons);
if (is_array($sessionCoupons)) {
$coupons = array_merge($coupons, $sessionCoupons);
}
$coupons = \array_unique($coupons);
$coupons = array_unique($coupons);
self::addSessionCouponsToOrder($Order, $sessionCoupons);
}
......@@ -266,7 +276,7 @@ public static function onQuiqqerOrderBasketToOrder(
/* @var $Coupon CouponCode */
try {
$Coupon = Handler::getCouponCodeByCode($coupon);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
continue;
}
......@@ -359,7 +369,7 @@ public static function onQuiqqerOrderSuccessful($Order)
try {
$CouponCode = CouponsHandler::getCouponCodeByCode($couponCode);
$CouponCode->redeem($Order->getCustomer(), $Order);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
}
......@@ -371,7 +381,7 @@ public static function onQuiqqerOrderSuccessful($Order)
*/
protected static function addSessionCouponsToOrder($Order, $coupons)
{
if (!\is_array($coupons)) {
if (!is_array($coupons)) {
return;
}
......@@ -416,13 +426,13 @@ protected static function addCouponToOrder($Order, $coupon)
$coupons = $Order->getDataEntry('quiqqer-coupons');
$coupons[] = $code;
$coupons = \array_unique($coupons);
$coupons = array_unique($coupons);
$Order->setData('quiqqer-coupons', $coupons);
$Order->update();
$CouponCode->addToOrder($Order);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
}
}
......@@ -610,7 +620,7 @@ protected static function createProductFields()
try {
Fields::getField($fieldId);
continue;
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
// Field does not exist -> create it
}
......@@ -627,7 +637,7 @@ protected static function createProductFields()
'options' => !empty($field['options']) ? $field['options'] : null,
'requiredField' => !empty($field['requiredField']) ? 1 : 0
]);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
continue;
}
......@@ -679,7 +689,7 @@ public static function onQuiqqerProductsProductCreate(ProductInterface $Product)
$Field->setValue($value);
$Product->addOwnField($Field);
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
}
......@@ -693,7 +703,7 @@ public static function onQuiqqerProductsProductCreate(ProductInterface $Product)
try {
$Product->update(QUI::getUsers()->getSystemUser());
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
}
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren