Validate email on quote
This commit is contained in:
parent
6fde2728d6
commit
bb9ff6ba65
@ -4,8 +4,8 @@ class OrderController extends OrderControllerCore
|
||||
public function init()
|
||||
{
|
||||
global $orderTotal;
|
||||
|
||||
parent::init();
|
||||
|
||||
ParentOrderController::init();
|
||||
|
||||
$this->step = (int)Tools::getValue('step', 0);
|
||||
$this->context->smarty->assign(array(
|
||||
@ -13,9 +13,11 @@ class OrderController extends OrderControllerCore
|
||||
'error' => false,
|
||||
));
|
||||
|
||||
/*if (!$this->nbProducts) {
|
||||
if (!$this->nbProducts) {
|
||||
$this->step = -1;
|
||||
}*/
|
||||
} elseif (Tools::getIsset('submitQuote')) {
|
||||
$this->step = 99;
|
||||
}
|
||||
|
||||
$product = $this->context->cart->checkQuantities(true);
|
||||
|
||||
@ -61,9 +63,7 @@ class OrderController extends OrderControllerCore
|
||||
{
|
||||
ParentOrderController::initContent();
|
||||
|
||||
$this->context->smarty->assign('current_order_step', (int)$this->step);
|
||||
|
||||
// Always set products
|
||||
// Always set products details
|
||||
$products = $this->context->cart->getProducts();
|
||||
$pCpt = 0;
|
||||
if ($products > 0) {
|
||||
@ -77,6 +77,10 @@ class OrderController extends OrderControllerCore
|
||||
}
|
||||
}
|
||||
|
||||
$isSent = false;
|
||||
$error = false;
|
||||
$errorMsg = '';
|
||||
|
||||
switch ((int)$this->step)
|
||||
{
|
||||
case -1:
|
||||
@ -84,10 +88,8 @@ class OrderController extends OrderControllerCore
|
||||
$this->setTemplate(_PS_THEME_DIR_.'shopping-cart.tpl');
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case 99:
|
||||
$id_lang = $this->context->language->id;
|
||||
$error = false;
|
||||
$erroMsg = '';
|
||||
|
||||
// Récupération des variables
|
||||
$name = Tools::getValue('name');
|
||||
@ -97,13 +99,13 @@ class OrderController extends OrderControllerCore
|
||||
$postcode = Tools::getValue('postcode');
|
||||
$info = Tools::getValue('info');
|
||||
$newsletter = Tools::getValue('newsletter');
|
||||
|
||||
|
||||
// Validation
|
||||
$requiredFields = array(
|
||||
'name' => $this->l("Invalid name"),
|
||||
'phone' => $this->l("Invalid phone"),
|
||||
'email' => $this->l("Invalid email"),
|
||||
'postcode' => $this->l("Invalid postcode"),
|
||||
'name' => Tools::displayError("Invalid name"),
|
||||
'phone' => Tools::displayError("Invalid phone"),
|
||||
'email' => Tools::displayError("Invalid email"),
|
||||
'postcode' => Tools::displayError("Invalid postcode"),
|
||||
);
|
||||
foreach ($requiredFields as $f => $errortxt) {
|
||||
if (empty($f)) {
|
||||
@ -114,12 +116,12 @@ class OrderController extends OrderControllerCore
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// Enregistrer email pour la newsletter
|
||||
// @todo : Enregistrer email pour la newsletter
|
||||
|
||||
|
||||
// Création du template d'email
|
||||
$baseUrl = Tools::getHttpHost($true).__PS_BASE_URI__;
|
||||
$products_html = $this->getEmailTemplateContent('quote_conf_product_list.html', Mail::TYPE_HTML, array(
|
||||
$products_html = $this->getEmailTemplateContent('quote_conf_product_list.tpl', Mail::TYPE_HTML, array(
|
||||
'base_url' => $baseUrl,
|
||||
'products' => $products,
|
||||
));
|
||||
@ -128,6 +130,7 @@ class OrderController extends OrderControllerCore
|
||||
'products' => $products,
|
||||
));
|
||||
$template_vars = array(
|
||||
'{date}' => date('d/m/Y H:i:s'),
|
||||
'{name}' => $name,
|
||||
'{company}' => $company,
|
||||
'{phone}' => $phone,
|
||||
@ -135,17 +138,19 @@ class OrderController extends OrderControllerCore
|
||||
'{postcode}' => $postcode,
|
||||
'{info}' => $info,
|
||||
'{newsletter}' => $newsletter,
|
||||
'{products}' => $products_html,
|
||||
'{products_html}' => $products_html,
|
||||
'{products_txt}' => $products_txt,
|
||||
);
|
||||
|
||||
// Envoi de l'email
|
||||
$shopMail = /*Configuration::get('PS_SHOP_EMAIL')*/'plouf@versionecologique.local';
|
||||
$shopMail = Configuration::get('PS_SHOP_EMAIL');
|
||||
$isSent = Mail::Send($id_lang, 'quote_conf', "Demande de devis", $template_vars, $shopMail);
|
||||
|
||||
if (!$isSent) {
|
||||
$error = true;
|
||||
$errorMsg = $this->l("An error occurred while sending your quote !");
|
||||
} else {
|
||||
$this->context->cart->delete();
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,130 +170,23 @@ class OrderController extends OrderControllerCore
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'currencySign' => $this->context->currency->sign,
|
||||
'currencyRate' => $this->context->currency->conversion_rate,
|
||||
'currencyFormat' => $this->context->currency->format,
|
||||
'currencyBlank' => $this->context->currency->blank,
|
||||
'error' => $error,
|
||||
'errorMsg' => $errorMsg,
|
||||
'emailSent' => $isSent,
|
||||
));
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
|
||||
}
|
||||
|
||||
public function getAddressesList(){
|
||||
if (Configuration::get('PS_GUEST_CHECKOUT_ENABLED') == 0 && ((int)$this->context->customer->is_guest != Configuration::get('PS_GUEST_CHECKOUT_ENABLED')))
|
||||
return;
|
||||
else if (!Customer::getAddressesTotalById($this->context->customer->id))
|
||||
return;
|
||||
$customer = $this->context->customer;
|
||||
|
||||
if (Validate::isLoadedObject($customer))
|
||||
{
|
||||
/* Getting customer addresses */
|
||||
$customerAddresses = $customer->getAddresses($this->context->language->id);
|
||||
|
||||
// Getting a list of formated address fields with associated values
|
||||
$formatedAddressFieldsValuesList = array();
|
||||
|
||||
foreach ($customerAddresses as $i => $address)
|
||||
{
|
||||
if (!Address::isCountryActiveById((int)($address['id_address'])))
|
||||
unset($customerAddresses[$i]);
|
||||
$tmpAddress = new Address($address['id_address']);
|
||||
$formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields'] = AddressFormat::getOrderedAddressFields($address['id_country']);
|
||||
$formatedAddressFieldsValuesList[$address['id_address']]['formated_fields_values'] = AddressFormat::getFormattedAddressFieldsValues(
|
||||
$tmpAddress,
|
||||
$formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields']);
|
||||
|
||||
unset($tmpAddress);
|
||||
}
|
||||
|
||||
if (key($customerAddresses) != 0)
|
||||
$customerAddresses = array_values($customerAddresses);
|
||||
|
||||
if (!count($customerAddresses) && !Tools::isSubmit('ajax'))
|
||||
{
|
||||
$bad_delivery = false;
|
||||
if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$this->context->cart->id_address_delivery)) || !Address::isCountryActiveById((int)$this->context->cart->id_address_invoice))
|
||||
{
|
||||
$back_url = $this->context->link->getPageLink('order', true, (int)$this->context->language->id, array('step' => Tools::getValue('step'), 'multi-shipping' => (int)Tools::getValue('multi-shipping')));
|
||||
$params = array('multi-shipping' => (int)Tools::getValue('multi-shipping'), 'id_address' => ($bad_delivery ? (int)$this->context->cart->id_address_delivery : (int)$this->context->cart->id_address_invoice), 'back' => $back_url);
|
||||
Tools::redirect($this->context->link->getPageLink('address', true, (int)$this->context->language->id, $params));
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
'addresses' => $customerAddresses,
|
||||
'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getCarriersList(){
|
||||
if (Tools::isSubmit('processAddress'))
|
||||
$this->processAddress();
|
||||
$this->autoStep();
|
||||
$this->_assignCarrier();
|
||||
return $this->smartyOutputContent(_PS_THEME_DIR_.'ajax-order-carrier.tpl');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Order process controller
|
||||
*/
|
||||
public function autoStep()
|
||||
{
|
||||
if ($this->step > 2 && (!$this->context->cart->id_address_delivery || !$this->context->cart->id_address_invoice)){
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
}
|
||||
|
||||
if ($this->step > 2 && !$this->context->cart->isVirtualCart())
|
||||
{
|
||||
$redirect = false;
|
||||
if (count($this->context->cart->getDeliveryOptionList()) == 0)
|
||||
$redirect = true;
|
||||
|
||||
$delivery_option = $this->context->cart->getDeliveryOption();
|
||||
if (is_array($delivery_option))
|
||||
$carrier = explode(',', $delivery_option[(int)$this->context->cart->id_address_delivery]);
|
||||
|
||||
if (!$redirect && !$this->context->cart->isMultiAddressDelivery())
|
||||
foreach ($this->context->cart->getProducts() as $product)
|
||||
{
|
||||
$carrier_list = Carrier::getAvailableCarrierList(new Product($product['id_product']), null, $this->context->cart->id_address_delivery);
|
||||
foreach ($carrier as $id_carrier)
|
||||
{
|
||||
if (!in_array($id_carrier, $carrier_list))
|
||||
$redirect = true;
|
||||
else
|
||||
{
|
||||
$redirect = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($redirect)
|
||||
break;
|
||||
}
|
||||
|
||||
if ($redirect)
|
||||
Tools::redirect('index.php?controller=order&step=2');
|
||||
}
|
||||
|
||||
if($this->step > 2)
|
||||
{
|
||||
$delivery = new Address((int)$this->context->cart->id_address_delivery);
|
||||
$invoice = new Address((int)$this->context->cart->id_address_invoice);
|
||||
|
||||
if ($delivery->deleted || $invoice->deleted)
|
||||
{
|
||||
if ($delivery->deleted)
|
||||
unset($this->context->cart->id_address_delivery);
|
||||
if ($invoice->deleted)
|
||||
unset($this->context->cart->id_address_invoice);
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,11 +95,7 @@
|
||||
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;">Référence</th>
|
||||
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;">Produit</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5" style="border:1px solid #D6D4D4;text-align:center;color:#777;padding:7px 0">
|
||||
{products}
|
||||
</td>
|
||||
</tr>
|
||||
{products_html}
|
||||
</tbody>
|
||||
</table>
|
||||
</font>
|
||||
|
@ -1,11 +1,7 @@
|
||||
[{shop_url}]
|
||||
|
||||
|
||||
|
||||
Message de {shop_name}
|
||||
|
||||
Bonjour,
|
||||
|
||||
Demande de devis!
|
||||
|
||||
Détails
|
||||
@ -20,9 +16,7 @@ Newsletter: {newsletter}
|
||||
|
||||
COMMANDE : {date}
|
||||
|
||||
RÉFÉRENCE
|
||||
|
||||
PRODUIT
|
||||
DEVIS :
|
||||
|
||||
{products_txt}
|
||||
|
||||
|
@ -1,68 +1,19 @@
|
||||
{foreach $list['products] as $product}
|
||||
{foreach $list['products'] as $product}
|
||||
<tr>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td>
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
{$product['reference']}
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
{$product['reference']}
|
||||
</font>
|
||||
</td>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td>
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
<strong>{$product['name']}</strong>
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
{$product['name']}
|
||||
</font>
|
||||
</td>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td align="right">
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
{$product['unit_price']}
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
{foreach $product['customization'] as $customization}
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td colspan="2" style="border:1px solid #D6D4D4;">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="10"> </td>
|
||||
<td>
|
||||
<font size="2" face="Open-sans, sans-serif" color="#555454">
|
||||
<strong>{$product['name']}</strong><br>
|
||||
{$customization['customization_text']}
|
||||
</font>
|
||||
</td>
|
||||
<td width="10"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<td style="border:1px solid #D6D4D4;"></td>
|
||||
<td style="border:1px solid #D6D4D4;">
|
||||
{if isset($product.configurator_opt)}
|
||||
{foreach item=group from=$product.configurator_opt}
|
||||
<small>
|
||||
@ -74,7 +25,7 @@
|
||||
{$i}{if !$smarty.foreach.opt.last},{/if}
|
||||
{/if}
|
||||
{/foreach}
|
||||
</small>
|
||||
</small><br/>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</td>
|
||||
|
@ -1,36 +1,18 @@
|
||||
{foreach $list['products] as $product}
|
||||
{$product['reference']}
|
||||
|
||||
{$product['name']}
|
||||
|
||||
{$product['price']}
|
||||
|
||||
{$product['quantity']}
|
||||
|
||||
{$product['price']}
|
||||
|
||||
{foreach $product['customization'] as $customization}
|
||||
{$product['name']} {$customization['customization_text']}
|
||||
|
||||
{$product['price']}
|
||||
|
||||
{$product['customization_quantity']}
|
||||
|
||||
{$product['quantity']}
|
||||
{/foreach}
|
||||
|
||||
{foreach $list['products'] as $product}
|
||||
REFERENCE : {$product['reference']}
|
||||
PRODUIT : {$product['name']}
|
||||
{if isset($product.configurator_opt)}
|
||||
{foreach item=group from=$product.configurator_opt}
|
||||
{foreach item=group from=$product.configurator_opt}
|
||||
|
||||
{$group['name']} :
|
||||
{foreach item=i from=$group['value'] name=opt}
|
||||
{if $group['type'] == 'file'}
|
||||
$list['base_url']upload/{$product['id_product']}/{$group['reference']}/{$i}
|
||||
{else}
|
||||
{$i}{if !$smarty.foreach.opt.last},{/if}
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
{$group['name']} :
|
||||
{foreach item=i from=$group['value'] name=opt}
|
||||
{if $group['type'] == 'file'}
|
||||
$list['base_url']upload/{$product['id_product']}/{$group['reference']}/{$i}
|
||||
{else}
|
||||
{$i}{if !$smarty.foreach.opt.last},{/if}
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
{/if}
|
||||
{/foreach}
|
@ -9,6 +9,7 @@
|
||||
<div class="bloc-left md5 xxs12">
|
||||
<div class="row">
|
||||
<div class="bloc-devis lg10 sm12">
|
||||
{if $emailSent == false && $error == false}
|
||||
<h2 class="title">{l s='Mon devis'}</h2>
|
||||
<div class="listing animated-full clearfix">
|
||||
{foreach item=product from=$products}
|
||||
@ -47,11 +48,12 @@
|
||||
<div class="continue-shop">
|
||||
<a href="#" class="btn">{l s='Compléter ma demande de devis'}</a>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if $step == 1 && $error == false}
|
||||
{if $emailSent == true && $error == false}
|
||||
<div class="bloc-right-confirmation lg5 md7 xxs12">
|
||||
<h2 class="title">{l s='Votre demande a bien été envoyée :)'}</h2>
|
||||
<p class="subtitle">{l s='Elle sera traitée super-rapidement par notre équipe. Prochaine étape : on vous recontacte par email ou par téléphone pour vous proposer un devis personnalisé'}</p>
|
||||
@ -66,16 +68,20 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if $step == 1 && $error == true}
|
||||
{if $emailSent == false && $error == true}
|
||||
<div>{$errorMsg}</div>
|
||||
{/if}
|
||||
|
||||
{if $step == 0 || ($step == 1 && $error == true)}
|
||||
{if $emailSent == false || $error == true}
|
||||
<div class="bloc-right md7 xxs12">
|
||||
<h2 class="title">{l s='Demande de devis'}</h2>
|
||||
{if $empty == 1}
|
||||
{l s='Votre devis est vide'}
|
||||
{else}
|
||||
<p class="subtitle">{l s='Une fois votre demande de devis envoyée, notre équipe vous contacte très rapidement pour vous proposer un devis personnalisé'}</p>
|
||||
<span>{l s='Qui devons-nous contacter ?'}</span>
|
||||
<form action="">
|
||||
<form action="{$request_uri}" method="post">
|
||||
<input type="hidden" name="step" value="1" />
|
||||
<div class="row w88">
|
||||
<div class="sm6 form-group">
|
||||
<label for="name">{l s='Nom du contact *'}</label>
|
||||
@ -114,8 +120,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn valid-form-btn">{l s='Envoyer ma demande de devis'} <i class="icon icon-mail"></i></button>
|
||||
<button type="submit" name="submitQuote" class="btn valid-form-btn">{l s='Envoyer ma demande de devis'} <i class="icon icon-mail"></i></button>
|
||||
</form>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user