order delivery form
This commit is contained in:
101
core/lib/Thelia/Core/Event/OrderEvent.php
Executable file
101
core/lib/Thelia/Core/Event/OrderEvent.php
Executable file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Address;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\Module;
|
||||
use Thelia\Model\Order;
|
||||
|
||||
class OrderEvent extends ActionEvent
|
||||
{
|
||||
protected $order = null;
|
||||
protected $billingAddress = null;
|
||||
protected $deliveryAddress = null;
|
||||
protected $deliveryModule = null;
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address $address
|
||||
*/
|
||||
public function setBillingAddress(Address $address)
|
||||
{
|
||||
$this->deliveryAddress = $address->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address $address
|
||||
*/
|
||||
public function setDeliveryAddress(Address $address)
|
||||
{
|
||||
$this->deliveryAddress = $address->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Module $module
|
||||
*/
|
||||
public function setDeliveryModule(Module $module)
|
||||
{
|
||||
$this->deliveryModule = $module->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Order
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|mixed|Address
|
||||
*/
|
||||
public function getBillingAddress()
|
||||
{
|
||||
return AddressQuery::create()->findPk($this->billingAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|mixed|Address
|
||||
*/
|
||||
public function getDeliveryAddress()
|
||||
{
|
||||
return AddressQuery::create()->findPk($this->deliveryAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|mixed|Address
|
||||
*/
|
||||
public function getDeliveryModule()
|
||||
{
|
||||
return AddressQuery::create()->findPk($this->deliveryModule);
|
||||
}
|
||||
}
|
||||
@@ -218,13 +218,20 @@ final class TheliaEvents
|
||||
|
||||
const CART_DELETEITEM = "action.deleteArticle";
|
||||
|
||||
/**
|
||||
* Order linked event
|
||||
*/
|
||||
const ORDER_SET_BILLING_ADDRESS = "action.order.setBillingAddress";
|
||||
const ORDER_SET_DELIVERY_ADDRESS = "action.order.setDeliveryAddress";
|
||||
const ORDER_SET_DELIVERY_MODULE = "action.order.setDeliveryModule";
|
||||
|
||||
/**
|
||||
* Sent on image processing
|
||||
*/
|
||||
const IMAGE_PROCESS = "action.processImage";
|
||||
|
||||
/**
|
||||
* Sent on cimage cache clear request
|
||||
* Sent on image cache clear request
|
||||
*/
|
||||
const IMAGE_CLEAR_CACHE = "action.clearImageCache";
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ use Thelia\Exception\InvalidCartException;
|
||||
use Thelia\Model\CartQuery;
|
||||
use Thelia\Model\Cart;
|
||||
use Thelia\Model\Currency;
|
||||
use Thelia\Model\Order;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Model\Lang;
|
||||
|
||||
@@ -43,6 +44,8 @@ use Thelia\Model\Lang;
|
||||
class Session extends BaseSession
|
||||
{
|
||||
/**
|
||||
* @param bool $forceDefault
|
||||
*
|
||||
* @return \Thelia\Model\Lang|null
|
||||
*/
|
||||
public function getLang($forceDefault = true)
|
||||
@@ -205,22 +208,19 @@ class Session extends BaseSession
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* assign delivery id in session
|
||||
*
|
||||
* @param $delivery_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setDelivery($delivery_id)
|
||||
// -- Order ------------------------------------------------------------------
|
||||
|
||||
|
||||
public function setOrder(Order $order)
|
||||
{
|
||||
$this->set("thelia.delivery_id", $delivery_id);
|
||||
$this->set("thelia.order", $order);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDelivery()
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->get("thelia.delivery_id");
|
||||
return $this->get("thelia.order");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user