Skip to content
Code-Schnipsel Gruppen Projekte

fix(CouponCodeInput): mobile buttons adjusted

Zusammengeführt Henning Leutz schlägt vor, dev in next zu mergen.
2 Dateien
+ 27
6
Änderungen vergleichen
  • Nebeneinander
  • In der Reihe
Dateien
2
@@ -2,6 +2,7 @@
namespace QUI\ERP\Coupons\Products;
use Exception;
use QUI;
use QUI\ERP\Coupons\CouponCode;
use QUI\ERP\Coupons\Handler as CouponsHandler;
@@ -10,7 +11,18 @@ use QUI\ERP\Discount\Discount;
use QUI\ERP\Discount\Handler as DiscountHandler;
use QUI\ERP\Products\Handler\Products as ProductsHandler;
use QUI\ERP\Products\Product\Product;
use QUI\ExceptionStack;
use QUI\HtmlToPdf\Document;
use QUI\Translator;
use function array_merge;
use function basename;
use function date;
use function date_create;
use function is_numeric;
use function mb_substr;
use function rename;
use function str_replace;
/**
* Class Handler
@@ -49,7 +61,7 @@ class Handler
foreach ($Order->getArticles() as $Article) {
try {
// Do not parse coupon codes / discounts
if (empty($Article->getId()) || !\is_numeric($Article->getId())) {
if (empty($Article->getId()) || !is_numeric($Article->getId())) {
continue;
}
@@ -99,23 +111,23 @@ class Handler
'quiqqer/coupons',
'DownloadProduct.pdf.filename',
[
'productTitle' => \str_replace(' ', '_', $productTitelSanitized),
'date' => \date('Y_m_d')
'productTitle' => str_replace(' ', '_', $productTitelSanitized),
'date' => date('Y_m_d')
]
);
$fileName .= '__' . \mb_substr($Order->getHash(), 0, 6);
$fileName .= '__' . mb_substr($Order->getUUID(), 0, 6);
$newCouponPdfFile = \str_replace(\basename($couponPdfFile, '.pdf'), $fileName, $couponPdfFile);
$newCouponPdfFile = str_replace(basename($couponPdfFile, '.pdf'), $fileName, $couponPdfFile);
\rename($couponPdfFile, $newCouponPdfFile);
rename($couponPdfFile, $newCouponPdfFile);
// Add PDF file to customer files
CustomerFiles::addFileToCustomer($Customer->getId(), $newCouponPdfFile);
CustomerFiles::addFileToDownloadEntry($Customer->getId(), \basename($newCouponPdfFile));
CustomerFiles::addFileToCustomer($Customer->getUUID(), $newCouponPdfFile);
CustomerFiles::addFileToDownloadEntry($Customer->getUUID(), basename($newCouponPdfFile));
$customerDir = CustomerFiles::getFolderPath($Customer);
$couponFilePathCustomerDir = $customerDir . DIRECTORY_SEPARATOR . \basename($newCouponPdfFile);
$couponFilePathCustomerDir = $customerDir . DIRECTORY_SEPARATOR . basename($newCouponPdfFile);
}
// Send coupon via email
@@ -128,16 +140,10 @@ class Handler
);
if ($deliveryTypeFieldData) {
switch ($deliveryTypeFieldData['value']) {
// by mail
case 1:
$sendMail = false;
break;
// by email
default:
$sendMail = true;
}
$sendMail = match ($deliveryTypeFieldData['value']) {
1 => false,
default => true,
};
} else {
$sendMail = $Product->getFieldValue(self::PRODUCT_FIELD_ID_SEND_MAIL);
}
@@ -156,7 +162,7 @@ class Handler
)
);
}
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
if ($Exception->getCode() === 404) {
QUI\System\Log::writeDebugException($Exception);
} else {
@@ -175,7 +181,7 @@ class Handler
* @return CouponCode
*
* @throws QUI\Exception
* @throws \Exception
* @throws Exception
*/
protected static function createCouponCodeFromProduct(
Product $Product,
@@ -188,7 +194,7 @@ class Handler
'quiqqer/coupons',
'ProductCoupon.coupon_title',
[
'orderId' => $Order->getPrefixedId(),
'orderId' => $Order->getPrefixedNumber(),
'productId' => $Product->getId()
]
),
@@ -202,7 +208,7 @@ class Handler
$daysValid = 1095; // 3 years;
}
$ValidUntil = \date_create('+ ' . $daysValid . ' days');
$ValidUntil = date_create('+ ' . $daysValid . ' days');
$couponAttributes['validUntilDate'] = $ValidUntil->format('Y-m-d');
// Transferable (=usable by other users or guests)
@@ -210,7 +216,7 @@ class Handler
$isTransferable = $Product->getFieldValue(self::PRODUCT_FIELD_ID_TRANSFERABLE);
if (empty($isTransferable)) {
$couponAttributes['userIds'] = [$User->getId()];
$couponAttributes['userIds'] = [$User->getUUID()];
}
}
@@ -263,14 +269,14 @@ class Handler
]);
}
\QUI\Translator::update(
Translator::update(
'quiqqer/discount',
'discount.' . $NewDiscount->getId() . '.title',
'quiqqer/discount',
$discountTitle
);
\QUI\Translator::publish('quiqqer/discount');
Translator::publish('quiqqer/discount');
return $NewDiscount;
}
@@ -279,6 +285,7 @@ class Handler
* @param CouponCode $CouponCode - The coupon code
* @param Product $Product - The product the coupon code was created from
* @return string - PDF file path
* @throws QUI\Exception
*/
public static function createCouponCodePdf(CouponCode $CouponCode, Product $Product): string
{
@@ -296,7 +303,7 @@ class Handler
$Engine = QUI::getTemplateManager()->getEngine();
$Engine->assign(
\array_merge(
array_merge(
[
'CouponCode' => $CouponCode,
'Product' => $Product->getViewFrontend(),
@@ -311,7 +318,7 @@ class Handler
$Document->setHeaderHTML($Engine->fetch($tplDir . 'CouponCode.header.html'));
$Document->setContentHTML($Engine->fetch($tplDir . 'CouponCode.body.html'));
$Document->setFooterHTML($Engine->fetch($tplDir . 'CouponCode.footer.html'));
} catch (\Exception $Exception) {
} catch (Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
@@ -326,19 +333,19 @@ class Handler
* @param QUI\Interfaces\Users\User $Customer
* @param string|null $couponPdfFile (optional) - Coupon PDF that is attached to the email
*
* @throws \Exception
* @throws Exception
*/
public static function sendCouponMail(
CouponCode $CouponCode,
Product $Product,
QUI\Interfaces\Users\User $Customer,
?string $couponPdfFile
) {
): void {
$recipient = QUI\ERP\Customer\Utils::getInstance()->getEmailByCustomer($Customer);
if (empty($recipient)) {
QUI\System\Log::addWarning(
'Cannot send coupon code e-mail to customer #' . $Customer->getUniqueId() . ' because user has no'
'Cannot send coupon code e-mail to customer #' . $Customer->getUUID() . ' because user has no'
. ' email address!'
);
@@ -378,7 +385,7 @@ class Handler
QUI::getLocale()->get(
'quiqqer/coupons',
'ProductCoupon.mail.body',
\array_merge(
array_merge(
$couponViewData,
[
'customerName' => $Customer->getName(),
@@ -400,8 +407,10 @@ class Handler
* @param Product $Product
* @return array
*
* @throws QUI\Database\Exception
* @throws QUI\ERP\Products\Product\Exception
* @throws QUI\Users\Exception
* @throws QUI\Exception
* @throws ExceptionStack
*/
protected static function getCouponViewData(CouponCode $CouponCode, Product $Product): array
{
@@ -456,6 +465,7 @@ class Handler
* which are NOT taxed at checkout but only when they are redeemed for a product.
*
* @return QUI\ERP\Tax\TaxType[]
* @throws QUI\Exception
*/
public static function getNoVatTaxTypes(): array
{