Skip to content
Code-Schnipsel Gruppen Projekte
Commit 93557117 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

Merge branch 'next-2.x' into 'main'

Next 2.x

See merge request !14
Übergeordnete 059ae672 db098393
No related branches found
No related tags found
2 Merge Requests!15Update 'next-3.x' with latest changes from 'main',!14Next 2.x
Pipeline #12952 mit Warnungen bestanden mit Phase
in 43 Sekunden
# Ignore developer files when exporting
.gitattributes export-ignore
.gitignore export-ignore
.gitlab-ci.yml export-ignore
.phive export-ignore
captainhook.json export-ignore
phpcs.xml.dist export-ignore
phpstan-baseline.neon export-ignore
phpstan.dist.neon export-ignore
phpunit.dist.xml export-ignore
tests export-ignore
# Explicitly set file type and line endings for PHP files, improves git diff output
*.php text eol=lf diff=php
\ No newline at end of file
tools/ tools/
phpstan.neon phpstan.neon
.phpunit.result.cache .phpunit.result.cache
phpunit.xml phpunit.xml
\ No newline at end of file tools/
phpstan.neon
.phpunit.result.cache
phpunit.xml
include: include:
- project: 'quiqqer/stabilization/semantic-release' - component: dev.quiqqer.com/quiqqer/stabilization/ci-cd-components/quiqqer-package-bundle/quiqqer-package-bundle@main
file: '/ci-templates/.gitlab-ci.yml'
# Remove the entire phpunit-php8.1 block, to allow PHPUnit to run on PHP 8.1 in your pipeline
phpunit-php8.1:
rules:
- when: never
# Remove the entire phpunit-php8.2 block, to allow PHPUnit to run on PHP 8.2 in your pipeline
phpunit-php8.2:
rules:
- when: never
# Remove the entire phpunit-php8.3 block, to allow PHPUnit to run on PHP 8.3 in your pipeline
phpunit-php8.3:
rules:
- when: never
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive"> <phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="^1.10.67" installed="1.10.67" location="./tools/phpstan" copy="false"/> <phar name="phpstan" version="1.11.8" installed="1.11.8" location="./tools/phpstan" copy="false"/>
<phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/>
<phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/>
<phar name="captainhook" version="^5.23.3" installed="5.23.3" location="./tools/captainhook" copy="false"/>
</phive> </phive>
# Contributing
This package follows the [QUIQQER contribution guidelines](https://dev.quiqqer.com/quiqqer/stabilization/documentation/-/wikis/home).
\ No newline at end of file
...@@ -29,3 +29,26 @@ div + .quiqqer-coupons-field { ...@@ -29,3 +29,26 @@ div + .quiqqer-coupons-field {
.quiqqer-coupons-remove .fa { .quiqqer-coupons-remove .fa {
margin-right: 0; margin-right: 0;
} }
/**
* Simple Checkout
*/
.quiqqer-coupons-field-simpleCheckout {
margin-top: 20px;
margin-left: 0 !important;
}
.quiqqer-coupons-field-simpleCheckout .quiqqer-coupons-couponcodeinput {
background: var(--_sectionBgColor);
display: flex;
padding: var(--_sectionPadding);
}
.quiqqer-coupons-field-simpleCheckout .quiqqer-coupons-couponcodeinput label {
flex-grow: 1;
}
.quiqqer-coupons-field-simpleCheckout .quiqqer-coupons-couponcodeinput-input {
width: calc(100% - 1rem);
}
\ No newline at end of file
...@@ -20,25 +20,25 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -20,25 +20,25 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
'text!package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput.html', 'text!package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput.html',
'css!package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput.css' 'css!package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput.css'
], function (QUI, QUIControl, QUILoader, Sessions, CouponCodes, QUIAjax, QUILocale, Mustache, template) { ], function(QUI, QUIControl, QUILoader, Sessions, CouponCodes, QUIAjax, QUILocale, Mustache, template) {
"use strict"; 'use strict';
var lg = 'quiqqer/coupons'; var lg = 'quiqqer/coupons';
return new Class({ return new Class({
Extends: QUIControl, Extends: QUIControl,
Type : 'package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', Type: 'package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput',
Binds: [ Binds: [
'$submit' '$submit'
], ],
initialize: function (options) { initialize: function(options) {
this.parent(options); this.parent(options);
this.$Input = null; this.$Input = null;
this.Loader = new QUILoader(); this.Loader = new QUILoader();
this.$running = false; this.$running = false;
this.addEvents({ this.addEvents({
...@@ -49,23 +49,27 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -49,23 +49,27 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
/** /**
* Event: onInject * Event: onInject
*/ */
$onInject: function () { $onInject: function() {
var self = this; var self = this;
var lgPrefix = 'controls.frontend.CouponCodeInput.template.'; var lgPrefix = 'controls.frontend.CouponCodeInput.template.';
this.$Elm.addClass('quiqqer-coupons-field'); this.$Elm.addClass('quiqqer-coupons-field');
if (this.$Elm.getParent('[data-name="quiqqer-simple-checkout"]')) {
this.$Elm.addClass('quiqqer-coupons-field-simpleCheckout');
}
this.$Elm.set('html', Mustache.render(template, { this.$Elm.set('html', Mustache.render(template, {
labelInput : QUILocale.get(lg, lgPrefix + 'labelInput'), labelInput: QUILocale.get(lg, lgPrefix + 'labelInput'),
labelInputPlaceholder: QUILocale.get(lg, lgPrefix + 'labelInputPlaceholder'), labelInputPlaceholder: QUILocale.get(lg, lgPrefix + 'labelInputPlaceholder'),
submitBtnText : QUILocale.get(lg, lgPrefix + 'submitBtnText') submitBtnText: QUILocale.get(lg, lgPrefix + 'submitBtnText')
})); }));
this.Loader.inject(this.$Elm); this.Loader.inject(this.$Elm);
this.$Input = this.$Elm.getElement('input[name="code"]'); this.$Input = this.$Elm.getElement('input[name="code"]');
this.$Input.addEvent('keyup', function (event) { this.$Input.addEvent('keyup', function(event) {
if (event.code === 13) { if (event.code === 13) {
self.$submit(); self.$submit();
} }
...@@ -73,7 +77,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -73,7 +77,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
this.$Elm.getElement( this.$Elm.getElement(
'button.quiqqer-coupons-couponcodeinput-btn' 'button.quiqqer-coupons-couponcodeinput-btn'
).addEvent('click', function (event) { ).addEvent('click', function(event) {
event.stop(); event.stop();
self.$submit(); self.$submit();
}); });
...@@ -81,23 +85,23 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -81,23 +85,23 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
if (this.isInOrder()) { if (this.isInOrder()) {
var OrderProcess = this.getOrderProcess(); var OrderProcess = this.getOrderProcess();
new Promise(function (resolve) { new Promise(function(resolve) {
if (!OrderProcess.isLoaded()) { if (!OrderProcess.isLoaded()) {
return OrderProcess.addEvent('onLoad', resolve); return OrderProcess.addEvent('onLoad', resolve);
} }
resolve(); resolve();
}).then(function () { }).then(function() {
if (OrderProcess.getAttribute('basketEditable') === false) { if (OrderProcess.getAttribute('basketEditable') === false) {
// remove coupon codes button // remove coupon codes button
new Element('button', { new Element('button', {
'class': 'quiqqer-coupons-remove', 'class': 'quiqqer-coupons-remove',
'html' : '<span class="fa fa-close"></span>', 'html': '<span class="fa fa-close"></span>',
title : QUILocale.get(lg, 'remove.coupons.button'), title: QUILocale.get(lg, 'remove.coupons.button'),
events : { events: {
click: function (e) { click: function(e) {
e.stop(); e.stop();
self.removeCouponsFromOrder().catch(function (e) { self.removeCouponsFromOrder().catch(function(e) {
console.error(e); console.error(e);
}); });
} }
...@@ -111,7 +115,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -111,7 +115,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
/** /**
* Submit a CouponCode * Submit a CouponCode
*/ */
$submit: function () { $submit: function() {
if (this.$running) { if (this.$running) {
return; return;
} }
...@@ -127,18 +131,56 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -127,18 +131,56 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
this.$running = true; this.$running = true;
this.Loader.show(); this.Loader.show();
// simple order
const SimpleCheckoutNode = this.getElm().getParent('[data-name="quiqqer-simple-checkout"]');
if (SimpleCheckoutNode) {
const SimpleCheckout = QUI.Controls.getById(SimpleCheckoutNode.get('data-quiid'));
let orderHash = window.location.hash.substring(1);
if (!orderHash || orderHash === '') {
orderHash = SimpleCheckout.getAttribute('orderHash');
}
QUIAjax.get('package_quiqqer_order-simple-checkout_ajax_frontend_getOrder', (response) => {
CouponCodes.addCouponCodeToBasket(code, response.order.uuid).then(() => {
if (SimpleCheckout) {
SimpleCheckout.$refreshBasket().then(() => {
this.$running = false;
this.Loader.hide();
});
return;
}
this.$running = false;
this.Loader.hide();
}).catch((err) => {
console.error(err);
this.$running = false;
this.Loader.hide();
});
}, {
'package': 'quiqqer/order-simple-checkout',
orderHash: orderHash
});
return;
}
// get order process // get order process
if (!this.isInOrder()) { if (!this.isInOrder()) {
QUIAjax.get('package_quiqqer_order_ajax_frontend_basket_getLastOrder', function (order) { QUIAjax.get('package_quiqqer_order_ajax_frontend_basket_getLastOrder', function(order) {
CouponCodes.addCouponCodeToBasket(code, order.hash).then(function (redeemed) { CouponCodes.addCouponCodeToBasket(code, order.hash).then(function(redeemed) {
if (!redeemed) { if (!redeemed) {
self.$running = false; self.$running = false;
self.Loader.hide(); self.Loader.hide();
return; return;
} }
self.$addCouponCodeToSession(code).then(function () { self.$addCouponCodeToSession(code).then(function() {
QUIAjax.get('package_quiqqer_order_ajax_frontend_basket_getOrderProcessUrl', function (url) { QUIAjax.get('package_quiqqer_order_ajax_frontend_basket_getOrderProcessUrl', function(url) {
window.location = url + '?coupon=' + code; window.location = url + '?coupon=' + code;
}, { }, {
'package': 'quiqqer/order' 'package': 'quiqqer/order'
...@@ -156,9 +198,9 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -156,9 +198,9 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
OrderProcess.Loader.show(); OrderProcess.Loader.show();
OrderProcess.getOrder().then(function (orderHash) { OrderProcess.getOrder().then(function(orderHash) {
return CouponCodes.addCouponCodeToBasket(code, orderHash); return CouponCodes.addCouponCodeToBasket(code, orderHash);
}).then(function (redeemed) { }).then(function(redeemed) {
self.$running = false; self.$running = false;
if (redeemed === false) { if (redeemed === false) {
...@@ -167,7 +209,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -167,7 +209,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
return; return;
} }
self.$addCouponCodeToSession(code).then(function () { self.$addCouponCodeToSession(code).then(function() {
OrderProcess.reload(); OrderProcess.reload();
}); });
}); });
...@@ -178,15 +220,15 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -178,15 +220,15 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
* @param code * @param code
* @return {Promise} * @return {Promise}
*/ */
$addCouponCodeToSession: function (code) { $addCouponCodeToSession: function(code) {
return Sessions.get('quiqqer-coupons').then(function (coupons) { return Sessions.get('quiqqer-coupons').then(function(coupons) {
if (!coupons || typeOf(coupons) !== 'array') { if (!coupons || typeOf(coupons) !== 'array') {
coupons = []; coupons = [];
} }
coupons.push(code); coupons.push(code);
coupons = coupons.filter(function (value, index, self) { coupons = coupons.filter(function(value, index, self) {
return self.indexOf(value) === index; return self.indexOf(value) === index;
}); });
...@@ -198,7 +240,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -198,7 +240,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
* Is the coupon in the order process? * Is the coupon in the order process?
* @return {boolean} * @return {boolean}
*/ */
isInOrder: function () { isInOrder: function() {
var OrderProcessNode = this.getElm().getParent( var OrderProcessNode = this.getElm().getParent(
'[data-qui="package/quiqqer/order/bin/frontend/controls/OrderProcess"]' '[data-qui="package/quiqqer/order/bin/frontend/controls/OrderProcess"]'
); );
...@@ -211,7 +253,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -211,7 +253,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
* *
* @return {Object} * @return {Object}
*/ */
getOrderProcess: function () { getOrderProcess: function() {
var OrderProcessNode = this.getElm().getParent( var OrderProcessNode = this.getElm().getParent(
'[data-qui="package/quiqqer/order/bin/frontend/controls/OrderProcess"]' '[data-qui="package/quiqqer/order/bin/frontend/controls/OrderProcess"]'
); );
...@@ -224,19 +266,19 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -224,19 +266,19 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
* *
* @return {Promise} * @return {Promise}
*/ */
removeCouponsFromOrder: function () { removeCouponsFromOrder: function() {
if (!this.isInOrder()) { if (!this.isInOrder()) {
return Promise.resolve(); return Promise.resolve();
} }
var self = this; var self = this;
return new Promise(function (resolve) { return new Promise(function(resolve) {
var OrderProcess = self.getOrderProcess(); var OrderProcess = self.getOrderProcess();
OrderProcess.Loader.show(); OrderProcess.Loader.show();
OrderProcess.getOrder().then(function (orderHash) { OrderProcess.getOrder().then(function(orderHash) {
QUIAjax.get('package_quiqqer_coupons_ajax_frontend_removeCoupons', function () { QUIAjax.get('package_quiqqer_coupons_ajax_frontend_removeCoupons', function() {
resolve(); resolve();
OrderProcess.reload(); OrderProcess.reload();
}, { }, {
......
{
"pre-commit": {
"enabled": true,
"actions": [
{
"action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting"
},
{
"action": "composer test"
}
]
}
}
\ No newline at end of file
{ {
"name": "quiqqer/coupons", "name": "quiqqer/coupons",
"type": "quiqqer-module", "type": "quiqqer-module",
"description": "Coupons for QUIQQER", "description": "Coupons for QUIQQER",
"license": "GPL-3.0+", "license": "GPL-3.0+",
"authors": [ "authors": [
{ {
"name": "Patrick M\u00fcller", "name": "Patrick Müller",
"email": "support@pcsg.de", "email": "support@pcsg.de",
"homepage": "https://www.pcsg.de", "homepage": "https://www.pcsg.de",
"role": "Developer" "role": "Developer"
}
],
"support": {
"email": "support@pcsg.de"
},
"require": {
"quiqqer/core": "^2",
"quiqqer/erp": "^3.2",
"quiqqer/discount": "^2",
"quiqqer/products": "^2",
"quiqqer/order": "^2"
},
"autoload": {
"psr-4": {
"QUI\\ERP\\Coupons\\": "src/QUI/ERP/Coupons"
}
},
"scripts": {
"test": [
"@dev:lint",
"@dev:phpunit"
],
"dev:phpunit": "./tools/phpunit",
"dev:lint": [
"@dev:lint:phpstan",
"@dev:lint:style"
],
"dev:lint:phpstan": "./tools/phpstan",
"dev:lint:style": "./tools/phpcs",
"dev:lint:style:fix": "./tools/phpcbf",
"dev:init": [
"@dev:init:check-requirements",
"@dev:init:tools",
"@dev:init:git-hooks"
],
"dev:init:check-requirements": [
"which composer > /dev/null || (echo 'Error: composer has to be globally installed'; exit 1)",
"which phive > /dev/null || (echo 'Error: PHIVE has to be globally installed'; exit 1)"
],
"dev:init:tools": "phive install --temporary",
"dev:init:git-hooks": "./tools/captainhook install --only-enabled --force"
},
"scripts-aliases": {
"test": [
"dev:test"
]
},
"scripts-descriptions": {
"test": "Runs linting, static analysis, and unit tests.",
"dev:phpunit": "Run PHPUnit test suites",
"dev:lint": "Run PHPStan and code style check",
"dev:lint:phpstan": "Run PHPStan",
"dev:lint:style": "Run code style check (PHP_CodeSniffer)",
"dev:lint:style:fix": "Try to fix code style errors automatically",
"dev:init": "Initialize the developer tooling (tools and git hooks)",
"dev:init:check-requirements": "Check if the necessary requirements are met",
"dev:init:tools": "Install all developer tools (requires PHIVE)",
"dev:init:git-hooks": "Install all git hooks (may require tools to be installed)"
} }
], }
"support": { \ No newline at end of file
"email": "support@pcsg.de"
},
"require": {
"quiqqer/core": "^2",
"quiqqer/erp": "^3.2",
"quiqqer/discount": "^2",
"quiqqer/products": "^2"
},
"autoload": {
"psr-4": {
"QUI\\ERP\\Coupons\\": "src/QUI/ERP/Coupons"
}
}
}
...@@ -42,4 +42,7 @@ ...@@ -42,4 +42,7 @@
<event on="onQuiqqerOrderSuccessful" fire="\QUI\ERP\Coupons\Events::removeCouponsFromSession"/> <event on="onQuiqqerOrderSuccessful" fire="\QUI\ERP\Coupons\Events::removeCouponsFromSession"/>
<event on="onQuiqqer::order::orderProcessFinish" fire="\QUI\ERP\Coupons\Events::removeCouponsFromSession"/> <event on="onQuiqqer::order::orderProcessFinish" fire="\QUI\ERP\Coupons\Events::removeCouponsFromSession"/>
<event on="onQuiqqerMigrationV2" fire="\QUI\ERP\Coupons\Events::onQuiqqerMigrationV2"/> <event on="onQuiqqerMigrationV2" fire="\QUI\ERP\Coupons\Events::onQuiqqerMigrationV2"/>
<!-- simple order compatibility -->
<event on="onQuiqqer::simple::order::basket::middle" fire="\QUI\ERP\Coupons\Events::templateOrderSimpleOrder"/>
</events> </events>
<?xml version="1.0"?>
<ruleset>
<!-- Use PSR-12 ruleset -->
<rule ref="PSR12"/>
<!-- Only scan *.php files -->
<arg name="extensions" value="php"/>
<!-- Ignore warnings -->
<arg name="warning-severity" value="0"/>
<!-- Process 64 (or number of CPU cores) files in parallel -->
<arg name="parallel" value="64"/>
<!-- Output relative file paths, by setting the current folder as the basepath -->
<arg name="basepath" value="."/>
<!-- Show colored output -->
<arg name="colors"/>
<!-- Scan everything in the current folder -->
<file>.</file>
</ruleset>
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method QUI\\\\ERP\\\\Products\\\\Interfaces\\\\PriceFactorInterface\\:\\:setVat\\(\\)\\.$#"
count: 1
path: ajax/backend/getCouponPrice.php
-
message: "#^Dead catch \\- Exception is never thrown in the try block\\.$#"
count: 1
path: ajax/delete.php
-
message: "#^Call to an undefined method QUI\\\\ERP\\\\Products\\\\Interfaces\\\\PriceFactorInterface\\:\\:setVat\\(\\)\\.$#"
count: 1
path: src/QUI/ERP/Coupons/CouponCode.php
-
message: "#^Method QUI\\\\ERP\\\\Coupons\\\\CouponCode\\:\\:getDiscounts\\(\\) should return array\\<QUI\\\\ERP\\\\Discount\\\\Discount\\> but returns array\\<int\\<0, max\\>, QUI\\\\CRUD\\\\Child\\>\\.$#"
count: 1
path: src/QUI/ERP/Coupons/CouponCode.php
-
message: "#^Offset 'standard' on array\\{title\\: array\\{de\\: 'Gutschein \\- Versand', en\\: 'Coupon delivery'\\}, type\\: 'ProductAttributeList', public\\: true, standard\\: false, requiredField\\: true, options\\: array\\{entries\\: array\\{array\\{title\\: array\\{de\\: 'per E \\- Mail', en\\: 'via email'\\}, sum\\: 0, type\\: 2, selected\\: true, userinput\\: false\\}, array\\{title\\: array\\{de\\: 'per Post', en\\: 'via mail'\\}, sum\\: 0, type\\: 2, selected\\: false, userinput\\: false\\}\\}\\}\\}\\|array\\{title\\: array\\{de\\: 'Gutschein Wert', en\\: 'Coupon amount'\\}, type\\: 'FloatType', public\\: false, standard\\: false, requiredField\\: true\\}\\|array\\{title\\: array\\{de\\: 'Gutschein\\-Code als…', en\\: 'Provide coupon code…'\\}, description\\: array\\{de\\: 'Der Gutschein wird…', en\\: 'The coupon is also…'\\}, type\\: 'BoolType', public\\: false, standard\\: false, requiredField\\: false\\}\\|array\\{title\\: array\\{de\\: 'Gutschein\\-Code ist…', en\\: 'Coupon code is…'\\}, description\\: array\\{de\\: 'Übertragbare…', en\\: 'Transferable…'\\}, type\\: 'BoolType', public\\: false, standard\\: false, requiredField\\: false\\}\\|array\\{title\\: array\\{de\\: 'Gutschein\\-Code per…', en\\: 'Send coupon code…'\\}, description\\: array\\{de\\: 'Der Gutschein\\-Code…', en\\: 'The coupon code is…'\\}, type\\: 'BoolType', public\\: false, standard\\: false, requiredField\\: false\\}\\|array\\{title\\: array\\{de\\: 'Gutschein\\-Code…', en\\: 'Coupon code…'\\}, type\\: 'IntType', public\\: false, standard\\: false, requiredField\\: true\\}\\|array\\{title\\: array\\{de\\: 'Gutschein…', en\\: 'Coupon description'\\}, description\\: array\\{de\\: 'Diese Beschreibung…', en\\: 'This description…'\\}, type\\: 'InputMultiLang', public\\: false, standard\\: false, requiredField\\: false\\}\\|array\\{title\\: array\\{de\\: 'Ist Einzweck…', en\\: 'Is single purpose…'\\}, description\\: array\\{de\\: 'Einzweck\\-Gutscheine…', en\\: 'Single\\-purpose…'\\}, type\\: 'BoolType', public\\: false, standard\\: false, requiredField\\: false\\}\\|array\\{title\\: array\\{de\\: 'Kunde darf…', en\\: 'Customer can choose…'\\}, description\\: array\\{de\\: 'Ist diese Funktion…', en\\: 'if this option is…'\\}, type\\: 'BoolType', public\\: false, standard\\: false, requiredField\\: false\\} in empty\\(\\) always exists and is always falsy\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Events.php
-
message: "#^Parameter \\#1 \\$id of static method QUI\\\\ERP\\\\Coupons\\\\Handler\\:\\:getCouponCode\\(\\) expects int, string\\|false given\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Handler.php
-
message: "#^Call to method createPDF\\(\\) on an unknown class QUI\\\\HtmlToPdf\\\\Document\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Call to method setAttribute\\(\\) on an unknown class QUI\\\\HtmlToPdf\\\\Document\\.$#"
count: 7
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Call to method setContentHTML\\(\\) on an unknown class QUI\\\\HtmlToPdf\\\\Document\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Call to method setFooterHTML\\(\\) on an unknown class QUI\\\\HtmlToPdf\\\\Document\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Call to method setHeaderHTML\\(\\) on an unknown class QUI\\\\HtmlToPdf\\\\Document\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Instantiated class QUI\\\\HtmlToPdf\\\\Document not found\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Parameter \\#1 \\$key of method QUI\\\\ERP\\\\Accounting\\\\Article\\:\\:getCustomField\\(\\) expects string, int given\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
...@@ -2,7 +2,7 @@ includes: ...@@ -2,7 +2,7 @@ includes:
- phpstan-baseline.neon - phpstan-baseline.neon
parameters: parameters:
level: 1 level: 5
paths: paths:
- src - src
- ajax - ajax
......
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/phpunit-bootstrap.php">
<testsuites>
<testsuite name="Tests">
<directory>tests/</directory>
</testsuite>
</testsuites>
</phpunit>
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
use function is_string; use function is_string;
use function json_decode; use function json_decode;
use function json_encode; use function json_encode;
use function method_exists;
/** /**
* Class Events * Class Events
...@@ -63,12 +64,12 @@ public static function onAdminLoadFooter(): void ...@@ -63,12 +64,12 @@ public static function onAdminLoadFooter(): void
* *
* @param Collector $Collector * @param Collector $Collector
* @param mixed $Basket * @param mixed $Basket
* @param AbstractOrder|null $Order * @param mixed $Order
*/ */
public static function templateOrderProcessBasketEnd( public static function templateOrderProcessBasketEnd(
Collector $Collector, Collector $Collector,
mixed $Basket, mixed $Basket,
AbstractOrder $Order = null mixed $Order = null
): void { ): void {
if ( if (
!($Basket instanceof Basket) !($Basket instanceof Basket)
...@@ -96,6 +97,26 @@ public static function templateOrderProcessBasketEnd( ...@@ -96,6 +97,26 @@ public static function templateOrderProcessBasketEnd(
); );
} }
public static function templateOrderSimpleOrder(
Collector $Collector,
AbstractOrder $Order
): void {
if ($Order instanceof QUI\ERP\Order\OrderInProcess && isset($_GET['coupon'])) {
try {
$code = Handler::sanitizeCode($_GET['coupon']);
$CouponCode = Handler::getCouponCodeByCode($code);
$CouponCode->checkRedemption(QUI::getUserBySession());
$CouponCode->addToOrder($Order);
} catch (Exception) {
}
}
$Collector->append(
'<div data-qui="package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput"></div>'
);
}
/** /**
* @param QUI\ERP\Order\OrderProcess $OrderProcess * @param QUI\ERP\Order\OrderProcess $OrderProcess
* @throws QUI\ERP\Order\Exception * @throws QUI\ERP\Order\Exception
...@@ -193,7 +214,9 @@ public static function onQuiqqerOrderBasketRemovePos( ...@@ -193,7 +214,9 @@ public static function onQuiqqerOrderBasketRemovePos(
$Order->setData('quiqqer-coupons', $orderCoupons); $Order->setData('quiqqer-coupons', $orderCoupons);
try { try {
$Order->save(); if (method_exists($Order, 'save')) {
$Order->save();
}
} catch (QUI\Exception) { } catch (QUI\Exception) {
} }
} }
......
<?php
if (!defined('QUIQQER_SYSTEM')) {
define('QUIQQER_SYSTEM', true);
}
if (!defined('QUIQQER_AJAX')) {
define('QUIQQER_AJAX', true);
}
require_once __DIR__ . '/../../../../bootstrap.php';
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