Merge pull request #350 from lunika/permanentDiscount

apply a permanent discount on a customer.
This commit is contained in:
Manuel Raynaud
2014-04-29 12:06:13 +02:00
19 changed files with 1186 additions and 1126 deletions

View File

@@ -1,3 +1,9 @@
#2.0.1
- possibility to apply a permanent discount on a customer
- display estimated shipping on cart page
- export newsletter subscribers list
- Fix redirect issues
#2.0.0 #2.0.0
- Coupons values are re-evaluated when a product quantity is changed in the shopping cart - Coupons values are re-evaluated when a product quantity is changed in the shopping cart
- You can declare new compilerPass in modules. See Thelia\Module\BaseModule::getCompilers phpDoc - You can declare new compilerPass in modules. See Thelia\Module\BaseModule::getCompilers phpDoc

View File

@@ -48,6 +48,12 @@ class Cart extends BaseAction implements EventSubscriberInterface
$append = $event->getAppend(); $append = $event->getAppend();
$quantity = $event->getQuantity(); $quantity = $event->getQuantity();
$currency = $cart->getCurrency(); $currency = $cart->getCurrency();
$customer = $cart->getCustomer();
$discount = 0;
if (null !== $customer && $customer->getDiscount() > 0) {
$discount = $customer->getDiscount();
}
$productSaleElementsId = $event->getProductSaleElementsId(); $productSaleElementsId = $event->getProductSaleElementsId();
$productId = $event->getProduct(); $productId = $event->getProduct();
@@ -60,7 +66,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
->findPk($productSaleElementsId); ->findPk($productSaleElementsId);
if (null !== $productSaleElements) { if (null !== $productSaleElements) {
$productPrices = $productSaleElements->getPricesByCurrency($currency); $productPrices = $productSaleElements->getPricesByCurrency($currency, $discount);
$event->setCartItem( $event->setCartItem(
$this->doAddItem($event->getDispatcher(), $cart, $productId, $productSaleElements, $quantity, $productPrices) $this->doAddItem($event->getDispatcher(), $cart, $productId, $productSaleElements, $quantity, $productPrices)
); );
@@ -151,11 +157,18 @@ class Cart extends BaseAction implements EventSubscriberInterface
public function updateCartPrices(\Thelia\Model\Cart $cart, Currency $currency) public function updateCartPrices(\Thelia\Model\Cart $cart, Currency $currency)
{ {
$customer = $cart->getCustomer();
$discount = 0;
if (null !== $customer && $customer->getDiscount() > 0) {
$discount = $customer->getDiscount();
}
// cart item // cart item
foreach ($cart->getCartItems() as $cartItem) { foreach ($cart->getCartItems() as $cartItem) {
$productSaleElements = $cartItem->getProductSaleElements(); $productSaleElements = $cartItem->getProductSaleElements();
$productPrice = $productSaleElements->getPricesByCurrency($currency); $productPrice = $productSaleElements->getPricesByCurrency($currency, $discount);
$cartItem $cartItem
->setPrice($productPrice->getPrice()) ->setPrice($productPrice->getPrice())

View File

@@ -112,7 +112,8 @@ trait CartTrait
*/ */
protected function duplicateCart(EventDispatcherInterface $dispatcher, CartModel $cart, Session $session, Customer $customer = null) protected function duplicateCart(EventDispatcherInterface $dispatcher, CartModel $cart, Session $session, Customer $customer = null)
{ {
$newCart = $cart->duplicate($this->generateCookie($session), $customer, $dispatcher); $currency = $session->getCurrency();
$newCart = $cart->duplicate($this->generateCookie($session), $customer, $currency, $dispatcher);
$session->setCart($newCart->getId()); $session->setCart($newCart->getId());
$cartEvent = new CartEvent($newCart); $cartEvent = new CartEvent($newCart);

View File

@@ -23,7 +23,6 @@ return array(
'Alpha code 3 *' => 'Alpha code 3 *', 'Alpha code 3 *' => 'Alpha code 3 *',
'Amount removed from the cart' => 'Amount removed from the cart', 'Amount removed from the cart' => 'Amount removed from the cart',
'Apply exchange rates on price in %sym' => 'Apply exchange rates on price in %sym', 'Apply exchange rates on price in %sym' => 'Apply exchange rates on price in %sym',
'Area' => 'Area',
'Attribute ID:Attribute AV ID' => 'Attribute ID:Attribute AV ID', 'Attribute ID:Attribute AV ID' => 'Attribute ID:Attribute AV ID',
'Auth mode' => 'Auth mode', 'Auth mode' => 'Auth mode',
'Available quantity' => 'Available quantity', 'Available quantity' => 'Available quantity',
@@ -212,7 +211,6 @@ return array(
'Value *' => 'Value *', 'Value *' => 'Value *',
'Warnings' => 'Warnings', 'Warnings' => 'Warnings',
'Weight' => 'Weight', 'Weight' => 'Weight',
'Weight *' => 'Weight *',
'Yes, I have a password :' => 'Yes, I have a password :', 'Yes, I have a password :' => 'Yes, I have a password :',
'You are already registered!' => 'You are already registered!', 'You are already registered!' => 'You are already registered!',
'Your Email Address' => 'Your Email Address', 'Your Email Address' => 'Your Email Address',
@@ -221,13 +219,13 @@ return array(
'Zip code' => 'Zip code', 'Zip code' => 'Zip code',
'date format' => 'date format', 'date format' => 'date format',
'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface', 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface',
'payment module %s is not a Thelia\Module\PaymentModuleInterface' => 'payment module %s is not a Thelia\Module\PaymentModuleInterface',
'language locale' => 'language locale', 'language locale' => 'language locale',
'mailing system modification' => 'mailing system modification', 'mailing system modification' => 'mailing system modification',
'password confirmation is not the same as password field' => 'password confirmation is not the same as password field', 'password confirmation is not the same as password field' => 'password confirmation is not the same as password field',
'password must be composed of at least 4 characters' => 'password must be composed of at least 4 characters', 'password must be composed of at least 4 characters' => 'password must be composed of at least 4 characters',
'payment module %s is not a Thelia\Module\PaymentModuleInterface' => 'payment module %s is not a Thelia\Module\PaymentModuleInterface',
'permanent discount (in percent)' => 'permanent discount (in percent)',
'quantity value is not valid' => 'quantity value is not valid', 'quantity value is not valid' => 'quantity value is not valid',
'shipping area name' => 'shipping area name',
'this product id does not exists : %d' => 'this product id does not exists : %d', 'this product id does not exists : %d' => 'this product id does not exists : %d',
'time format' => 'time format', 'time format' => 'time format',
); );

View File

@@ -299,6 +299,7 @@ return array(
'password confirmation is not the same as password field' => 'le mot de passe de confirmation n\'est pas le même que le champ mot de passe', 'password confirmation is not the same as password field' => 'le mot de passe de confirmation n\'est pas le même que le champ mot de passe',
'password must be composed of at least 4 characters' => 'le mot de passe doit être composé d\'au moins 4 caractères', 'password must be composed of at least 4 characters' => 'le mot de passe doit être composé d\'au moins 4 caractères',
'payment module %s is not a Thelia\Module\PaymentModuleInterface' => 'Le module de paiement %s n\'est pas une instance de Thelia\Module\PaymentModuleInterface ', 'payment module %s is not a Thelia\Module\PaymentModuleInterface' => 'Le module de paiement %s n\'est pas une instance de Thelia\Module\PaymentModuleInterface ',
'permanent discount (in percent)' => 'Remise permanente (en pourcentage)',
'quantity value is not valid' => 'la valeur de la quantité n\'est pas valide', 'quantity value is not valid' => 'la valeur de la quantité n\'est pas valide',
'superior or equal to' => 'supérieur ou égal à', 'superior or equal to' => 'supérieur ou égal à',
'superior to' => 'supérieur à', 'superior to' => 'supérieur à',

View File

@@ -1,132 +1,132 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config" <config xmlns="http://thelia.net/schema/dic/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd"> xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<forms> <forms>
<!-- Forms for Frontend --> <!-- Forms for Frontend -->
<form name="thelia.front.customer.login" class="Thelia\Form\CustomerLogin"/> <form name="thelia.front.customer.login" class="Thelia\Form\CustomerLogin"/>
<form name="thelia.front.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/> <form name="thelia.front.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
<form name="thelia.front.customer.create" class="Thelia\Form\CustomerCreateForm"/> <form name="thelia.front.customer.create" class="Thelia\Form\CustomerCreateForm"/>
<form name="thelia.front.customer.profile.update" class="Thelia\Form\CustomerProfileUpdateForm"/> <form name="thelia.front.customer.profile.update" class="Thelia\Form\CustomerProfileUpdateForm"/>
<form name="thelia.front.customer.password.update" class="Thelia\Form\CustomerPasswordUpdateForm"/> <form name="thelia.front.customer.password.update" class="Thelia\Form\CustomerPasswordUpdateForm"/>
<form name="thelia.front.address.create" class="Thelia\Form\AddressCreateForm"/> <form name="thelia.front.address.create" class="Thelia\Form\AddressCreateForm"/>
<form name="thelia.front.address.update" class="Thelia\Form\AddressUpdateForm"/> <form name="thelia.front.address.update" class="Thelia\Form\AddressUpdateForm"/>
<form name="thelia.front.contact" class="Thelia\Form\ContactForm"/> <form name="thelia.front.contact" class="Thelia\Form\ContactForm"/>
<form name="thelia.front.newsletter" class="Thelia\Form\NewsletterForm"/> <form name="thelia.front.newsletter" class="Thelia\Form\NewsletterForm"/>
<form name="thelia.admin.login" class="Thelia\Form\AdminLogin"/> <form name="thelia.admin.login" class="Thelia\Form\AdminLogin"/>
<form name="thelia.admin.seo" class="Thelia\Form\SeoForm"/> <form name="thelia.admin.seo" class="Thelia\Form\SeoForm"/>
<form name="thelia.admin.customer.create" class="Thelia\Form\CustomerCreateForm"/> <form name="thelia.admin.customer.create" class="Thelia\Form\CustomerCreateForm"/>
<form name="thelia.admin.customer.update" class="Thelia\Form\CustomerUpdateForm"/> <form name="thelia.admin.customer.update" class="Thelia\Form\CustomerUpdateForm"/>
<form name="thelia.admin.address.create" class="Thelia\Form\AddressCreateForm" /> <form name="thelia.admin.address.create" class="Thelia\Form\AddressCreateForm" />
<form name="thelia.admin.address.update" class="Thelia\Form\AddressUpdateForm" /> <form name="thelia.admin.address.update" class="Thelia\Form\AddressUpdateForm" />
<form name="thelia.admin.category.creation" class="Thelia\Form\CategoryCreationForm"/> <form name="thelia.admin.category.creation" class="Thelia\Form\CategoryCreationForm"/>
<form name="thelia.admin.category.modification" class="Thelia\Form\CategoryModificationForm"/> <form name="thelia.admin.category.modification" class="Thelia\Form\CategoryModificationForm"/>
<form name="thelia.admin.category.image.modification" class="Thelia\Form\CategoryImageModification"/> <form name="thelia.admin.category.image.modification" class="Thelia\Form\CategoryImageModification"/>
<form name="thelia.admin.category.document.modification" class="Thelia\Form\CategoryDocumentModification"/> <form name="thelia.admin.category.document.modification" class="Thelia\Form\CategoryDocumentModification"/>
<form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/> <form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/>
<form name="thelia.admin.product.modification" class="Thelia\Form\ProductModificationForm"/> <form name="thelia.admin.product.modification" class="Thelia\Form\ProductModificationForm"/>
<form name="thelia.admin.product.details.modification" class="Thelia\Form\ProductDetailsModificationForm"/> <form name="thelia.admin.product.details.modification" class="Thelia\Form\ProductDetailsModificationForm"/>
<form name="thelia.admin.product.image.modification" class="Thelia\Form\ProductImageModification"/> <form name="thelia.admin.product.image.modification" class="Thelia\Form\ProductImageModification"/>
<form name="thelia.admin.product.document.modification" class="Thelia\Form\ProductDocumentModification"/> <form name="thelia.admin.product.document.modification" class="Thelia\Form\ProductDocumentModification"/>
<form name="thelia.admin.product_sale_element.update" class="Thelia\Form\ProductSaleElementUpdateForm"/> <form name="thelia.admin.product_sale_element.update" class="Thelia\Form\ProductSaleElementUpdateForm"/>
<form name="thelia.admin.product_default_sale_element.update" class="Thelia\Form\ProductDefaultSaleElementUpdateForm"/> <form name="thelia.admin.product_default_sale_element.update" class="Thelia\Form\ProductDefaultSaleElementUpdateForm"/>
<form name="thelia.admin.product_combination.build" class="Thelia\Form\ProductCombinationGenerationForm"/> <form name="thelia.admin.product_combination.build" class="Thelia\Form\ProductCombinationGenerationForm"/>
<form name="thelia.admin.product.deletion" class="Thelia\Form\ProductModificationForm"/> <form name="thelia.admin.product.deletion" class="Thelia\Form\ProductModificationForm"/>
<form name="thelia.admin.folder.creation" class="Thelia\Form\FolderCreationForm"/> <form name="thelia.admin.folder.creation" class="Thelia\Form\FolderCreationForm"/>
<form name="thelia.admin.folder.modification" class="Thelia\Form\FolderModificationForm"/> <form name="thelia.admin.folder.modification" class="Thelia\Form\FolderModificationForm"/>
<form name="thelia.admin.folder.image.modification" class="Thelia\Form\FolderImageModification"/> <form name="thelia.admin.folder.image.modification" class="Thelia\Form\FolderImageModification"/>
<form name="thelia.admin.folder.document.modification" class="Thelia\Form\FolderDocumentModification"/> <form name="thelia.admin.folder.document.modification" class="Thelia\Form\FolderDocumentModification"/>
<form name="thelia.admin.content.creation" class="Thelia\Form\ContentCreationForm"/> <form name="thelia.admin.content.creation" class="Thelia\Form\ContentCreationForm"/>
<form name="thelia.admin.content.modification" class="Thelia\Form\ContentModificationForm"/> <form name="thelia.admin.content.modification" class="Thelia\Form\ContentModificationForm"/>
<form name="thelia.admin.content.image.modification" class="Thelia\Form\ContentImageModification"/> <form name="thelia.admin.content.image.modification" class="Thelia\Form\ContentImageModification"/>
<form name="thelia.admin.content.document.modification" class="Thelia\Form\ContentDocumentModification"/> <form name="thelia.admin.content.document.modification" class="Thelia\Form\ContentDocumentModification"/>
<form name="thelia.cart.add" class="Thelia\Form\CartAdd"/> <form name="thelia.cart.add" class="Thelia\Form\CartAdd"/>
<form name="thelia.order.delivery" class="Thelia\Form\OrderDelivery"/> <form name="thelia.order.delivery" class="Thelia\Form\OrderDelivery"/>
<form name="thelia.order.payment" class="Thelia\Form\OrderPayment"/> <form name="thelia.order.payment" class="Thelia\Form\OrderPayment"/>
<form name="thelia.order.update.address" class="Thelia\Form\OrderUpdateAddress"/> <form name="thelia.order.update.address" class="Thelia\Form\OrderUpdateAddress"/>
<form name="thelia.order.coupon" class="Thelia\Form\CouponCode"/> <form name="thelia.order.coupon" class="Thelia\Form\CouponCode"/>
<form name="thelia.admin.config.creation" class="Thelia\Form\ConfigCreationForm"/> <form name="thelia.admin.config.creation" class="Thelia\Form\ConfigCreationForm"/>
<form name="thelia.admin.config.modification" class="Thelia\Form\ConfigModificationForm"/> <form name="thelia.admin.config.modification" class="Thelia\Form\ConfigModificationForm"/>
<form name="thelia.admin.message.creation" class="Thelia\Form\MessageCreationForm"/> <form name="thelia.admin.message.creation" class="Thelia\Form\MessageCreationForm"/>
<form name="thelia.admin.message.modification" class="Thelia\Form\MessageModificationForm"/> <form name="thelia.admin.message.modification" class="Thelia\Form\MessageModificationForm"/>
<form name="thelia.admin.currency.creation" class="Thelia\Form\CurrencyCreationForm"/> <form name="thelia.admin.currency.creation" class="Thelia\Form\CurrencyCreationForm"/>
<form name="thelia.admin.currency.modification" class="Thelia\Form\CurrencyModificationForm"/> <form name="thelia.admin.currency.modification" class="Thelia\Form\CurrencyModificationForm"/>
<form name="thelia.admin.coupon.creation" class="Thelia\Form\CouponCreationForm"/> <form name="thelia.admin.coupon.creation" class="Thelia\Form\CouponCreationForm"/>
<form name="thelia.admin.attribute.creation" class="Thelia\Form\AttributeCreationForm"/> <form name="thelia.admin.attribute.creation" class="Thelia\Form\AttributeCreationForm"/>
<form name="thelia.admin.attribute.modification" class="Thelia\Form\AttributeModificationForm"/> <form name="thelia.admin.attribute.modification" class="Thelia\Form\AttributeModificationForm"/>
<form name="thelia.admin.feature.creation" class="Thelia\Form\FeatureCreationForm"/> <form name="thelia.admin.feature.creation" class="Thelia\Form\FeatureCreationForm"/>
<form name="thelia.admin.feature.modification" class="Thelia\Form\FeatureModificationForm"/> <form name="thelia.admin.feature.modification" class="Thelia\Form\FeatureModificationForm"/>
<form name="thelia.admin.attributeav.creation" class="Thelia\Form\AttributeAvCreationForm"/> <form name="thelia.admin.attributeav.creation" class="Thelia\Form\AttributeAvCreationForm"/>
<form name="thelia.admin.featureav.creation" class="Thelia\Form\FeatureAvCreationForm"/> <form name="thelia.admin.featureav.creation" class="Thelia\Form\FeatureAvCreationForm"/>
<form name="thelia.admin.taxrule.modification" class="Thelia\Form\TaxRuleModificationForm"/> <form name="thelia.admin.taxrule.modification" class="Thelia\Form\TaxRuleModificationForm"/>
<form name="thelia.admin.taxrule.taxlistupdate" class="Thelia\Form\TaxRuleTaxListUpdateForm"/> <form name="thelia.admin.taxrule.taxlistupdate" class="Thelia\Form\TaxRuleTaxListUpdateForm"/>
<form name="thelia.admin.taxrule.add" class="Thelia\Form\TaxRuleCreationForm"/> <form name="thelia.admin.taxrule.add" class="Thelia\Form\TaxRuleCreationForm"/>
<form name="thelia.admin.tax.modification" class="Thelia\Form\TaxModificationForm"/> <form name="thelia.admin.tax.modification" class="Thelia\Form\TaxModificationForm"/>
<form name="thelia.admin.tax.taxlistupdate" class="Thelia\Form\TaxTaxListUpdateForm"/> <form name="thelia.admin.tax.taxlistupdate" class="Thelia\Form\TaxTaxListUpdateForm"/>
<form name="thelia.admin.tax.add" class="Thelia\Form\TaxCreationForm"/> <form name="thelia.admin.tax.add" class="Thelia\Form\TaxCreationForm"/>
<form name="thelia.admin.profile.add" class="Thelia\Form\ProfileCreationForm"/> <form name="thelia.admin.profile.add" class="Thelia\Form\ProfileCreationForm"/>
<form name="thelia.admin.profile.modification" class="Thelia\Form\ProfileModificationForm"/> <form name="thelia.admin.profile.modification" class="Thelia\Form\ProfileModificationForm"/>
<form name="thelia.admin.profile.resource-access.modification" class="Thelia\Form\ProfileUpdateResourceAccessForm"/> <form name="thelia.admin.profile.resource-access.modification" class="Thelia\Form\ProfileUpdateResourceAccessForm"/>
<form name="thelia.admin.profile.module-access.modification" class="Thelia\Form\ProfileUpdateModuleAccessForm"/> <form name="thelia.admin.profile.module-access.modification" class="Thelia\Form\ProfileUpdateModuleAccessForm"/>
<form name="thelia.admin.administrator.add" class="Thelia\Form\AdministratorCreationForm"/> <form name="thelia.admin.administrator.add" class="Thelia\Form\AdministratorCreationForm"/>
<form name="thelia.admin.administrator.update" class="Thelia\Form\AdministratorModificationForm"/> <form name="thelia.admin.administrator.update" class="Thelia\Form\AdministratorModificationForm"/>
<form name="thelia.admin.mailing-system.update" class="Thelia\Form\MailingSystemModificationForm"/> <form name="thelia.admin.mailing-system.update" class="Thelia\Form\MailingSystemModificationForm"/>
<form name="thelia.admin.template.creation" class="Thelia\Form\TemplateCreationForm"/> <form name="thelia.admin.template.creation" class="Thelia\Form\TemplateCreationForm"/>
<form name="thelia.admin.template.modification" class="Thelia\Form\TemplateModificationForm"/> <form name="thelia.admin.template.modification" class="Thelia\Form\TemplateModificationForm"/>
<form name="thelia.admin.country.creation" class="Thelia\Form\CountryCreationForm"/> <form name="thelia.admin.country.creation" class="Thelia\Form\CountryCreationForm"/>
<form name="thelia.admin.country.modification" class="Thelia\Form\CountryModificationForm"/> <form name="thelia.admin.country.modification" class="Thelia\Form\CountryModificationForm"/>
<form name="thelia.admin.area.create" class="Thelia\Form\Area\AreaCreateForm"/> <form name="thelia.admin.area.create" class="Thelia\Form\Area\AreaCreateForm"/>
<form name="thelia.admin.area.modification" class="Thelia\Form\Area\AreaModificationForm"/> <form name="thelia.admin.area.modification" class="Thelia\Form\Area\AreaModificationForm"/>
<form name="thelia.admin.area.country" class="Thelia\Form\Area\AreaCountryForm"/> <form name="thelia.admin.area.country" class="Thelia\Form\Area\AreaCountryForm"/>
<form name="thelia.admin.area.postage" class="Thelia\Form\Area\AreaPostageForm"/> <form name="thelia.admin.area.postage" class="Thelia\Form\Area\AreaPostageForm"/>
<form name="thelia.shopping_zone_area" class="Thelia\Form\ShippingZone\ShippingZoneAddArea"/> <form name="thelia.shopping_zone_area" class="Thelia\Form\ShippingZone\ShippingZoneAddArea"/>
<form name="thelia.shopping_zone_remove_area" class="Thelia\Form\ShippingZone\ShippingZoneRemoveArea"/> <form name="thelia.shopping_zone_remove_area" class="Thelia\Form\ShippingZone\ShippingZoneRemoveArea"/>
<form name="thelia.lang.update" class="Thelia\Form\Lang\LangUpdateForm"/> <form name="thelia.lang.update" class="Thelia\Form\Lang\LangUpdateForm"/>
<form name="thelia.lang.create" class="Thelia\Form\Lang\LangCreateForm"/> <form name="thelia.lang.create" class="Thelia\Form\Lang\LangCreateForm"/>
<form name="thelia.lang.defaultBehavior" class="Thelia\Form\Lang\LangDefaultBehaviorForm"/> <form name="thelia.lang.defaultBehavior" class="Thelia\Form\Lang\LangDefaultBehaviorForm"/>
<form name="thelia.lang.url" class="Thelia\Form\Lang\LangUrlForm"/> <form name="thelia.lang.url" class="Thelia\Form\Lang\LangUrlForm"/>
<form name="thelia.configuration.store" class="Thelia\Form\ConfigStoreForm"/> <form name="thelia.configuration.store" class="Thelia\Form\ConfigStoreForm"/>
<form name="thelia.system-logs.configuration" class="Thelia\Form\SystemLogConfigurationForm"/> <form name="thelia.system-logs.configuration" class="Thelia\Form\SystemLogConfigurationForm"/>
<form name="thelia.admin.module.modification" class="Thelia\Form\ModuleModificationForm"/> <form name="thelia.admin.module.modification" class="Thelia\Form\ModuleModificationForm"/>
<form name="thelia.cache.flush" class="Thelia\Form\Cache\CacheFlushForm"/> <form name="thelia.cache.flush" class="Thelia\Form\Cache\CacheFlushForm"/>
<form name="thelia.assets.flush" class="Thelia\Form\Cache\AssetsFlushForm"/> <form name="thelia.assets.flush" class="Thelia\Form\Cache\AssetsFlushForm"/>
<form name="thelia.images-and-documents-cache.flush" class="Thelia\Form\Cache\ImagesAndDocumentsCacheFlushForm"/> <form name="thelia.images-and-documents-cache.flush" class="Thelia\Form\Cache\ImagesAndDocumentsCacheFlushForm"/>
</forms> </forms>
</config> </config>

View File

@@ -19,7 +19,6 @@ use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Form\Cache\AssetsFlushForm; use Thelia\Form\Cache\AssetsFlushForm;
use Thelia\Form\Cache\CacheFlushForm; use Thelia\Form\Cache\CacheFlushForm;
use Thelia\Form\Cache\ImagesAndDocumentsCacheFlushForm; use Thelia\Form\Cache\ImagesAndDocumentsCacheFlushForm;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Log\Tlog; use Thelia\Log\Tlog;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;

View File

@@ -90,6 +90,7 @@ class CustomerController extends AbstractCrudController
'lastname' => $object->getLastname(), 'lastname' => $object->getLastname(),
'email' => $object->getEmail(), 'email' => $object->getEmail(),
'title' => $object->getTitleId(), 'title' => $object->getTitleId(),
'discount' => $object->getDiscount(),
); );
if ($address !== null) { if ($address !== null) {

View File

@@ -173,8 +173,7 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
new \ReflectionClass($module->getFullNamespace()); new \ReflectionClass($module->getFullNamespace());
$exists = true; $exists = true;
} } catch (\ReflectionException $ex) {
catch(\ReflectionException $ex) {
$exists = false; $exists = false;
} }

View File

@@ -457,12 +457,19 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
} }
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry(); $taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
/** @var \Thelia\Core\Security\SecurityContext $securityContext */
$securityContext = $this->container->get('thelia.securityContext');
foreach ($loopResult->getResultDataCollection() as $product) { foreach ($loopResult->getResultDataCollection() as $product) {
$loopResultRow = new LoopResultRow($product); $loopResultRow = new LoopResultRow($product);
$price = $product->getVirtualColumn('price'); $price = $product->getVirtualColumn('price');
if ($securityContext->hasCustomerUser() && $securityContext->getCustomerUser()->getDiscount() > 0) {
$price = $price * (1-($securityContext->getCustomerUser()->getDiscount()/100));
}
try { try {
$taxedPrice = $product->getTaxedPrice( $taxedPrice = $product->getTaxedPrice(
$taxCountry, $taxCountry,
@@ -472,6 +479,10 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
$taxedPrice = null; $taxedPrice = null;
} }
$promoPrice = $product->getVirtualColumn('promo_price'); $promoPrice = $product->getVirtualColumn('promo_price');
if ($securityContext->hasCustomerUser() && $securityContext->getCustomerUser()->getDiscount() > 0) {
$promoPrice = $promoPrice * (1-($securityContext->getCustomerUser()->getDiscount()/100));
}
try { try {
$taxedPromoPrice = $product->getTaxedPromoPrice( $taxedPromoPrice = $product->getTaxedPromoPrice(
$taxCountry, $taxCountry,
@@ -938,6 +949,8 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
$loopResult = new LoopResult($results); $loopResult = new LoopResult($results);
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry(); $taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
/** @var \Thelia\Core\Security\SecurityContext $securityContext */
$securityContext = $this->container->get('thelia.securityContext');
foreach ($loopResult->getResultDataCollection() as $product) { foreach ($loopResult->getResultDataCollection() as $product) {
@@ -945,10 +958,14 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
$price = $product->getRealLowestPrice(); $price = $product->getRealLowestPrice();
if ($securityContext->hasCustomerUser() && $securityContext->getCustomerUser()->getDiscount() > 0) {
$price = $price * (1-($securityContext->getCustomerUser()->getDiscount()/100));
}
try { try {
$taxedPrice = $product->getTaxedPrice( $taxedPrice = $product->getTaxedPrice(
$taxCountry, $taxCountry,
$product->getRealLowestPrice() $price
); );
} catch (TaxEngineException $e) { } catch (TaxEngineException $e) {
$taxedPrice = null; $taxedPrice = null;

View File

@@ -135,22 +135,34 @@ class ProductSaleElements extends BaseLoop implements PropelSearchLoopInterface
public function parseResults(LoopResult $loopResult) public function parseResults(LoopResult $loopResult)
{ {
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry(); $taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
/** @var \Thelia\Core\Security\SecurityContext $securityContext */
$securityContext = $this->container->get('thelia.securityContext');
$discount = 0;
if ($securityContext->hasCustomerUser() && $securityContext->getCustomerUser()->getDiscount() > 0) {
$discount = $securityContext->getCustomerUser()->getDiscount();
}
foreach ($loopResult->getResultDataCollection() as $PSEValue) { foreach ($loopResult->getResultDataCollection() as $PSEValue) {
$loopResultRow = new LoopResultRow($PSEValue); $loopResultRow = new LoopResultRow($PSEValue);
$price = $PSEValue->getPrice(); $price = $PSEValue->getPrice('price_PRICE', $discount);
try { try {
$taxedPrice = $PSEValue->getTaxedPrice( $taxedPrice = $PSEValue->getTaxedPrice(
$taxCountry $taxCountry,
'price_PRICE',
$discount
); );
} catch (TaxEngineException $e) { } catch (TaxEngineException $e) {
$taxedPrice = null; $taxedPrice = null;
} }
$promoPrice = $PSEValue->getPromoPrice();
$promoPrice = $PSEValue->getPromoPrice('price_PROMO_PRICE', $discount);
try { try {
$taxedPromoPrice = $PSEValue->getTaxedPromoPrice( $taxedPromoPrice = $PSEValue->getTaxedPromoPrice(
$taxCountry $taxCountry,
'price_PROMO_PRICE',
$discount
); );
} catch (TaxEngineException $e) { } catch (TaxEngineException $e) {
$taxedPromoPrice = null; $taxedPromoPrice = null;

View File

@@ -158,6 +158,12 @@ class CustomerUpdateForm extends BaseForm
"for" => "title" "for" => "title"
) )
)) ))
->add('discount', 'text', array(
'label' => Translator::getInstance()->trans('permanent discount (in percent)'),
'label_attr' => array(
'for' => 'discount'
)
))
; ;
} }

View File

@@ -18,7 +18,7 @@ class Cart extends BaseCart
* @param Customer $customer * @param Customer $customer
* @return Cart * @return Cart
*/ */
public function duplicate($token, Customer $customer = null, EventDispatcherInterface $dispatcher) public function duplicate($token, Customer $customer = null, Currency $currency = null, EventDispatcherInterface $dispatcher)
{ {
$cartItems = $this->getCartItems(); $cartItems = $this->getCartItems();
@@ -26,11 +26,21 @@ class Cart extends BaseCart
$cart->setAddressDeliveryId($this->getAddressDeliveryId()); $cart->setAddressDeliveryId($this->getAddressDeliveryId());
$cart->setAddressInvoiceId($this->getAddressInvoiceId()); $cart->setAddressInvoiceId($this->getAddressInvoiceId());
$cart->setToken($token); $cart->setToken($token);
// TODO : set current Currency $discount = 0;
$cart->setCurrencyId($this->getCurrencyId());
if (null === $currency) {
$currencyQuery = CurrencyQuery::create();
$currency = $currencyQuery->findPk($this->getCurrencyId()) ?: $currencyQuery->findOneByByDefault(1);
}
$cart->setCurrency($currency);
if ($customer) { if ($customer) {
$cart->setCustomer($customer); $cart->setCustomer($customer);
if ($customer->getDiscount() > 0) {
$discount = $customer->getDiscount();
}
} }
$cart->save(); $cart->save();
@@ -50,25 +60,18 @@ class Cart extends BaseCart
$item->setProductId($cartItem->getProductId()); $item->setProductId($cartItem->getProductId());
$item->setQuantity($cartItem->getQuantity()); $item->setQuantity($cartItem->getQuantity());
$item->setProductSaleElements($productSaleElements); $item->setProductSaleElements($productSaleElements);
if ($currentDateTime <= $cartItem->getPriceEndOfLife()) { $prices = $productSaleElements->getPricesByCurrency($currency, $discount);
$item->setPrice($cartItem->getPrice()) $item
->setPromoPrice($cartItem->getPromoPrice()) ->setPrice($prices->getPrice())
->setPromo($productSaleElements->getPromo()) ->setPromoPrice($prices->getPromoPrice())
// TODO : new price EOF or duplicate current priceEOF from $cartItem ? ->setPromo($productSaleElements->getPromo());
->setPriceEndOfLife($cartItem->getPriceEndOfLife());
} else {
$productPrices = ProductPriceQuery::create()->filterByProductSaleElements($productSaleElements)->findOne();
$item->setPrice($productPrices->getPrice())
->setPromoPrice($productPrices->getPromoPrice())
->setPromo($productSaleElements->getPromo())
->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30));
}
$item->save(); $item->save();
$dispatcher->dispatch(TheliaEvents::CART_ITEM_DUPLICATE, new CartItemDuplicationItem($item, $cartItem)); $dispatcher->dispatch(TheliaEvents::CART_ITEM_DUPLICATE, new CartItemDuplicationItem($item, $cartItem));
} }
} }
$this->delete();
return $cart; return $cart;
} }

View File

@@ -143,6 +143,15 @@ class Customer extends BaseCustomer implements UserInterface
->findOne(); ->findOne();
} }
public function setRef($v)
{
if (null !== $v) {
parent::setRef($v);
}
return $this;
}
/** /**
* create hash for plain password and set it in Customer object * create hash for plain password and set it in Customer object
* *

View File

@@ -165,7 +165,8 @@ class Module extends BaseModule
/** /**
* @return true if this module is a delivery module * @return true if this module is a delivery module
*/ */
public function isDeliveryModule() { public function isDeliveryModule()
{
$moduleReflection = new \ReflectionClass($this->getFullNamespace()); $moduleReflection = new \ReflectionClass($this->getFullNamespace());
return $moduleReflection->implementsInterface("Thelia\Module\DeliveryModuleInterface"); return $moduleReflection->implementsInterface("Thelia\Module\DeliveryModuleInterface");
@@ -174,17 +175,18 @@ class Module extends BaseModule
/** /**
* @return true if this module is a payment module * @return true if this module is a payment module
*/ */
public function isPayementModule() { public function isPayementModule()
{
$moduleReflection = new \ReflectionClass($this->getFullNamespace()); $moduleReflection = new \ReflectionClass($this->getFullNamespace());
return $moduleReflection->implementsInterface("Thelia\Module\PaymentModuleInterface"); return $moduleReflection->implementsInterface("Thelia\Module\PaymentModuleInterface");
} }
/** /**
* @return BaseModule a new module instance. * @return BaseModule a new module instance.
*/ */
public function createInstance() { public function createInstance()
{
$moduleClass = new \ReflectionClass($this->getFullNamespace()); $moduleClass = new \ReflectionClass($this->getFullNamespace());
return $moduleClass->newInstance(); return $moduleClass->newInstance();

View File

@@ -8,10 +8,14 @@ use Thelia\TaxEngine\Calculator;
class ProductSaleElements extends BaseProductSaleElements class ProductSaleElements extends BaseProductSaleElements
{ {
public function getPrice($virtualColumnName = 'price_PRICE') public function getPrice($virtualColumnName = 'price_PRICE', $discount = 0)
{ {
try { try {
$amount = $this->getVirtualColumn($virtualColumnName); $amount = $this->getVirtualColumn($virtualColumnName);
if ($discount > 0) {
$amount = $amount * (1-($discount/100));
}
} catch (PropelException $e) { } catch (PropelException $e) {
throw new PropelException("Virtual column `$virtualColumnName` does not exist in ProductSaleElements::getPrice"); throw new PropelException("Virtual column `$virtualColumnName` does not exist in ProductSaleElements::getPrice");
} }
@@ -19,10 +23,14 @@ class ProductSaleElements extends BaseProductSaleElements
return $amount; return $amount;
} }
public function getPromoPrice($virtualColumnName = 'price_PROMO_PRICE') public function getPromoPrice($virtualColumnName = 'price_PROMO_PRICE', $discount = 0)
{ {
try { try {
$amount = $this->getVirtualColumn($virtualColumnName); $amount = $this->getVirtualColumn($virtualColumnName);
if ($discount > 0) {
$amount = $amount * (1-($discount/100));
}
} catch (PropelException $e) { } catch (PropelException $e) {
throw new PropelException("Virtual column `$virtualColumnName` does not exist in ProductSaleElements::getPromoPrice"); throw new PropelException("Virtual column `$virtualColumnName` does not exist in ProductSaleElements::getPromoPrice");
} }
@@ -30,18 +38,18 @@ class ProductSaleElements extends BaseProductSaleElements
return $amount; return $amount;
} }
public function getTaxedPrice(Country $country) public function getTaxedPrice(Country $country , $virtualColumnName = 'price_PRICE', $discount = 0)
{ {
$taxCalculator = new Calculator(); $taxCalculator = new Calculator();
return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()), 2); return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice($virtualColumnName, $discount)), 2);
} }
public function getTaxedPromoPrice(Country $country) public function getTaxedPromoPrice(Country $country, $virtualColumnName = 'price_PROMO_PRICE', $discount = 0)
{ {
$taxCalculator = new Calculator(); $taxCalculator = new Calculator();
return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()), 2); return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice($virtualColumnName, $discount)), 2);
} }
/** /**
@@ -56,7 +64,7 @@ class ProductSaleElements extends BaseProductSaleElements
* @return ProductPriceTools * @return ProductPriceTools
* @throws \RuntimeException * @throws \RuntimeException
*/ */
public function getPricesByCurrency($currency) public function getPricesByCurrency(Currency $currency, $discount = 0)
{ {
$defaultCurrency = Currency::getDefaultCurrency(); $defaultCurrency = Currency::getDefaultCurrency();
@@ -85,6 +93,11 @@ class ProductSaleElements extends BaseProductSaleElements
$promoPrice = $productPrice->getPromoPrice(); $promoPrice = $productPrice->getPromoPrice();
} }
if ($discount > 0) {
$price = $price * (1-($discount/100));
$promoPrice = $promoPrice * (1-($discount/100));
}
$productPriceTools = new ProductPriceTools($price, $promoPrice); $productPriceTools = new ProductPriceTools($price, $promoPrice);
return $productPriceTools; return $productPriceTools;

File diff suppressed because it is too large Load Diff

View File

@@ -361,6 +361,7 @@ return array(
'Edit country "%name"' => 'Modifier le pays "%name"', 'Edit country "%name"' => 'Modifier le pays "%name"',
'Edit currency "%name"' => 'Modifier la devise "%name"', 'Edit currency "%name"' => 'Modifier la devise "%name"',
'Edit customer %firstname %lastname' => 'Modification du client %firstname %lastname ', 'Edit customer %firstname %lastname' => 'Modification du client %firstname %lastname ',
'Edit customer %firstname %lastname (Ref : %ref)' => 'Modification du client %firstname %lastname (Ref : %ref) ',
'Edit delivery address' => 'Editer l\'adresse de livraison', 'Edit delivery address' => 'Editer l\'adresse de livraison',
'Edit document "%name"' => 'Modifier le document "%name"', 'Edit document "%name"' => 'Modifier le document "%name"',
'Edit feature "%name"' => 'Modifier la caractéristique "%name"', 'Edit feature "%name"' => 'Modifier la caractéristique "%name"',
@@ -413,6 +414,7 @@ return array(
'Editing tax rule' => 'En cours de modification de la règle de taxe', 'Editing tax rule' => 'En cours de modification de la règle de taxe',
'Editing template "%name"' => 'Modification du gabarit "%name"', 'Editing template "%name"' => 'Modification du gabarit "%name"',
'Editing variable "%name"' => 'Modification de la variable "%name" ', 'Editing variable "%name"' => 'Modification de la variable "%name" ',
'Email' => 'Email',
'Email address' => 'Adresse e-mail', 'Email address' => 'Adresse e-mail',
'Email used when you send an email to your customers (Order confirmations, etc).' => 'Adresse email utilisé pour envoyer les mails à vos clients', 'Email used when you send an email to your customers (Order confirmations, etc).' => 'Adresse email utilisé pour envoyer les mails à vos clients',
'Enable remote SMTP use : ' => 'Activer l\'utilisation d\'un serveur SMTP distant:', 'Enable remote SMTP use : ' => 'Activer l\'utilisation d\'un serveur SMTP distant:',
@@ -986,6 +988,7 @@ return array(
'newsletter subscribers' => 'Inscrits à la newsletter', 'newsletter subscribers' => 'Inscrits à la newsletter',
'order amount' => 'Montant de la commande', 'order amount' => 'Montant de la commande',
'orders for this customer' => 'commandes pour ce client', 'orders for this customer' => 'commandes pour ce client',
'permanent discount' => 'Remise permanente (en pourcentage)',
'short description' => 'description court', 'short description' => 'description court',
'tax rules' => 'règles de taxe', 'tax rules' => 'règles de taxe',
'taxes' => 'taxes', 'taxes' => 'taxes',

View File

@@ -22,7 +22,7 @@
<div class="row"> <div class="row">
<div class="col-md-12 title title-without-tabs"> <div class="col-md-12 title title-without-tabs">
{intl l="Edit customer %firstname %lastname" firstname={$FIRSTNAME} lastname={$LASTNAME}} {intl l="Edit customer %firstname %lastname (Ref : %ref)" firstname={$FIRSTNAME} lastname={$LASTNAME} ref={$REF}}
</div> </div>
<div class="form-container"> <div class="form-container">
@@ -80,7 +80,14 @@
{form_field form=$form field='email'} {form_field form=$form field='email'}
<div class="form-group {if $error}has-error{/if}"> <div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label> <label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Lastname'}"> <input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Email'}">
</div>
{/form_field}
{form_field form=$form field='discount'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='permanent discount'}">
</div> </div>
{/form_field} {/form_field}