colissimo module
This commit is contained in:
@@ -279,12 +279,6 @@ class Order extends BaseAction implements EventSubscriberInterface
|
|||||||
$this->getDispatcher()->dispatch(TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($this->getRequest())));
|
$this->getDispatcher()->dispatch(TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($this->getRequest())));
|
||||||
|
|
||||||
/* call pay method */
|
/* call pay method */
|
||||||
/*$paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
|
||||||
$paymentModuleInstance = $paymentModuleReflection->newInstance();
|
|
||||||
|
|
||||||
$paymentModuleInstance->setRequest($this->getRequest());
|
|
||||||
$paymentModuleInstance->setDispatcher($this->getDispatcher());*/
|
|
||||||
|
|
||||||
$paymentModuleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode()));
|
$paymentModuleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode()));
|
||||||
$paymentModuleInstance->pay($placedOrder);
|
$paymentModuleInstance->pay($placedOrder);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,9 +84,6 @@ class OrderController extends BaseFrontController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get postage amount */
|
/* get postage amount */
|
||||||
/*$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
|
|
||||||
$moduleInstance = $moduleReflection->newInstance();*/
|
|
||||||
|
|
||||||
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
|
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
|
||||||
$postage = $moduleInstance->getPostage($deliveryAddress->getCountry());
|
$postage = $moduleInstance->getPostage($deliveryAddress->getCountry());
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,16 @@
|
|||||||
|
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<p>{intl l="Prices are not dynamically editable yet."}</p>
|
<p>{intl l="Prices are not dynamically editable yet."}</p>
|
||||||
<p>{intl l="Prices below can be edited in Colissmo module code."}</p>
|
<p>{intl l="Prices below can be edited in local/modules/Colissimo/Config/prices.json file."}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="general-block-decorator">
|
<div class="general-block-decorator">
|
||||||
|
|
||||||
|
{loop type="area" name="list area" backend_context=true}
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-condensed table-left-aligned">
|
<table class="table table-striped table-condensed table-left-aligned">
|
||||||
<caption class="clearfix">
|
<caption class="clearfix">
|
||||||
{intl l="Collismo prices"}
|
{intl l="Area : "}{$NAME}
|
||||||
{loop type="auth" name="can_create" role="ADMIN" module="colissimo" access="CREATE"}
|
{loop type="auth" name="can_create" role="ADMIN" module="colissimo" access="CREATE"}
|
||||||
<a class="btn btn-default btn-primary pull-right" title="{intl l='Create a new price slice'}" href="#price_slice_create_dialog" data-toggle="modal">
|
<a class="btn btn-default btn-primary pull-right" title="{intl l='Create a new price slice'}" href="#price_slice_create_dialog" data-toggle="modal">
|
||||||
<span class="glyphicon glyphicon-plus"></span>
|
<span class="glyphicon glyphicon-plus"></span>
|
||||||
@@ -29,10 +31,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{loop type="colissimo" name="colissimo" area=$ID}
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td>{$MAX_WEIGHT}</td>
|
||||||
<td></td>
|
<td>{$PRICE}</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
{loop type="auth" name="can_change" role="ADMIN" module="colissimo" access="UPDATE"}
|
{loop type="auth" name="can_change" role="ADMIN" module="colissimo" access="UPDATE"}
|
||||||
@@ -41,10 +43,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{/loop}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
{/loop}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -70,7 +74,7 @@
|
|||||||
|
|
||||||
dialog_id = "price_slice_delete_dialog"
|
dialog_id = "price_slice_delete_dialog"
|
||||||
dialog_title = {intl l="Delete a price slice"}
|
dialog_title = {intl l="Delete a price slice"}
|
||||||
dialog_body = "Not available yet."
|
dialog_message = "Not available yet."
|
||||||
|
|
||||||
dialog_ok_label = {intl l="Delete"}
|
dialog_ok_label = {intl l="Delete"}
|
||||||
dialog_cancel_label = {intl l="Cancel"}
|
dialog_cancel_label = {intl l="Cancel"}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface
|
|||||||
|
|
||||||
const JSON_PRICE_RESOURCE = "prices.json";
|
const JSON_PRICE_RESOURCE = "prices.json";
|
||||||
|
|
||||||
public function getPrices()
|
public static function getPrices()
|
||||||
{
|
{
|
||||||
if(null === self::$prices) {
|
if(null === self::$prices) {
|
||||||
self::$prices = json_decode(file_get_contents(sprintf('%s/Config/%s', __DIR__, self::JSON_PRICE_RESOURCE)), true);
|
self::$prices = json_decode(file_get_contents(sprintf('%s/Config/%s', __DIR__, self::JSON_PRICE_RESOURCE)), true);
|
||||||
@@ -55,9 +55,9 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws \Thelia\Exception\OrderException
|
* @throws \Thelia\Exception\OrderException
|
||||||
*/
|
*/
|
||||||
public function getPostageAmount($areaId, $weight)
|
public static function getPostageAmount($areaId, $weight)
|
||||||
{
|
{
|
||||||
$prices = $this->getPrices();
|
$prices = self::getPrices();
|
||||||
|
|
||||||
/* check if Colissimo delivers the asked area */
|
/* check if Colissimo delivers the asked area */
|
||||||
if(!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) {
|
if(!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) {
|
||||||
@@ -119,7 +119,7 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface
|
|||||||
{
|
{
|
||||||
$cartWeight = $this->getContainer()->get('request')->getSession()->getCart()->getWeight();
|
$cartWeight = $this->getContainer()->get('request')->getSession()->getCart()->getWeight();
|
||||||
|
|
||||||
$postage = $this->getPostageAmount(
|
$postage = self::getPostageAmount(
|
||||||
$country->getAreaId(),
|
$country->getAreaId(),
|
||||||
$cartWeight
|
$cartWeight
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,9 +5,7 @@
|
|||||||
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">
|
||||||
|
|
||||||
<loops>
|
<loops>
|
||||||
<!-- sample definition
|
<loop class="Colissimo\Loop\Price" name="colissimo"/>
|
||||||
<loop name="MySuperLoop" class="MyModule\Loop\MySuperLoop" />
|
|
||||||
-->
|
|
||||||
</loops>
|
</loops>
|
||||||
|
|
||||||
<forms>
|
<forms>
|
||||||
|
|||||||
88
local/modules/Colissimo/Loop/Price.php
Executable file
88
local/modules/Colissimo/Loop/Price.php
Executable file
@@ -0,0 +1,88 @@
|
|||||||
|
<?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 Colissimo\Loop;
|
||||||
|
|
||||||
|
use Colissimo\Colissimo;
|
||||||
|
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
|
||||||
|
use Thelia\Core\Template\Element\BaseLoop;
|
||||||
|
use Thelia\Core\Template\Element\LoopResult;
|
||||||
|
use Thelia\Core\Template\Element\LoopResultRow;
|
||||||
|
|
||||||
|
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||||
|
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Price loop
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Class Price
|
||||||
|
* @package Colissimo\Loop
|
||||||
|
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||||
|
*/
|
||||||
|
class Price extends BaseLoop implements ArraySearchLoopInterface
|
||||||
|
{
|
||||||
|
/* set countable to false since we need to preserve keys */
|
||||||
|
protected $countable = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ArgumentCollection
|
||||||
|
*/
|
||||||
|
protected function getArgDefinitions()
|
||||||
|
{
|
||||||
|
return new ArgumentCollection(
|
||||||
|
Argument::createIntTypeArgument('area', null, true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildArray()
|
||||||
|
{
|
||||||
|
$area = $this->getArea();
|
||||||
|
|
||||||
|
$prices = Colissimo::getPrices();
|
||||||
|
|
||||||
|
if(!isset($prices[$area]) || !isset($prices[$area]["slices"])) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$areaPrices = $prices[$area]["slices"];
|
||||||
|
ksort($areaPrices);
|
||||||
|
|
||||||
|
return $areaPrices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function parseResults(LoopResult $loopResult)
|
||||||
|
{
|
||||||
|
foreach ($loopResult->getResultDataCollection() as $maxWeight => $price) {
|
||||||
|
$loopResultRow = new LoopResultRow();
|
||||||
|
$loopResultRow->set("MAX_WEIGHT", $maxWeight)
|
||||||
|
->set("PRICE", $price);
|
||||||
|
|
||||||
|
$loopResult->addRow($loopResultRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $loopResult;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user