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

feat: coupon products

Übergeordneter c580a59d
Branches feat-couponproducts
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -12,6 +12,7 @@
<field>672</field>
<field>673</field>
<field>674</field>
<field>675</field>
</fields>
</fieldCategory>
</fieldCategories>
......
......@@ -420,58 +420,64 @@ protected static function createProductFields()
{
$fields = [
CouponProductType::PRODUCT_FIELD_ID_TRANSFERABLE => [
'title' => [
'title' => [
'de' => 'Gutschein-Code ist übertragbar',
'en' => 'Coupon code is transferable'
],
'type' => Fields::TYPE_BOOL,
'public' => false,
'standard' => false
'type' => Fields::TYPE_BOOL,
'public' => false,
'standard' => false,
'requiredField' => false
],
CouponProductType::PRODUCT_FIELD_ID_GENERATE_PDF => [
'title' => [
'title' => [
'de' => 'Gutschein-Code als PDF bereitstellen',
'en' => 'Provide coupon code as PDF'
],
'type' => Fields::TYPE_BOOL,
'public' => false,
'standard' => false
'type' => Fields::TYPE_BOOL,
'public' => false,
'standard' => false,
'requiredField' => false
],
CouponProductType::PRODUCT_FIELD_ID_COUPON_AMOUNT => [
'title' => [
'title' => [
'de' => 'Gutschein Wert',
'en' => 'Coupon amount'
],
'type' => Fields::TYPE_FLOAT,
'public' => false,
'standard' => false
'type' => Fields::TYPE_FLOAT,
'public' => false,
'standard' => false,
'requiredField' => true
],
CouponProductType::PRODUCT_FIELD_ID_DAYS_VALID => [
'title' => [
'title' => [
'de' => 'Gutschein-Code Gültigkeit (Tage)',
'en' => 'Coupon code validity (days)'
],
'type' => Fields::TYPE_INT,
'public' => false,
'standard' => false
'type' => Fields::TYPE_INT,
'public' => false,
'standard' => false,
'requiredField' => true
],
CouponProductType::PRODUCT_FIELD_ID_COUPON_DESCRIPTION => [
'title' => [
'title' => [
'de' => 'Gutschein-Beschreibung',
'en' => 'Coupon description'
],
'type' => Fields::TYPE_INPUT_MULTI_LANG,
'public' => false,
'standard' => false
'type' => Fields::TYPE_INPUT_MULTI_LANG,
'public' => false,
'standard' => false,
'requiredField' => true
],
CouponProductType::PRODUCT_FIELD_ID_IS_PRODUCT_SPECIFIC_COUPON => [
'title' => [
'de' => 'Ist Gutschein für ein spezifisches Produkt ("Einzweck-Gutschein")',
'en' => 'Is coupon for a specific product ("single purpose coupon")'
'title' => [
'de' => 'Ist Gutschein für spezifische Produkte ("Einzweck-Gutschein")',
'en' => 'Is coupon for specific products ("single purpose coupon")'
],
'type' => Fields::TYPE_BOOL,
'public' => false,
'standard' => false
'type' => Fields::TYPE_BOOL,
'public' => false,
'standard' => false,
'requiredField' => false
]
];
......@@ -494,7 +500,8 @@ protected static function createProductFields()
'systemField' => 0,
'standardField' => !empty($field['standard']) ? 1 : 0,
'publicField' => !empty($field['public']) ? 1 : 0,
'options' => !empty($field['options']) ? $field['options'] : null
'options' => !empty($field['options']) ? $field['options'] : null,
'requiredField' => !empty($field['requiredField']) ? 1 : 0
]);
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
......@@ -521,13 +528,16 @@ public static function onQuiqqerProductsProductCreate(ProductInterface $Product)
return;
}
$UniqueProduct = $Product->createUniqueProduct();
$UniqueProduct->calc();
$fields = [
CouponProductType::PRODUCT_FIELD_ID_TRANSFERABLE => true,
CouponProductType::PRODUCT_FIELD_ID_GENERATE_PDF => true,
CouponProductType::PRODUCT_FIELD_ID_COUPON_AMOUNT => null,
CouponProductType::PRODUCT_FIELD_ID_DAYS_VALID => 1095, // 3 years
CouponProductType::PRODUCT_FIELD_ID_COUPON_DESCRIPTION => null,
CouponProductType::PRODUCT_FIELD_ID_IS_PRODUCT_SPECIFIC_COUPON => false
CouponProductType::PRODUCT_FIELD_ID_TRANSFERABLE => true,
CouponProductType::PRODUCT_FIELD_ID_GENERATE_PDF => true,
CouponProductType::PRODUCT_FIELD_ID_COUPON_AMOUNT => $UniqueProduct->getPrice()->getValue(),
CouponProductType::PRODUCT_FIELD_ID_DAYS_VALID => 1095, // 3 years
CouponProductType::PRODUCT_FIELD_ID_COUPON_DESCRIPTION => null,
// CouponProductType::PRODUCT_FIELD_ID_IS_PRODUCT_SPECIFIC_COUPON => false // @todo later
];
foreach ($fields as $fieldId => $value) {
......
......@@ -170,7 +170,8 @@ protected static function createDiscountFromProduct(Product $Product): Discount
'active' => 1,
'discount' => $discountAmount,
'discount_type' => DiscountHandler::DISCOUNT_TYPE_CURRENCY,
'hidden' => 1
'hidden' => 1,
'scope' => DiscountHandler::DISCOUNT_SCOPE_GRAND_TOTAL
]);
$L = new QUI\Locale();
......
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