diff --git a/products.xml b/products.xml index 6a634fa3ce74d4395a677f6e4a608d23fcdd6ad0..cb83a200233686b2968e608445da0e8497511830 100644 --- a/products.xml +++ b/products.xml @@ -12,6 +12,7 @@ <field>672</field> <field>673</field> <field>674</field> + <field>675</field> </fields> </fieldCategory> </fieldCategories> diff --git a/src/QUI/ERP/Coupons/Events.php b/src/QUI/ERP/Coupons/Events.php index 7c0b6f28842ee6d316e5e37b6d6f7085b747a8bc..e00a78fc643a51be17a9ed98d597d077c07cb38f 100644 --- a/src/QUI/ERP/Coupons/Events.php +++ b/src/QUI/ERP/Coupons/Events.php @@ -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) { diff --git a/src/QUI/ERP/Coupons/Products/Handler.php b/src/QUI/ERP/Coupons/Products/Handler.php index a930fd16a83ec07281f84a9c23d4090a1d156098..ab2c75c8df7a15e7111fe7617aec9e7229c0249c 100644 --- a/src/QUI/ERP/Coupons/Products/Handler.php +++ b/src/QUI/ERP/Coupons/Products/Handler.php @@ -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();