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

feat: quiqqer v2 compatibility

Übergeordneter 11bf29b5
No related branches found
No related tags found
3 Merge Requests!22refactor(SimpleCheckoutWindow): style and UX,!18Next 2.x,!16Feat quiqqer v2
......@@ -13,14 +13,14 @@ function ($orderHash) {
try {
$Order = $OrderHandler->getOrderByHash($orderHash);
$Customer = $Order->getCustomer();
$customerId = $Customer->getId();
$customerId = $Customer->getUUID();
if ($User->getId() === $customerId) {
if ($User->getUUID() === $customerId) {
return $Order->toArray();
}
return false;
} catch (QUI\Exception $exception) {
} catch (QUI\Exception) {
}
return null;
......
......@@ -4,7 +4,6 @@
* This file contains package_quiqqer_order-simple-checkout_ajax_frontend_newOrderInProcess
*/
use QUI\ERP\Order\Guest\GuestOrder;
use QUI\ERP\Products\Handler\Products;
QUI::$Ajax->registerFunction(
......@@ -17,23 +16,24 @@ function ($products) {
if (!count($products)) {
// select the last order in processing
try {
return $Orders->getLastOrderInProcessFromUser($this->getUser())->getHash();
} catch (QUI\Exception $exception) {
return QUI\ERP\Order\Factory::getInstance()->createOrderInProcess()->getHash();
return $Orders->getLastOrderInProcessFromUser($this->getUser())->getUUID();
} catch (QUI\Exception) {
return QUI\ERP\Order\Factory::getInstance()->createOrderInProcess()->getUUID();
}
}
if (
QUI::getUsers()->isNobodyUser($UserSession)
&& QUI::getPackageManager()->isInstalled('quiqqer/order-guestorder')
&& !GuestOrder::isActive()
&& class_exists('QUI\ERP\Order\Guest\GuestOrder')
&& !QUI\ERP\Order\Guest\GuestOrder::isActive()
) {
throw new QUI\Exception('Please log in');
}
try {
$OrderInProcess = QUI\ERP\Order\Factory::getInstance()->createOrderInProcess();
} catch (\Exception $exception) {
} catch (Exception) {
}
if (!isset($OrderInProcess)) {
......@@ -71,14 +71,14 @@ function ($products) {
}
$OrderInProcess->addArticle($BasketProduct->toArticle());
} catch (\Exception $exception) {
} catch (Exception) {
continue;
}
}
$OrderInProcess->save();
return $OrderInProcess->getHash();
return $OrderInProcess->getUUID();
},
['products']
);
{
"name": "quiqqer\/order-simple-checkout",
"name": "quiqqer/order-simple-checkout",
"type": "quiqqer-module",
"description": "A simple checkout",
"license": [
......@@ -10,22 +10,22 @@
{
"name": "Henning Leutz",
"email": "support@pcsg.de",
"homepage": "http:\/\/www.pcsg.de",
"homepage": "https://www.pcsg.de",
"role": "Developer"
}
],
"support": {
"email": "support@pcsg.de",
"url": "http:\/\/www.pcsg.de"
"url": "https://www.pcsg.de"
},
"require": {
"php": ">=7.4",
"quiqqer\/order": "^1.11|@dev",
"quiqqer\/frontend-users": "^1.10.3|@dev"
"php": "^8",
"quiqqer/order": "^2",
"quiqqer/frontend-users": "^2"
},
"autoload": {
"psr-4": {
"QUI\\ERP\\Order\\SimpleCheckout\\": "src\/QUI\/ERP\/Order\/SimpleCheckout"
"QUI\\ERP\\Order\\SimpleCheckout\\": "src/QUI/ERP/Order/SimpleCheckout"
}
}
}
......@@ -3,8 +3,6 @@
namespace QUI\ERP\Order\SimpleCheckout;
use QUI;
use QUI\ERP\Order\Basket\Exception;
use QUI\ERP\Order\Basket\ExceptionBasketNotFound;
use function dirname;
......@@ -13,9 +11,6 @@ class Basket extends QUI\Control
protected Checkout $Checkout;
/**
* @throws ExceptionBasketNotFound
* @throws Exception
* @throws QUI\Database\Exception
*/
public function __construct(Checkout $Checkout, $attributes = [])
{
......
......@@ -3,6 +3,7 @@
namespace QUI\ERP\Order\SimpleCheckout;
use QUI;
use QUI\ERP\Order\Basket\ExceptionBasketNotFound;
use QUI\ERP\Order\Controls\Checkout\Login;
use QUI\ERP\Order\Controls\Checkout\Registration;
use QUI\ERP\Order\OrderInProcess;
......@@ -12,6 +13,7 @@
use QUI\ERP\Order\SimpleCheckout\Steps\CheckoutShipping;
use QUI\Exception;
use function class_exists;
use function dirname;
use function file_exists;
......@@ -53,7 +55,10 @@ public function getBody(): string
return $Engine->fetch($templateLogin);
}
if (!QUI\ERP\Order\Guest\GuestOrder::isActive()) {
if (
class_exists('QUI\ERP\Order\Guest\GuestOrder')
&& !QUI\ERP\Order\Guest\GuestOrder::isActive()
) {
return $Engine->fetch($templateLogin);
}
......@@ -126,7 +131,7 @@ public function isValid(): bool
QUI\ERP\Order\Controls\OrderProcess\CustomerData::validateAddress(
$Order->getInvoiceAddress()
);
} catch (QUI\Exception $exception) {
} catch (QUI\Exception) {
return false;
}
......@@ -148,6 +153,7 @@ public function isValid(): bool
public function gatherMissingOrderDetails(): array
{
$missing = [];
$Order = null;
// check address
try {
......@@ -156,20 +162,26 @@ public function gatherMissingOrderDetails(): array
QUI\ERP\Order\Controls\OrderProcess\CustomerData::validateAddress(
$Order->getInvoiceAddress()
);
} catch (QUI\Exception $exception) {
} catch (QUI\Exception) {
$missing[] = 'address';
}
// check payment
$Payment = $Order->getPayment();
if (!$Payment) {
if (!$Order) {
$missing[] = 'payment';
}
// check shipping
if (QUI::getPackageManager()->isInstalled('quiqqer/shipping') && !$Order->getShipping()) {
$missing[] = 'shipping';
if (QUI::getPackageManager()->isInstalled('quiqqer/shipping')) {
$missing[] = 'shipping';
}
} else {
$Payment = $Order->getPayment();
if (!$Payment) {
$missing[] = 'payment';
}
if (QUI::getPackageManager()->isInstalled('quiqqer/shipping') && !$Order->getShipping()) {
$missing[] = 'shipping';
}
}
return $missing;
......@@ -186,11 +198,15 @@ public function orderWithCosts(): array
$Order = $OrderInProcess->createOrder(QUI::getUsers()->getSystemUser());
$Order->setData('orderedWithCosts', true);
$Order->save(QUI::getUsers()->getSystemUser());
$this->setAttribute('orderHash', $Order->getHash());
$this->setAttribute('orderHash', $Order->getUUID());
return $this->getOrderProcessStep();
}
/**
* @throws QUI\ERP\Order\Basket\Exception
* @throws \Exception
*/
public function getOrderProcessStep(): array
{
$OrderHandler = QUI\ERP\Order\Handler::getInstance();
......@@ -199,7 +215,7 @@ public function getOrderProcessStep(): array
// init order process
$OrderProcess = new QUI\ERP\Order\OrderProcess([
'Order' => $Order,
'orderHash' => $Order->getHash(),
'orderHash' => $Order->getUUID(),
'step' => 'Processing'
]);
......@@ -215,7 +231,7 @@ public function getOrderProcessStep(): array
'step' => $current,
'url' => $OrderProcess->getStepUrl($current),
'hash' => $OrderProcess->getStepHash(),
'orderHash' => $Order->getHash(),
'orderHash' => $Order->getUUID(),
'productCount' => $Order->getArticles()->count(),
];
}
......@@ -234,7 +250,7 @@ public function getOrder(): ?OrderInProcess
if ($this->getAttribute('orderHash')) {
try {
return $Orders->getOrderInProcessByHash($this->getAttribute('orderHash'));
} catch (QUI\Exception $exception) {
} catch (QUI\Exception) {
}
}
......@@ -245,7 +261,7 @@ public function getOrder(): ?OrderInProcess
if (!$OrderInProcess->getOrderId()) {
$Order = $OrderInProcess;
}
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
}
if ($Order === null) {
......@@ -270,6 +286,7 @@ public function getUser(): QUI\Interfaces\Users\User
* Get the shipping html for the current order.
*
* @return string The shipping information
* @throws \Exception
*/
public function getShipping(): string
{
......@@ -290,6 +307,7 @@ public function getShipping(): string
* Get the payment html for the current order.
*
* @return string The shipping information
* @throws \Exception
*/
public function getPayments(): string
{
......@@ -306,6 +324,12 @@ public function getPayments(): string
}
}
/**
* @throws ExceptionBasketNotFound
* @throws QUI\ERP\Order\Basket\Exception
* @throws QUI\Database\Exception
* @throws \Exception
*/
public function getBasket(): string
{
$Basket = new Basket($this);
......
......@@ -3,6 +3,7 @@
namespace QUI\ERP\Order\SimpleCheckout\Steps;
use QUI;
use QUI\ERP\Address;
use QUI\ERP\Order\SimpleCheckout\Checkout;
use QUI\ERP\Order\SimpleCheckout\CheckoutStepInterface;
use QUI\Exception;
......@@ -44,6 +45,7 @@ public function __construct(Checkout $Checkout, $attributes = [])
*
* @return string The HTML body content for the checkout delivery step.
* @throws Exception
* @throws QUI\ERP\Order\Exception
*/
public function getBody(): string
{
......@@ -61,7 +63,9 @@ public function getBody(): string
/**
* Retrieves the invoice address for the current user.
*
* @return null|QUI\ERP\Address
* @return null|Address
* @throws Exception
* @throws QUI\ERP\Order\Exception
*/
protected function getDeliveryAddress(): ?QUI\ERP\Address
{
......@@ -73,7 +77,7 @@ protected function getDeliveryAddress(): ?QUI\ERP\Address
*
* @throws QUI\ERP\Order\Exception|Exception
*/
public function validate()
public function validate(): void
{
QUI\ERP\Order\Controls\OrderProcess\CustomerData::validateAddress(
$this->Checkout->getOrder()->getInvoiceAddress()
......
......@@ -6,6 +6,7 @@
use QUI\ERP\Order\SimpleCheckout\Checkout;
use QUI\ERP\Order\SimpleCheckout\CheckoutStepInterface;
use QUI\Exception;
use QUI\Users\Address;
use QUI\Users\User;
use function dirname;
......@@ -46,6 +47,7 @@ public function __construct(Checkout $Checkout, $attributes = [])
*
* @return string The HTML body content for the checkout delivery step.
* @throws Exception
* @throws QUI\ERP\Order\Exception
*/
public function getBody(): string
{
......@@ -92,7 +94,7 @@ public function getBody(): string
if (!empty($settings)) {
$settings = json_decode($settings, true);
}
} catch (QUI\Exception $Exception) {
} catch (QUI\Exception) {
$settings = [];
}
......@@ -125,9 +127,11 @@ public function getBody(): string
/**
* Retrieves the invoice address for the current user.
*
* @return false|QUI\Users\Address|null
* @return Address|null
* @throws Exception
* @throws QUI\ERP\Order\Exception
*/
protected function getInvoiceAddress()
protected function getInvoiceAddress(): ?Address
{
$User = QUI::getUserBySession();
$Order = $this->Checkout->getOrder();
......@@ -163,7 +167,7 @@ protected function getInvoiceAddress()
*
* @throws QUI\ERP\Order\Exception|Exception
*/
public function validate()
public function validate(): void
{
QUI\ERP\Order\Controls\OrderProcess\CustomerData::validateAddress(
$this->Checkout->getOrder()->getInvoiceAddress()
......
......@@ -33,11 +33,10 @@ public function getBody(): string
try {
$Delivery->validate();
} catch (QUI\Exception $exception) {
} catch (QUI\Exception) {
return $Engine->fetch(dirname(__FILE__) . '/CheckoutPayment.html');
}
$Payment = new Payment([
'Order' => $this->Checkout->getOrder()
]);
......
......@@ -36,11 +36,10 @@ public function getBody(): string
try {
$Delivery->validate();
} catch (QUI\Exception $exception) {
} catch (QUI\Exception) {
return $Engine->fetch(dirname(__FILE__) . '/CheckoutShipping.html');
}
$Shipping = new QUI\ERP\Shipping\Order\Shipping([
'Order' => $this->Checkout->getOrder()
]);
......
<?php
/**
* This file contains the simple checkout site type
*
* @var QUI\Projects\Project $Project
* @var QUI\Projects\Site $Site
* @var QUI\Interfaces\Template\EngineInterface $Engine
* @var QUI\Template $Template
*/
$Site->setAttribute('nocache', true);
try {
......
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