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

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

fix: handle cases where project has no images by creating demo data for product page

See merge request !41
Übergeordnete a5bbd324 d1333e7c
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!41fix: handle cases where project has no images by creating demo data for product page,!33Update 'next-3.x' with latest changes from 'main'
Pipeline-Nr. 12297 mit Warnungen bestanden
......@@ -36,10 +36,8 @@ function ($orderHash, $orderData) {
'country' => $orderData['country']
];
$ErpAddress = new Address($erpAddressData);
if (isset($orderData['company'])) {
$ErpAddress->setAttribute('company', $orderData['company']);
$erpAddressData['company'] = $orderData['company'];
}
// get user address
......@@ -62,22 +60,14 @@ function ($orderHash, $orderData) {
$erpAddressData['uuid'] = $Address->getUUID();
$erpAddressData['id'] = $Address->getId();
$ErpAddress = new Address($erpAddressData);
$address = $ErpAddress->getAttributes();
// save address
$Address->setAttribute('firstname', $ErpAddress->getAttribute('firstname'));
$Address->setAttribute('lastname', $ErpAddress->getAttribute('lastname'));
$Address->setAttribute('street_no', $ErpAddress->getAttribute('street_no'));
$Address->setAttribute('zip', $ErpAddress->getAttribute('zip'));
$Address->setAttribute('city', $ErpAddress->getAttribute('city'));
$Address->setAttribute('country', $ErpAddress->getAttribute('country'));
if ($ErpAddress->getAttribute('company')) {
$Address->setAttribute('company', $ErpAddress->getAttribute('company'));
foreach ($address as $k => $v) {
$Address->setAttribute($k, $v);
}
$Address->save(QUI::getUsers()->getSystemUser());
if (isset($orderData['billing_address']) && $orderData['billing_address'] === 'different') {
$Order?->setDeliveryAddress($ErpAddress);
......@@ -86,17 +76,21 @@ function ($orderHash, $orderData) {
$orderData['billing_street_no'] = $orderData['billing_street'] . ' ' . $orderData['billing_street_number'];
}
$Order?->setInvoiceAddress(
new Address([
'firstname' => $orderData['billing_firstname'],
'lastname' => $orderData['billing_lastname'],
'street_no' => $orderData['billing_street_no'],
'zip' => $orderData['billing_zip'],
'city' => $orderData['billing_city'],
'country' => $orderData['billing_country'],
'uuid' => $Address->getUUID()
])
);
$billingAddress = [
'firstname' => $orderData['billing_firstname'],
'lastname' => $orderData['billing_lastname'],
'street_no' => $orderData['billing_street_no'],
'zip' => $orderData['billing_zip'],
'city' => $orderData['billing_city'],
'country' => $orderData['billing_country'],
'uuid' => $Address->getUUID()
];
if (!empty($orderData['billing_company'])) {
$billingAddress['company'] = $orderData['billing_company'];
}
$Order?->setInvoiceAddress(new Address($billingAddress));
} else {
$Order?->setInvoiceAddress($ErpAddress);
$Order?->removeDeliveryAddress();
......@@ -123,7 +117,16 @@ function ($orderHash, $orderData) {
$User->setCompanyStatus(false);
}
if (isset($orderData['vatId'])) {
$User->setAttribute('quiqqer.erp.euVatId', $orderData['vatId']);
}
if (isset($orderData['chUID'])) {
$User->setAttribute('quiqqer.erp.chUID', $orderData['chUID']);
}
$User->save(QUI::getUsers()->getSystemUser());
$Order->setCustomer($User);
} catch (QUI\Exception $Exception) {
Log::addError($Exception->getMessage());
}
......
bin/images/demo/placeholder-image-vertical-grey.png

14,5 KiB

......@@ -103,12 +103,39 @@ public static function getDemoBricksData(Edit $Site): array
{
$Project = $Site->getProject();
$Media = $Project->getMedia();
$PlaceholdersImage = $Media->getPlaceholderImage();
if (!$PlaceholdersImage) {
try {
$Media = $Project->getMedia();
$imageIds = $Media->getChildrenIds([
'limit' => 1,
'where' => [
'type' => 'image',
'active' => 1,
'deleted' => 0
]
]);
if (!$Media->getPlaceholderImage()) {
throw new QUI\Exception('Placeholder image is missing');
if (isset($imageIds[0])) {
$Image = $Media->get($imageIds[0]);
} else {
$RootFolder = $Media->firstChild();
$Image = $RootFolder->uploadFile(
OPT_DIR . 'quiqqer/order-simple-checkout/bin/images/demo/placeholder-image-vertical-grey.png'
);
$Image->activate();
}
$Config = QUI::getConfig('etc/projects.ini.php');
$Config->setValue($Project->getName(), 'placeholder', $Image->getUrl());
$Config->save();
$PlaceholdersImage = $Image;
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
}
$PlaceholdersImage = $Media->getPlaceholderImage();
$placeholderImage = $PlaceholdersImage->getUrl();
return [
......
......@@ -22,7 +22,7 @@
$Template->extendHeader('<script>const QUIQQER_LANDING_PAGE_CTA_URL = "' . $ctaUrl . '";</script>');
if (empty($productId)) {
$Engine->assign('Product', null);
$Engine->assign('ProductControl', null);
} else {
try {
$Product = Products::getProduct($productId);
......@@ -32,6 +32,6 @@
$Engine->assign('ProductControl', $ProductControl);
} catch (\QUI\ERP\Products\Product\Exception) {
$Engine->assign('Product', null);
$Engine->assign('ProductControl', null);
}
}
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren