diff --git a/core/lib/Thelia/Coupon/Type/RemoveAmountOnCategories.php b/core/lib/Thelia/Coupon/Type/RemoveAmountOnCategories.php new file mode 100644 index 000000000..2372dbfb4 --- /dev/null +++ b/core/lib/Thelia/Coupon/Type/RemoveAmountOnCategories.php @@ -0,0 +1,81 @@ + + * + */ +class RemoveAmountOnCategories extends CouponAbstract +{ + const CATEGORIES_LIST = 'categories'; + + /** @var string Service Id */ + protected $serviceId = 'thelia.coupon.type.remove_amount_on_categories'; + + /** + * Get I18n name + * + * @return string + */ + public function getName() + { + return $this->facade + ->getTranslator() + ->trans('Fixed amount discount on selected categories', array(), 'coupon'); + } + + /** + * Get I18n tooltip + * + * @return string + */ + public function getToolTip() + { + $toolTip = $this->facade + ->getTranslator() + ->trans( + 'This coupon subtracts the specified amount from the order total for each product of the selected categories. If the discount is greater than the total order, the customer will only pay the shipping, or nothing if the coupon also provides free shipping.', + array(), + 'coupon' + ); + + return $toolTip; + } + + /** + * Return effects generated by the coupon + * A negative value + * + * @return float Amount removed from the Total Checkout + */ + public function exec() + { + return $this->amount; + } + + public function drawBackOfficeInputs() + { + return $this->facade->getParser()->render('coupon/type-fragments/remove-amount-on-categories.html', [ + 'amount_field_name' => self::INPUT_AMOUNT_NAME, + 'amount_value' => $this->amount, + + 'categories_field_name' => self::CATEGORIES_LIST, + 'categories_values' => isset($this->values[self::CATEGORIES_LIST]) ? $this->values[self::CATEGORIES_LIST] : array() + + ]); + } +} diff --git a/templates/backOffice/default/coupon/type-fragments/remove-amount-on-categories.html b/templates/backOffice/default/coupon/type-fragments/remove-amount-on-categories.html new file mode 100644 index 000000000..b14a171a5 --- /dev/null +++ b/templates/backOffice/default/coupon/type-fragments/remove-amount-on-categories.html @@ -0,0 +1,19 @@ +