From 567fee839c7a5c2ded6d4bc2e70df14e1d3e1559 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Wed, 28 May 2014 12:02:56 +0200 Subject: [PATCH] Added RemoveAmountOnCategories coupon type --- .../Coupon/Type/RemoveAmountOnCategories.php | 81 +++++++++++++++++++ .../remove-amount-on-categories.html | 19 +++++ 2 files changed, 100 insertions(+) create mode 100644 core/lib/Thelia/Coupon/Type/RemoveAmountOnCategories.php create mode 100644 templates/backOffice/default/coupon/type-fragments/remove-amount-on-categories.html 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 @@ +
+ +
+ + {loop type="currency" name="get-symbol" default_only="true"} +
{$SYMBOL}
+ {/loop} +
+
+ +
+ + + {intl l='Use Ctrl+click to select (or deselect) more that one category'} +