dynamic delivery modules on delivery front template
This commit is contained in:
@@ -131,6 +131,10 @@
|
||||
<default key="_view">order-delivery</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.delivery.ajax-module-list" path="/order/deliveryModuleList">
|
||||
<default key="_controller">Front\Controller\OrderController::getDeliveryModuleListAjaxAction</default>
|
||||
</route>
|
||||
|
||||
<route id="order.invoice.process" path="/order/invoice" methods="post">
|
||||
<default key="_controller">Front\Controller\OrderController::invoice</default>
|
||||
<default key="_view">order-invoice</default>
|
||||
|
||||
@@ -41,6 +41,7 @@ use Thelia\Model\Base\OrderQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\Order;
|
||||
use Thelia\TaxEngine\TaxEngine;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
@@ -260,5 +261,18 @@ class OrderController extends BaseFrontController
|
||||
return $this->generateOrderPdf($order_id, ConfigQuery::read('pdf_delivery_file', 'delivery'));
|
||||
}
|
||||
|
||||
public function getDeliveryModuleListAjaxAction()
|
||||
{
|
||||
$country = $this->getRequest()->get(
|
||||
'country_id',
|
||||
TaxEngine::getInstance($this->getRequest()->getSession())->getDeliveryCountry()->getId()
|
||||
);
|
||||
|
||||
$this->checkXmlHttpRequest();
|
||||
$args = array('country' => $country);
|
||||
|
||||
return $this->render('ajax/order-delivery-module-list', $args);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
22
templates/frontOffice/default/ajax/order-delivery-module-list.html
Executable file
22
templates/frontOffice/default/ajax/order-delivery-module-list.html
Executable file
@@ -0,0 +1,22 @@
|
||||
{form name="thelia.order.delivery"}
|
||||
{loop type="delivery" name="deliveries" force_return="true" country=$country}
|
||||
|
||||
{assign var="isDeliveryMethodChecked" value="0"}
|
||||
<div class="radio">
|
||||
{form_field form=$form field='delivery-module'}
|
||||
{if $isPost}
|
||||
{if $value == $ID}
|
||||
{assign var="isDeliveryMethodChecked" value="1"}
|
||||
{/if}
|
||||
{elseif $LOOP_COUNT == 1}
|
||||
{assign var="isDeliveryMethodChecked" value="1"}
|
||||
{/if}
|
||||
<label for="delivery-method_{$ID}">
|
||||
<input type="radio" name="{$name}" id="delivery-method_{$ID}"{if $isDeliveryMethodChecked} checked="checked"{/if} value="{$ID}">
|
||||
<strong>{$TITLE}</strong> / {$POSTAGE} {currency attr="symbol"}
|
||||
</label>
|
||||
{/form_field}
|
||||
</div>
|
||||
{/loop}
|
||||
{elseloop rel="deliveries"}<div class="deliveries-warning">{intl l="<strong>Sorry!</strong> We are not able to give you a delivery method for your order."}</div>{/elseloop}
|
||||
{/form}
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
{block name="main-content"}
|
||||
|
||||
<div class="main">
|
||||
<article id="cart" class="col-main" role="main" aria-labelledby="main-label">
|
||||
|
||||
@@ -60,7 +61,7 @@
|
||||
<th>
|
||||
<div class="radio">
|
||||
<label for="delivery-address_{$ID}">
|
||||
<input type="radio" name="{$name}" value="{$ID}"{if $isDeliveryAddressChecked} checked="checked"{/if} id="delivery-address_{$ID}">
|
||||
<input type="radio" class="js-change-delivery-address" data-country="{$COUNTRY}" name="{$name}" value="{$ID}"{if $isDeliveryAddressChecked} checked="checked"{/if} id="delivery-address_{$ID}">
|
||||
{$LABEL|default:"{intl l='Address %nb' nb={$LOOP_COUNT}}"}
|
||||
</label>
|
||||
</div>
|
||||
@@ -120,27 +121,7 @@
|
||||
<span class="help-block"><span class="icon-remove"></span> {$message}</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{loop type="delivery" name="deliveries" force_return="true"}
|
||||
{assign var="isDeliveryMethodChecked" value="0"}
|
||||
<div class="radio">
|
||||
{form_field form=$form field='delivery-module'}
|
||||
{if $isPost}
|
||||
{if $value == $ID}
|
||||
{assign var="isDeliveryMethodChecked" value="1"}
|
||||
{/if}
|
||||
{elseif $LOOP_COUNT == 1}
|
||||
{assign var="isDeliveryMethodChecked" value="1"}
|
||||
{/if}
|
||||
<label for="delivery-method_{$ID}">
|
||||
<input type="radio" name="{$name}" id="delivery-method_{$ID}"{if $isDeliveryMethodChecked} checked="checked"{/if} value="{$ID}">
|
||||
<strong>{$TITLE}</strong> / {$POSTAGE} {currency attr="symbol"}
|
||||
</label>
|
||||
{/form_field}
|
||||
</div>
|
||||
{/loop}
|
||||
{elseloop rel="deliveries"}<div class="deliveries-warning">{intl l="<strong>Sorry!</strong> We are not able to give you a delivery method for your order."}</div>{/elseloop}
|
||||
</div>
|
||||
<div class="panel-body" id="delivery-module-list-block"></div>
|
||||
</div>
|
||||
|
||||
{/form_field}
|
||||
@@ -153,4 +134,25 @@
|
||||
|
||||
</article>
|
||||
</div>
|
||||
|
||||
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$('#delivery-module-list-block').load('{url path="/order/deliveryModuleList"}');
|
||||
|
||||
$('.js-change-delivery-address').change(function(e) {
|
||||
$('#delivery-module-list-block').load(
|
||||
'{url path="/order/deliveryModuleList"}',
|
||||
{literal}
|
||||
{country_id: $(this).data('country')}
|
||||
{/literal}
|
||||
);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{/block}
|
||||
Reference in New Issue
Block a user