Skip to content
GitLab
Erkunden
Anmelden
Registrieren
Primärnavigation
Suchen oder aufrufen …
Projekt
coupons
Verwalten
Aktivität
Mitglieder
Labels
Planen
Tickets
6
Ticketübersichten
Meilensteine
Wiki
Code
Merge Requests
0
Repository
Branch
Commits
Tags
Repository-Diagramm
Revisionen vergleichen
Build
Pipelines
Aufgaben
Pipeline-Zeitpläne
Artefakte
Bereitstellung
Releases
Betreiben
Umgebungen
Überwachen
Vorfälle
Service-Desk
Analysieren
Wertschöpfungskettenanalyse
Mitwirkenden-Analyse
CI/CD-Analyse
Repository-Analysen
Hilfe
Hilfe
Support
GitLab-Dokumentation
GitLab-Pläne vergleichen
Community-Forum
Zu GitLab beitragen
Feedback geben
Tastenkürzel
?
Code-Schnipsel
Gruppen
Projekte
Show more breadcrumbs
QUIQQER
coupons
Commits
53cd7010
Bestätigt
Commit
53cd7010
erstellt
vor 2 Jahren
von
Henning Leutz
Dateien durchsuchen
Optionen
Downloads
Patches
Einfaches Diff
refactor: code style
Übergeordneter
8e6d6642
No related branches found
Branches enthält Commit
No related tags found
Tags enthält Commit
Keine zugehörigen Merge Requests gefunden
Änderungen
1
Leerzeichenänderungen ausblenden
Inline
Nebeneinander
1 geänderte Datei
src/QUI/ERP/Coupons/Events.php
+38
-28
38 Ergänzungen, 28 Löschungen
src/QUI/ERP/Coupons/Events.php
wird angezeigt
mit
38 Ergänzungen
und
28 Löschungen
src/QUI/ERP/Coupons/Events.php
+
38
−
28
Zeige Datei @
53cd7010
...
...
@@ -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
);
}
}
...
...
This diff is collapsed.
Zum Erweitern klicken.
Vorschau
0%
Wiederholen
oder
Neue Datei anhängen
.
Abbrechen
You are about to add
0
people
to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Kommentar speichern
Abbrechen
Bitte
registrieren
oder
Anmelden
zum Kommentieren