change price if needed when customer log in or log out
This commit is contained in:
@@ -51,7 +51,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
|||||||
$customer = $cart->getCustomer();
|
$customer = $cart->getCustomer();
|
||||||
$discount = 0;
|
$discount = 0;
|
||||||
|
|
||||||
if(null !== $customer && $customer->getDiscount() > 0) {
|
if (null !== $customer && $customer->getDiscount() > 0) {
|
||||||
$discount = $customer->getDiscount();
|
$discount = $customer->getDiscount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
|||||||
$customer = $cart->getCustomer();
|
$customer = $cart->getCustomer();
|
||||||
$discount = 0;
|
$discount = 0;
|
||||||
|
|
||||||
if(null !== $customer && $customer->getDiscount() > 0) {
|
if (null !== $customer && $customer->getDiscount() > 0) {
|
||||||
$discount = $customer->getDiscount();
|
$discount = $customer->getDiscount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,6 @@ class ProductSaleElements extends BaseLoop implements PropelSearchLoopInterface
|
|||||||
$taxedPromoPrice = null;
|
$taxedPromoPrice = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$loopResultRow
|
$loopResultRow
|
||||||
->set("ID" , $PSEValue->getId())
|
->set("ID" , $PSEValue->getId())
|
||||||
->set("QUANTITY" , $PSEValue->getQuantity())
|
->set("QUANTITY" , $PSEValue->getQuantity())
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user