Skip to content
Code-Schnipsel Gruppen Projekte
Commit 62d3b978 erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

refactor: different default fields for physical / digital products

Übergeordneter 14b2070b
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
...@@ -650,16 +650,20 @@ public static function onQuiqqerProductsProductCreate(ProductInterface $Product) ...@@ -650,16 +650,20 @@ public static function onQuiqqerProductsProductCreate(ProductInterface $Product)
$UniqueProduct->calc(); $UniqueProduct->calc();
$fields = [ $fields = [
CouponProductsHandler::PRODUCT_FIELD_ID_TRANSFERABLE => true, // CouponProductsHandler::PRODUCT_FIELD_ID_TRANSFERABLE => true,
CouponProductsHandler::PRODUCT_FIELD_ID_SEND_MAIL => $isDigital, CouponProductsHandler::PRODUCT_FIELD_ID_COUPON_AMOUNT => $UniqueProduct->getPrice()->getValue(),
CouponProductsHandler::PRODUCT_FIELD_ID_GENERATE_PDF => $isDigital, CouponProductsHandler::PRODUCT_FIELD_ID_DAYS_VALID => 1095, // 3 years
CouponProductsHandler::PRODUCT_FIELD_ID_COUPON_AMOUNT => $UniqueProduct->getPrice()->getValue(), CouponProductsHandler::PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON => false
CouponProductsHandler::PRODUCT_FIELD_ID_DAYS_VALID => 1095, // 3 years
CouponProductsHandler::PRODUCT_FIELD_ID_COUPON_DESCRIPTION => null,
CouponProductsHandler::PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON => false,
CouponProductsHandler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT => false
]; ];
// Digital coupons get some extra fields
if ($isDigital) {
$fields[CouponProductsHandler::PRODUCT_FIELD_ID_SEND_MAIL] = true;
$fields[CouponProductsHandler::PRODUCT_FIELD_ID_GENERATE_PDF] = true;
$fields[CouponProductsHandler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT] = false;
$fields[CouponProductsHandler::PRODUCT_FIELD_ID_COUPON_DESCRIPTION] = null;
}
foreach ($fields as $fieldId => $value) { foreach ($fields as $fieldId => $value) {
try { try {
$Field = Fields::getField($fieldId); $Field = Fields::getField($fieldId);
......
...@@ -79,6 +79,13 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O ...@@ -79,6 +79,13 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O
) )
); );
/**
* Physical coupons are not sent via mail or PDF
*/
if ($Product instanceof PhysicalCouponProductType) {
continue;
}
// Generate coupon PDF // Generate coupon PDF
if ($Product->getFieldValue(self::PRODUCT_FIELD_ID_GENERATE_PDF)) { if ($Product->getFieldValue(self::PRODUCT_FIELD_ID_GENERATE_PDF)) {
$couponPdfFile = self::createCouponCodePdf($CouponCode, $Product); $couponPdfFile = self::createCouponCodePdf($CouponCode, $Product);
...@@ -197,10 +204,12 @@ protected static function createCouponCodeFromProduct( ...@@ -197,10 +204,12 @@ protected static function createCouponCodeFromProduct(
$couponAttributes['validUntilDate'] = $ValidUntil->format('Y-m-d'); $couponAttributes['validUntilDate'] = $ValidUntil->format('Y-m-d');
// Transferable (=usable by other users or guests) // Transferable (=usable by other users or guests)
$isTransferable = $Product->getFieldValue(self::PRODUCT_FIELD_ID_TRANSFERABLE); if ($Product->hasField(self::PRODUCT_FIELD_ID_TRANSFERABLE)) {
$isTransferable = $Product->getFieldValue(self::PRODUCT_FIELD_ID_TRANSFERABLE);
if (empty($isTransferable)) { if (empty($isTransferable)) {
$couponAttributes['userIds'] = [$User->getId()]; $couponAttributes['userIds'] = [$User->getId()];
}
} }
return CouponsHandler::createCouponCode([$Discount->getId()], $couponAttributes); return CouponsHandler::createCouponCode([$Discount->getId()], $couponAttributes);
......
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