order creation
This commit is contained in:
@@ -23,15 +23,16 @@
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\CartEvent;
|
||||
use Thelia\Core\Event\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\ProductPrice;
|
||||
use Thelia\Model\ProductPriceQuery;
|
||||
use Thelia\Model\CartItem;
|
||||
use Thelia\Model\CartItemQuery;
|
||||
use Thelia\Model\Base\AddressQuery;
|
||||
use Thelia\Model\OrderStatus;
|
||||
use Thelia\Model\Map\OrderTableMap;
|
||||
use Thelia\Model\OrderAddress;
|
||||
use Thelia\Model\OrderStatusQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
@@ -67,6 +68,130 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function setInvoiceAddress(OrderEvent $event)
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->chosenInvoiceAddress = $event->getInvoiceAddress();
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function setPaymentModule(OrderEvent $event)
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->setPaymentModuleId($event->getPaymentModule());
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function create(OrderEvent $event)
|
||||
{
|
||||
$con = \Propel\Runtime\Propel::getConnection(
|
||||
OrderTableMap::DATABASE_NAME
|
||||
);
|
||||
|
||||
$con->beginTransaction();
|
||||
|
||||
$sessionOrder = $event->getOrder();
|
||||
|
||||
/* use a copy to avoid errored reccord in session */
|
||||
$placedOrder = $sessionOrder->copy();
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$currency = $this->getSession()->getCurrency();
|
||||
$lang = $this->getSession()->getLang();
|
||||
$deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress);
|
||||
$invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress);
|
||||
|
||||
/* fulfill order */
|
||||
$placedOrder->setCustomerId($customer->getId());
|
||||
$placedOrder->setCurrencyId($currency->getId());
|
||||
$placedOrder->setCurrencyRate($currency->getRate());
|
||||
$placedOrder->setLangId($lang->getId());
|
||||
|
||||
/* hard save the delivery and invoice addresses */
|
||||
$deliveryOrderAddress = new OrderAddress();
|
||||
$deliveryOrderAddress
|
||||
->setCustomerTitleId($deliveryAddress->getTitleId())
|
||||
->setCompany($deliveryAddress->getCompany())
|
||||
->setFirstname($deliveryAddress->getFirstname())
|
||||
->setLastname($deliveryAddress->getLastname())
|
||||
->setAddress1($deliveryAddress->getAddress1())
|
||||
->setAddress2($deliveryAddress->getAddress2())
|
||||
->setAddress3($deliveryAddress->getAddress3())
|
||||
->setZipcode($deliveryAddress->getZipcode())
|
||||
->setCity($deliveryAddress->getCity())
|
||||
->setCountryId($deliveryAddress->getCountryId())
|
||||
->save($con)
|
||||
;
|
||||
|
||||
$invoiceOrderAddress = new OrderAddress();
|
||||
$invoiceOrderAddress
|
||||
->setCustomerTitleId($invoiceAddress->getTitleId())
|
||||
->setCompany($invoiceAddress->getCompany())
|
||||
->setFirstname($invoiceAddress->getFirstname())
|
||||
->setLastname($invoiceAddress->getLastname())
|
||||
->setAddress1($invoiceAddress->getAddress1())
|
||||
->setAddress2($invoiceAddress->getAddress2())
|
||||
->setAddress3($invoiceAddress->getAddress3())
|
||||
->setZipcode($invoiceAddress->getZipcode())
|
||||
->setCity($invoiceAddress->getCity())
|
||||
->setCountryId($invoiceAddress->getCountryId())
|
||||
->save($con)
|
||||
;
|
||||
|
||||
$placedOrder->setDeliveryOrderAddressId($deliveryOrderAddress->getId());
|
||||
$placedOrder->setInvoiceOrderAddressId($invoiceOrderAddress->getId());
|
||||
|
||||
$placedOrder->setStatusId(
|
||||
OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_NOT_PAID)->getId()
|
||||
);
|
||||
|
||||
$placedOrder->save($con);
|
||||
|
||||
/* fulfill order_products and decrease stock // @todo dispatch event */
|
||||
|
||||
/* discount */
|
||||
|
||||
/* postage */
|
||||
|
||||
|
||||
$con->commit();
|
||||
|
||||
|
||||
/* dispatch mail event */
|
||||
|
||||
/* clear session ? */
|
||||
|
||||
/* call pay method */
|
||||
|
||||
$out = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function setReference(OrderEvent $event)
|
||||
{
|
||||
$this->setRef($this->generateRef());
|
||||
}
|
||||
|
||||
public function generateRef()
|
||||
{
|
||||
return sprintf('O', uniqid('', true), $this->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
*
|
||||
@@ -92,6 +217,40 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
return array(
|
||||
TheliaEvents::ORDER_SET_DELIVERY_ADDRESS => array("setDeliveryAddress", 128),
|
||||
TheliaEvents::ORDER_SET_DELIVERY_MODULE => array("setDeliveryModule", 128),
|
||||
TheliaEvents::ORDER_SET_INVOICE_ADDRESS => array("setInvoiceAddress", 128),
|
||||
TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128),
|
||||
TheliaEvents::ORDER_PAY => array("create", 128),
|
||||
TheliaEvents::ORDER_SET_REFERENCE => array("setReference", 128),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the security context
|
||||
*
|
||||
* @return SecurityContext
|
||||
*/
|
||||
protected function getSecurityContext()
|
||||
{
|
||||
return $this->container->get('thelia.securityContext');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected function getRequest()
|
||||
{
|
||||
return $this->container->get('request');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the session from the current request
|
||||
*
|
||||
* @return \Thelia\Core\HttpFoundation\Session\Session
|
||||
*/
|
||||
protected function getSession()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
return $request->getSession();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,4 +139,6 @@ trait CartTrait
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
abstract public function getDispatcher();
|
||||
}
|
||||
|
||||
@@ -227,6 +227,7 @@
|
||||
<argument type="service" id="request" />
|
||||
<argument type="service" id="thelia.securityContext" />
|
||||
<argument type="service" id="thelia.parser.context"/>
|
||||
<argument type="service" id="event_dispatcher"/>
|
||||
</service>
|
||||
|
||||
<service id="smarty.plugin.adminUtilities" class="Thelia\Core\Template\Smarty\Plugins\AdminUtilities" scope="request">
|
||||
|
||||
@@ -112,6 +112,9 @@
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<!-- end cart routes -->
|
||||
|
||||
<!-- order management process -->
|
||||
<route id="order.delivery.process" path="/order/delivery" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::deliver</default>
|
||||
<default key="_view">order_delivery</default>
|
||||
@@ -123,7 +126,7 @@
|
||||
</route>
|
||||
|
||||
<route id="order.invoice.process" path="/order/invoice" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::pay</default>
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::invoice</default>
|
||||
<default key="_view">order_invoice</default>
|
||||
</route>
|
||||
|
||||
@@ -132,12 +135,9 @@
|
||||
<default key="_view">order_invoice</default>
|
||||
</route>
|
||||
|
||||
<!-- end cart routes -->
|
||||
|
||||
<!-- order management process -->
|
||||
<route id="order.delivery.add" path="/delivery/choose/{delivery_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\DeliveryController::select</default>
|
||||
<requirement key="delivery_id">\d+</requirement>
|
||||
<route id="order.payment.process" path="/order/pay">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::pay</default>
|
||||
<default key="_view">order_payment</default>
|
||||
</route>
|
||||
<!-- end order management process -->
|
||||
|
||||
|
||||
@@ -72,7 +72,13 @@ class BaseFrontController extends BaseController
|
||||
if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId()) {
|
||||
$this->redirectToRoute("order.delivery");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function checkValidInvoice()
|
||||
{
|
||||
$order = $this->getSession()->getOrder();
|
||||
if(null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId()) {
|
||||
$this->redirectToRoute("order.invoice");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<?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\Controller\Front;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class DeliveryController
|
||||
* @package Thelia\Controller\Front
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class DeliveryController extends BaseFrontController
|
||||
{
|
||||
public function select($delivery_id)
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser() === false) {
|
||||
$this->redirect(URL::getInstance()->getIndexPage());
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$deliveryModule = ModuleQuery::create()
|
||||
->filterById($delivery_id)
|
||||
->filterByActivate(1)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
if ($deliveryModule) {
|
||||
$request->getSession()->setDelivery($delivery_id);
|
||||
} else {
|
||||
$this->pageNotFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class OrderController extends BaseFrontController
|
||||
* set invoice address
|
||||
* set payment module
|
||||
*/
|
||||
public function pay()
|
||||
public function invoice()
|
||||
{
|
||||
$this->checkAuth();
|
||||
$this->checkCartNotEmpty();
|
||||
@@ -134,23 +134,23 @@ class OrderController extends BaseFrontController
|
||||
try {
|
||||
$form = $this->validateForm($orderPayment, "post");
|
||||
|
||||
$deliveryAddressId = $form->get("delivery-address")->getData();
|
||||
$deliveryModuleId = $form->get("delivery-module")->getData();
|
||||
$invoiceAddressId = $form->get("invoice-address")->getData();
|
||||
$paymentModuleId = $form->get("payment-module")->getData();
|
||||
|
||||
/* check that the invoice address belongs to the current customer */
|
||||
$deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId);
|
||||
if($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
|
||||
$invoiceAddress = AddressQuery::create()->findPk($invoiceAddressId);
|
||||
if($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
|
||||
throw new \Exception("Invoice address does not belong to the current customer");
|
||||
}
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
$orderEvent->setInvoiceAddress($deliveryAddressId);
|
||||
$orderEvent->setPaymentModule($deliveryModuleId);
|
||||
$orderEvent->setInvoiceAddress($invoiceAddressId);
|
||||
$orderEvent->setPaymentModule($paymentModuleId);
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_INVOICE_ADDRESS, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_PAYMENT_MODULE, $orderEvent);
|
||||
|
||||
$this->redirectToRoute("order.invoice");
|
||||
$this->redirectToRoute("order.payment.process");
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
@@ -161,7 +161,7 @@ class OrderController extends BaseFrontController
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
Tlog::getInstance()->error(sprintf("Error during order payment process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$orderPayment->setErrorMessage($message);
|
||||
|
||||
@@ -173,6 +173,25 @@ class OrderController extends BaseFrontController
|
||||
|
||||
}
|
||||
|
||||
public function pay()
|
||||
{
|
||||
/* check customer */
|
||||
$this->checkAuth();
|
||||
|
||||
/* check cart count */
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
/* check delivery address and module */
|
||||
$this->checkValidDelivery();
|
||||
|
||||
/* check invoice address and payment module */
|
||||
$this->checkValidInvoice();
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_PAY, $orderEvent);
|
||||
}
|
||||
|
||||
protected function getOrderEvent()
|
||||
{
|
||||
$order = $this->getOrder($this->getRequest());
|
||||
|
||||
@@ -33,6 +33,7 @@ class OrderEvent extends ActionEvent
|
||||
protected $deliveryModule = null;
|
||||
protected $paymentModule = null;
|
||||
protected $postage = null;
|
||||
protected $ref = null;
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
@@ -55,7 +56,7 @@ class OrderEvent extends ActionEvent
|
||||
*/
|
||||
public function setInvoiceAddress($address)
|
||||
{
|
||||
$this->deliveryAddress = $address;
|
||||
$this->invoiceAddress = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,6 +91,14 @@ class OrderEvent extends ActionEvent
|
||||
$this->postage = $postage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $ref
|
||||
*/
|
||||
public function setRef($ref)
|
||||
{
|
||||
$this->ref = $ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Order
|
||||
*/
|
||||
@@ -137,4 +146,12 @@ class OrderEvent extends ActionEvent
|
||||
{
|
||||
return $this->postage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getRef()
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,9 +215,12 @@ final class TheliaEvents
|
||||
/**
|
||||
* 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";
|
||||
const ORDER_SET_INVOICE_ADDRESS = "action.order.setInvoiceAddress";
|
||||
const ORDER_SET_PAYMENT_MODULE = "action.order.setPaymentModule";
|
||||
const ORDER_PAY = "action.order.pay";
|
||||
const ORDER_SET_REFERENCE = "action.order.setReference";
|
||||
|
||||
/**
|
||||
* Sent on image processing
|
||||
|
||||
@@ -65,6 +65,8 @@ abstract class BaseI18nLoop extends BaseLoop
|
||||
{
|
||||
/* manage translations */
|
||||
|
||||
$fr = $this->getForce_return();
|
||||
|
||||
return ModelCriteriaTools::getI18n(
|
||||
$this->getBackend_context(),
|
||||
$this->getLang(),
|
||||
|
||||
@@ -58,7 +58,19 @@ class Argument
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value === null ? null : (string) $value;
|
||||
$x = $value === null;
|
||||
|
||||
if($value === null) {
|
||||
$this->value = null;
|
||||
} else {
|
||||
if(false === $value) {
|
||||
/* (string) $value = "" */
|
||||
$this->value = 0;
|
||||
} else {
|
||||
$this->value = (string) $value;
|
||||
}
|
||||
}
|
||||
//$this->value = $value === null ? null : (string) $value;
|
||||
}
|
||||
|
||||
public static function createAnyTypeArgument($name, $default=null, $mandatory=false, $empty=true)
|
||||
|
||||
@@ -110,4 +110,13 @@ class Cart extends BaseLoop
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the event dispatcher,
|
||||
*
|
||||
* @return \Symfony\Component\EventDispatcher\EventDispatcher
|
||||
*/
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->dispatcher;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Core\Template\Smarty\Plugins;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
@@ -53,12 +54,14 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
private $securityContext;
|
||||
protected $parserContext;
|
||||
protected $request;
|
||||
protected $dispatcher;
|
||||
|
||||
public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext)
|
||||
public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext, ContainerAwareEventDispatcher $dispatcher)
|
||||
{
|
||||
$this->securityContext = $securityContext;
|
||||
$this->parserContext = $parserContext;
|
||||
$this->request = $request;
|
||||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,6 +198,12 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
return $order->getPostage();
|
||||
case 'delivery_address':
|
||||
return $order->chosenDeliveryAddress;
|
||||
case 'invoice_address':
|
||||
return $order->chosenInvoiceAddress;
|
||||
case 'delivery_module':
|
||||
return $order->getDeliveryModuleId();
|
||||
case 'payment_module':
|
||||
return $order->getPaymentModuleId();
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf("%s has no '%s' attribute", 'Order', $attribute));
|
||||
@@ -320,4 +329,14 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
new SmartyPluginDescriptor('function', 'order', $this, 'orderDataAccess'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the event dispatcher,
|
||||
*
|
||||
* @return \Symfony\Component\EventDispatcher\EventDispatcher
|
||||
*/
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->dispatcher;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1653,8 +1653,18 @@ abstract class Order implements ActiveRecordInterface
|
||||
$modifiedColumns[':p' . $index++] = 'UPDATED_AT';
|
||||
}
|
||||
|
||||
$db = Propel::getServiceContainer()->getAdapter(OrderTableMap::DATABASE_NAME);
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderTableMap::DATABASE_NAME);
|
||||
|
||||
$tableName = OrderTableMap::TABLE_NAME;
|
||||
|
||||
if ($db->useQuoteIdentifier()) {
|
||||
$tableName = $db->quoteIdentifierTable($tableName);
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'INSERT INTO order (%s) VALUES (%s)',
|
||||
'INSERT INTO %s (%s) VALUES (%s)',
|
||||
$tableName,
|
||||
implode(', ', $modifiedColumns),
|
||||
implode(', ', array_keys($modifiedColumns))
|
||||
);
|
||||
|
||||
@@ -150,7 +150,7 @@ class OrderStatusTableMap extends TableMap
|
||||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
|
||||
$this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
} // initialize()
|
||||
|
||||
@@ -215,7 +215,7 @@ class OrderTableMap extends TableMap
|
||||
$this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null);
|
||||
$this->addForeignKey('INVOICE_ORDER_ADDRESS_ID', 'InvoiceOrderAddressId', 'INTEGER', 'order_address', 'ID', true, null, null);
|
||||
$this->addForeignKey('DELIVERY_ORDER_ADDRESS_ID', 'DeliveryOrderAddressId', 'INTEGER', 'order_address', 'ID', true, null, null);
|
||||
$this->addColumn('INVOICE_DATE', 'InvoiceDate', 'DATE', true, null, null);
|
||||
$this->addColumn('INVOICE_DATE', 'InvoiceDate', 'DATE', false, null, null);
|
||||
$this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', true, null, null);
|
||||
$this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', true, null, null);
|
||||
$this->addColumn('TRANSACTION_REF', 'TransactionRef', 'VARCHAR', false, 100, null);
|
||||
|
||||
@@ -2,13 +2,26 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Event\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Base\Order as BaseOrder;
|
||||
|
||||
class Order extends BaseOrder
|
||||
{
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
public $chosenDeliveryAddress = null;
|
||||
public $chosenInvoiceAddress = null;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
/*public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_SET_REFERENCE, new OrderEvent($this));
|
||||
}*/
|
||||
|
||||
/**
|
||||
* calculate the total amount
|
||||
*
|
||||
|
||||
@@ -4,6 +4,11 @@ namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\OrderStatus as BaseOrderStatus;
|
||||
|
||||
class OrderStatus extends BaseOrderStatus {
|
||||
|
||||
class OrderStatus extends BaseOrderStatus
|
||||
{
|
||||
const CODE_NOT_PAID = "not_paid";
|
||||
const CODE_PAID = "paid";
|
||||
const CODE_PROCESSED = "processed";
|
||||
const CODE_SENT = "sent";
|
||||
const CODE_CANCELED = "canceled";
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ abstract class BaseModule extends ContainerAware
|
||||
$image = new ModuleImage();
|
||||
$image->setModuleId($module->getId());
|
||||
$image->setPosition($imagePosition);
|
||||
$image->save();
|
||||
$image->save($con);
|
||||
|
||||
$imageDirectory = sprintf("%s/../../../../local/media/images/module", __DIR__);
|
||||
$imageFileName = sprintf("%s-%d-%s", $module->getCode(), $image->getId(), $fileName);
|
||||
@@ -131,7 +131,7 @@ abstract class BaseModule extends ContainerAware
|
||||
}
|
||||
|
||||
$image->setFile($imageFileName);
|
||||
$image->save();
|
||||
$image->save($con);
|
||||
|
||||
$con->commit();
|
||||
$imagePosition++;
|
||||
|
||||
@@ -1167,3 +1167,22 @@ INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`)
|
||||
INSERT INTO `tax_rule_country` (`tax_rule_id`, `country_id`, `tax_id`, `position`, `created_at`, `updated_at`)
|
||||
VALUES
|
||||
(1, 64, 1, 1, NOW(), NOW());
|
||||
|
||||
INSERT INTO `order_status`(`id`, `code`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'not_paid', NOW(), NOW()),
|
||||
(2, 'paid', NOW(), NOW()),
|
||||
(3, 'processing', NOW(), NOW()),
|
||||
(4, 'sent', NOW(), NOW()),
|
||||
(5, 'canceled', NOW(), NOW());
|
||||
|
||||
INSERT INTO `order_status_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES
|
||||
(1, 'en_US', 'Not paid', '', '', ''),
|
||||
(1, 'fr_FR', 'Non payée', '', '', ''),
|
||||
(2, 'en_US', 'Paid', '', '', ''),
|
||||
(2, 'fr_FR', 'Payée', '', '', ''),
|
||||
(3, 'en_US', 'Processing', '', '', ''),
|
||||
(3, 'fr_FR', 'Traitement', '', '', ''),
|
||||
(4, 'en_US', 'Sent', '', '', ''),
|
||||
(4, 'fr_FR', 'Envoyée', '', '', ''),
|
||||
(5, 'en_US', 'Canceled', '', '', ''),
|
||||
(5, 'fr_FR', 'Annulée', '', '', '');
|
||||
|
||||
@@ -641,7 +641,7 @@ CREATE TABLE `order`
|
||||
`customer_id` INTEGER NOT NULL,
|
||||
`invoice_order_address_id` INTEGER NOT NULL,
|
||||
`delivery_order_address_id` INTEGER NOT NULL,
|
||||
`invoice_date` DATE NOT NULL,
|
||||
`invoice_date` DATE,
|
||||
`currency_id` INTEGER NOT NULL,
|
||||
`currency_rate` FLOAT NOT NULL,
|
||||
`transaction_ref` VARCHAR(100) COMMENT 'transaction reference - usually use to identify a transaction with banking modules',
|
||||
@@ -788,10 +788,11 @@ DROP TABLE IF EXISTS `order_status`;
|
||||
CREATE TABLE `order_status`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`code` VARCHAR(45),
|
||||
`code` VARCHAR(45) NOT NULL,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`)
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `code_UNIQUE` (`code`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
@@ -500,7 +500,7 @@
|
||||
<column name="customer_id" required="true" type="INTEGER" />
|
||||
<column name="invoice_order_address_id" required="true" type="INTEGER" />
|
||||
<column name="delivery_order_address_id" required="true" type="INTEGER" />
|
||||
<column name="invoice_date" required="true" type="DATE" />
|
||||
<column name="invoice_date" type="DATE" />
|
||||
<column name="currency_id" required="true" type="INTEGER" />
|
||||
<column name="currency_rate" required="true" type="FLOAT" />
|
||||
<column description="transaction reference - usually use to identify a transaction with banking modules" name="transaction_ref" size="100" type="VARCHAR" />
|
||||
@@ -613,11 +613,14 @@
|
||||
</table>
|
||||
<table name="order_status" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="code" size="45" type="VARCHAR" />
|
||||
<column name="code" required="true" size="45" type="VARCHAR" />
|
||||
<column name="title" size="255" type="VARCHAR" />
|
||||
<column name="description" type="CLOB" />
|
||||
<column name="chapo" type="LONGVARCHAR" />
|
||||
<column name="postscriptum" type="LONGVARCHAR" />
|
||||
<unique name="code_UNIQUE">
|
||||
<unique-column name="code" />
|
||||
</unique>
|
||||
<behavior name="timestampable" />
|
||||
<behavior name="i18n">
|
||||
<parameter name="i18n_columns" value="title, description, chapo, postscriptum" />
|
||||
|
||||
@@ -262,17 +262,24 @@
|
||||
|
||||
<div id="payment-method" class="panel">
|
||||
<div class="panel-heading">Choose your payment method</div>
|
||||
|
||||
{if $error}
|
||||
<span class="help-block"><span class="icon-remove"></span> {$message}</span>
|
||||
{/if}
|
||||
|
||||
<div class="panel-body">
|
||||
<ul class="list-payment">
|
||||
|
||||
{loop type="payment" name="payments" force_return="true"}
|
||||
|
||||
{assign "paymentModuleId" $ID}
|
||||
|
||||
{loop type="image" name="paymentspicture" source="module" source_id=$ID force_return="true" width="100" height="72"}
|
||||
|
||||
<li>
|
||||
<div class="radio">
|
||||
<label for="payment_{$ID}">
|
||||
<input type="radio" name="payment" id="payment_{$ID}" value="test">
|
||||
<label for="payment_{$paymentModuleId}_{$ID}">
|
||||
<input type="radio" name="{$name}" id="payment_{$paymentModuleId}_{$ID}" value="{$paymentModuleId}">
|
||||
<img src="{$IMAGE_URL}">
|
||||
</label>
|
||||
</div>
|
||||
@@ -288,7 +295,7 @@
|
||||
{/form_field}
|
||||
|
||||
<a href="{url path="/order/delivery"}" role="button" class="btn btn-back"><span>Back</span></a>
|
||||
<button type="submit" class="btn btn-checkout-next"><span>TO REMOVE</span></button>
|
||||
<button type="submit" class="btn btn-checkout-next"><span>Next Step</span></button>
|
||||
</form>
|
||||
|
||||
{/form}
|
||||
|
||||
60
templates/default/order_payment.html
Normal file
60
templates/default/order_payment.html
Normal file
@@ -0,0 +1,60 @@
|
||||
{extends file="layout.tpl"}
|
||||
|
||||
{block name="breadcrumb"}
|
||||
<nav class="nav-breadcrumb" role="navigation" aria-labelledby="breadcrumb-label">
|
||||
<strong id="breadcrumb-label">You are here: </strong>
|
||||
<ul class="breadcrumb" itemprop="breadcrumb">
|
||||
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="{navigate to="index"}" itemprop="url"><span itemprop="title">Home</span></a></li>
|
||||
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="{url path="/cart"}" itemprop="url"><span itemprop="title">Cart</span></a></li>
|
||||
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="active"><span itemprop="title">Secure Payment</span></li>
|
||||
</ul>
|
||||
</nav><!-- /.nav-breadcrumb -->
|
||||
{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
<div class="main">
|
||||
<article class="col-main clearfix" role="main" aria-labelledby="main-label">
|
||||
|
||||
<h1 id="main-label" class="page-header">Your Cart</h1>
|
||||
|
||||
<div class="btn-group checkout-progress">
|
||||
<a href="cart.php" role="button" class="btn btn-step disabled"><span class="step-nb">1</span> <span class="step-label">Your Cart</span></a>
|
||||
<a href="cart-step2.php" role="button" class="btn btn-step disabled"><span class="step-nb">2</span> <span class="step-label">Billing and delivery</span></a>
|
||||
<a href="cart-step3.php" role="button" class="btn btn-step disabled"><span class="step-nb">3</span> <span class="step-label">Check my order</span></a>
|
||||
<a href="cart-step4.php" role="button" class="btn btn-step active"><span class="step-nb">4</span> <span class="step-label">Secure payment</span></a>
|
||||
</div>
|
||||
|
||||
<div id="payment-success" class="panel">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">You chose to pay by : <span class="payment-method">Cheque</span></h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<h3>Thank you for the trust you place in us.</h3>
|
||||
<p>A summary of your order email has been sent to the following address: email@toto.com</p>
|
||||
<p>Your order will be confirmed by us upon receipt of your payment.</p>
|
||||
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Order number : </dt>
|
||||
<dd>PRO123456788978979</dd>
|
||||
<dt>Date : </dt>
|
||||
<dd>02/12/2013</dd>
|
||||
<dt>Total : </dt>
|
||||
<dd>$216.25</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="{navigate to="index"}" role="button" class="btn btn-checkout-home"><span>Go home</span></a>
|
||||
|
||||
</article>
|
||||
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
<script type="text/javascript">
|
||||
jQuery(function($order) {
|
||||
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
Reference in New Issue
Block a user