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

refactor: separation of physical and digital products

Übergeordneter bfa09761
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
...@@ -193,9 +193,21 @@ Best Wishes<br/> ...@@ -193,9 +193,21 @@ Best Wishes<br/>
<de><![CDATA[Bitte fülle alle Pflichtfelder aus.]]></de> <de><![CDATA[Bitte fülle alle Pflichtfelder aus.]]></de>
<en><![CDATA[Please fill out all required fields.]]></en> <en><![CDATA[Please fill out all required fields.]]></en>
</locale> </locale>
<locale name="product_type.CouponProductType.title"> <locale name="product_type.DigitalCouponProductType.title">
<de><![CDATA[Gutschein]]></de> <de><![CDATA[Gutschein (digital)]]></de>
<en><![CDATA[Coupon]]></en> <en><![CDATA[Coupon (digital)]]></en>
</locale>
<locale name="product_type.DigitalCouponProductType.description">
<de><![CDATA[Gutschein, der ausschließlich digital angeboten wird (Versand per E-Mail und/oder PDF-Download).]]></de>
<en><![CDATA[Coupon offered exclusively digitally (sent by e-mail and/or PDF download).]]></en>
</locale>
<locale name="product_type.PhysicalCouponProductType.title">
<de><![CDATA[Gutschein (physisch)]]></de>
<en><![CDATA[Coupon (physical)]]></en>
</locale>
<locale name="product_type.PhysicalCouponProductType.description">
<de><![CDATA[Gutschein, der physisch erstellt und versandt wird (kann zusätzlich auch digital angeboten werden).]]></de>
<en><![CDATA[Coupon that is physically created and shipped (can additionally be offered digitally).]]></en>
</locale> </locale>
<!-- Ajax --> <!-- Ajax -->
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
</copyright> </copyright>
<provider> <provider>
<productType src="\QUI\ERP\Coupons\Products\CouponProductType"/> <productType src="\QUI\ERP\Coupons\Products\DigitalCouponProductType"/>
<productType src="\QUI\ERP\Coupons\Products\PhysicalCouponProductType"/>
</provider> </provider>
</package> </package>
......
...@@ -11,9 +11,11 @@ ...@@ -11,9 +11,11 @@
use QUI\ERP\Order\Basket\BasketGuest; use QUI\ERP\Order\Basket\BasketGuest;
use QUI\ERP\Coupons\Handler as CouponsHandler; use QUI\ERP\Coupons\Handler as CouponsHandler;
use QUI\ERP\Discount\EventHandling as DiscountEvents; use QUI\ERP\Discount\EventHandling as DiscountEvents;
use QUI\ERP\Coupons\Products\CouponProductType; use QUI\ERP\Coupons\Products\DigitalCouponProductType;
use QUI\ERP\Coupons\Products\PhysicalCouponProductType;
use QUI\ERP\Coupons\Products\CouponProductException; use QUI\ERP\Coupons\Products\CouponProductException;
use QUI\ERP\Accounting\Calc as ErpCalc; use QUI\ERP\Accounting\Calc as ErpCalc;
use QUI\ERP\Coupons\Products\Handler as CouponProductsHandler;
/** /**
* Class Events * Class Events
...@@ -434,7 +436,7 @@ public static function removeCouponsFromSession() ...@@ -434,7 +436,7 @@ public static function removeCouponsFromSession()
protected static function createProductFields() protected static function createProductFields()
{ {
$fields = [ $fields = [
CouponProductType::PRODUCT_FIELD_ID_TRANSFERABLE => [ CouponProductsHandler::PRODUCT_FIELD_ID_TRANSFERABLE => [
'title' => [ 'title' => [
'de' => 'Gutschein-Code ist übertragbar', 'de' => 'Gutschein-Code ist übertragbar',
'en' => 'Coupon code is transferable' 'en' => 'Coupon code is transferable'
...@@ -451,7 +453,7 @@ protected static function createProductFields() ...@@ -451,7 +453,7 @@ protected static function createProductFields()
'standard' => false, 'standard' => false,
'requiredField' => false 'requiredField' => false
], ],
CouponProductType::PRODUCT_FIELD_ID_SEND_MAIL => [ CouponProductsHandler::PRODUCT_FIELD_ID_SEND_MAIL => [
'title' => [ 'title' => [
'de' => 'Gutschein-Code per E-Mail senden', 'de' => 'Gutschein-Code per E-Mail senden',
'en' => 'Send coupon code via email' 'en' => 'Send coupon code via email'
...@@ -469,7 +471,7 @@ protected static function createProductFields() ...@@ -469,7 +471,7 @@ protected static function createProductFields()
'standard' => false, 'standard' => false,
'requiredField' => false 'requiredField' => false
], ],
CouponProductType::PRODUCT_FIELD_ID_GENERATE_PDF => [ CouponProductsHandler::PRODUCT_FIELD_ID_GENERATE_PDF => [
'title' => [ 'title' => [
'de' => 'Gutschein-Code als PDF bereitstellen', 'de' => 'Gutschein-Code als PDF bereitstellen',
'en' => 'Provide coupon code as PDF' 'en' => 'Provide coupon code as PDF'
...@@ -487,7 +489,7 @@ protected static function createProductFields() ...@@ -487,7 +489,7 @@ protected static function createProductFields()
'standard' => false, 'standard' => false,
'requiredField' => false 'requiredField' => false
], ],
CouponProductType::PRODUCT_FIELD_ID_COUPON_AMOUNT => [ CouponProductsHandler::PRODUCT_FIELD_ID_COUPON_AMOUNT => [
'title' => [ 'title' => [
'de' => 'Gutschein Wert', 'de' => 'Gutschein Wert',
'en' => 'Coupon amount' 'en' => 'Coupon amount'
...@@ -497,7 +499,7 @@ protected static function createProductFields() ...@@ -497,7 +499,7 @@ protected static function createProductFields()
'standard' => false, 'standard' => false,
'requiredField' => true 'requiredField' => true
], ],
CouponProductType::PRODUCT_FIELD_ID_DAYS_VALID => [ CouponProductsHandler::PRODUCT_FIELD_ID_DAYS_VALID => [
'title' => [ 'title' => [
'de' => 'Gutschein-Code Gültigkeit (Tage)', 'de' => 'Gutschein-Code Gültigkeit (Tage)',
'en' => 'Coupon code validity (days)' 'en' => 'Coupon code validity (days)'
...@@ -507,7 +509,7 @@ protected static function createProductFields() ...@@ -507,7 +509,7 @@ protected static function createProductFields()
'standard' => false, 'standard' => false,
'requiredField' => true 'requiredField' => true
], ],
CouponProductType::PRODUCT_FIELD_ID_COUPON_DESCRIPTION => [ CouponProductsHandler::PRODUCT_FIELD_ID_COUPON_DESCRIPTION => [
'title' => [ 'title' => [
'de' => 'Gutschein-Beschreibung', 'de' => 'Gutschein-Beschreibung',
'en' => 'Coupon description' 'en' => 'Coupon description'
...@@ -519,9 +521,9 @@ protected static function createProductFields() ...@@ -519,9 +521,9 @@ protected static function createProductFields()
'type' => Fields::TYPE_INPUT_MULTI_LANG, 'type' => Fields::TYPE_INPUT_MULTI_LANG,
'public' => false, 'public' => false,
'standard' => false, 'standard' => false,
'requiredField' => true 'requiredField' => false
], ],
CouponProductType::PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON => [ CouponProductsHandler::PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON => [
'title' => [ 'title' => [
'de' => 'Ist Einzweck-Gutschein (Besteuerung bei Gutschein-Kauf)', 'de' => 'Ist Einzweck-Gutschein (Besteuerung bei Gutschein-Kauf)',
'en' => 'Is single purpose coupon (taxation on voucher purchase)' 'en' => 'Is single purpose coupon (taxation on voucher purchase)'
...@@ -541,7 +543,7 @@ protected static function createProductFields() ...@@ -541,7 +543,7 @@ protected static function createProductFields()
'standard' => false, 'standard' => false,
'requiredField' => false 'requiredField' => false
], ],
CouponProductType::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT => [ CouponProductsHandler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT => [
'title' => [ 'title' => [
'de' => 'Gutschein - Versand', 'de' => 'Gutschein - Versand',
'en' => 'Coupon delivery' 'en' => 'Coupon delivery'
...@@ -575,7 +577,7 @@ protected static function createProductFields() ...@@ -575,7 +577,7 @@ protected static function createProductFields()
] ]
] ]
], ],
CouponProductType::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT_ALLOW => [ CouponProductsHandler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT_ALLOW => [
'title' => [ 'title' => [
'de' => 'Kunde darf Gutschein - Versandart wählen', 'de' => 'Kunde darf Gutschein - Versandart wählen',
'en' => 'Customer can choose coupon delivery type' 'en' => 'Customer can choose coupon delivery type'
...@@ -639,22 +641,23 @@ protected static function createProductFields() ...@@ -639,22 +641,23 @@ protected static function createProductFields()
*/ */
public static function onQuiqqerProductsProductCreate(ProductInterface $Product) public static function onQuiqqerProductsProductCreate(ProductInterface $Product)
{ {
if (!($Product instanceof CouponProductType)) { if (!($Product instanceof DigitalCouponProductType) && !($Product instanceof PhysicalCouponProductType)) {
return; return;
} }
$isDigital = $Product instanceof DigitalCouponProductType;
$UniqueProduct = $Product->createUniqueProduct(); $UniqueProduct = $Product->createUniqueProduct();
$UniqueProduct->calc(); $UniqueProduct->calc();
$fields = [ $fields = [
CouponProductType::PRODUCT_FIELD_ID_TRANSFERABLE => true, CouponProductsHandler::PRODUCT_FIELD_ID_TRANSFERABLE => true,
CouponProductType::PRODUCT_FIELD_ID_SEND_MAIL => true, CouponProductsHandler::PRODUCT_FIELD_ID_SEND_MAIL => $isDigital,
CouponProductType::PRODUCT_FIELD_ID_GENERATE_PDF => true, CouponProductsHandler::PRODUCT_FIELD_ID_GENERATE_PDF => $isDigital,
CouponProductType::PRODUCT_FIELD_ID_COUPON_AMOUNT => $UniqueProduct->getPrice()->getValue(), CouponProductsHandler::PRODUCT_FIELD_ID_COUPON_AMOUNT => $UniqueProduct->getPrice()->getValue(),
CouponProductType::PRODUCT_FIELD_ID_DAYS_VALID => 1095, // 3 years CouponProductsHandler::PRODUCT_FIELD_ID_DAYS_VALID => 1095, // 3 years
CouponProductType::PRODUCT_FIELD_ID_COUPON_DESCRIPTION => null, CouponProductsHandler::PRODUCT_FIELD_ID_COUPON_DESCRIPTION => null,
CouponProductType::PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON => false, CouponProductsHandler::PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON => false,
CouponProductType::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT => false CouponProductsHandler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT => false
]; ];
foreach ($fields as $fieldId => $value) { foreach ($fields as $fieldId => $value) {
...@@ -694,11 +697,11 @@ public static function onQuiqqerProductsProductCreate(ProductInterface $Product) ...@@ -694,11 +697,11 @@ public static function onQuiqqerProductsProductCreate(ProductInterface $Product)
*/ */
public static function onQuiqqerProductsProductActivate(ProductInterface $Product) public static function onQuiqqerProductsProductActivate(ProductInterface $Product)
{ {
if (!($Product instanceof CouponProductType)) { if (!($Product instanceof DigitalCouponProductType) && !($Product instanceof PhysicalCouponProductType)) {
return; return;
} }
$isSinglePurposeCoupon = $Product->getFieldValue(CouponProductType::PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON); $isSinglePurposeCoupon = $Product->getFieldValue(CouponProductsHandler::PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON);
if (!empty($isSinglePurposeCoupon)) { if (!empty($isSinglePurposeCoupon)) {
return; return;
......
...@@ -8,23 +8,10 @@ ...@@ -8,23 +8,10 @@
/** /**
* Class DigitalProduct * Class DigitalProduct
* *
* Represents a non-physical product that does not require shipping. * Represents a non-physical coupon that does not require shipping.
*/ */
class CouponProductType extends DigitalProduct class DigitalCouponProductType extends DigitalProduct
{ {
/**
* Special fields for coupon products
*/
const PRODUCT_FIELD_ID_TRANSFERABLE = 670;
const PRODUCT_FIELD_ID_GENERATE_PDF = 671;
const PRODUCT_FIELD_ID_COUPON_AMOUNT = 672;
const PRODUCT_FIELD_ID_DAYS_VALID = 673;
const PRODUCT_FIELD_ID_COUPON_DESCRIPTION = 674;
const PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON = 675;
const PRODUCT_FIELD_ID_SEND_MAIL = 676;
const PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT = 678;
const PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT_ALLOW = 679;
/** /**
* Model constructor * Model constructor
* *
...@@ -38,15 +25,15 @@ public function __construct($pid, $product = []) ...@@ -38,15 +25,15 @@ public function __construct($pid, $product = [])
{ {
parent::__construct($pid, $product); parent::__construct($pid, $product);
if (!empty($this->fields[self::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT_ALLOW])) { if (!empty($this->fields[Handler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT_ALLOW])) {
$userDeliveryTypeSelectAllow = $this->getFieldValue( $userDeliveryTypeSelectAllow = $this->getFieldValue(
self::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT_ALLOW Handler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT_ALLOW
); );
if ($userDeliveryTypeSelectAllow) { if ($userDeliveryTypeSelectAllow) {
try { try {
$Field = QUI\ERP\Products\Handler\Fields::getField( $Field = QUI\ERP\Products\Handler\Fields::getField(
self::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT Handler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT
); );
$Field->setProduct($this); $Field->setProduct($this);
...@@ -56,7 +43,7 @@ public function __construct($pid, $product = []) ...@@ -56,7 +43,7 @@ public function __construct($pid, $product = [])
QUI\System\Log::writeException($Exception); QUI\System\Log::writeException($Exception);
} }
} else { } else {
unset($this->fields[self::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT]); unset($this->fields[Handler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT]);
} }
} }
} }
...@@ -71,7 +58,7 @@ public static function getTypeTitle($Locale = null) ...@@ -71,7 +58,7 @@ public static function getTypeTitle($Locale = null)
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
} }
return $Locale->get('quiqqer/coupons', 'product_type.CouponProductType.title'); return $Locale->get('quiqqer/coupons', 'product_type.DigitalCouponProductType.title');
} }
/** /**
...@@ -84,6 +71,6 @@ public static function getTypeDescription($Locale = null) ...@@ -84,6 +71,6 @@ public static function getTypeDescription($Locale = null)
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
} }
return $Locale->get('quiqqer/coupons', 'product_type.CouponProductType.description'); return $Locale->get('quiqqer/coupons', 'product_type.DigitalCouponProductType.description');
} }
} }
...@@ -19,6 +19,19 @@ ...@@ -19,6 +19,19 @@
*/ */
class Handler class Handler
{ {
/**
* Special fields for coupon products
*/
const PRODUCT_FIELD_ID_TRANSFERABLE = 670;
const PRODUCT_FIELD_ID_GENERATE_PDF = 671;
const PRODUCT_FIELD_ID_COUPON_AMOUNT = 672;
const PRODUCT_FIELD_ID_DAYS_VALID = 673;
const PRODUCT_FIELD_ID_COUPON_DESCRIPTION = 674;
const PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON = 675;
const PRODUCT_FIELD_ID_SEND_MAIL = 676;
const PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT = 678;
const PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT_ALLOW = 679;
/** /**
* Create coupons from all coupon products of an order. * Create coupons from all coupon products of an order.
* *
...@@ -43,7 +56,8 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O ...@@ -43,7 +56,8 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O
$Product = ProductsHandler::getProduct($Article->getId()); $Product = ProductsHandler::getProduct($Article->getId());
// Only parse coupon products // Only parse coupon products
if (!($Product instanceof CouponProductType)) { if (!($Product instanceof DigitalCouponProductType) &&
!($Product instanceof PhysicalCouponProductType)) {
continue; continue;
} }
...@@ -59,14 +73,14 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O ...@@ -59,14 +73,14 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O
'productTitle' => $Product->getTitle(), 'productTitle' => $Product->getTitle(),
'productId' => $Product->getId(), 'productId' => $Product->getId(),
'couponAmount' => $Currency->format( 'couponAmount' => $Currency->format(
$Product->getFieldValue(CouponProductType::PRODUCT_FIELD_ID_COUPON_AMOUNT) $Product->getFieldValue(self::PRODUCT_FIELD_ID_COUPON_AMOUNT)
) )
] ]
) )
); );
// Generate coupon PDF // Generate coupon PDF
if ($Product->getFieldValue(CouponProductType::PRODUCT_FIELD_ID_GENERATE_PDF)) { if ($Product->getFieldValue(self::PRODUCT_FIELD_ID_GENERATE_PDF)) {
$couponPdfFile = self::createCouponCodePdf($CouponCode, $Product); $couponPdfFile = self::createCouponCodePdf($CouponCode, $Product);
// Rename file // Rename file
...@@ -101,7 +115,7 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O ...@@ -101,7 +115,7 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O
* Check if customer explicitly chose "send by email" * Check if customer explicitly chose "send by email"
*/ */
$deliveryTypeFieldData = $Article->getCustomField( $deliveryTypeFieldData = $Article->getCustomField(
CouponProductType::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT self::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT
); );
if ($deliveryTypeFieldData) { if ($deliveryTypeFieldData) {
...@@ -116,7 +130,7 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O ...@@ -116,7 +130,7 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O
$sendMail = true; $sendMail = true;
} }
} else { } else {
$sendMail = $Product->getFieldValue(CouponProductType::PRODUCT_FIELD_ID_SEND_MAIL); $sendMail = $Product->getFieldValue(self::PRODUCT_FIELD_ID_SEND_MAIL);
} }
if ($sendMail) { if ($sendMail) {
...@@ -173,7 +187,7 @@ protected static function createCouponCodeFromProduct( ...@@ -173,7 +187,7 @@ protected static function createCouponCodeFromProduct(
]; ];
// Valid until // Valid until
$daysValid = $Product->getFieldValue(CouponProductType::PRODUCT_FIELD_ID_DAYS_VALID); $daysValid = $Product->getFieldValue(self::PRODUCT_FIELD_ID_DAYS_VALID);
if (empty($daysValid)) { if (empty($daysValid)) {
$daysValid = 1095; // 3 years; $daysValid = 1095; // 3 years;
...@@ -183,7 +197,7 @@ protected static function createCouponCodeFromProduct( ...@@ -183,7 +197,7 @@ 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(CouponProductType::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()];
...@@ -204,7 +218,7 @@ protected static function createDiscountFromProduct(Product $Product): Discount ...@@ -204,7 +218,7 @@ protected static function createDiscountFromProduct(Product $Product): Discount
{ {
$Handler = DiscountHandler::getInstance(); $Handler = DiscountHandler::getInstance();
$discountAmount = $Product->getFieldValue(CouponProductType::PRODUCT_FIELD_ID_COUPON_AMOUNT); $discountAmount = $Product->getFieldValue(self::PRODUCT_FIELD_ID_COUPON_AMOUNT);
if (empty($discountAmount)) { if (empty($discountAmount)) {
$discountAmount = $Product->getPrice()->getValue(); $discountAmount = $Product->getPrice()->getValue();
...@@ -212,7 +226,7 @@ protected static function createDiscountFromProduct(Product $Product): Discount ...@@ -212,7 +226,7 @@ protected static function createDiscountFromProduct(Product $Product): Discount
// Determine discount calculation basis based on coupon type // Determine discount calculation basis based on coupon type
$isProductSpecificCoupon = $Product->getFieldValue( $isProductSpecificCoupon = $Product->getFieldValue(
CouponProductType::PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON self::PRODUCT_FIELD_ID_IS_SINGLE_PURPOSE_COUPON
); );
// @todo für Einzweck-Gutscheine muss ein spezieller Rabatt-Typ verwendet werden // @todo für Einzweck-Gutscheine muss ein spezieller Rabatt-Typ verwendet werden
...@@ -411,7 +425,7 @@ protected static function getCouponViewData(CouponCode $CouponCode, Product $Pro ...@@ -411,7 +425,7 @@ protected static function getCouponViewData(CouponCode $CouponCode, Product $Pro
'productTitle' => $Product->getTitle(), 'productTitle' => $Product->getTitle(),
'userName' => $User ? $User->getName() : false, 'userName' => $User ? $User->getName() : false,
'couponDescription' => $Product->getFieldValueByLocale( 'couponDescription' => $Product->getFieldValueByLocale(
CouponProductType::PRODUCT_FIELD_ID_COUPON_DESCRIPTION self::PRODUCT_FIELD_ID_COUPON_DESCRIPTION
), ),
'discountAmountFormatted' => $DiscountAmount->getDisplayPrice(), 'discountAmountFormatted' => $DiscountAmount->getDisplayPrice(),
'createDateFormatted' => $Locale->formatDate( 'createDateFormatted' => $Locale->formatDate(
......
<?php
namespace QUI\ERP\Coupons\Products;
use QUI;
use QUI\ERP\Products\Product\Types\DigitalProduct;
/**
* Class PhysicalCouponProductType
*
* Represents a physical coupon that requires shipping.
*/
class PhysicalCouponProductType extends QUI\ERP\Products\Product\Types\AbstractType
{
/**
* Model constructor
*
* @param integer $pid - Product-ID
* @param array $product - Product Data
*
* @throws QUI\ERP\Products\Product\Exception
* @throws QUI\Exception
*/
public function __construct($pid, $product = [])
{
parent::__construct($pid, $product);
if (!empty($this->fields[Handler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT_ALLOW])) {
$userDeliveryTypeSelectAllow = $this->getFieldValue(
Handler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT_ALLOW
);
if ($userDeliveryTypeSelectAllow) {
try {
$Field = QUI\ERP\Products\Handler\Fields::getField(
Handler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT
);
$Field->setProduct($this);
$this->fields[$Field->getId()] = $Field;
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeException($Exception);
}
} else {
unset($this->fields[Handler::PRODUCT_FIELD_ID_USER_DELIVERY_TYPE_SELECT]);
}
}
}
/**
* @param QUI\Locale $Locale
* @return string
*/
public static function getTypeTitle($Locale = null)
{
if ($Locale === null) {
$Locale = QUI::getLocale();
}
return $Locale->get('quiqqer/coupons', 'product_type.PhysicalCouponProductType.title');
}
/**
* @param QUI\Locale $Locale
* @return string
*/
public static function getTypeDescription($Locale = null)
{
if ($Locale === null) {
$Locale = QUI::getLocale();
}
return $Locale->get('quiqqer/coupons', 'product_type.PhysicalCouponProductType.description');
}
}
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