Merge pull request #350 from lunika/permanentDiscount
apply a permanent discount on a customer.
This commit is contained in:
@@ -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
|
||||
- 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
|
||||
|
||||
@@ -48,6 +48,12 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
$append = $event->getAppend();
|
||||
$quantity = $event->getQuantity();
|
||||
$currency = $cart->getCurrency();
|
||||
$customer = $cart->getCustomer();
|
||||
$discount = 0;
|
||||
|
||||
if (null !== $customer && $customer->getDiscount() > 0) {
|
||||
$discount = $customer->getDiscount();
|
||||
}
|
||||
|
||||
$productSaleElementsId = $event->getProductSaleElementsId();
|
||||
$productId = $event->getProduct();
|
||||
@@ -60,7 +66,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
->findPk($productSaleElementsId);
|
||||
|
||||
if (null !== $productSaleElements) {
|
||||
$productPrices = $productSaleElements->getPricesByCurrency($currency);
|
||||
$productPrices = $productSaleElements->getPricesByCurrency($currency, $discount);
|
||||
$event->setCartItem(
|
||||
$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)
|
||||
{
|
||||
|
||||
$customer = $cart->getCustomer();
|
||||
$discount = 0;
|
||||
|
||||
if (null !== $customer && $customer->getDiscount() > 0) {
|
||||
$discount = $customer->getDiscount();
|
||||
}
|
||||
|
||||
// cart item
|
||||
foreach ($cart->getCartItems() as $cartItem) {
|
||||
$productSaleElements = $cartItem->getProductSaleElements();
|
||||
|
||||
$productPrice = $productSaleElements->getPricesByCurrency($currency);
|
||||
$productPrice = $productSaleElements->getPricesByCurrency($currency, $discount);
|
||||
|
||||
$cartItem
|
||||
->setPrice($productPrice->getPrice())
|
||||
|
||||
@@ -112,7 +112,8 @@ trait CartTrait
|
||||
*/
|
||||
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());
|
||||
|
||||
$cartEvent = new CartEvent($newCart);
|
||||
|
||||
@@ -23,7 +23,6 @@ return array(
|
||||
'Alpha code 3 *' => 'Alpha code 3 *',
|
||||
'Amount removed from the cart' => 'Amount removed from the cart',
|
||||
'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',
|
||||
'Auth mode' => 'Auth mode',
|
||||
'Available quantity' => 'Available quantity',
|
||||
@@ -212,7 +211,6 @@ return array(
|
||||
'Value *' => 'Value *',
|
||||
'Warnings' => 'Warnings',
|
||||
'Weight' => 'Weight',
|
||||
'Weight *' => 'Weight *',
|
||||
'Yes, I have a password :' => 'Yes, I have a password :',
|
||||
'You are already registered!' => 'You are already registered!',
|
||||
'Your Email Address' => 'Your Email Address',
|
||||
@@ -221,13 +219,13 @@ return array(
|
||||
'Zip code' => 'Zip code',
|
||||
'date format' => 'date format',
|
||||
'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',
|
||||
'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 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',
|
||||
'shipping area name' => 'shipping area name',
|
||||
'this product id does not exists : %d' => 'this product id does not exists : %d',
|
||||
'time format' => 'time format',
|
||||
);
|
||||
|
||||
@@ -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 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 ',
|
||||
'permanent discount (in percent)' => 'Remise permanente (en pourcentage)',
|
||||
'quantity value is not valid' => 'la valeur de la quantité n\'est pas valide',
|
||||
'superior or equal to' => 'supérieur ou égal à',
|
||||
'superior to' => 'supérieur à',
|
||||
|
||||
@@ -1,132 +1,132 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<config xmlns="http://thelia.net/schema/dic/config"
|
||||
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">
|
||||
|
||||
<forms>
|
||||
<!-- Forms for Frontend -->
|
||||
<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.create" class="Thelia\Form\CustomerCreateForm"/>
|
||||
<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.address.create" class="Thelia\Form\AddressCreateForm"/>
|
||||
<form name="thelia.front.address.update" class="Thelia\Form\AddressUpdateForm"/>
|
||||
<form name="thelia.front.contact" class="Thelia\Form\ContactForm"/>
|
||||
<form name="thelia.front.newsletter" class="Thelia\Form\NewsletterForm"/>
|
||||
|
||||
<form name="thelia.admin.login" class="Thelia\Form\AdminLogin"/>
|
||||
<form name="thelia.admin.seo" class="Thelia\Form\SeoForm"/>
|
||||
|
||||
<form name="thelia.admin.customer.create" class="Thelia\Form\CustomerCreateForm"/>
|
||||
<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.update" class="Thelia\Form\AddressUpdateForm" />
|
||||
|
||||
<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.image.modification" class="Thelia\Form\CategoryImageModification"/>
|
||||
<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.modification" class="Thelia\Form\ProductModificationForm"/>
|
||||
<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.document.modification" class="Thelia\Form\ProductDocumentModification"/>
|
||||
|
||||
<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_combination.build" class="Thelia\Form\ProductCombinationGenerationForm"/>
|
||||
|
||||
<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.modification" class="Thelia\Form\FolderModificationForm"/>
|
||||
<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.content.creation" class="Thelia\Form\ContentCreationForm"/>
|
||||
<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.document.modification" class="Thelia\Form\ContentDocumentModification"/>
|
||||
|
||||
<form name="thelia.cart.add" class="Thelia\Form\CartAdd"/>
|
||||
|
||||
<form name="thelia.order.delivery" class="Thelia\Form\OrderDelivery"/>
|
||||
<form name="thelia.order.payment" class="Thelia\Form\OrderPayment"/>
|
||||
<form name="thelia.order.update.address" class="Thelia\Form\OrderUpdateAddress"/>
|
||||
|
||||
<form name="thelia.order.coupon" class="Thelia\Form\CouponCode"/>
|
||||
|
||||
<form name="thelia.admin.config.creation" class="Thelia\Form\ConfigCreationForm"/>
|
||||
<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.modification" class="Thelia\Form\MessageModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.currency.creation" class="Thelia\Form\CurrencyCreationForm"/>
|
||||
<form name="thelia.admin.currency.modification" class="Thelia\Form\CurrencyModificationForm"/>
|
||||
|
||||
<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.modification" class="Thelia\Form\AttributeModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.feature.creation" class="Thelia\Form\FeatureCreationForm"/>
|
||||
<form name="thelia.admin.feature.modification" class="Thelia\Form\FeatureModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.attributeav.creation" class="Thelia\Form\AttributeAvCreationForm"/>
|
||||
|
||||
<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.taxlistupdate" class="Thelia\Form\TaxRuleTaxListUpdateForm"/>
|
||||
<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.taxlistupdate" class="Thelia\Form\TaxTaxListUpdateForm"/>
|
||||
<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.modification" class="Thelia\Form\ProfileModificationForm"/>
|
||||
<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.administrator.add" class="Thelia\Form\AdministratorCreationForm"/>
|
||||
<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.template.creation" class="Thelia\Form\TemplateCreationForm"/>
|
||||
<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.modification" class="Thelia\Form\CountryModificationForm"/>
|
||||
|
||||
<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.country" class="Thelia\Form\Area\AreaCountryForm"/>
|
||||
<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_remove_area" class="Thelia\Form\ShippingZone\ShippingZoneRemoveArea"/>
|
||||
|
||||
<form name="thelia.lang.update" class="Thelia\Form\Lang\LangUpdateForm"/>
|
||||
<form name="thelia.lang.create" class="Thelia\Form\Lang\LangCreateForm"/>
|
||||
<form name="thelia.lang.defaultBehavior" class="Thelia\Form\Lang\LangDefaultBehaviorForm"/>
|
||||
<form name="thelia.lang.url" class="Thelia\Form\Lang\LangUrlForm"/>
|
||||
|
||||
<form name="thelia.configuration.store" class="Thelia\Form\ConfigStoreForm"/>
|
||||
<form name="thelia.system-logs.configuration" class="Thelia\Form\SystemLogConfigurationForm"/>
|
||||
|
||||
<form name="thelia.admin.module.modification" class="Thelia\Form\ModuleModificationForm"/>
|
||||
|
||||
<form name="thelia.cache.flush" class="Thelia\Form\Cache\CacheFlushForm"/>
|
||||
<form name="thelia.assets.flush" class="Thelia\Form\Cache\AssetsFlushForm"/>
|
||||
<form name="thelia.images-and-documents-cache.flush" class="Thelia\Form\Cache\ImagesAndDocumentsCacheFlushForm"/>
|
||||
|
||||
</forms>
|
||||
|
||||
</config>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<config xmlns="http://thelia.net/schema/dic/config"
|
||||
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">
|
||||
|
||||
<forms>
|
||||
<!-- Forms for Frontend -->
|
||||
<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.create" class="Thelia\Form\CustomerCreateForm"/>
|
||||
<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.address.create" class="Thelia\Form\AddressCreateForm"/>
|
||||
<form name="thelia.front.address.update" class="Thelia\Form\AddressUpdateForm"/>
|
||||
<form name="thelia.front.contact" class="Thelia\Form\ContactForm"/>
|
||||
<form name="thelia.front.newsletter" class="Thelia\Form\NewsletterForm"/>
|
||||
|
||||
<form name="thelia.admin.login" class="Thelia\Form\AdminLogin"/>
|
||||
<form name="thelia.admin.seo" class="Thelia\Form\SeoForm"/>
|
||||
|
||||
<form name="thelia.admin.customer.create" class="Thelia\Form\CustomerCreateForm"/>
|
||||
<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.update" class="Thelia\Form\AddressUpdateForm" />
|
||||
|
||||
<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.image.modification" class="Thelia\Form\CategoryImageModification"/>
|
||||
<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.modification" class="Thelia\Form\ProductModificationForm"/>
|
||||
<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.document.modification" class="Thelia\Form\ProductDocumentModification"/>
|
||||
|
||||
<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_combination.build" class="Thelia\Form\ProductCombinationGenerationForm"/>
|
||||
|
||||
<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.modification" class="Thelia\Form\FolderModificationForm"/>
|
||||
<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.content.creation" class="Thelia\Form\ContentCreationForm"/>
|
||||
<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.document.modification" class="Thelia\Form\ContentDocumentModification"/>
|
||||
|
||||
<form name="thelia.cart.add" class="Thelia\Form\CartAdd"/>
|
||||
|
||||
<form name="thelia.order.delivery" class="Thelia\Form\OrderDelivery"/>
|
||||
<form name="thelia.order.payment" class="Thelia\Form\OrderPayment"/>
|
||||
<form name="thelia.order.update.address" class="Thelia\Form\OrderUpdateAddress"/>
|
||||
|
||||
<form name="thelia.order.coupon" class="Thelia\Form\CouponCode"/>
|
||||
|
||||
<form name="thelia.admin.config.creation" class="Thelia\Form\ConfigCreationForm"/>
|
||||
<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.modification" class="Thelia\Form\MessageModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.currency.creation" class="Thelia\Form\CurrencyCreationForm"/>
|
||||
<form name="thelia.admin.currency.modification" class="Thelia\Form\CurrencyModificationForm"/>
|
||||
|
||||
<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.modification" class="Thelia\Form\AttributeModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.feature.creation" class="Thelia\Form\FeatureCreationForm"/>
|
||||
<form name="thelia.admin.feature.modification" class="Thelia\Form\FeatureModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.attributeav.creation" class="Thelia\Form\AttributeAvCreationForm"/>
|
||||
|
||||
<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.taxlistupdate" class="Thelia\Form\TaxRuleTaxListUpdateForm"/>
|
||||
<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.taxlistupdate" class="Thelia\Form\TaxTaxListUpdateForm"/>
|
||||
<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.modification" class="Thelia\Form\ProfileModificationForm"/>
|
||||
<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.administrator.add" class="Thelia\Form\AdministratorCreationForm"/>
|
||||
<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.template.creation" class="Thelia\Form\TemplateCreationForm"/>
|
||||
<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.modification" class="Thelia\Form\CountryModificationForm"/>
|
||||
|
||||
<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.country" class="Thelia\Form\Area\AreaCountryForm"/>
|
||||
<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_remove_area" class="Thelia\Form\ShippingZone\ShippingZoneRemoveArea"/>
|
||||
|
||||
<form name="thelia.lang.update" class="Thelia\Form\Lang\LangUpdateForm"/>
|
||||
<form name="thelia.lang.create" class="Thelia\Form\Lang\LangCreateForm"/>
|
||||
<form name="thelia.lang.defaultBehavior" class="Thelia\Form\Lang\LangDefaultBehaviorForm"/>
|
||||
<form name="thelia.lang.url" class="Thelia\Form\Lang\LangUrlForm"/>
|
||||
|
||||
<form name="thelia.configuration.store" class="Thelia\Form\ConfigStoreForm"/>
|
||||
<form name="thelia.system-logs.configuration" class="Thelia\Form\SystemLogConfigurationForm"/>
|
||||
|
||||
<form name="thelia.admin.module.modification" class="Thelia\Form\ModuleModificationForm"/>
|
||||
|
||||
<form name="thelia.cache.flush" class="Thelia\Form\Cache\CacheFlushForm"/>
|
||||
<form name="thelia.assets.flush" class="Thelia\Form\Cache\AssetsFlushForm"/>
|
||||
<form name="thelia.images-and-documents-cache.flush" class="Thelia\Form\Cache\ImagesAndDocumentsCacheFlushForm"/>
|
||||
|
||||
</forms>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -19,7 +19,6 @@ use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Form\Cache\AssetsFlushForm;
|
||||
use Thelia\Form\Cache\CacheFlushForm;
|
||||
use Thelia\Form\Cache\ImagesAndDocumentsCacheFlushForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ class CustomerController extends AbstractCrudController
|
||||
'lastname' => $object->getLastname(),
|
||||
'email' => $object->getEmail(),
|
||||
'title' => $object->getTitleId(),
|
||||
'discount' => $object->getDiscount(),
|
||||
);
|
||||
|
||||
if ($address !== null) {
|
||||
|
||||
@@ -173,8 +173,7 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
new \ReflectionClass($module->getFullNamespace());
|
||||
|
||||
$exists = true;
|
||||
}
|
||||
catch(\ReflectionException $ex) {
|
||||
} catch (\ReflectionException $ex) {
|
||||
$exists = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -457,12 +457,19 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
|
||||
}
|
||||
|
||||
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
|
||||
/** @var \Thelia\Core\Security\SecurityContext $securityContext */
|
||||
$securityContext = $this->container->get('thelia.securityContext');
|
||||
|
||||
foreach ($loopResult->getResultDataCollection() as $product) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($product);
|
||||
|
||||
$price = $product->getVirtualColumn('price');
|
||||
|
||||
if ($securityContext->hasCustomerUser() && $securityContext->getCustomerUser()->getDiscount() > 0) {
|
||||
$price = $price * (1-($securityContext->getCustomerUser()->getDiscount()/100));
|
||||
}
|
||||
|
||||
try {
|
||||
$taxedPrice = $product->getTaxedPrice(
|
||||
$taxCountry,
|
||||
@@ -472,6 +479,10 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
|
||||
$taxedPrice = null;
|
||||
}
|
||||
$promoPrice = $product->getVirtualColumn('promo_price');
|
||||
|
||||
if ($securityContext->hasCustomerUser() && $securityContext->getCustomerUser()->getDiscount() > 0) {
|
||||
$promoPrice = $promoPrice * (1-($securityContext->getCustomerUser()->getDiscount()/100));
|
||||
}
|
||||
try {
|
||||
$taxedPromoPrice = $product->getTaxedPromoPrice(
|
||||
$taxCountry,
|
||||
@@ -938,6 +949,8 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
|
||||
$loopResult = new LoopResult($results);
|
||||
|
||||
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
|
||||
/** @var \Thelia\Core\Security\SecurityContext $securityContext */
|
||||
$securityContext = $this->container->get('thelia.securityContext');
|
||||
|
||||
foreach ($loopResult->getResultDataCollection() as $product) {
|
||||
|
||||
@@ -945,10 +958,14 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
|
||||
|
||||
$price = $product->getRealLowestPrice();
|
||||
|
||||
if ($securityContext->hasCustomerUser() && $securityContext->getCustomerUser()->getDiscount() > 0) {
|
||||
$price = $price * (1-($securityContext->getCustomerUser()->getDiscount()/100));
|
||||
}
|
||||
|
||||
try {
|
||||
$taxedPrice = $product->getTaxedPrice(
|
||||
$taxCountry,
|
||||
$product->getRealLowestPrice()
|
||||
$price
|
||||
);
|
||||
} catch (TaxEngineException $e) {
|
||||
$taxedPrice = null;
|
||||
|
||||
@@ -135,22 +135,34 @@ class ProductSaleElements extends BaseLoop implements PropelSearchLoopInterface
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$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) {
|
||||
$loopResultRow = new LoopResultRow($PSEValue);
|
||||
|
||||
$price = $PSEValue->getPrice();
|
||||
$price = $PSEValue->getPrice('price_PRICE', $discount);
|
||||
try {
|
||||
$taxedPrice = $PSEValue->getTaxedPrice(
|
||||
$taxCountry
|
||||
$taxCountry,
|
||||
'price_PRICE',
|
||||
$discount
|
||||
);
|
||||
} catch (TaxEngineException $e) {
|
||||
$taxedPrice = null;
|
||||
}
|
||||
$promoPrice = $PSEValue->getPromoPrice();
|
||||
|
||||
$promoPrice = $PSEValue->getPromoPrice('price_PROMO_PRICE', $discount);
|
||||
try {
|
||||
$taxedPromoPrice = $PSEValue->getTaxedPromoPrice(
|
||||
$taxCountry
|
||||
$taxCountry,
|
||||
'price_PROMO_PRICE',
|
||||
$discount
|
||||
);
|
||||
} catch (TaxEngineException $e) {
|
||||
$taxedPromoPrice = null;
|
||||
|
||||
@@ -158,6 +158,12 @@ class CustomerUpdateForm extends BaseForm
|
||||
"for" => "title"
|
||||
)
|
||||
))
|
||||
->add('discount', 'text', array(
|
||||
'label' => Translator::getInstance()->trans('permanent discount (in percent)'),
|
||||
'label_attr' => array(
|
||||
'for' => 'discount'
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class Cart extends BaseCart
|
||||
* @param Customer $customer
|
||||
* @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();
|
||||
|
||||
@@ -26,11 +26,21 @@ class Cart extends BaseCart
|
||||
$cart->setAddressDeliveryId($this->getAddressDeliveryId());
|
||||
$cart->setAddressInvoiceId($this->getAddressInvoiceId());
|
||||
$cart->setToken($token);
|
||||
// TODO : set current Currency
|
||||
$cart->setCurrencyId($this->getCurrencyId());
|
||||
$discount = 0;
|
||||
|
||||
if (null === $currency) {
|
||||
$currencyQuery = CurrencyQuery::create();
|
||||
$currency = $currencyQuery->findPk($this->getCurrencyId()) ?: $currencyQuery->findOneByByDefault(1);
|
||||
}
|
||||
|
||||
$cart->setCurrency($currency);
|
||||
|
||||
if ($customer) {
|
||||
$cart->setCustomer($customer);
|
||||
|
||||
if ($customer->getDiscount() > 0) {
|
||||
$discount = $customer->getDiscount();
|
||||
}
|
||||
}
|
||||
|
||||
$cart->save();
|
||||
@@ -50,25 +60,18 @@ class Cart extends BaseCart
|
||||
$item->setProductId($cartItem->getProductId());
|
||||
$item->setQuantity($cartItem->getQuantity());
|
||||
$item->setProductSaleElements($productSaleElements);
|
||||
if ($currentDateTime <= $cartItem->getPriceEndOfLife()) {
|
||||
$item->setPrice($cartItem->getPrice())
|
||||
->setPromoPrice($cartItem->getPromoPrice())
|
||||
->setPromo($productSaleElements->getPromo())
|
||||
// TODO : new price EOF or duplicate current priceEOF from $cartItem ?
|
||||
->setPriceEndOfLife($cartItem->getPriceEndOfLife());
|
||||
} else {
|
||||
$productPrices = ProductPriceQuery::create()->filterByProductSaleElements($productSaleElements)->findOne();
|
||||
$prices = $productSaleElements->getPricesByCurrency($currency, $discount);
|
||||
$item
|
||||
->setPrice($prices->getPrice())
|
||||
->setPromoPrice($prices->getPromoPrice())
|
||||
->setPromo($productSaleElements->getPromo());
|
||||
|
||||
$item->setPrice($productPrices->getPrice())
|
||||
->setPromoPrice($productPrices->getPromoPrice())
|
||||
->setPromo($productSaleElements->getPromo())
|
||||
->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30));
|
||||
}
|
||||
$item->save();
|
||||
$dispatcher->dispatch(TheliaEvents::CART_ITEM_DUPLICATE, new CartItemDuplicationItem($item, $cartItem));
|
||||
}
|
||||
|
||||
}
|
||||
$this->delete();
|
||||
|
||||
return $cart;
|
||||
}
|
||||
|
||||
@@ -143,6 +143,15 @@ class Customer extends BaseCustomer implements UserInterface
|
||||
->findOne();
|
||||
}
|
||||
|
||||
public function setRef($v)
|
||||
{
|
||||
if (null !== $v) {
|
||||
parent::setRef($v);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* create hash for plain password and set it in Customer object
|
||||
*
|
||||
|
||||
@@ -165,7 +165,8 @@ class Module extends BaseModule
|
||||
/**
|
||||
* @return true if this module is a delivery module
|
||||
*/
|
||||
public function isDeliveryModule() {
|
||||
public function isDeliveryModule()
|
||||
{
|
||||
$moduleReflection = new \ReflectionClass($this->getFullNamespace());
|
||||
|
||||
return $moduleReflection->implementsInterface("Thelia\Module\DeliveryModuleInterface");
|
||||
@@ -174,17 +175,18 @@ class Module extends BaseModule
|
||||
/**
|
||||
* @return true if this module is a payment module
|
||||
*/
|
||||
public function isPayementModule() {
|
||||
public function isPayementModule()
|
||||
{
|
||||
$moduleReflection = new \ReflectionClass($this->getFullNamespace());
|
||||
|
||||
return $moduleReflection->implementsInterface("Thelia\Module\PaymentModuleInterface");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return BaseModule a new module instance.
|
||||
*/
|
||||
public function createInstance() {
|
||||
public function createInstance()
|
||||
{
|
||||
$moduleClass = new \ReflectionClass($this->getFullNamespace());
|
||||
|
||||
return $moduleClass->newInstance();
|
||||
|
||||
@@ -8,10 +8,14 @@ use Thelia\TaxEngine\Calculator;
|
||||
|
||||
class ProductSaleElements extends BaseProductSaleElements
|
||||
{
|
||||
public function getPrice($virtualColumnName = 'price_PRICE')
|
||||
public function getPrice($virtualColumnName = 'price_PRICE', $discount = 0)
|
||||
{
|
||||
try {
|
||||
$amount = $this->getVirtualColumn($virtualColumnName);
|
||||
|
||||
if ($discount > 0) {
|
||||
$amount = $amount * (1-($discount/100));
|
||||
}
|
||||
} catch (PropelException $e) {
|
||||
throw new PropelException("Virtual column `$virtualColumnName` does not exist in ProductSaleElements::getPrice");
|
||||
}
|
||||
@@ -19,10 +23,14 @@ class ProductSaleElements extends BaseProductSaleElements
|
||||
return $amount;
|
||||
}
|
||||
|
||||
public function getPromoPrice($virtualColumnName = 'price_PROMO_PRICE')
|
||||
public function getPromoPrice($virtualColumnName = 'price_PROMO_PRICE', $discount = 0)
|
||||
{
|
||||
try {
|
||||
$amount = $this->getVirtualColumn($virtualColumnName);
|
||||
|
||||
if ($discount > 0) {
|
||||
$amount = $amount * (1-($discount/100));
|
||||
}
|
||||
} catch (PropelException $e) {
|
||||
throw new PropelException("Virtual column `$virtualColumnName` does not exist in ProductSaleElements::getPromoPrice");
|
||||
}
|
||||
@@ -30,18 +38,18 @@ class ProductSaleElements extends BaseProductSaleElements
|
||||
return $amount;
|
||||
}
|
||||
|
||||
public function getTaxedPrice(Country $country)
|
||||
public function getTaxedPrice(Country $country , $virtualColumnName = 'price_PRICE', $discount = 0)
|
||||
{
|
||||
$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();
|
||||
|
||||
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
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getPricesByCurrency($currency)
|
||||
public function getPricesByCurrency(Currency $currency, $discount = 0)
|
||||
{
|
||||
$defaultCurrency = Currency::getDefaultCurrency();
|
||||
|
||||
@@ -85,6 +93,11 @@ class ProductSaleElements extends BaseProductSaleElements
|
||||
$promoPrice = $productPrice->getPromoPrice();
|
||||
}
|
||||
|
||||
if ($discount > 0) {
|
||||
$price = $price * (1-($discount/100));
|
||||
$promoPrice = $promoPrice * (1-($discount/100));
|
||||
}
|
||||
|
||||
$productPriceTools = new ProductPriceTools($price, $promoPrice);
|
||||
|
||||
return $productPriceTools;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -361,6 +361,7 @@ return array(
|
||||
'Edit country "%name"' => 'Modifier le pays "%name"',
|
||||
'Edit currency "%name"' => 'Modifier la devise "%name"',
|
||||
'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 document "%name"' => 'Modifier le document "%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 template "%name"' => 'Modification du gabarit "%name"',
|
||||
'Editing variable "%name"' => 'Modification de la variable "%name" ',
|
||||
'Email' => 'Email',
|
||||
'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',
|
||||
'Enable remote SMTP use : ' => 'Activer l\'utilisation d\'un serveur SMTP distant:',
|
||||
@@ -986,6 +988,7 @@ return array(
|
||||
'newsletter subscribers' => 'Inscrits à la newsletter',
|
||||
'order amount' => 'Montant de la commande',
|
||||
'orders for this customer' => 'commandes pour ce client',
|
||||
'permanent discount' => 'Remise permanente (en pourcentage)',
|
||||
'short description' => 'description court',
|
||||
'tax rules' => 'règles de taxe',
|
||||
'taxes' => 'taxes',
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<div class="row">
|
||||
|
||||
<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 class="form-container">
|
||||
@@ -80,7 +80,14 @@
|
||||
{form_field form=$form field='email'}
|
||||
<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='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>
|
||||
{/form_field}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user