Initial commit

This commit is contained in:
2019-11-20 07:44:43 +01:00
commit 5bf49c4a81
41188 changed files with 5459177 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
require_once(dirname(__FILE__) . '/../../config/config.inc.php');
include(dirname(__FILE__) . '/../../init.php');
include(dirname(__FILE__) . '/installmentpayment.php');
if (!defined('_PS_VERSION_')) {
exit;
}
if (Tools::getIsset('installmentpayment_type')) {
$id_cart = (int) Context::getContext()->cart->id;
if ((int) Tools::getValue('installmentpayment_type') == 0) {
Db::getInstance()->delete('installmentpayment', 'id_cart=' . (int) $id_cart);
} else {
//$installement = InstallmentPayment::getinstallmentInfos($id_cart);
$cartdata = new Cart($id_cart);
$total = (float) $cartdata->getOrderTotalGross(true, Cart::BOTH);
$id_defaultgroup = Db::getInstance()->executeS('SELECT id_default_group FROM ' . _DB_PREFIX_ . 'customer WHERE id_customer = ' . (int) Context::getContext()->customer->id);
if(is_array($id_defaultgroup))
{
$id_defaultgroup = $id_defaultgroup[0]['id_default_group'];
}
$sql = 'SELECT price FROM `' . _DB_PREFIX_ . 'installmentpayment_group` WHERE id_group=' . (int) $id_defaultgroup;
$data = Db::getInstance()->getRow($sql);
if(!empty($data)){
$percent = $data['price'];
}
else
{
$percent = Configuration::get('ACOMPTE_PERCENTAGE');
}
$acompte = (float) $total - ($total * (100 - $percent) / 100);
$rest = $total - $acompte;
$data_insert = array(
'id_cart' => (int) $id_cart,
'total' => $total,
'payer' => $acompte,
'rest' => $rest,
'state' => 0,
);
Db::getInstance()->insert('installmentpayment', $data_insert);
}
Context::getContext()->cookie->__set('installmentpayment_type', (int) Tools::getValue('installmentpayment_type'));
die(Hook::exec('displayPayment'));
die(Hook::exec('displayPaymentTop'));
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>installmentpayment</name>
<displayName><![CDATA[Installment payment]]></displayName>
<version><![CDATA[1.0.24]]></version>
<description><![CDATA[Allows you to set a percentage payment to ask to your customers for the payment of their order.]]></description>
<author><![CDATA[MagAvenue]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Are you sure you want to uninstall?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>installmentpayment</name>
<displayName><![CDATA[Installment payment]]></displayName>
<version><![CDATA[1.0.24]]></version>
<description><![CDATA[Allows you to set a percentage payment to ask to your customers for the payment of their order.]]></description>
<author><![CDATA[MagAvenue]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Are you sure you want to uninstall?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>installmentpayment</name>
<displayName><![CDATA[Module de paiement en Commande en RDV tailleur ]]></displayName>
<version><![CDATA[1.0.24]]></version>
<description><![CDATA[Ce module vous permet de d&eacute;finir un pourcentage d&#039;acompte &agrave; demander &agrave; vos clients pour la prise en compte de leur commande.]]></description>
<author><![CDATA[MagAvenue]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Etes-vous sûr de vouloir désinstaller le module ?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,118 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
use PrestaShop\PrestaShop\Core\Payment\PaymentOption;
class InstallmentpaymentInstallmentpaymentModuleFrontController extends ModuleFrontController
{
public $ssl = true;
public function __construct()
{
parent::__construct();
}
public function initContent()
{
$this->display_column_left = false;
$this->display_column_right = false;
parent::initContent();
$id_order = Tools::getValue('select');
if (!Context::getContext()->customer->isLogged() && (int) $id_order > 0) {
Tools::redirect(
'index.php?controller=authentication&back=' . urlencode($this->context->link->getModuleLink('installmentpayment', 'installmentpayment', array('select' => $id_order)))
);
}
$order = new Order((int) $id_order);
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$rest_paid = $installment['rest'];
} else {
Tools::redirect(
'index.php?controller=authentication&back=' . urlencode($this->context->link->getModuleLink('installmentpayment', 'installmentpayment', array('select' => $id_order)))
);
}
if ((int) $id_order > 0) {
Context::getContext()->cookie->__set('installmentpayment_id_order', $id_order);
}
$oldCart = new Cart($order->id_cart);
$cart = $oldCart->duplicate();
$this->context->cookie->id_cart = $cart['cart']->id;
$context = $this->context;
$context->cart = $cart['cart'];
$this->context->cookie->write();
$this->context->smarty->assign('hide_left_column', true);
$this->context->smarty->assign('hide_right_column', true);
if (Tools::substr(str_replace('.', '', _PS_VERSION_), 0, 2) == 16) {
if (Context::getContext()->customer->id) {
$cartdata = new Cart($order->id_cart);
$total = (float) $cartdata->getOrderTotalGross(true, Cart::BOTH);
$this->context->smarty->assign(array(
'reference' => $order->reference,
'total' => $total,
'HOOK_PAYMENT' => Hook::exec('displayPayment')
));
$this->setTemplate('order-payment-classic.tpl');
}
} else {
if (Context::getContext()->customer->id) {
$b = new PaymentOptionsFinder();
$data = $b->present();
$cartdata = new Cart($order->id_cart);
$total = (float) $cartdata->getOrderTotalGross(true, Cart::BOTH);
$id_defaultgroup = Db::getInstance()->executeS('SELECT id_default_group FROM ' . _DB_PREFIX_ . 'customer WHERE id_customer = ' . (int) Context::getContext()->customer->id);
if(is_array($id_defaultgroup))
{
$id_defaultgroup = $id_defaultgroup[0]['id_default_group'];
}
$sql = 'SELECT price FROM `' . _DB_PREFIX_ . 'installmentpayment_group` WHERE id_group=' . (int) $id_defaultgroup;
$dataprice = Db::getInstance()->getRow($sql);
if(!empty($data)){
$acompte = (float) $total - ($total * (100 - $dataprice['price']) / 100);
$percent = $dataprice['price'];
}
else
{
$acompte = (float) $total - ($total * (100 - Configuration::get('ACOMPTE_PERCENTAGE')) / 100);
$percent = Configuration::get('ACOMPTE_PERCENTAGE');
}
$presentedCart = $this->cart_presenter->present($this->context->cart);
$this->context->smarty->assign(array(
'reference' => $order->reference,
'payment_options' => $data,
'cart' => $presentedCart,
'selected_payment_option' => 1,
'show_final_summary' => Configuration::get('PS_FINAL_SUMMARY_ENABLED'),
'installmentpayment_type' => (int) Context::getContext()->cookie->installmentpayment_type,
'percent' => $percent,
'acompte_chose' => Configuration::get('ACOMPTE_CHOICE'),
'acompte' => $acompte,
));
$this->setTemplate('module:installmentpayment/views/templates/front/checkout.tpl');
}
}
}
public function setMedia() {
parent::setMedia();
$this->addCSS( _THEME_CSS_DIR_ . 'modules/stripe_official/views/css/front.css');
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,64 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
require_once(dirname(__FILE__) . '/../../config/config.inc.php');
include(dirname(__FILE__) . '/../../init.php');
include(dirname(__FILE__) . '/installmentpayment.php');
if (!defined('_PS_VERSION_') || !Tools::getIsset('key') || Tools::getValue('key') != 'Zrt978heov87MagT') {
exit;
}
$time = time();
$tendays = time() - (Configuration::get('ACOMPTE_DAYS') * 24 * 60 * 60);
$date = date('Y-d-m', $tendays);
$sql = 'SELECT id_order FROM `' . _DB_PREFIX_ . 'orders` where `date_add` like "' . $date . '%" ';
$return = Db::getInstance()->executeS($sql);
if (!empty($return)) {
foreach ($return as $key => $order) {
$context;
$order = new Order($order['id_order']);
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` where `id_cart`=' . (int) $order->id_cart . ' and `rest` > 0';
$installement = Db::getInstance()->executeS($sql);
if (!empty($installement)) {
$iso = Language::getIsoById((int) $context->language->id);
$customer = new Customer((int) $order->id_customer);
$link = new LinkCore();
$installement = $installement[0];
if (isset($installement['state'])) {
$templateVars = array(
'{firstname}' => $customer->firstname,
'{lastname}' => $customer->lastname,
'{email}' => $customer->email,
'{reference}' => $order->reference,
'{pay}' => Tools::displayPrice($installement['payer'], new Currency($order->id_currency)),
'{rest}' => Tools::displayPrice($installement['rest'], new Currency($order->id_currency)),
'{total}' => Tools::displayPrice($installement['total'], new Currency($order->id_currency)),
'{be_paid}' => Tools::displayPrice((float) Tools::getValue('installmentpayment'), new Currency($order->id_currency)),
'{installement_url}' => $link->getModuleLink('installmentpayment', 'installmentpayment', array('select' => $order->id))
);
$template = 'claim';
//$customer->email = 'magavenueanuj@gmail.com';
$subject = 'Il reste à payer pour la commande n° #' . $order->reference;
if (file_exists(_PS_MODULE_DIR_ . 'installmentpayment/mails/' . $iso . '/' . $template . '.txt') and file_exists(_PS_MODULE_DIR_ . 'installmentpayment/mails/' . $iso . '/' . $template . '.html')) {
Mail::Send((int) $context->language->id, $template, $subject, $templateVars, $customer->email, null, Configuration::get('PS_SHOP_EMAIL'), Configuration::get('PS_SHOP_NAME'), null, null, _PS_MODULE_DIR_ . 'installmentpayment/mails/');
}
}
}
}
echo 'Ok';
}
exit;

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -0,0 +1,93 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Message from {shop_name}</title>
</head>
<body>
<table class="table table-mail" style="width:100%;margin-top:10px;-moz-box-shadow:0 0 5px #afafaf;-webkit-box-shadow:0 0 5px #afafaf;-o-box-shadow:0 0 5px #afafaf;box-shadow:0 0 5px #afafaf;filter:progid:DXImageTransform.Microsoft.Shadow(color=#afafaf,Direction=134,Strength=5)">
<tr>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
<td align="center" style="padding:7px 0">
<table class="table" bgcolor="#ffffff" style="width:100%">
<tr>
<td align="center" class="logo" style="border-bottom:4px solid #333333;padding:7px 0">
<a title="{shop_name}" href="{shop_url}" style="color:#337ff1">
<img src="{shop_logo}" alt="{shop_name}" />
</a>
</td>
</tr>
<tr>
<td align="center" class="titleblock" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span class="title" style="font-weight:500;font-size:28px;text-transform:uppercase;line-height:33px">Hi {firstname} {lastname},</span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="box" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span style="color:#777">
We inform you of the remaining amount at paying for your order # <span style="color:#333"><strong>{reference}</strong></span>.<br /><br />
Total order: <span style="color:#333"><strong>{total}</strong></span><br><br>
Amounts due: <span style="color:#333"><strong>{rest}</strong></span><br><br>
Remains to pay: <span style="color:#333"><strong>{pay}</strong></span><br><br>
See you soon on <a style="color: #a2d1da; font-weight: bold; text-decoration: none;" href="{shop_url}">{shop_name}</a>,<br /><br />
Customer Service from {shop_name}<br><br>
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
You can review your order and download your invoice from the <a href="{history_url}" style="color:#337ff1">"Order history"</a> section of your customer account by clicking <a href="{my_account_url}" style="color:#337ff1">"My account"</a> on our shop. </span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
For paying the rest <a href="{installement_url}" style="color:#337ff1">"Order paying"</a> on our shop. </span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="footer" style="border-top:4px solid #333333;padding:7px 0">
<span><a href="{shop_url}" style="color:#337ff1">{shop_name}</a> </span>
</td>
</tr>
</table>
</td>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,10 @@
Hi {firstname} {lastname},
We inform you of the remaining amount to complete your order #{reference}
Total order:{rest}
For paying the rest [{installement_url}]
[{my_account_url}] on our shop.
Best,
{shop_name} Team

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,405 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>Message from {shop_name}</title>
<style> @media only screen and (max-width: 300px){
body {
width:218px !important;
margin:auto !important;
}
thead, tbody{width: 100%}
.table {width:195px !important;margin:auto !important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto !important;display: block !important;}
span.title{font-size:20px !important;line-height: 23px !important}
span.subtitle{font-size: 14px !important;line-height: 18px !important;padding-top:10px !important;display:block !important;}
td.box p{font-size: 12px !important;font-weight: bold !important;}
.table-recap table, .table-recap thead, .table-recap tbody, .table-recap th, .table-recap td, .table-recap tr {
display: block !important;
}
.table-recap{width: 200px!important;}
.table-recap tr td, .conf_body td{text-align:center !important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
@media only screen and (min-width: 301px) and (max-width: 500px) {
body {width:425px!important;margin:auto!important;}
thead, tbody{width: 100%}
.table {margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
.table-recap{width: 295px !important;}
.table-recap tr td, .conf_body td{text-align:center !important;}
.table-recap tr th{font-size: 10px !important}
}
@media only screen and (min-width: 501px) and (max-width: 768px) {
body {width:478px!important;margin:auto!important;}
thead, tbody{width: 100%}
.table {margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
}
@media only screen and (max-device-width: 480px) {
body {width:340px!important;margin:auto!important;}
thead, tbody{width: 100%}
.table {margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
.table-recap{width: 295px!important;}
.table-recap tr td, .conf_body td{text-align:center!important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
</style>
</head>
<body style="-webkit-text-size-adjust:none;background-color:#fff;width:650px;font-family:Open-sans, sans-serif;color:#555454;font-size:13px;line-height:18px;margin:auto" >
<table class="table table-mail" style="width:100%;margin-top:10px;-moz-box-shadow:0 0 5px #afafaf;-webkit-box-shadow:0 0 5px #afafaf;-o-box-shadow:0 0 5px #afafaf;box-shadow:0 0 5px #afafaf;filter:progid:DXImageTransform.Microsoft.Shadow(color=#afafaf,Direction=134,Strength=5)">
<tr>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
<td align="center" style="padding:7px 0">
<table class="table" bgcolor="#ffffff" style="width:100%">
<tr>
<td align="center" class="logo" style="border-bottom:4px solid #333333;padding:7px 0">
<a title="{shop_name}" href="{shop_url}" style="color:#337ff1">
<img src="{shop_logo}" alt="{shop_name}" />
</a>
</td>
</tr>
<tr>
<td align="center" class="titleblock" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span class="title" style="font-weight:500;font-size:28px;text-transform:uppercase;line-height:33px">Hi {firstname} {lastname},</span><br/>
<span class="subtitle" style="font-weight:500;font-size:16px;text-transform:uppercase;line-height:25px">Thank you for shopping with {shop_name}!</span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="box" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Order details </p>
<span style="color:#777">
<span style="color:#333"><strong>Order:</strong></span> {order_name} Placed on {date}<br /><br />
<span style="color:#333"><strong>Payment:</strong></span> {payment}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<table class="table table-recap" bgcolor="#ffffff" style="width:100%;border-collapse:collapse"><!-- Title -->
<tr>
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;">Reference</th>
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;">Product</th>
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;" width="17%">Unit price</th>
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;">Quantity</th>
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;" width="17%">Total price</th>
</tr>
<tr>
<td colspan="5" style="border:1px solid #D6D4D4;text-align:center;color:#777;padding:7px 0">
&nbsp;&nbsp;{products}
</td>
</tr>
<tr>
<td colspan="5" style="border:1px solid #D6D4D4;text-align:center;color:#777;padding:7px 0">
&nbsp;&nbsp;{discounts}
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Products</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" align="right" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_products}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Discounts</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_discounts}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Gift-wrapping</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_wrapping}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Shipping</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_shipping}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Total Tax paid</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_tax_paid}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Total paid</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="4" face="Open-sans, sans-serif" color="#555454">
{total_paid}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</font>
</td>
</tr>
<tr>
<td class="box" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Shipping </p>
<span style="color:#777">
<span style="color:#333"><strong>Carrier:</strong></span> {carrier}<br /><br />
<span style="color:#333"><strong>Payment:</strong></span> {payment}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td style="padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td class="box address" width="310" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Delivery address </p>
<span data-html-only="1" style="color:#777">
{delivery_block_html}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
<td width="20" class="space_address" style="padding:7px 0">&nbsp;</td>
<td class="box address" width="310" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Billing address </p>
<span data-html-only="1" style="color:#777">
{invoice_block_html}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td ><span>You will received a mail in {days} days, for paying the balance of this order.</span></td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
You can review your order and download your invoice from the <a href="{history_url}" style="color:#337ff1">"Order history"</a> section of your customer account by clicking <a href="{my_account_url}" style="color:#337ff1">"My account"</a> on our shop. </span>
</font>
</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
If you have a guest account, you can follow your order via the <a href="{guest_tracking_url}?id_order={order_name}" style="color:#337ff1">"Guest Tracking"</a> section on our shop. </span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="footer" style="border-top:4px solid #333333;padding:7px 0">
<span><a href="{shop_url}" style="color:#337ff1">{shop_name}</a> powered by <a href="http://www.prestashop.com/" style="color:#337ff1">PrestaShop&trade;</a></span>
</td>
</tr>
</table>
</td>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,72 @@
[{shop_url}]
Hi {firstname} {lastname},
Thank you for shopping with {shop_name}!
ORDER: {order_name} Placed on {date}
PAYMENT: {payment}
REFERENCE
PRODUCT
UNIT PRICE
QUANTITY
TOTAL PRICE
{products_txt}
{discounts}
PRODUCTS
{total_products}
DISCOUNTS
{total_discounts}
GIFT-WRAPPING
{total_wrapping}
SHIPPING
{total_shipping}
TOTAL TAX PAID
{total_tax_paid}
TOTAL PAID
{total_paid}
CARRIER: {carrier}
PAYMENT: {payment}
{delivery_block_txt}
{invoice_block_txt}
You will received a mail in {days} days, for paying the balance of this order.
You can review your order and download your invoice from the
"Order history" [{history_url}]
section of your customer account by clicking "My account"
[{my_account_url}] on our shop.
If you have a guest account, you can follow your order via the
"Guest Tracking"
[{guest_tracking_url}?id_order={order_name}]
section on our shop.
{shop_name} [{shop_url}] powered
by PrestaShop(tm) [http://www.prestashop.com/]

View File

@@ -0,0 +1,93 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Message de {shop_name}</title>
</head>
<body>
<table class="table table-mail" style="width:100%;margin-top:10px;-moz-box-shadow:0 0 5px #afafaf;-webkit-box-shadow:0 0 5px #afafaf;-o-box-shadow:0 0 5px #afafaf;box-shadow:0 0 5px #afafaf;filter:progid:DXImageTransform.Microsoft.Shadow(color=#afafaf,Direction=134,Strength=5)">
<tr>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
<td align="center" style="padding:7px 0">
<table class="table" bgcolor="#ffffff" style="width:100%">
<tr>
<td align="center" class="logo" style="border-bottom:4px solid #333333;padding:7px 0">
<a title="{shop_name}" href="{shop_url}" style="color:#337ff1">
<img src="{shop_logo}" alt="{shop_name}" />
</a>
</td>
</tr>
<tr>
<td align="center" class="titleblock" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span class="title" style="font-weight:500;font-size:28px;text-transform:uppercase;line-height:33px">Bonjour {firstname} {lastname},</span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="box" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span style="color:#777">
Nous vous informons qu&#039;il vous reste un montant &agrave; r&eacute;gler sur votre commande #<span style="color:#333"><strong>{reference}</strong></span>.<br /><br />
Total de la commande : <span style="color:#333"><strong>{total}</strong></span><br><br>
Montant pay&eacute; : <span style="color:#333"><strong>{pay}</strong></span><br><br>
Montant restant : <span style="color:#333"><strong>{rest}</strong></span><br><br>
A bient&ocirc;t sur <a style="color: #a2d1da; font-weight: bold; text-decoration: none;" href="{shop_url}">{shop_name}</a>,<br /><br />
Le service client de {shop_name}<br><br>
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
Vous pouvez revoir votre commande et t&eacute;l&eacute;charger votre facture en allant dans la partie <a href="{history_url}" style="color:#337ff1">"Historique de commandes"</a> de votre compte client, qui est accessible sur <a href="{my_account_url}" style="color:#337ff1">"Mon compte"</a> sur notre boutique. </span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
Pour r&eacute;gler le solde de votre commande, cliquez sur le lien suivant : <a href="{installement_url}" style="color:#337ff1">"Je r&egrave;gle ma commande"</a>. </span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="footer" style="border-top:4px solid #333333;padding:7px 0">
<span><a href="{shop_url}" style="color:#337ff1">{shop_name}</a> </span>
</td>
</tr>
</table>
</td>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,8 @@
Bonjour {firstname} {lastname},
Nous vous informons qu'il vous reste un montant à régler sur votre commande #{reference}
Total de la commande : {rest}
Pour régler le solde de votre commande, cliquez sur le lien suivant : "Régler ma commande" [{installement_url}].
Le service client de {shop_name}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,407 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>Message de {shop_name}</title>
<style> @media only screen and (max-width: 300px){
body {
width:218px !important;
margin:auto !important;
}
thead, tbody{width: 100%}
.table {width:195px !important;margin:auto !important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto !important;display: block !important;}
span.title{font-size:20px !important;line-height: 23px !important}
span.subtitle{font-size: 14px !important;line-height: 18px !important;padding-top:10px !important;display:block !important;}
td.box p{font-size: 12px !important;font-weight: bold !important;}
.table-recap table, .table-recap thead, .table-recap tbody, .table-recap th, .table-recap td, .table-recap tr {
display: block !important;
}
.table-recap{width: 200px!important;}
.table-recap tr td, .conf_body td{text-align:center !important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
@media only screen and (min-width: 301px) and (max-width: 500px) {
body {width:425px!important;margin:auto!important;}
thead, tbody{width: 100%}
.table {margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
.table-recap{width: 295px !important;}
.table-recap tr td, .conf_body td{text-align:center !important;}
.table-recap tr th{font-size: 10px !important}
}
@media only screen and (min-width: 501px) and (max-width: 768px) {
body {width:478px!important;margin:auto!important;}
thead, tbody{width: 100%}
.table {margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
}
@media only screen and (max-device-width: 480px) {
body {width:340px!important;margin:auto!important;}
thead, tbody{width: 100%}
.table {margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
.table-recap{width: 295px!important;}
.table-recap tr td, .conf_body td{text-align:center!important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
</style>
</head>
<body style="-webkit-text-size-adjust:none;background-color:#fff;width:650px;font-family:Open-sans, sans-serif;color:#555454;font-size:13px;line-height:18px;margin:auto" >
<table class="table table-mail" style="width:100%;margin-top:10px;-moz-box-shadow:0 0 5px #afafaf;-webkit-box-shadow:0 0 5px #afafaf;-o-box-shadow:0 0 5px #afafaf;box-shadow:0 0 5px #afafaf;filter:progid:DXImageTransform.Microsoft.Shadow(color=#afafaf,Direction=134,Strength=5)">
<tr>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
<td align="center" style="padding:7px 0">
<table class="table" bgcolor="#ffffff" style="width:100%">
<tr>
<td align="center" class="logo" style="border-bottom:4px solid #333333;padding:7px 0">
<a title="{shop_name}" href="{shop_url}" style="color:#337ff1">
<img src="{shop_logo}" alt="{shop_name}" />
</a>
</td>
</tr>
<tr>
<td align="center" class="titleblock" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span class="title" style="font-weight:500;font-size:28px;text-transform:uppercase;line-height:33px">Bonjour {firstname} {lastname},</span><br/>
<span class="subtitle" style="font-weight:500;font-size:16px;text-transform:uppercase;line-height:25px">Merci d'avoir effectué vos achats sur {shop_name}!</span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="box" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Détails de la commande </p>
<span style="color:#777">
<span style="color:#333"><strong>Commande :</strong></span> {order_name} passée le {date}<br /><br />
<span style="color:#333"><strong>Paiement :</strong></span> {payment}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<table class="table table-recap" bgcolor="#ffffff" style="width:100%;border-collapse:collapse"><!-- Title -->
<tr>
<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>
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;" width="17%">Prix unitaire</th>
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;">Quantité</th>
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;" width="17%">Prix total</th>
</tr>
<tr>
<td colspan="5" style="border:1px solid #D6D4D4;text-align:center;color:#777;padding:7px 0">
&nbsp;&nbsp;{products}
</td>
</tr>
<tr>
<td colspan="5" style="border:1px solid #D6D4D4;text-align:center;color:#777;padding:7px 0">
&nbsp;&nbsp;{discounts}
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Produits</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" align="right" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_products}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Réductions</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_discounts}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Paquet cadeau</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_wrapping}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Livraison</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_shipping}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>TVA totale</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_tax_paid}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Total payé</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="4" face="Open-sans, sans-serif" color="#555454">
{total_paid}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</font>
</td>
</tr>
<tr>
<td class="box" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Livraison </p>
<span style="color:#777">
<span style="color:#333"><strong>Transporteur :</strong></span> {carrier}<br /><br />
<span style="color:#333"><strong>Paiement :</strong></span> {payment}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td style="padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td class="box address" width="310" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Adresse de livraison </p>
<span data-html-only="1" style="color:#777">
{delivery_block_html}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
<td width="20" class="space_address" style="padding:7px 0">&nbsp;</td>
<td class="box address" width="310" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Adresse de facturation </p>
<span data-html-only="1" style="color:#777">
{invoice_block_html}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td ><span>You will received a mail in {days} days, for paying the balance of this order.</span></td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
Vous pouvez accéder à tout moment au suivi de votre commande et télécharger votre facture dans <a href="{history_url}" style="color:#337ff1">"Historique des commandes"</a> de la rubrique <a href="{my_account_url}" style="color:#337ff1">"Mon compte"</a> sur notre site. </span>
</font>
</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
Si vous avez un compte invité, vous pouvez suivre votre commande dans la section <a href="{guest_tracking_url}?id_order={order_name}" style="color:#337ff1">"Suivi invité"</a> de notre site. </span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="footer" style="border-top:4px solid #333333;padding:7px 0">
<span><a href="{shop_url}" style="color:#337ff1">{shop_name}</a> powered by <a href="http://www.prestashop.com/" style="color:#337ff1">PrestaShop&trade;</a></span>
</td>
</tr>
</table>
</td>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,72 @@
[{shop_url}]
Bonjour {firstname} {lastname},
Merci d'avoir effectué vos achats sur {shop_name}!
COMMANDE : {order_name} passée le {date}
PAIEMENT : {payment}
RÉFÉRENCE
PRODUIT
PRIX UNITAIRE
QUANTITÉ
PRIX TOTAL
{products_txt}
{discounts}
PRODUITS
{total_products}
RÉDUCTIONS
{total_discounts}
PAQUET CADEAU
{total_wrapping}
LIVRAISON
{total_shipping}
TVA TOTALE
{total_tax_paid}
TOTAL PAYÉ
{total_paid}
TRANSPORTEUR : {carrier}
PAIEMENT : {payment}
{delivery_block_txt}
{invoice_block_txt}
You will received a mail in {days} days, for paying the balance of this order.
Vous pouvez accéder à tout moment au suivi de votre commande et
télécharger votre facture dans "Historique des commandes"
[{history_url}] de la rubrique "Mon compte"
[{my_account_url}] sur notre site.
Si vous avez un compte invité, vous pouvez suivre votre commande
dans la section "Suivi invité"
[{guest_tracking_url}?id_order={order_name}] de
notre site.
{shop_name} [{shop_url}] powered by
PrestaShop(tm) [http://www.prestashop.com/]

View File

@@ -0,0 +1,93 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Message de {shop_name}</title>
</head>
<body>
<table class="table table-mail" style="width:100%;margin-top:10px;-moz-box-shadow:0 0 5px #afafaf;-webkit-box-shadow:0 0 5px #afafaf;-o-box-shadow:0 0 5px #afafaf;box-shadow:0 0 5px #afafaf;filter:progid:DXImageTransform.Microsoft.Shadow(color=#afafaf,Direction=134,Strength=5)">
<tr>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
<td align="center" style="padding:7px 0">
<table class="table" bgcolor="#ffffff" style="width:100%">
<tr>
<td align="center" class="logo" style="border-bottom:4px solid #333333;padding:7px 0">
<a title="{shop_name}" href="{shop_url}" style="color:#337ff1">
<img src="{shop_logo}" alt="{shop_name}" />
</a>
</td>
</tr>
<tr>
<td align="center" class="titleblock" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span class="title" style="font-weight:500;font-size:28px;text-transform:uppercase;line-height:33px">Bonjour {firstname} {lastname},</span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="box" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span style="color:#777">
Nous vous informons qu&#039;il vous reste un montant &agrave; r&eacute;gler sur votre commande #<span style="color:#333"><strong>{reference}</strong></span>.<br /><br />
Total de la commande : <span style="color:#333"><strong>{total}</strong></span><br><br>
Montant pay&eacute; : <span style="color:#333"><strong>{pay}</strong></span><br><br>
Montant restant : <span style="color:#333"><strong>{rest}</strong></span><br><br>
A bient&ocirc;t sur <a style="color: #a2d1da; font-weight: bold; text-decoration: none;" href="{shop_url}">{shop_name}</a>,<br /><br />
Le service client de {shop_name}<br><br>
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
Vous pouvez revoir votre commande et t&eacute;l&eacute;charger votre facture en allant dans la partie <a href="{history_url}" style="color:#337ff1">"Historique de commandes"</a> de votre compte client, qui est accessible sur <a href="{my_account_url}" style="color:#337ff1">"Mon compte"</a> sur notre boutique. </span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
Pour r&eacute;gler le solde de votre commande, cliquez sur le lien suivant : <a href="{installement_url}" style="color:#337ff1">"Je r&egrave;gle ma commande"</a>. </span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="footer" style="border-top:4px solid #333333;padding:7px 0">
<span><a href="{shop_url}" style="color:#337ff1">{shop_name}</a> </span>
</td>
</tr>
</table>
</td>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,8 @@
Bonjour {firstname} {lastname},
Nous vous informons qu'il vous reste un montant à régler sur votre commande #{reference}
Total de la commande : {rest}
Pour régler le solde de votre commande, cliquez sur le lien suivant : "Régler ma commande" [{installement_url}].
Le service client de {shop_name}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,407 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>Message de {shop_name}</title>
<style> @media only screen and (max-width: 300px){
body {
width:218px !important;
margin:auto !important;
}
thead, tbody{width: 100%}
.table {width:195px !important;margin:auto !important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto !important;display: block !important;}
span.title{font-size:20px !important;line-height: 23px !important}
span.subtitle{font-size: 14px !important;line-height: 18px !important;padding-top:10px !important;display:block !important;}
td.box p{font-size: 12px !important;font-weight: bold !important;}
.table-recap table, .table-recap thead, .table-recap tbody, .table-recap th, .table-recap td, .table-recap tr {
display: block !important;
}
.table-recap{width: 200px!important;}
.table-recap tr td, .conf_body td{text-align:center !important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
@media only screen and (min-width: 301px) and (max-width: 500px) {
body {width:425px!important;margin:auto!important;}
thead, tbody{width: 100%}
.table {margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
.table-recap{width: 295px !important;}
.table-recap tr td, .conf_body td{text-align:center !important;}
.table-recap tr th{font-size: 10px !important}
}
@media only screen and (min-width: 501px) and (max-width: 768px) {
body {width:478px!important;margin:auto!important;}
thead, tbody{width: 100%}
.table {margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
}
@media only screen and (max-device-width: 480px) {
body {width:340px!important;margin:auto!important;}
thead, tbody{width: 100%}
.table {margin:auto!important;}
.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
.table-recap{width: 295px!important;}
.table-recap tr td, .conf_body td{text-align:center!important;}
.address{display: block !important;margin-bottom: 10px !important;}
.space_address{display: none !important;}
}
</style>
</head>
<body style="-webkit-text-size-adjust:none;background-color:#fff;width:650px;font-family:Open-sans, sans-serif;color:#555454;font-size:13px;line-height:18px;margin:auto" >
<table class="table table-mail" style="width:100%;margin-top:10px;-moz-box-shadow:0 0 5px #afafaf;-webkit-box-shadow:0 0 5px #afafaf;-o-box-shadow:0 0 5px #afafaf;box-shadow:0 0 5px #afafaf;filter:progid:DXImageTransform.Microsoft.Shadow(color=#afafaf,Direction=134,Strength=5)">
<tr>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
<td align="center" style="padding:7px 0">
<table class="table" bgcolor="#ffffff" style="width:100%">
<tr>
<td align="center" class="logo" style="border-bottom:4px solid #333333;padding:7px 0">
<a title="{shop_name}" href="{shop_url}" style="color:#337ff1">
<img src="{shop_logo}" alt="{shop_name}" />
</a>
</td>
</tr>
<tr>
<td align="center" class="titleblock" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span class="title" style="font-weight:500;font-size:28px;text-transform:uppercase;line-height:33px">Bonjour {firstname} {lastname},</span><br/>
<span class="subtitle" style="font-weight:500;font-size:16px;text-transform:uppercase;line-height:25px">Merci d'avoir effectué vos achats sur {shop_name}!</span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="box" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Détails de la commande </p>
<span style="color:#777">
<span style="color:#333"><strong>Commande :</strong></span> {order_name} passée le {date}<br /><br />
<span style="color:#333"><strong>Paiement :</strong></span> {payment}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<table class="table table-recap" bgcolor="#ffffff" style="width:100%;border-collapse:collapse"><!-- Title -->
<tr>
<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>
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;" width="17%">Prix unitaire</th>
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;">Quantité</th>
<th bgcolor="#f8f8f8" style="border:1px solid #D6D4D4;background-color: #fbfbfb;color: #333;font-family: Arial;font-size: 13px;padding: 10px;" width="17%">Prix total</th>
</tr>
<tr>
<td colspan="5" style="border:1px solid #D6D4D4;text-align:center;color:#777;padding:7px 0">
&nbsp;&nbsp;{products}
</td>
</tr>
<tr>
<td colspan="5" style="border:1px solid #D6D4D4;text-align:center;color:#777;padding:7px 0">
&nbsp;&nbsp;{discounts}
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Produits</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" align="right" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_products}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Réductions</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_discounts}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Paquet cadeau</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_wrapping}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Livraison</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_shipping}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>TVA totale</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
{total_tax_paid}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="conf_body">
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<strong>Total payé</strong>
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
<td bgcolor="#f8f8f8" colspan="4" style="border:1px solid #D6D4D4;color:#333;padding:7px 0">
<table class="table" style="width:100%;border-collapse:collapse">
<tr>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
<td align="right" style="color:#333;padding:0">
<font size="4" face="Open-sans, sans-serif" color="#555454">
{total_paid}
</font>
</td>
<td width="10" style="color:#333;padding:0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</font>
</td>
</tr>
<tr>
<td class="box" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Livraison </p>
<span style="color:#777">
<span style="color:#333"><strong>Transporteur :</strong></span> {carrier}<br /><br />
<span style="color:#333"><strong>Paiement :</strong></span> {payment}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td style="padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td class="box address" width="310" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Adresse de livraison </p>
<span data-html-only="1" style="color:#777">
{delivery_block_html}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
<td width="20" class="space_address" style="padding:7px 0">&nbsp;</td>
<td class="box address" width="310" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0">
<table class="table" style="width:100%">
<tr>
<td width="10" style="padding:7px 0">&nbsp;</td>
<td style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<p data-html-only="1" style="border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px">
Adresse de facturation </p>
<span data-html-only="1" style="color:#777">
{invoice_block_html}
</span>
</font>
</td>
<td width="10" style="padding:7px 0">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td ><span>You will received a mail in {days} days, for paying the balance of this order.</span></td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
Vous pouvez accéder à tout moment au suivi de votre commande et télécharger votre facture dans <a href="{history_url}" style="color:#337ff1">"Historique des commandes"</a> de la rubrique <a href="{my_account_url}" style="color:#337ff1">"Mon compte"</a> sur notre site. </span>
</font>
</td>
</tr>
<tr>
<td class="linkbelow" style="padding:7px 0">
<font size="2" face="Open-sans, sans-serif" color="#555454">
<span>
Si vous avez un compte invité, vous pouvez suivre votre commande dans la section <a href="{guest_tracking_url}?id_order={order_name}" style="color:#337ff1">"Suivi invité"</a> de notre site. </span>
</font>
</td>
</tr>
<tr>
<td class="space_footer" style="padding:0!important">&nbsp;</td>
</tr>
<tr>
<td class="footer" style="border-top:4px solid #333333;padding:7px 0">
<span><a href="{shop_url}" style="color:#337ff1">{shop_name}</a> powered by <a href="http://www.prestashop.com/" style="color:#337ff1">PrestaShop&trade;</a></span>
</td>
</tr>
</table>
</td>
<td class="space" style="width:20px;padding:7px 0">&nbsp;</td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,72 @@
[{shop_url}]
Bonjour {firstname} {lastname},
Merci d'avoir effectué vos achats sur {shop_name}!
COMMANDE : {order_name} passée le {date}
PAIEMENT : {payment}
RÉFÉRENCE
PRODUIT
PRIX UNITAIRE
QUANTITÉ
PRIX TOTAL
{products_txt}
{discounts}
PRODUITS
{total_products}
RÉDUCTIONS
{total_discounts}
PAQUET CADEAU
{total_wrapping}
LIVRAISON
{total_shipping}
TVA TOTALE
{total_tax_paid}
TOTAL PAYÉ
{total_paid}
TRANSPORTEUR : {carrier}
PAIEMENT : {payment}
{delivery_block_txt}
{invoice_block_txt}
You will received a mail in {days} days, for paying the balance of this order.
Vous pouvez accéder à tout moment au suivi de votre commande et
télécharger votre facture dans "Historique des commandes"
[{history_url}] de la rubrique "Mon compte"
[{my_account_url}] sur notre site.
Si vous avez un compte invité, vous pouvez suivre votre commande
dans la section "Suivi invité"
[{guest_tracking_url}?id_order={order_name}] de
notre site.
{shop_name} [{shop_url}] powered by
PrestaShop(tm) [http://www.prestashop.com/]

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,842 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
use PrestaShop\PrestaShop\Adapter\ServiceLocator;
class Cart extends CartCore
{
public function getSummaryDetails($id_lang = null, $refresh = false)
{
$summary = $this->getSummaryDetailsInstallment($id_lang, $refresh);
if (!Module::isEnabled('freelivery')) {
return $summary;
}
if (!isset(Context::getContext()->cart)) {
return $summary;
}
$ps_free_price = Tools::convertPrice(Configuration::get('PS_SHIPPING_FREE_PRICE'), Currency::getCurrencyInstance(Context::getContext()->cart->id_currency));
$total = $summary['total_products_wt'];
if ((int) Configuration::get('FREELIVERY_CALCULATION_RULE')) {
$total += $summary['total_discounts'];
}
$ps_remaining = $ps_free_price - $total;
$freelivery_remaining = isset($GLOBALS['freelivery_remaining']) ? $GLOBALS['freelivery_remaining'] : false;
if ($summary['total_shipping'] == 0 || ($total >= $ps_free_price && $ps_free_price > 0)) {
$summary['freelivery_remaining'] = 0;
} elseif ($ps_remaining < $freelivery_remaining && $ps_free_price > 0) {
$summary['freelivery_remaining'] = $ps_remaining;
} else {
$summary['freelivery_remaining'] = (float) $freelivery_remaining;
}
$summary['free_ship'] = $summary['freelivery_remaining'] > 0 ? 0 : 1; // Can't set to true/false because of old 1.6 versions
return $summary;
}
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null)
{
$_GET['id_cart_freelivery'] = $this->id;
return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone);
}
public static function debugBacktraceUrl($start = 0, $limit = null)
{
$backtrace = debug_backtrace();
array_shift($backtrace);
for ($i = 0; $i < $start; ++$i) {
array_shift($backtrace);
}
$data = array();
$i = 0;
foreach ($backtrace as $id => $trace) {
if ((int) $limit && ( ++$i > $limit)) {
break;
}
$relative_file = (isset($trace['file'])) ? 'in /' . ltrim(str_replace(array(_PS_ROOT_DIR_, '\\'), array('', '/'), $trace['file']), '/') : '';
$current_line = (isset($trace['line'])) ? ':' . $trace['line'] : '';
$fileName = ((isset($trace['class'])) ? $trace['class'] : '') . ((isset($trace['type'])) ? $trace['type'] : '') . $trace['function'];
$data[$relative_file] = $fileName;
}
return $data;
}
/**
* This function returns the total cart amount
*
* Possible values for $type:
* Cart::ONLY_PRODUCTS
* Cart::ONLY_DISCOUNTS
* Cart::BOTH
* Cart::BOTH_WITHOUT_SHIPPING
* Cart::ONLY_SHIPPING
* Cart::ONLY_WRAPPING
* Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING
* Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING
*
* @param bool $withTaxes With or without taxes
* @param int $type Total type
* @param bool $use_cache Allow using cache of the method CartRule::getContextualValue
* @return float Order total
*/
public function getOrderTotal($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true, $gross = false, $small = false)
{
$address_factory = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\AddressFactory');
$price_calculator = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\Product\\PriceCalculator');
$configuration = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Core\\ConfigurationInterface');
$ps_tax_address_type = $configuration->get('PS_TAX_ADDRESS_TYPE');
$ps_use_ecotax = $configuration->get('PS_USE_ECOTAX');
$ps_round_type = $configuration->get('PS_ROUND_TYPE');
$ps_ecotax_tax_rules_group_id = $configuration->get('PS_ECOTAX_TAX_RULES_GROUP_ID');
$compute_precision = $configuration->get('_PS_PRICE_COMPUTE_PRECISION_');
$pre_commande = false;
$backtrace = $this->debugBacktraceUrl();
$i = 1;
foreach ($backtrace as $backtracekey => $backtracevalue) {
if ($i == 1 && strpos($backtracekey, '/modules/') !== false && (int) Configuration::get('ACOMPTE_CHOICE') == 1 || $i == 1 && strpos($backtracekey, '/modules/') !== false && isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0) {
$small = true;
}
$i++;
}
if (!$this->id) {
return 0;
}
$type = (int) $type;
$array_type = array(
Cart::ONLY_PRODUCTS,
Cart::ONLY_DISCOUNTS,
Cart::BOTH,
Cart::BOTH_WITHOUT_SHIPPING,
Cart::ONLY_SHIPPING,
Cart::ONLY_WRAPPING,
Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING,
Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING,
);
$virtual_context = Context::getContext()->cloneContext();
$virtual_context->cart = $this;
if (!in_array($type, $array_type)) {
die(Tools::displayError());
}
$with_shipping = in_array($type, array(Cart::BOTH, Cart::ONLY_SHIPPING));
if ($type == Cart::ONLY_DISCOUNTS && !CartRule::isFeatureActive()) {
return 0;
}
$virtual = $this->isVirtualCart();
if ($virtual && $type == Cart::ONLY_SHIPPING) {
return 0;
}
if ($virtual && $type == Cart::BOTH) {
$type = Cart::BOTH_WITHOUT_SHIPPING;
}
if ($with_shipping || $type == Cart::ONLY_DISCOUNTS) {
if (is_null($products) && is_null($id_carrier)) {
$shipping_fees = $this->getTotalShippingCost(null, (bool) $with_taxes);
} else {
$shipping_fees = $this->getPackageShippingCost((int) $id_carrier, (bool) $with_taxes, null, $products);
}
} else {
$shipping_fees = 0;
}
if ($type == Cart::ONLY_SHIPPING) {
return $shipping_fees;
}
if ($type == Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING) {
$type = Cart::ONLY_PRODUCTS;
}
$param_product = true;
if (is_null($products)) {
$param_product = false;
$products = $this->getProducts();
}
if ($type == Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING) {
foreach ($products as $key => $product) {
if ($product['is_virtual']) {
unset($products[$key]);
}
}
$type = Cart::ONLY_PRODUCTS;
}
$order_total = 0;
if (Tax::excludeTaxeOption()) {
$with_taxes = false;
}
$products_total = array();
$ecotax_total = 0;
foreach ($products as $product) {
if ($virtual_context->shop->id != $product['id_shop']) {
$virtual_context->shop = new Shop((int) $product['id_shop']);
}
if ($ps_tax_address_type == 'id_address_invoice') {
$id_address = (int) $this->id_address_invoice;
} else {
$id_address = (int) $product['id_address_delivery'];
} // Get delivery address of the product from the cart
if (!$address_factory->addressExists($id_address)) {
$id_address = null;
}
$null = null;
$price = $price_calculator->getProductPrice(
(int) $product['id_product'],
$with_taxes,
(int) $product['id_product_attribute'],
6,
null,
false,
true,
$product['cart_quantity'],
false,
(int) $this->id_customer ? (int) $this->id_customer : null,
(int) $this->id,
$id_address,
$null,
$ps_use_ecotax,
true,
$virtual_context
);
$address = $address_factory->findOrCreate($id_address, true);
if ($with_taxes) {
$id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $product['id_product'], $virtual_context);
$tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
} else {
$id_tax_rules_group = 0;
}
if (in_array($ps_round_type, array(Order::ROUND_ITEM, Order::ROUND_LINE))) {
if (!isset($products_total[$id_tax_rules_group])) {
$products_total[$id_tax_rules_group] = 0;
}
} elseif (!isset($products_total[$id_tax_rules_group . '_' . $id_address])) {
$products_total[$id_tax_rules_group . '_' . $id_address] = 0;
}
switch ($ps_round_type) {
case Order::ROUND_TOTAL:
$products_total[$id_tax_rules_group . '_' . $id_address] += $price * (int) $product['cart_quantity'];
break;
case Order::ROUND_LINE:
$product_price = $price * $product['cart_quantity'];
$products_total[$id_tax_rules_group] += Tools::ps_round($product_price, $compute_precision);
break;
case Order::ROUND_ITEM:
default:
$product_price = $price;
$products_total[$id_tax_rules_group] += Tools::ps_round($product_price, $compute_precision) * (int) $product['cart_quantity'];
break;
}
}
foreach ($products_total as $key => $price) {
$order_total += $price;
}
$order_total_products = $order_total;
if ($type == Cart::ONLY_DISCOUNTS) {
$order_total = 0;
}
$wrapping_fees = 0;
$include_gift_wrapping = (!$configuration->get('PS_ATCP_SHIPWRAP') || $type !== Cart::ONLY_PRODUCTS);
if ($this->gift && $include_gift_wrapping) {
$wrapping_fees = Tools::convertPrice(Tools::ps_round($this->getGiftWrappingPrice($with_taxes), $compute_precision), Currency::getCurrencyInstance((int) $this->id_currency));
}
if ($type == Cart::ONLY_WRAPPING) {
return $wrapping_fees;
}
$order_total_discount = 0;
$order_shipping_discount = 0;
if (!in_array($type, array(Cart::ONLY_SHIPPING, Cart::ONLY_PRODUCTS)) && CartRule::isFeatureActive()) {
if ($with_shipping || $type == Cart::ONLY_DISCOUNTS) {
$cart_rules = $this->getCartRules(CartRule::FILTER_ACTION_ALL);
} else {
$cart_rules = $this->getCartRules(CartRule::FILTER_ACTION_REDUCTION);
foreach ($this->getCartRules(CartRule::FILTER_ACTION_GIFT) as $tmp_cart_rule) {
$flag = false;
foreach ($cart_rules as $cart_rule) {
if ($tmp_cart_rule['id_cart_rule'] == $cart_rule['id_cart_rule']) {
$flag = true;
}
}
if (!$flag) {
$cart_rules[] = $tmp_cart_rule;
}
}
}
$id_address_delivery = 0;
if (isset($products[0])) {
$id_address_delivery = (is_null($products) ? $this->id_address_delivery : $products[0]['id_address_delivery']);
}
$package = array('id_carrier' => $id_carrier, 'id_address' => $id_address_delivery, 'products' => $products);
$flag = false;
foreach ($cart_rules as $cart_rule) {
if (($with_shipping || $type == Cart::ONLY_DISCOUNTS) && $cart_rule['obj']->free_shipping && !$flag) {
$order_shipping_discount = (float) Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_SHIPPING, ($param_product ? $package : null), $use_cache), $compute_precision);
$flag = true;
}
if ((int) $cart_rule['obj']->gift_product) {
$in_order = false;
if (is_null($products)) {
$in_order = true;
} else {
foreach ($products as $product) {
if ($cart_rule['obj']->gift_product == $product['id_product'] && $cart_rule['obj']->gift_product_attribute == $product['id_product_attribute']) {
$in_order = true;
}
}
}
if ($in_order) {
$order_total_discount += $cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_GIFT, $package, $use_cache);
}
}
if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0) {
$order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package, $use_cache), $compute_precision);
}
}
$order_total_discount = min(Tools::ps_round($order_total_discount, 2), (float) $order_total_products) + (float) $order_shipping_discount;
$order_total -= $order_total_discount;
}
if ($type == Cart::BOTH) {
$order_total += $shipping_fees + $wrapping_fees;
}
if ($order_total < 0 && $type != Cart::ONLY_DISCOUNTS) {
return 0;
}
if ($type == Cart::ONLY_DISCOUNTS) {
return $order_total_discount;
}
$page_name = Dispatcher::getInstance()->getController();
$pages_name = array();
$controllers = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
foreach ($controllers as $key => $value) {
if ($key != 'orderconfirmation' && $key != 'pagenotfound') {
$pages_name[] = $key;
}
}
$groups = Db::getInstance()->executeS('SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group WHERE id_customer = ' . (int) Context::getContext()->customer->id);
$groupIdsTakenFromDb = Configuration::get('ACOMPTE_GROUP');
$selectedgroups = @unserialize($groupIdsTakenFromDb);
if ($selectedgroups === false && $selectedgroups !== 'b:0;') {
$selectedgroups = array();
}
$group_accepted = false;
foreach ($groups as $group) {
if (in_array($group['id_group'], $selectedgroups)) {
$group_accepted = true;
break;
}
}
$categoryIdsTakenFromDb = Configuration::get('ACOMPTE_CATS');
$selectedcategories = @unserialize($categoryIdsTakenFromDb);
if ($selectedcategories === false && $selectedcategories !== 'b:0;') {
$selectedcategories = array();
}
if ($group_accepted && ($type == Cart::BOTH || ($virtual && $type == Cart::BOTH_WITHOUT_SHIPPING)) && ((float) Configuration::get('ACOMPTE_MIN_AMOUNT') == 0 || $order_total > (float) Configuration::get('ACOMPTE_MIN_AMOUNT')) && !empty($selectedcategories)) {
if (is_array($this->_products) && !empty($this->_products)) {
foreach ($this->_products as $product) {
if (in_array((int) $product['id_category_default'], $selectedcategories)) {
$pre_commande = true;
break;
} else {
/**/
$sql = 'SELECT id_product FROM `' . _DB_PREFIX_ . 'category_product` WHERE `id_product` = ' . (int) $product['id_product'] . ' AND `id_category` IN (';
foreach ($selectedcategories as $category) {
$sql .= (int) $category . ',';
}
$sql = rtrim($sql, ',') . ')';
/**/
if (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql)) {
$pre_commande = true;
break;
}
}
}
}
if ($pre_commande && ((isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0) || (int) Configuration::get('ACOMPTE_CHOICE') == 1 || $page_name == 'installmentpayment')) {
if (((!in_array($page_name, $pages_name) || (($page_name == 'order' && Tools::getValue('step') == 3) || $page_name == 'order-opc')) && !$gross) || $small) {
if ((int) Configuration::get('ACOMPTE_TOTALTYPE') != 0 || (int) Configuration::get('ACOMPTE_SHIPPING') != 0) {
$order_total = 0;
if ((int) Configuration::get('ACOMPTE_TOTALTYPE') == 0) {
foreach ($products_total as $key => $price) {
if (Configuration::get('PS_ROUND_TYPE') == Order::ROUND_TOTAL) {
$tmp = explode('_', $key);
$address = Address::initialize((int) $tmp[1], true);
$tax_calculator = TaxManagerFactory::getManager($address, $tmp[0])->getTaxCalculator();
$order_total += Tools::ps_round($price + $tax_calculator->getTaxesTotalAmount($price), _PS_PRICE_COMPUTE_PRECISION_);
} else {
$order_total += $price;
}
}
} else {
foreach ($products as $product) { // products refer to the cart details
if ($virtual_context->shop->id != $product['id_shop']) {
$virtual_context->shop = new Shop((int) $product['id_shop']);
}
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
$id_address = (int) $this->id_address_invoice;
} else {
$id_address = (int) $product['id_address_delivery']; // Get delivery address of the product from the cart
}
if (!Address::addressExists($id_address)) {
$id_address = null;
}
$price = Product::getPriceStatic(
(int) $product['id_product'],
false,
(int) $product['id_product_attribute'],
6,
null,
false,
true,
$product['cart_quantity'],
false,
(int) $this->id_customer ? (int) $this->id_customer : null,
(int) $this->id,
$id_address,
null,
false,
true,
$virtual_context
);
$order_total += $price * $product['cart_quantity'];
}
}
if ((int) Configuration::get('ACOMPTE_SHIPPING') == 0) {
$order_total += $shipping_fees + $wrapping_fees;
}
}//else
$id_defaultgroup = Db::getInstance()->executeS('SELECT id_default_group FROM ' . _DB_PREFIX_ . 'customer WHERE id_customer = ' . (int) Context::getContext()->customer->id);
if(is_array($id_defaultgroup))
{
$id_defaultgroup = $id_defaultgroup[0]['id_default_group'];
}
$sql = 'SELECT price FROM `' . _DB_PREFIX_ . 'installmentpayment_group` WHERE id_group=' . (int) $id_defaultgroup;
$data = Db::getInstance()->getRow($sql);
if(!empty($data)){
$order_total = $order_total - ($order_total * (100 - $data['price']) / 100);
}
else
{
if ((int) Configuration::get('ACOMPTE_TYPE') == 1) {
if ($order_total > (float) Configuration::get('ACOMPTE_PERCENTAGE')) {
$order_total = (float) Configuration::get('ACOMPTE_PERCENTAGE');
}
} else {
$order_total = $order_total - ($order_total * (100 - Configuration::get('ACOMPTE_PERCENTAGE')) / 100);
}
}
}
if ($page_name == 'installmentpayment' || (isset(Context::getContext()->cookie->installmentpayment_id_order) && !empty(Context::getContext()->cookie->installmentpayment_id_order))) {
if (Tools::getValue('select') != '') {
Context::getContext()->cookie->__set('installmentpayment_id_order', (int) Tools::getValue('select'));
}
$order = new Order((int) Context::getContext()->cookie->installmentpayment_id_order);
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$rest_paid = $installment['rest'];
$order_total = $rest_paid;
}
}
}
}
return Tools::ps_round((float) $order_total, _PS_PRICE_COMPUTE_PRECISION_);
}
public function getOrderTotalGross($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true, $small = false)
{
return $this->getOrderTotal($with_taxes, $type, $products, $id_carrier, $use_cache, true);
}
public function getOrderTotalSmall($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true, $small = true)
{
return $this->getOrderTotal($with_taxes, $type, $products, $id_carrier, $use_cache, true, true);
}
/**
* Return useful informations for cart
*
* @return array Cart details
*/
public function getSummaryDetailsInstallment($id_lang = null, $refresh = false)
{
$context = Context::getContext();
if (!$id_lang) {
$id_lang = $context->language->id;
}
$delivery = new Address((int) $this->id_address_delivery);
$invoice = new Address((int) $this->id_address_invoice);
$formatted_addresses = array(
'delivery' => AddressFormat::getFormattedLayoutData($delivery),
'invoice' => AddressFormat::getFormattedLayoutData($invoice)
);
$base_total_tax_inc = $this->getOrderTotalGross(true);
$base_total_tax_exc = $this->getOrderTotalGross(false);
$total_tax = $base_total_tax_inc - $base_total_tax_exc;
if ($total_tax < 0) {
$total_tax = 0;
}
$currency = new Currency($this->id_currency);
$products = $this->getProducts($refresh);
$gift_products = array();
$cart_rules = $this->getCartRules();
$total_shipping = $this->getTotalShippingCost();
$total_shipping_tax_exc = $this->getTotalShippingCost(null, false);
$total_products_wt = $this->getOrderTotalGross(true, Cart::ONLY_PRODUCTS);
$total_products = $this->getOrderTotalGross(false, Cart::ONLY_PRODUCTS);
$total_discounts = $this->getOrderTotalGross(true, Cart::ONLY_DISCOUNTS);
$total_discounts_tax_exc = $this->getOrderTotalGross(false, Cart::ONLY_DISCOUNTS);
foreach ($cart_rules as &$cart_rule) {
if ($cart_rule['free_shipping'] && (empty($cart_rule['code']) || preg_match('/^' . CartRule::BO_ORDER_CODE_PREFIX . '[0-9]+/', $cart_rule['code']))) {
$cart_rule['value_real'] -= $total_shipping;
$cart_rule['value_tax_exc'] -= $total_shipping_tax_exc;
$cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$cart_rule['value_tax_exc'] = Tools::ps_round($cart_rule['value_tax_exc'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
if ($total_discounts > $cart_rule['value_real']) {
$total_discounts -= $total_shipping;
}
if ($total_discounts_tax_exc > $cart_rule['value_tax_exc']) {
$total_discounts_tax_exc -= $total_shipping_tax_exc;
}
$total_shipping = 0;
$total_shipping_tax_exc = 0;
}
if ($cart_rule['gift_product']) {
foreach ($products as $key => &$product) {
if (empty($product['gift']) && $product['id_product'] == $cart_rule['gift_product'] && $product['id_product_attribute'] == $cart_rule['gift_product_attribute']) {
$total_products_wt = Tools::ps_round($total_products_wt - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$total_products = Tools::ps_round($total_products - $product['price'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$total_discounts = Tools::ps_round($total_discounts - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$total_discounts_tax_exc = Tools::ps_round($total_discounts_tax_exc - $product['price'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'] - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$cart_rule['value_tax_exc'] = Tools::ps_round($cart_rule['value_tax_exc'] - $product['price'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$product['total_wt'] = Tools::ps_round($product['total_wt'] - $product['price_wt'], (int) $currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$product['total'] = Tools::ps_round($product['total'] - $product['price'], (int) $currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$product['cart_quantity'] --;
if (!$product['cart_quantity']) {
unset($products[$key]);
}
$gift_product = $product;
$gift_product['cart_quantity'] = 1;
$gift_product['price'] = 0;
$gift_product['price_wt'] = 0;
$gift_product['total_wt'] = 0;
$gift_product['total'] = 0;
$gift_product['gift'] = true;
$gift_products[] = $gift_product;
break; // One gift product per cart rule
}
}
}
}
foreach ($cart_rules as $key => &$cart_rule) {
if ((float) $cart_rule['value_real'] == 0 && (int) $cart_rule['free_shipping'] == 0) {
unset($cart_rules[$key]);
}
}
return array(
'delivery' => $delivery,
'delivery_state' => State::getNameById($delivery->id_state),
'invoice' => $invoice,
'invoice_state' => State::getNameById($invoice->id_state),
'formattedAddresses' => $formatted_addresses,
'products' => array_values($products),
'gift_products' => $gift_products,
'discounts' => array_values($cart_rules),
'is_virtual_cart' => (int) $this->isVirtualCart(),
'total_discounts' => $total_discounts,
'total_discounts_tax_exc' => $total_discounts_tax_exc,
'total_wrapping' => $this->getOrderTotalGross(true, Cart::ONLY_WRAPPING),
'total_wrapping_tax_exc' => $this->getOrderTotalGross(false, Cart::ONLY_WRAPPING),
'total_shipping' => $total_shipping,
'total_shipping_tax_exc' => $total_shipping_tax_exc,
'total_products_wt' => $total_products_wt,
'total_products' => $total_products,
'total_price' => $base_total_tax_inc,
'total_tax' => $total_tax,
'total_price_without_tax' => $base_total_tax_exc,
'is_multi_address_delivery' => $this->isMultiAddressDelivery() || ((int) Tools::getValue('multi-shipping') == 1),
'free_ship' => $total_shipping ? 0 : 1,
'carrier' => new Carrier($this->id_carrier, $id_lang),
);
}
/**
* Return cart products
*
* @result array Products
*/
public function getProducts($refresh = false, $id_product = false, $id_country = null, $fullInfos = true)
{
if (Dispatcher::getInstance()->getController() != "pagenotfound" || strpos($_SERVER['REQUEST_URI'], '/modules/paypal') === false) {
return parent::getProducts();
}
if (!$this->id) {
return array();
}
if ($this->_products !== null && !$refresh) {
if (is_int($id_product)) {
foreach ($this->_products as $product) {
if ($product['id_product'] == $id_product) {
return array($product);
}
}
return array();
}
return $this->_products;
}
$sql = new DbQuery();
$sql->select('cp.`id_product_attribute`, cp.`id_product`, cp.`quantity` AS cart_quantity, cp.id_shop, pl.`name`, p.`is_virtual`,
pl.`description_short`, pl.`available_now`, pl.`available_later`, product_shop.`id_category_default`, p.`id_supplier`,
p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`,
product_shop.`available_for_order`, product_shop.`price`, product_shop.`active`, product_shop.`unity`, product_shop.`unit_price_ratio`,
stock.`quantity` AS quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, p.`weight`,
p.`date_add`, p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category,
CONCAT(LPAD(cp.`id_product`, 10, 0), LPAD(IFNULL(cp.`id_product_attribute`, 0), 10, 0), IFNULL(cp.`id_address_delivery`, 0)) AS unique_id, cp.id_address_delivery,
product_shop.advanced_stock_management, ps.product_supplier_reference supplier_reference, IFNULL(sp.`reduction_type`, 0) AS reduction_type');
$sql->from('cart_product', 'cp');
$sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');
$sql->innerJoin('product_shop', 'product_shop', '(product_shop.`id_shop` = cp.`id_shop` AND product_shop.`id_product` = p.`id_product`)');
$sql->leftJoin('product_lang', 'pl', '
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $this->id_lang . Shop::addSqlRestrictionOnLang('pl', 'cp.id_shop'));
$sql->leftJoin('category_lang', 'cl', '
product_shop.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = ' . (int) $this->id_lang . Shop::addSqlRestrictionOnLang('cl', 'cp.id_shop'));
$sql->leftJoin('product_supplier', 'ps', 'ps.`id_product` = cp.`id_product` AND ps.`id_product_attribute` = cp.`id_product_attribute` AND ps.`id_supplier` = p.`id_supplier`');
$sql->leftJoin('specific_price', 'sp', 'sp.`id_product` = cp.`id_product`'); // AND 'sp.`id_shop` = cp.`id_shop`
$sql->join(Product::sqlStock('cp', 'cp'));
$sql->where('cp.`id_cart` = ' . (int) $this->id);
if ($id_product) {
$sql->where('cp.`id_product` = ' . (int) $id_product);
}
$sql->where('p.`id_product` IS NOT NULL');
$sql->groupBy('unique_id');
$sql->orderBy('cp.`date_add`, p.`id_product`, cp.`id_product_attribute` ASC');
if (Customization::isFeatureActive()) {
$sql->select('cu.`id_customization`, cu.`quantity` AS customization_quantity');
$sql->leftJoin('customization', 'cu', 'p.`id_product` = cu.`id_product` AND cp.`id_product_attribute` = cu.`id_product_attribute` AND cu.`id_cart` = ' . (int) $this->id);
} else {
$sql->select('NULL AS customization_quantity, NULL AS id_customization');
}
if (Combination::isFeatureActive()) {
$sql->select('
product_attribute_shop.`price` AS price_attribute, product_attribute_shop.`ecotax` AS ecotax_attr,
IF (IFNULL(pa.`reference`, \'\') = \'\', p.`reference`, pa.`reference`) AS reference,
(p.`weight`+ pa.`weight`) weight_attribute,
IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13,
IF (IFNULL(pa.`upc`, \'\') = \'\', p.`upc`, pa.`upc`) AS upc,
pai.`id_image` as pai_id_image, il.`legend` as pai_legend,
IFNULL(product_attribute_shop.`minimal_quantity`, product_shop.`minimal_quantity`) as minimal_quantity,
IF(product_attribute_shop.wholesale_price > 0, product_attribute_shop.wholesale_price, product_shop.`wholesale_price`) wholesale_price
');
$sql->leftJoin('product_attribute', 'pa', 'pa.`id_product_attribute` = cp.`id_product_attribute`');
$sql->leftJoin('product_attribute_shop', 'product_attribute_shop', '(product_attribute_shop.`id_shop` = cp.`id_shop` AND product_attribute_shop.`id_product_attribute` = pa.`id_product_attribute`)');
$sql->leftJoin('product_attribute_image', 'pai', 'pai.`id_product_attribute` = pa.`id_product_attribute`');
$sql->leftJoin('image_lang', 'il', 'il.`id_image` = pai.`id_image` AND il.`id_lang` = ' . (int) $this->id_lang);
} else {
$sql->select(
'p.`reference` AS reference, p.`ean13`,
p.`upc` AS upc, product_shop.`minimal_quantity` AS minimal_quantity, product_shop.`wholesale_price` wholesale_price'
);
}
$result = Db::getInstance()->executeS($sql);
$products_ids = array();
$pa_ids = array();
if ($result) {
foreach ($result as $row) {
$products_ids[] = $row['id_product'];
$pa_ids[] = $row['id_product_attribute'];
}
}
Product::cacheProductsFeatures($products_ids);
Cart::cacheSomeAttributesLists($pa_ids, $this->id_lang);
$this->_products = array();
if (empty($result)) {
return array();
}
$cart_shop_context = Context::getContext()->cloneContext();
foreach ($result as &$row) {
if (isset($row['ecotax_attr']) && $row['ecotax_attr'] > 0) {
$row['ecotax'] = (float) $row['ecotax_attr'];
}
$row['stock_quantity'] = (int) $row['quantity'];
$row['quantity'] = (int) $row['cart_quantity'];
if (isset($row['id_product_attribute']) && (int) $row['id_product_attribute'] && isset($row['weight_attribute'])) {
$row['weight'] = (float) $row['weight_attribute'];
}
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
$address_id = (int) $this->id_address_invoice;
} else {
$address_id = (int) $row['id_address_delivery'];
}
if (!Address::addressExists($address_id)) {
$address_id = null;
}
if ($cart_shop_context->shop->id != $row['id_shop']) {
$cart_shop_context->shop = new Shop((int) $row['id_shop']);
}
$address = Address::initialize($address_id, true);
$id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $row['id_product'], $cart_shop_context);
$tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
if (!Tools::getIsset('specific_price_output')) {
$specific_price_output = array();
}
$row['price'] = Product::getPriceStatic(
(int) $row['id_product'],
false,
isset($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null,
6,
null,
false,
true,
$row['cart_quantity'],
false,
(int) $this->id_customer ? (int) $this->id_customer : null,
(int) $this->id,
$address_id,
$specific_price_output,
false,
true,
$cart_shop_context
);
switch (Configuration::get('PS_ROUND_TYPE')) {
case Order::ROUND_TOTAL:
$row['total'] = $row['price'] * (int) $row['cart_quantity'];
$row['total_wt'] = $tax_calculator->addTaxes($row['price']) * (int) $row['cart_quantity'];
break;
case Order::ROUND_LINE:
$row['total'] = Tools::ps_round($row['price'] * (int) $row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
$row['total_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['price']) * (int) $row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
break;
case Order::ROUND_ITEM:
default:
$row['total'] = Tools::ps_round($row['price'], _PS_PRICE_COMPUTE_PRECISION_) * (int) $row['cart_quantity'];
$row['total_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['price']), _PS_PRICE_COMPUTE_PRECISION_) * (int) $row['cart_quantity'];
break;
}
$row['price_wt'] = $tax_calculator->addTaxes($row['price']);
$row['description_short'] = Tools::nl2br($row['description_short']);
if (!isset($row['pai_id_image']) || $row['pai_id_image'] == 0) {
$cache_id = 'Cart::getProducts_' . '-pai_id_image-' . (int) $row['id_product'] . '-' . (int) $this->id_lang . '-' . (int) $row['id_shop'];
if (!Cache::isStored($cache_id)) {
$row2 = Db::getInstance()->getRow('
SELECT image_shop.`id_image` id_image, il.`legend`
FROM `' . _DB_PREFIX_ . 'image` i
JOIN `' . _DB_PREFIX_ . 'image_shop` image_shop ON (i.id_image = image_shop.id_image AND image_shop.cover=1 AND image_shop.id_shop=' . (int) $row['id_shop'] . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $this->id_lang . ')
WHERE i.`id_product` = ' . (int) $row['id_product'] . ' AND image_shop.`cover` = 1');
Cache::store($cache_id, $row2);
}
$row2 = Cache::retrieve($cache_id);
if (!$row2) {
$row2 = array('id_image' => false, 'legend' => false);
} else {
$row = array_merge($row, $row2);
}
} else {
$row['id_image'] = $row['pai_id_image'];
$row['legend'] = $row['pai_legend'];
}
$row['reduction_applies'] = ($specific_price_output && (float) $specific_price_output['reduction']);
$row['quantity_discount_applies'] = ($specific_price_output && $row['cart_quantity'] >= (int) $specific_price_output['from_quantity']);
$row['id_image'] = Product::defineProductImage($row, $this->id_lang);
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
$row['features'] = Product::getFeaturesStatic((int) $row['id_product']);
if (array_key_exists($row['id_product_attribute'] . '-' . $this->id_lang, self::$_attributesLists)) {
$row = array_merge($row, self::$_attributesLists[$row['id_product_attribute'] . '-' . $this->id_lang]);
}
$row = Product::getTaxesInformations($row, $cart_shop_context);
$this->_products[] = $row;
}
$categoryIdsTakenFromDb = Configuration::get('ACOMPTE_CATS');
$selectedcategories = @unserialize($categoryIdsTakenFromDb);
if ($selectedcategories === false && $selectedcategories !== 'b:0;') {
$selectedcategories = array();
}
$pre_commande = false;
if (is_array($this->_products) && !empty($this->_products)) { //&& count($this->_products)>0
foreach ($this->_products as $product) {
if (in_array((int) $product['id_category_default'], $selectedcategories)) {
$pre_commande = true;
break;
} else {
/**/
$sql = 'SELECT id_product FROM `' . _DB_PREFIX_ . 'category_product` WHERE `id_product` = ' . (int) $product['id_product'] . ' AND `id_category` IN (';
foreach ($selectedcategories as $category) {
$sql .= (int) $category . ',';
}
$sql = rtrim($sql, ',') . ')';
/**/
if (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql)) {
$pre_commande = true;
break;
}
}
}
}
if (!$pre_commande) {
return parent::getProducts();
}
$order_total = $this->getOrderTotal(true);
$price_wt = $this->getOrderTotal(true);
$this->_products = array();
$row['cart_quantity'] = 1;
$row['price_wt'] = $price_wt;
$row['name'] = 'Acompte';
$row['attributes'] = '';
$row['id_product1'] = '';
$id_defaultgroup = Db::getInstance()->executeS('SELECT id_default_group FROM ' . _DB_PREFIX_ . 'customer WHERE id_customer = ' . (int) Context::getContext()->customer->id);
if(is_array($id_defaultgroup))
{
$id_defaultgroup = $id_defaultgroup[0]['id_default_group'];
}
$sql = 'SELECT price FROM `' . _DB_PREFIX_ . 'installmentpayment_group` WHERE id_group=' . (int) $id_defaultgroup;
$data = Db::getInstance()->getRow($sql);
if(!empty($data)){
$row['description_short'] = "Pourcentage " . $data['price'] . '%';
}
else
{
if ((int) Configuration::get('ACOMPTE_TYPE') == 1) {
if ($order_total > (float) Configuration::get('ACOMPTE_PERCENTAGE')) {
$row['description_short'] = "Acompte " . Configuration::get('ACOMPTE_PERCENTAGE');
}
} else {
$row['description_short'] = "Pourcentage " . Configuration::get('ACOMPTE_PERCENTAGE') . '%';
}
}
$this->_products[] = $row;
return $this->_products;
}
/**
* Return shipping total for the cart
*
* @param array $delivery_option Array of the delivery option for each address
* @param booleal $use_tax
* @param Country $default_country
* @return float Shipping total
*/
public function getTotalShippingCost($delivery_option = null, $use_tax = true, Country $default_country = null)
{
if (Dispatcher::getInstance()->getController() != "pagenotfound") {
return parent::getTotalShippingCost($delivery_option, $use_tax, $default_country);
}
return 0;
}
}

View File

@@ -0,0 +1,131 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class Hook extends HookCore
{
public static function getHookModuleExecList($hook_name = null)
{
$context = Context::getContext();
$cache_id = 'hook_module_exec_list_' . (isset($context->shop->id) ? '_' . $context->shop->id : '') . ((isset($context->customer)) ? '_' . $context->customer->id : '');
if (!Cache::isStored($cache_id) || $hook_name == 'displayPayment' || $hook_name == 'displayBackOfficeHeader') {
$frontend = true;
$groups = array();
$use_groups = Group::isFeatureActive();
if (isset($context->employee)) {
$frontend = false;
} else {
if ($use_groups) {
if (isset($context->customer) && $context->customer->isLogged()) {
$groups = $context->customer->getGroups();
} elseif (isset($context->customer) && $context->customer->isLogged(true)) {
$groups = array((int) Configuration::get('PS_GUEST_GROUP'));
} else {
$groups = array((int) Configuration::get('PS_UNIDENTIFIED_GROUP'));
}
}
}
$sql = new DbQuery();
$sql->select('h.`name` as hook, m.`id_module`, h.`id_hook`, m.`name` as module');
$sql->from('module', 'm');
if ($hook_name != 'displayBackOfficeHeader') {
$sql->join(Shop::addSqlAssociation('module', 'm', true, 'module_shop.enable_device & ' . (int) Context::getContext()->getDevice()));
$sql->innerJoin('module_shop', 'ms', 'ms.`id_module` = m.`id_module`');
}
$sql->innerJoin('hook_module', 'hm', 'hm.`id_module` = m.`id_module`');
$sql->innerJoin('hook', 'h', 'hm.`id_hook` = h.`id_hook`');
if ($hook_name != 'displayPayment') {
$sql->where('h.name != "displayPayment"');
} elseif ($frontend) {
if (Validate::isLoadedObject($context->country)) {
$sql->where('(h.name = "displayPayment" AND (SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country mc WHERE mc.id_module = m.id_module AND id_country = ' . (int) $context->country->id . ' AND id_shop = ' . (int) $context->shop->id . ' LIMIT 1) = ' . (int) $context->country->id . ')');
}
if (Validate::isLoadedObject($context->currency)) {
$sql->where('(h.name = "displayPayment" AND (SELECT id_currency FROM ' . _DB_PREFIX_ . 'module_currency mcr WHERE mcr.id_module = m.id_module AND id_currency IN (' . (int) $context->currency->id . ', -1, -2) LIMIT 1) IN (' . (int) $context->currency->id . ', -1, -2))');
}
}
if (Validate::isLoadedObject($context->shop)) {
$sql->where('hm.id_shop = ' . (int) $context->shop->id);
}
if ($frontend) {
if ($use_groups) {
$sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`');
if (Validate::isLoadedObject($context->shop)) {
$sql->where('mg.id_shop = ' . ((int) $context->shop->id) . (count($groups) ? ' AND mg.`id_group` IN (' . implode(', ', $groups) . ')' : ''));
} elseif (count($groups)) {
$sql->where('mg.`id_group` IN (' . implode(', ', $groups) . ')');
}
}
}
$sql->groupBy('hm.id_hook, hm.id_module');
$sql->orderBy('hm.`position`');
$list = array();
if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql)) {
foreach ($result as $row) {
$enable = true;
if (Db::getInstance()->getValue('SELECT `id_hook` FROM `' . _DB_PREFIX_ . 'hook` WHERE `id_hook` = ' . (int) $row['id_hook'] . ' AND `name` = \'displayPayment\'')) {
if (isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0) {
$paymentIdsTakenFromDb = Configuration::get('ACOMPTE_PAYMENT');
$selectedpayments = @unserialize($paymentIdsTakenFromDb);
if ($selectedpayments === false && $selectedpayments !== 'b:0;') {
$selectedpayments = array();
}
if (!empty($selectedpayments)) {
if (!in_array($row['id_module'], $selectedpayments)) {
$enable = false;
}
}
}
}
if ($enable) {
$row['hook'] = Tools::strtolower($row['hook']);
if (!isset($list[$row['hook']])) {
$list[$row['hook']] = array();
}
$list[$row['hook']][] = array(
'id_hook' => $row['id_hook'],
'module' => $row['module'],
'id_module' => $row['id_module'],
);
}
}
}
if ($hook_name != 'displayPayment' && $hook_name != 'displayBackOfficeHeader') {
Cache::store($cache_id, $list);
self::$_hook_modules_cache_exec = $list;
}
} else {
$list = Cache::retrieve($cache_id);
}
if ($hook_name) {
$retro_hook_name = Tools::strtolower(Hook::getRetroHookName($hook_name));
$hook_name = Tools::strtolower($hook_name);
$return = array();
$inserted_modules = array();
if (isset($list[$hook_name])) {
$return = $list[$hook_name];
}
foreach ($return as $module) {
$inserted_modules[] = $module['id_module'];
}
if (isset($list[$retro_hook_name])) {
foreach ($list[$retro_hook_name] as $retro_module_call) {
if (!in_array($retro_module_call['id_module'], $inserted_modules)) {
$return[] = $retro_module_call;
}
}
}
return (count($return) > 0 ? $return : false);
} else {
return $list;
}
}
}

View File

@@ -0,0 +1,665 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
abstract class PaymentModule extends PaymentModuleCore
{
/**
* Validate an order in database
* Function called from a payment module
*
* @param int $id_cart
* @param int $id_order_state
* @param float $amount_paid Amount really paid by customer (in the default currency)
* @param string $payment_method Payment method (eg. 'Credit card')
* @param null $message Message to attach to order
* @param array $extra_vars
* @param null $currency_special
* @param bool $dont_touch_amount
* @param bool $secure_key
* @param Shop $shop
*
* @return bool
* @throws PrestaShopException
*/
/*
* module: installmentpayment
* date: 2019-07-11 18:27:47
* version: 1.0.24
*/
public function validateOrder(
$id_cart,
$id_order_state,
$amount_paid,
$payment_method = 'Unknown',
$message = null,
$extra_vars = array(),
$currency_special = null,
$dont_touch_amount = false,
$secure_key = false,
Shop $shop = null
) {
if (isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0 && (int) Configuration::get('ACOMPTE_STATUSES') > 0) {
$id_order_state = (int) Configuration::get('ACOMPTE_STATUSES');
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
}
if (!isset($this->context)) {
$this->context = Context::getContext();
}
$this->context->cart = new Cart($id_cart);
$this->context->customer = new Customer($this->context->cart->id_customer);
$this->context->cart->setTaxCalculationMethod();
$this->context->language = new Language($this->context->cart->id_lang);
$this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop));
ShopUrl::resetMainDomainCache();
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$context_country = $this->context->country;
}
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
if (!Validate::isLoadedObject($order_status)) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t load Order status');
}
if (!$this->active) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
die(Tools::displayError());
}
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
die(Tools::displayError());
}
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
$package_list = $this->context->cart->getPackageList();
$cart_delivery_option = $this->context->cart->getDeliveryOption();
foreach ($delivery_option_list as $id_address => $package) {
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
foreach ($package as $key => $val) {
$cart_delivery_option[$id_address] = $key;
break;
}
}
}
$order_list = array();
$order_detail_list = array();
do {
$reference = Order::generateReference();
} while (Order::getByReference($reference)->count());
$this->currentOrderReference = $reference;
$order_creation_failed = false;
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
foreach ($cart_delivery_option as $id_address => $key_carriers) {
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
foreach ($data['package_list'] as $id_package) {
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
}
}
}
CartRule::cleanCache();
$cart_rules = $this->context->cart->getCartRules();
foreach ($cart_rules as $cart_rule) {
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
if ($error = $rule->checkValidity($this->context, true, true)) {
$this->context->cart->removeCartRule((int) $rule->id);
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
}
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
} else {
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
$error = Tools::displayError(sprintf('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart', (int) $rule->id, $rule_name));
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
}
}
}
}
foreach ($package_list as $id_address => $packageByAddress) {
foreach ($packageByAddress as $id_package => $package) {
if (isset(Context::getContext()->cookie->installmentpayment_id_order) && !empty(Context::getContext()->cookie->installmentpayment_id_order)) {
$installmentpayment_id_order = Context::getContext()->cookie->installmentpayment_id_order;
$order = new Order($installmentpayment_id_order);
$payment_method = Module::getInstanceByName($this->name);
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$rest_paid = $installment['rest'];
$this->currentOrder = (int) $installmentpayment_id_order;
}
$payment = new OrderPayment();
$payment->order_reference = Tools::substr($order->reference, 0, 9);
$payment->id_currency = $order->id_currency;
$payment->amount = $rest_paid;
if ($order->total_paid != 0) {
$payment->payment_method = $payment_method->displayName;
} else {
$payment->payment_method = null;
}
$payment->conversion_rate = 1;
if (isset($extra_vars['transaction_id'])) {
$transaction_id = $extra_vars['transaction_id'];
} else {
$transaction_id = null;
}
$payment->transaction_id = $transaction_id;
$payment->save();
$id_order_invoice = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_order_invoice`
FROM `' . _DB_PREFIX_ . 'order_invoice`
WHERE number = ' . (int) $order->invoice_number);
PrestaShopLogger::addLog('PaymentModule::validateOrder - LOG DEV4 ligne 158 _' . $payment->amount . '_' . $transaction_id . '_' . $id_order_invoice, 3, null, 'Cart', (int) $order->id, true);
$res = Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order`)
VALUES(' . (int) $id_order_invoice . ', ' . (int) $payment->id . ', ' . (int) $installmentpayment_id_order . ')');
$total = $order->total_paid;
$acompte = $total;
$id_cart = $order->id_cart;
$rest = 0;
$data_insert = array(
'id_cart' => (int) $id_cart,
'total' => $total,
'payer' => $acompte,
'rest' => $rest,
'state' => 0,
);
Db::getInstance()->update('installmentpayment', $data_insert, 'id_cart=' . (int) $id_cart);
return true;
} else {
$order = new Order();
}
$order->product_list = $package['product_list'];
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$address = new Address($id_address);
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
if (!$this->context->country->active) {
throw new PrestaShopException('The delivery address country is not active.');
}
}
$carrier = null;
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
$order->id_carrier = (int) $carrier->id;
$id_carrier = (int) $carrier->id;
} else {
$order->id_carrier = 0;
$id_carrier = 0;
}
$order->id_customer = (int) $this->context->cart->id_customer;
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
$order->id_address_delivery = (int) $id_address;
$order->id_currency = $this->context->currency->id;
$order->id_lang = (int) $this->context->cart->id_lang;
$order->id_cart = (int) $this->context->cart->id;
$order->reference = $reference;
$order->id_shop = (int) $this->context->shop->id;
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
$order->payment = $payment_method;
if (isset($this->name)) {
$order->module = $this->name;
}
$order->recyclable = $this->context->cart->recyclable;
$order->gift = (int) $this->context->cart->gift;
$order->gift_message = $this->context->cart->gift_message;
$order->mobile_theme = $this->context->cart->mobile_theme;
$order->conversion_rate = $this->context->currency->conversion_rate;
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
$order->total_paid_real = 0;
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
$order->total_discounts = $order->total_discounts_tax_incl;
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list);
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list);
$order->total_shipping = $order->total_shipping_tax_incl;
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
}
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
$order->total_wrapping = $order->total_wrapping_tax_incl;
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
$total_in_order = $order->total_paid_tax_incl;
$order->total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotalGross(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); //$order->total_paid_tax_incl;
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
$order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00';
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$result = $order->add();
if (!$result) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t save Order');
}
if ($order_status->logable && (number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_))) {
PrestaShopLogger::addLog('lg 235 id_order:' . (int) $order->id . ' M=' . $cart_total_paid . ' H=' . $amount_paid . 'G=' . $total_in_order, 1, null, 'OKKKKKK', (int) $id_cart, true);
}
$order_list[] = $order;
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$order_detail = new OrderDetail(null, null, $this->context);
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
$order_detail_list[] = $order_detail;
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
if (!is_null($carrier)) {
$order_carrier = new OrderCarrier();
$order_carrier->id_order = (int) $order->id;
$order_carrier->id_carrier = (int) $id_carrier;
$order_carrier->weight = (float) $order->getTotalWeight();
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
$order_carrier->add();
}
}
}
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$this->context->country = $context_country;
}
if (!$this->context->country->active) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('The order address country is not active.');
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
if ($order_status->logable) {
if (isset($extra_vars['transaction_id'])) {
$transaction_id = $extra_vars['transaction_id'];
} else {
$transaction_id = null;
}
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t save Order Payment');
} else {
PrestaShopLogger::addLog('PaymentModule::validateOrder - LOG DEV4 ligne 293_' . $amount_paid . '_' . $transaction_id, 3, null, 'Cart', (int) $order->id, true);
}
}
$cart_rule_used = array();
CartRule::cleanCache();
foreach ($order_detail_list as $key => $order_detail) {
$order = $order_list[$key];
if (!$order_creation_failed && isset($order->id)) {
if (!$secure_key) {
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
}
if (isset($message) & !empty($message)) {
$msg = new Message();
$message = strip_tags($message, '<br>');
if (Validate::isCleanHtml($message)) {
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$msg->message = $message;
$msg->id_order = (int) $order->id;
$msg->private = 1;
$msg->add();
}
}
$virtual_product = true;
$product_var_tpl_list = array();
foreach ($order->product_list as $product) {
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
$product_var_tpl = array(
'reference' => $product['reference'],
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
'quantity' => $product['quantity'],
'customization' => array()
);
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart);
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
$product_var_tpl['customization'] = array();
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
$customization_text = '';
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
$customization_text .= $text['name'] . ': ' . $text['value'] . '<br />';
}
}
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
}
$customization_quantity = (int) $product['customization_quantity'];
$product_var_tpl['customization'][] = array(
'customization_text' => $customization_text,
'customization_quantity' => $customization_quantity,
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
);
}
}
$product_var_tpl_list[] = $product_var_tpl;
if (!$product['is_virtual']) {
$virtual_product &= false;
}
} // end foreach ($product)
$product_list_txt = '';
$product_list_html = '';
if (count($product_var_tpl_list) > 0) {
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
}
$cart_rules_list = array();
$total_reduction_value_ti = 0;
$total_reduction_value_tex = 0;
foreach ($cart_rules as $cart_rule) {
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
$values = array(
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
);
if (!$values['tax_excl']) {
continue;
}
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
$voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
unset($voucher->id);
$voucher->code = empty($voucher->code) ? Tools::substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . ((int) $matches[1] + 1), $voucher->code);
}
if ($voucher->reduction_tax) {
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
}
} else {
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
}
}
if ($voucher->reduction_amount <= 0) {
continue;
}
$voucher->id_customer = $order->id_customer;
$voucher->quantity = 1;
$voucher->quantity_per_user = 1;
$voucher->free_shipping = 0;
if ($voucher->add()) {
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
$params = array(
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
'{voucher_num}' => $voucher->code,
'{firstname}' => $this->context->customer->firstname,
'{lastname}' => $this->context->customer->lastname,
'{id_order}' => $order->reference,
'{order_name}' => $order->getUniqReference()
);
Mail::Send(
(int) $order->id_lang,
'voucher',
sprintf(Mail::l('New voucher for your order %s', (int) $order->id_lang), $order->reference),
$params,
$this->context->customer->email,
$this->context->customer->firstname . ' ' . $this->context->customer->lastname,
null,
null,
null,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
}
$total_reduction_value_ti += $values['tax_incl'];
$total_reduction_value_tex += $values['tax_excl'];
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
$cart_rule_used[] = $cart_rule['obj']->id;
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
$cart_rule_to_update->update();
}
$cart_rules_list[] = array(
'voucher_name' => $cart_rule['obj']->name,
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
);
}
$cart_rules_list_txt = '';
$cart_rules_list_html = '';
if (count($cart_rules_list) > 0) {
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
}
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
if ($old_message) {
$update_message = new Message((int) $old_message['id_message']);
$update_message->id_order = (int) $order->id;
$update_message->update();
$customer_thread = new CustomerThread();
$customer_thread->id_contact = 0;
$customer_thread->id_customer = (int) $order->id_customer;
$customer_thread->id_shop = (int) $this->context->shop->id;
$customer_thread->id_order = (int) $order->id;
$customer_thread->id_lang = (int) $this->context->language->id;
$customer_thread->email = $this->context->customer->email;
$customer_thread->status = 'open';
$customer_thread->token = Tools::passwdGen(12);
$customer_thread->add();
$customer_message = new CustomerMessage();
$customer_message->id_customer_thread = $customer_thread->id;
$customer_message->id_employee = 0;
$customer_message->message = $update_message->message;
$customer_message->private = 0;
if (!$customer_message->add()) {
$this->errors[] = Tools::displayError('An error occurred while saving message');
}
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
}
Hook::exec('actionValidateOrder', array(
'cart' => $this->context->cart,
'order' => $order,
'customer' => $this->context->customer,
'currency' => $this->context->currency,
'orderStatus' => $order_status
));
foreach ($this->context->cart->getProducts() as $product) {
if ($order_status->logable) {
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
}
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$new_history = new OrderHistory();
$new_history->id_order = (int) $order->id;
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
$new_history->addWithemail(true, $extra_vars);
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) {
$history = new OrderHistory();
$history->id_order = (int) $order->id;
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
$history->addWithemail();
}
unset($order_detail);
$order = new Order($order->id);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
$invoice = new Address($order->id_address_invoice);
$delivery = new Address($order->id_address_delivery);
$delivery_state = $delivery->id_state ? new State($delivery->id_state) : false;
$invoice_state = $invoice->id_state ? new State($invoice->id_state) : false;
$data = array(
'{firstname}' => $this->context->customer->firstname,
'{lastname}' => $this->context->customer->lastname,
'{email}' => $this->context->customer->email,
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
'firstname' => '<span style="font-weight:bold;">%s</span>',
'lastname' => '<span style="font-weight:bold;">%s</span>'
)),
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
'firstname' => '<span style="font-weight:bold;">%s</span>',
'lastname' => '<span style="font-weight:bold;">%s</span>'
)),
'{delivery_company}' => $delivery->company,
'{delivery_firstname}' => $delivery->firstname,
'{delivery_lastname}' => $delivery->lastname,
'{delivery_address1}' => $delivery->address1,
'{delivery_address2}' => $delivery->address2,
'{delivery_city}' => $delivery->city,
'{delivery_postal_code}' => $delivery->postcode,
'{delivery_country}' => $delivery->country,
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
'{delivery_other}' => $delivery->other,
'{invoice_company}' => $invoice->company,
'{invoice_vat_number}' => $invoice->vat_number,
'{invoice_firstname}' => $invoice->firstname,
'{invoice_lastname}' => $invoice->lastname,
'{invoice_address2}' => $invoice->address2,
'{invoice_address1}' => $invoice->address1,
'{invoice_city}' => $invoice->city,
'{invoice_postal_code}' => $invoice->postcode,
'{invoice_country}' => $invoice->country,
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
'{invoice_other}' => $invoice->other,
'{order_name}' => $order->getUniqReference(),
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
'{payment}' => Tools::substr($order->payment, 0, 32),
'{products}' => $product_list_html,
'{products_txt}' => $product_list_txt,
'{discounts}' => $cart_rules_list_html,
'{discounts_txt}' => $cart_rules_list_txt,
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
'{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false),
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
'{days}' => Configuration::get('ACOMPTE_DAYS'),
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false)
);
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$smartynew = new Smarty;
$smartynew->assign('totalpay', Tools::displayPrice($order->total_paid_tax_incl, $this->context->currency, false));
$smartynew->assign('title', $this->l('Acompte'));
$contentExtra = $smartynew->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/invoice.extra.tpl');
$data['{total_paid}'] = Tools::displayPrice($order->total_paid, $this->context->currency, false) . $contentExtra ;
}
if (is_array($extra_vars)) {
$data = array_merge($data, $extra_vars);
}
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty);
$file_attachement = array();
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['mime'] = 'application/pdf';
} else {
$file_attachement = null;
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
}
if (file_exists(_PS_MODULE_DIR_ . 'installmentpayment/mails/' . Language::getIsoById((int) $this->context->language->id) . '/order_conf.txt') and file_exists(_PS_MODULE_DIR_ .'installmentpayment/mails/' . Language::getIsoById((int) $this->context->language->id) . '/order_conf.html')) {
if (Validate::isEmail($this->context->customer->email)) {
Mail::Send(
(int) $order->id_lang,
'order_conf',
Mail::l('Order confirmation', (int) $order->id_lang),
$data,
$this->context->customer->email,
$this->context->customer->firstname . ' ' . $this->context->customer->lastname,
null,
null,
$file_attachement,
null,
_PS_MODULE_DIR_ . 'installmentpayment/mails/' . Language::getIsoById((int) $this->context->language->id) . '/order_conf.html',
false,
(int) $order->id_shop
);
}
}
else
{
if (Validate::isEmail($this->context->customer->email)) {
Mail::Send(
(int) $order->id_lang,
'order_conf',
Mail::l('Order confirmation', (int) $order->id_lang),
$data,
$this->context->customer->email,
$this->context->customer->firstname . ' ' . $this->context->customer->lastname,
null,
null,
$file_attachement,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
}
}
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$product_list = $order->getProducts();
foreach ($product_list as $product) {
if (StockAvailable::dependsOnStock($product['product_id'])) {
StockAvailable::synchronize($product['product_id'], $order->id_shop);
}
}
}
} else {
$error = Tools::displayError('Order creation failed');
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', (int) $order->id_cart);
die($error);
}
} // End foreach $order_detail_list
foreach ($order->getOrderDetailList() as $detail) {
$order_detail = new OrderDetail($detail['id_order_detail']);
$order_detail->updateTaxAmount($order);
}
if (isset($order) && $order->id) {
$this->currentOrder = (int) $order->id;
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
}
return true;
} else {
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', (int) $this->context->cart->id);
die($error);
}
if ((int) $this->context->cookie->id_cart) {
$this->context->cookie->__unset('id_cart');
}
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,424 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class OrderHistory extends OrderHistoryCore
{
public function addWithemail($autodate = true, $template_vars = false, Context $context = null)
{
$order = new Order($this->id_order);
if (!$this->add($autodate)) {
return false;
}
if (!$this->sendEmail($order, $template_vars)) {
return false;
}
return true;
}
public function sendEmail($order, $template_vars = false)
{
$file_attachement = array();
$context = Context::getContext();
$order = new Order($this->id_order);
$new_order_state = new OrderState($this->id_order_state, Configuration::get('PS_LANG_DEFAULT'));
$result = Db::getInstance()->getRow(
'SELECT osl.`template`, c.`lastname`,c.`id_customer`, c.`firstname`, osl.`name` AS osname,
c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`
FROM `' . _DB_PREFIX_ . 'order_history` oh
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state`
AND osl.`id_lang` = o.`id_lang`)
WHERE oh.`id_order_history` = ' . (int) $this->id . ' AND os.`send_email` = 1'
);
if (isset($result['template']) && Validate::isEmail($result['email'])) {
$topic = $result['osname'];
$data = array(
'{lastname}' => $result['lastname'],
'{firstname}' => $result['firstname'],
'{id_order}' => (int) $this->id_order,
'{order_name}' => $order->getUniqReference()
);
if ($template_vars) {
$data = array_merge($data, $template_vars);
}
if ($result['module_name']) {
$module = Module::getInstanceByName($result['module_name']);
if (Validate::isLoadedObject($module) &&
isset($module->extra_mail_vars) &&
is_array($module->extra_mail_vars)) {
$data = array_merge($data, $module->extra_mail_vars);
}
}
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$data['{total_paid}'] = Tools::displayPrice((float) $order->total_paid_tax_incl, new Currency((int) $order->id_currency), false);
} else {
$data['{total_paid}'] = Tools::displayPrice((float) $order->total_paid, new Currency((int) $order->id_currency), false);
}
$data['{order_name}'] = $order->getUniqReference();
$virtual_products = $order->getVirtualProducts();
if ($virtual_products && $new_order_state && $new_order_state->logable) {
$assign = array();
foreach ($virtual_products as $key => $virtual_product) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtual_product['product_id']);
$product_download = new ProductDownload($id_product_download);
if ($product_download->display_filename != '') {
$assign[$key]['name'] = $product_download->display_filename;
$dl_link = $product_download->getTextLink(false, $virtual_product['download_hash'])
. '&id_order=' . $order->id
. '&secure_key=' . $order->secure_key;
$assign[$key]['link'] = $dl_link;
if ($virtual_product['download_deadline'] != '0000-00-00 00:00:00') {
$assign[$key]['deadline'] = Tools::displayDate($virtual_product['download_deadline'], $order->id_lang);
}
if ($product_download->nb_downloadable != 0) {
$assign[$key]['downloadable'] = $product_download->nb_downloadable;
}
}
}
$context->smarty->assign('virtualProducts', $assign);
$context->smarty->assign('id_order', $order->id);
$iso = Language::getIsoById((int) ($order->id_lang));
$links = $context->smarty->fetch(_PS_MAIL_DIR_ . $iso . '/download-product.tpl');
$tmp_array = array('{nbProducts}' => count($virtual_products), '{virtualProducts}' => $links);
$data = array_merge($data, $tmp_array);
if (!empty($assign)) {
Mail::Send(
(int) $order->id_lang,
'download_product',
Mail::l(
'Virtual product to download',
$order->id_lang
),
$data,
$result['email'],
$result['firstname'] . ' ' . $result['lastname'],
null,
null,
null,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
}
if (Validate::isLoadedObject($order)) {
if ((int) $result['id_order_state'] === 2 &&
(int) Configuration::get('PS_INVOICE') &&
$order->invoice_number) {
$context = Context::getContext();
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get(
'PS_INVOICE_PREFIX',
(int) $order->id_lang,
null,
$order->id_shop
)
. sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['mime'] = 'application/pdf';
} else {
$file_attachement = null;
}
$result['email'] = $result['email'];
Mail::Send(
(int) $order->id_lang,
$result['template'],
$topic,
$data,
$result['email'],
$result['firstname'] . ' ' . $result['lastname'],
null,
null,
$file_attachement,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
if (Validate::isLoadedObject($order) && !Tools::getIsset('sendStateEmail')) {
$customerGroupe = Customer::getGroupsStatic($result['id_customer']);
if ((int) $this->id_order_state === (int) Configuration::get('IMPRIMEUR_ORDERSTATE') &&
in_array(7, $customerGroupe) &&
(int) $result['id_order_state'] != 2) {
$context = Context::getContext();
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get(
'PS_INVOICE_PREFIX',
(int) $order->id_lang,
null,
$order->id_shop
)
. sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['mime'] = 'application/pdf';
Mail::Send(
(int) $order->id_lang,
$result['template'],
$topic,
$data,
Configuration::get('IMPRIMEUR_EMAIL'),
$result['firstname'] . ' ' . $result['lastname'],
null,
null,
$file_attachement,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
}
}
return true;
}
/**
* Sets the new state of the given order
*
* @param int $new_order_state
* @param int/object $id_order
* @param bool $use_existing_payment
*/
public function changeIdOrderState($new_order_state, $id_order, $use_existing_payment = false)
{
if (!$new_order_state || !$id_order) {
return;
}
if (!is_object($id_order) && is_numeric($id_order)) {
$order = new Order((int) $id_order);
} elseif (is_object($id_order)) {
$order = $id_order;
} else {
return;
}
ShopUrl::cacheMainDomainForShop($order->id_shop);
$new_os = new OrderState((int) $new_order_state, $order->id_lang);
$old_os = $order->getCurrentOrderState();
if (in_array($new_os->id, array(Configuration::get('PS_OS_PAYMENT'), Configuration::get('PS_OS_WS_PAYMENT')))) {
Hook::exec('actionPaymentConfirmation', array('id_order' => (int) $order->id), null, false, true, false, $order->id_shop);
}
Hook::exec('actionOrderStatusUpdate', array('newOrderStatus' => $new_os, 'id_order' => (int) $order->id), null, false, true, false, $order->id_shop);
if (Validate::isLoadedObject($order) && ($new_os instanceof OrderState)) {
$context = Context::getContext();
$virtual_products = $order->getVirtualProducts();
if ($virtual_products && (!$old_os || !$old_os->logable) && $new_os && $new_os->logable) {
$assign = array();
foreach ($virtual_products as $key => $virtual_product) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtual_product['product_id']);
$product_download = new ProductDownload($id_product_download);
if ($product_download->display_filename != '') {
$assign[$key]['name'] = $product_download->display_filename;
$dl_link = $product_download->getTextLink(false, $virtual_product['download_hash'])
. '&id_order=' . (int) $order->id
. '&secure_key=' . $order->secure_key;
$assign[$key]['link'] = $dl_link;
if (isset($virtual_product['download_deadline']) && $virtual_product['download_deadline'] != '0000-00-00 00:00:00') {
$assign[$key]['deadline'] = Tools::displayDate($virtual_product['download_deadline']);
}
if ($product_download->nb_downloadable != 0) {
$assign[$key]['downloadable'] = (int) $product_download->nb_downloadable;
}
}
}
$customer = new Customer((int) $order->id_customer);
$links = '<ul>';
foreach ($assign as $product) {
$links .= '<li>';
$links .= '<a href="' . $product['link'] . '">' . Tools::htmlentitiesUTF8($product['name']) . '</a>';
if (isset($product['deadline'])) {
$links .= '&nbsp;' . Tools::htmlentitiesUTF8(Tools::displayError('expires on', false)) . '&nbsp;' . $product['deadline'];
}
if (isset($product['downloadable'])) {
$links .= '&nbsp;' . Tools::htmlentitiesUTF8(sprintf(Tools::displayError('downloadable %d time(s)', false), (int) $product['downloadable']));
}
$links .= '</li>';
}
$links .= '</ul>';
$data = array(
'{lastname}' => $customer->lastname,
'{firstname}' => $customer->firstname,
'{id_order}' => (int) $order->id,
'{order_name}' => $order->getUniqReference(),
'{nbProducts}' => count($virtual_products),
'{virtualProducts}' => $links
);
if (!empty($assign)) {
Mail::Send((int) $order->id_lang, 'download_product', Mail::l('The virtual product that you bought is available for download', $order->id_lang), $data, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop);
}
}
$manager = null;
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$manager = StockManagerFactory::getManager();
}
$error_or_canceled_statuses = array(Configuration::get('PS_OS_ERROR'), Configuration::get('PS_OS_CANCELED'));
$employee = null;
if (!(int) $this->id_employee || !Validate::isLoadedObject(($employee = new Employee((int) $this->id_employee)))) {
if (!Validate::isLoadedObject($old_os) && $context != null) {
$employee = $context->employee; // filled if from BO and order created (because no old_os)
if ($employee) {
$this->id_employee = $employee->id;
}
} else {
$employee = null;
}
}
foreach ($order->getProductsDetail() as $product) {
if (Validate::isLoadedObject($old_os)) {
if ($new_os->logable && !$old_os->logable) {
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
if (!Pack::isPack($product['product_id']) &&
in_array($old_os->id, $error_or_canceled_statuses) &&
!StockAvailable::dependsOnStock($product['id_product'], (int) $order->id_shop)) {
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int) $product['product_quantity'], $order->id_shop);
}
} elseif (!$new_os->logable && $old_os->logable) {// if becoming unlogable => removes sale
ProductSale::removeProductSale($product['product_id'], $product['product_quantity']);
if (!Pack::isPack($product['product_id']) &&
in_array($new_os->id, $error_or_canceled_statuses) &&
!StockAvailable::dependsOnStock($product['id_product'])) {
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int) $product['product_quantity'], $order->id_shop);
}
} elseif (!$new_os->logable && !$old_os->logable &&
in_array($new_os->id, $error_or_canceled_statuses) &&
!in_array($old_os->id, $error_or_canceled_statuses) &&
!StockAvailable::dependsOnStock($product['id_product'])) {// if waiting for payment => payment error/canceled
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int) $product['product_quantity'], $order->id_shop);
}
}
if ($new_os->shipped == 1 && (!Validate::isLoadedObject($old_os) || $old_os->shipped == 0) &&
Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') &&
Warehouse::exists($product['id_warehouse']) &&
$manager != null &&
(int) $product['advanced_stock_management'] == 1) {
$warehouse = new Warehouse($product['id_warehouse']);
$manager->removeProduct(
$product['product_id'],
$product['product_attribute_id'],
$warehouse,
($product['product_quantity'] - $product['product_quantity_refunded'] - $product['product_quantity_return']),
Configuration::get('PS_STOCK_CUSTOMER_ORDER_REASON'),
true,
(int) $order->id,
0,
$employee
);
} elseif ($new_os->shipped == 0 && Validate::isLoadedObject($old_os) && $old_os->shipped == 1 &&
Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') &&
Warehouse::exists($product['id_warehouse']) &&
$manager != null &&
(int) $product['advanced_stock_management'] == 1) {// @since.1.5.0 : if the order was shipped, and is not anymore, we need to restock products
if (Pack::isPack($product['product_id'])) {
$pack_products = Pack::getItems($product['product_id'], Configuration::get('PS_LANG_DEFAULT', null, null, $order->id_shop));
foreach ($pack_products as $pack_product) {
if ($pack_product->advanced_stock_management == 1) {
$mvts = StockMvt::getNegativeStockMvts($order->id, $pack_product->id, 0, $pack_product->pack_quantity * $product['product_quantity']);
foreach ($mvts as $mvt) {
$manager->addProduct(
$pack_product->id,
0,
new Warehouse($mvt['id_warehouse']),
$mvt['physical_quantity'],
null,
$mvt['price_te'],
true,
null,
$employee
);
}
if (!StockAvailable::dependsOnStock($product['id_product'])) {
StockAvailable::updateQuantity($pack_product->id, 0, (int) $pack_product->pack_quantity * $product['product_quantity'], $order->id_shop);
}
}
}
} else {// else, it's not a pack, re-stock using the last negative stock mvts
$mvts = StockMvt::getNegativeStockMvts($order->id, $product['product_id'], $product['product_attribute_id'], ($product['product_quantity'] - $product['product_quantity_refunded'] - $product['product_quantity_return']));
foreach ($mvts as $mvt) {
$manager->addProduct(
$product['product_id'],
$product['product_attribute_id'],
new Warehouse($mvt['id_warehouse']),
$mvt['physical_quantity'],
null,
$mvt['price_te'],
true
);
}
}
}
}
}
$this->id_order_state = (int) $new_order_state;
if (!Validate::isLoadedObject($new_os) || !Validate::isLoadedObject($order)) {
die(Tools::displayError('Invalid new order status'));
}
$order->current_state = $this->id_order_state;
$order->valid = $new_os->logable;
$order->update();
if ($new_os->invoice && !$order->invoice_number) {
$order->setInvoice($use_existing_payment);
} elseif ($new_os->delivery && !$order->delivery_number) {
$order->setDeliverySlip();
}
if ($new_os->paid == 1 && (!isset(Context::getContext()->cookie->installmentpayment_type) || (int) Context::getContext()->cookie->installmentpayment_type <= 0)) {
$invoices = $order->getInvoicesCollection();
if ($order->total_paid != 0) {
$payment_method = Module::getInstanceByName($order->module);
}
foreach ($invoices as $invoice) {
$rest_paid = $invoice->getRestPaid();
if ($rest_paid > 0 && (!isset(Context::getContext()->cookie->installmentpayment_type) || (int) Context::getContext()->cookie->installmentpayment_type <= 0)) {
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$rest_paid = $installment['payer'];
}
$payment = new OrderPayment();
$payment->order_reference = Tools::substr($order->reference, 0, 9);
$payment->id_currency = $order->id_currency;
$payment->amount = $rest_paid;
if ($order->total_paid != 0) {
$payment->payment_method = $payment_method->displayName;
} else {
$payment->payment_method = null;
}
if ($payment->id_currency == $order->id_currency) {
$order->total_paid_real += $payment->amount;
} else {
$order->total_paid_real += Tools::ps_round(Tools::convertPrice($payment->amount, $payment->id_currency, false), 2);
}
$order->save();
$payment->conversion_rate = 1;
$payment->save();
PrestaShopLogger::addLog('ORDERHISTORY::changeIdOrderState - LOG DEV4 ligne 426 _' . $payment->amount . '_', 3, null, 'Cart', (int) $order->id, true);
Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order`)
VALUES(' . (int) $invoice->id . ', ' . (int) $payment->id . ', ' . (int) $order->id . ')');
}
}
}
if ($new_os->delivery) {
$order->setDelivery();
}
Hook::exec('actionOrderStatusPostUpdate', array('newOrderStatus' => $new_os, 'id_order' => (int) $order->id,), null, false, true, false, $order->id_shop);
ShopUrl::resetMainDomainCache();
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,72 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore
{
public function getHeader()
{
if (Tools::getIsset('installmentpayment')) {
$this->title = HTMLTemplateInvoice::l('Facture acompte n°') . $this->order->id;
}
return parent::getHeader();
}
public function getFilename()
{
if (Tools::getIsset('installmentpayment')) {
$id_lang = Context::getContext()->language->id;
$id_shop = (int) $this->order->id_shop;
return Configuration::get('PS_INVOICE_PREFIX', $id_lang, null, $id_shop) . sprintf('%06d', $this->order->id) . '.pdf';
}
return parent::getFilename();
}
public function getContent()
{
parent::getContent();
$iso_code = Context::getContext()->language->iso_code;
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $this->order->id_cart;
$installmentpayment = Db::getInstance()->getRow($sql);
if (isset($installmentpayment['rest']) && $installmentpayment['rest'] > 0) {
$data = array(
'paid' => $installmentpayment['payer'],
'rest' => $installmentpayment['rest'],
'acompte' => Tools::getIsset('installmentpayment') ? 1 : 0
);
$this->smarty->assign($data);
}
if (Tools::getIsset('installmentpayment')) {
$tpls = array(
'style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')),
'addresses_tab' => $this->smarty->fetch($this->getTemplate('invoice.addresses-tab')),
'summary_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.empty.tpl'),
'tax_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.tax-tab2_' . $iso_code . '.tpl'),
'product_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.empty2.tpl'),
'payment_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.empty2.tpl'),
'total_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.total-tab2_' . $iso_code . '.tpl')
);
} else {
$tpls = array(
'style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')),
'addresses_tab' => $this->smarty->fetch($this->getTemplate('invoice.addresses-tab')),
'summary_tab' => $this->smarty->fetch($this->getTemplate('invoice.summary-tab')),
'product_tab' => $this->smarty->fetch($this->getTemplate('invoice.product-tab')),
'tax_tab' => $this->getTaxTabContent(),
'payment_tab' => $this->smarty->fetch($this->getTemplate('invoice.payment-tab')),
'total_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/invoice.total-tab_' . $iso_code . '.tpl')
);
}
$this->smarty->assign($tpls);
$country = new Country((int) $this->order->id_address_invoice);
return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code));
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,944 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class AdminOrdersController extends AdminOrdersControllerCore
{
public function __construct()
{
$sql = 'UPDATE `' . _DB_PREFIX_ . 'orders` SET total_paid_tax_incl = total_paid';
Db::getInstance()->execute($sql);
parent::__construct();
}
public function postProcess()
{
if (Tools::isSubmit('id_order') && Tools::getValue('id_order') > 0) {
$order = new Order(Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order)) {
$this->errors[] = Tools::displayError('The order cannot be found within your database.');
}
ShopUrl::cacheMainDomainForShop((int) $order->id_shop);
}
if (Tools::isSubmit('submitShippingNumber') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$order_carrier = new OrderCarrier(Tools::getValue('id_order_carrier'));
if (!Validate::isLoadedObject($order_carrier)) {
$this->errors[] = Tools::displayError('The order carrier ID is invalid.');
} elseif (!Validate::isTrackingNumber(Tools::getValue('tracking_number'))) {
$this->errors[] = Tools::displayError('The tracking number is incorrect.');
} else {
$order->shipping_number = Tools::getValue('tracking_number');
$order->update();
$order_carrier->tracking_number = pSQL(Tools::getValue('tracking_number'));
if ($order_carrier->update()) {
$customer = new Customer((int) $order->id_customer);
$carrier = new Carrier((int) $order->id_carrier, $order->id_lang);
if (!Validate::isLoadedObject($customer)) {
throw new PrestaShopException('Can\'t load Customer object');
}
if (!Validate::isLoadedObject($carrier)) {
throw new PrestaShopException('Can\'t load Carrier object');
}
$templateVars = array(
'{followup}' => str_replace('@', $order->shipping_number, $carrier->url),
'{firstname}' => $customer->firstname,
'{lastname}' => $customer->lastname,
'{id_order}' => $order->id,
'{shipping_number}' => $order->shipping_number,
'{order_name}' => $order->getUniqReference()
);
if (@Mail::Send((int) $order->id_lang, 'in_transit', Mail::l('Package in transit', (int) $order->id_lang), $templateVars, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int) $order->id_shop)) {
Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order, 'customer' => $customer, 'carrier' => $carrier), null, false, true, false, $order->id_shop);
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
}
} else {
$this->errors[] = Tools::displayError('The order carrier cannot be updated.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitState') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$order_state = new OrderState(Tools::getValue('id_order_state'));
if (!Validate::isLoadedObject($order_state)) {
$this->errors[] = Tools::displayError('The new order status is invalid.');
} else {
$current_order_state = $order->getCurrentOrderState();
if ($current_order_state->id != $order_state->id) {
$history = new OrderHistory();
$history->id_order = $order->id;
$history->id_employee = (int) $this->context->employee->id;
$use_existings_payment = false;
if (!$order->hasInvoice()) {
$use_existings_payment = true;
}
$history->changeIdOrderState((int) $order_state->id, $order, $use_existings_payment);
$carrier = new Carrier($order->id_carrier, $order->id_lang);
$templateVars = array();
if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number) {
$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));
}
if ($history->addWithemail(true, $templateVars)) {
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
foreach ($order->getProducts() as $product) {
if (StockAvailable::dependsOnStock($product['product_id'])) {
StockAvailable::synchronize($product['product_id'], (int) $product['id_shop']);
}
}
}
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . (int) $order->id . '&vieworder&token=' . $this->token);
}
$this->errors[] = Tools::displayError('An error occurred while changing order status, or we were unable to send an email to the customer.');
} else {
$this->errors[] = Tools::displayError('The order has already been assigned this status.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitMessage') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$customer = new Customer(Tools::getValue('id_customer'));
if (!Validate::isLoadedObject($customer)) {
$this->errors[] = Tools::displayError('The customer is invalid.');
} elseif (!Tools::getValue('message')) {
$this->errors[] = Tools::displayError('The message cannot be blank.');
} else {
$rules = call_user_func(array('Message', 'getValidationRules'), 'Message');
foreach ($rules['required'] as $field) {
if (($value = Tools::getValue($field)) == false && (string) $value != '0') {
if (!Tools::getValue('id_' . $this->table) || $field != 'passwd') {
$this->errors[] = sprintf(Tools::displayError('field %s is required.'), $field);
}
}
}
foreach ($rules['size'] as $field => $maxLength) {
if (Tools::getValue($field) && Tools::strlen(Tools::getValue($field)) > $maxLength) {
$this->errors[] = sprintf(Tools::displayError('field %1$s is too long (%2$d chars max).'), $field, $maxLength);
}
}
foreach ($rules['validate'] as $field => $function) {
if (Tools::getValue($field)) {
if (!Validate::$function(htmlentities(Tools::getValue($field), ENT_COMPAT, 'UTF-8'))) {
$this->errors[] = sprintf(Tools::displayError('field %s is invalid.'), $field);
}
}
}
if (!count($this->errors)) {
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($customer->email, $order->id);
if (!$id_customer_thread) {
$customer_thread = new CustomerThread();
$customer_thread->id_contact = 0;
$customer_thread->id_customer = (int) $order->id_customer;
$customer_thread->id_shop = (int) $this->context->shop->id;
$customer_thread->id_order = (int) $order->id;
$customer_thread->id_lang = (int) $this->context->language->id;
$customer_thread->email = $customer->email;
$customer_thread->status = 'open';
$customer_thread->token = Tools::passwdGen(12);
$customer_thread->add();
} else {
$customer_thread = new CustomerThread((int) $id_customer_thread);
}
$customer_message = new CustomerMessage();
$customer_message->id_customer_thread = $customer_thread->id;
$customer_message->id_employee = (int) $this->context->employee->id;
$customer_message->message = Tools::getValue('message');
$customer_message->private = Tools::getValue('visibility');
if (!$customer_message->add()) {
$this->errors[] = Tools::displayError('An error occurred while saving the message.');
} elseif ($customer_message->private) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . (int) $order->id . '&vieworder&conf=11&token=' . $this->token);
} else {
$message = $customer_message->message;
if (Configuration::get('PS_MAIL_TYPE', null, null, $order->id_shop) != Mail::TYPE_TEXT) {
$message = Tools::nl2br($customer_message->message);
}
$varsTpl = array(
'{lastname}' => $customer->lastname,
'{firstname}' => $customer->firstname,
'{id_order}' => $order->id,
'{order_name}' => $order->getUniqReference(),
'{message}' => $message
);
if (@Mail::Send((int) $order->id_lang, 'order_merchant_comment', Mail::l('New message regarding your order', (int) $order->id_lang), $varsTpl, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int) $order->id_shop)) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=11' . '&token=' . $this->token);
}
}
$this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to delete this.');
}
} elseif (Tools::isSubmit('partialRefund') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
if (Tools::isSubmit('partialRefundProduct') && ($refunds = Tools::getValue('partialRefundProduct')) && is_array($refunds)) {
$amount = 0;
$order_detail_list = array();
$full_quantity_list = array();
foreach ($refunds as $id_order_detail => $amount_detail) {
$quantity = Tools::getValue('partialRefundProductQuantity');
if (!$quantity[$id_order_detail]) {
continue;
}
$full_quantity_list[$id_order_detail] = (int) $quantity[$id_order_detail];
$order_detail_list[$id_order_detail] = array(
'quantity' => (int) $quantity[$id_order_detail],
'id_order_detail' => (int) $id_order_detail
);
$order_detail = new OrderDetail((int) $id_order_detail);
if (empty($amount_detail)) {
$order_detail_list[$id_order_detail]['unit_price'] = (!Tools::getValue('TaxMethod') ? $order_detail->unit_price_tax_excl : $order_detail->unit_price_tax_incl);
$order_detail_list[$id_order_detail]['amount'] = $order_detail->unit_price_tax_incl * $order_detail_list[$id_order_detail]['quantity'];
} else {
$order_detail_list[$id_order_detail]['amount'] = (float) str_replace(',', '.', $amount_detail);
$order_detail_list[$id_order_detail]['unit_price'] = $order_detail_list[$id_order_detail]['amount'] / $order_detail_list[$id_order_detail]['quantity'];
}
$amount += $order_detail_list[$id_order_detail]['amount'];
if (!$order->hasBeenDelivered() || ($order->hasBeenDelivered() && Tools::isSubmit('reinjectQuantities')) && $order_detail_list[$id_order_detail]['quantity'] > 0) {
$this->reinjectQuantity($order_detail, $order_detail_list[$id_order_detail]['quantity']);
}
}
$shipping_cost_amount = (float) str_replace(',', '.', Tools::getValue('partialRefundShippingCost')) ? (float) str_replace(',', '.', Tools::getValue('partialRefundShippingCost')) : false;
if ($amount == 0 && $shipping_cost_amount == 0) {
if (!empty($refunds)) {
$this->errors[] = Tools::displayError('Please enter a quantity to proceed with your refund.');
} else {
$this->errors[] = Tools::displayError('Please enter an amount to proceed with your refund.');
}
return false;
}
$choosen = false;
$voucher = 0;
if ((int) Tools::getValue('refund_voucher_off') == 1) {
$amount -= $voucher = (float) Tools::getValue('order_discount_price');
} elseif ((int) Tools::getValue('refund_voucher_off') == 2) {
$choosen = true;
$amount = $voucher = (float) Tools::getValue('refund_voucher_choose');
}
if ($shipping_cost_amount > 0) {
if (!Tools::getValue('TaxMethod')) {
$tax = new Tax();
$tax->rate = $order->carrier_tax_rate;
$tax_calculator = new TaxCalculator(array($tax));
$amount += $tax_calculator->addTaxes($shipping_cost_amount);
} else {
$amount += $shipping_cost_amount;
}
}
$order_carrier = new OrderCarrier((int) $order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier)) {
$order_carrier->weight = (float) $order->getTotalWeight();
if ($order_carrier->update()) {
$order->weight = sprintf("%.3f " . Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
}
if ($amount >= 0) {
if (!OrderSlip::create($order, $order_detail_list, $shipping_cost_amount, $voucher, $choosen, (Tools::getValue('TaxMethod') ? false : true))) {
$this->errors[] = Tools::displayError('You cannot generate a partial credit slip.');
} else {
Hook::exec('actionOrderSlipAdd', array('order' => $order, 'productList' => $order_detail_list, 'qtyList' => $full_quantity_list), null, false, true, false, $order->id_shop);
$customer = new Customer((int) ($order->id_customer));
$params = array();
$params['{lastname}'] = $customer->lastname;
$params['{firstname}'] = $customer->firstname;
$params['{id_order}'] = $order->id;
$params['{order_name}'] = $order->getUniqReference();
@Mail::Send(
(int) $order->id_lang,
'credit_slip',
Mail::l('New credit slip regarding your order', (int) $order->id_lang),
$params,
$customer->email,
$customer->firstname . ' ' . $customer->lastname,
null,
null,
null,
null,
_PS_MAIL_DIR_,
true,
(int) $order->id_shop
);
}
foreach ($order_detail_list as &$product) {
$order_detail = new OrderDetail((int) $product['id_order_detail']);
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
StockAvailable::synchronize($order_detail->product_id);
}
}
if (Tools::isSubmit('generateDiscountRefund') && !count($this->errors) && $amount > 0) {
$cart_rule = new CartRule();
$cart_rule->description = sprintf($this->l('Credit slip for order #%d'), $order->id);
$language_ids = Language::getIDs(false);
foreach ($language_ids as $id_lang) {
$cart_rule->name[$id_lang] = sprintf('V0C%1$dO%2$d', $order->id_customer, $order->id);
}
$cart_rule->code = sprintf('V0C%1$dO%2$d', $order->id_customer, $order->id);
$cart_rule->quantity = 1;
$cart_rule->quantity_per_user = 1;
$cart_rule->id_customer = $order->id_customer;
$now = time();
$cart_rule->date_from = date('Y-m-d H:i:s', $now);
$cart_rule->date_to = date('Y-m-d H:i:s', strtotime('+1 year'));
$cart_rule->partial_use = 1;
$cart_rule->active = 1;
$cart_rule->reduction_amount = $amount;
$cart_rule->reduction_tax = $order->getTaxCalculationMethod() != PS_TAX_EXC;
$cart_rule->minimum_amount_currency = $order->id_currency;
$cart_rule->reduction_currency = $order->id_currency;
if (!$cart_rule->add()) {
$this->errors[] = Tools::displayError('You cannot generate a voucher.');
} else {
foreach ($language_ids as $id_lang) {
$cart_rule->name[$id_lang] = sprintf('V%1$dC%2$dO%3$d', $cart_rule->id, $order->id_customer, $order->id);
}
$cart_rule->code = sprintf('V%1$dC%2$dO%3$d', $cart_rule->id, $order->id_customer, $order->id);
if (!$cart_rule->update()) {
$this->errors[] = Tools::displayError('You cannot generate a voucher.');
} else {
$currency = $this->context->currency;
$customer = new Customer((int) ($order->id_customer));
$params['{lastname}'] = $customer->lastname;
$params['{firstname}'] = $customer->firstname;
$params['{id_order}'] = $order->id;
$params['{order_name}'] = $order->getUniqReference();
$params['{voucher_amount}'] = Tools::displayPrice($cart_rule->reduction_amount, $currency, false);
$params['{voucher_num}'] = $cart_rule->code;
@Mail::Send((int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order #%s', (int) $order->id_lang), $order->reference), $params, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int) $order->id_shop);
}
}
}
} else {
if (!empty($refunds)) {
$this->errors[] = Tools::displayError('Please enter a quantity to proceed with your refund.');
} else {
$this->errors[] = Tools::displayError('Please enter an amount to proceed with your refund.');
}
}
if (!count($this->errors)) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=30&token=' . $this->token);
}
} else {
$this->errors[] = Tools::displayError('The partial refund data is incorrect.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to delete this.');
}
} elseif (Tools::isSubmit('cancelProduct') && isset($order)) {
if ($this->tabAccess['delete'] == '1') {
if (!Tools::isSubmit('id_order_detail') && !Tools::isSubmit('id_customization')) {
$this->errors[] = Tools::displayError('You must select a product.');
} elseif (!Tools::isSubmit('cancelQuantity') && !Tools::isSubmit('cancelCustomizationQuantity')) {
$this->errors[] = Tools::displayError('You must enter a quantity.');
} else {
$productList = Tools::getValue('id_order_detail');
if ($productList) {
$productList = array_map('intval', $productList);
}
$customizationList = Tools::getValue('id_customization');
if ($customizationList) {
$customizationList = array_map('intval', $customizationList);
}
$qtyList = Tools::getValue('cancelQuantity');
if ($qtyList) {
$qtyList = array_map('intval', $qtyList);
}
$customizationQtyList = Tools::getValue('cancelCustomizationQuantity');
if ($customizationQtyList) {
$customizationQtyList = array_map('intval', $customizationQtyList);
}
$full_product_list = $productList;
$full_quantity_list = $qtyList;
if ($customizationList) {
foreach ($customizationList as $key => $id_order_detail) {
$full_product_list[(int) $id_order_detail] = $id_order_detail;
if (isset($customizationQtyList[$key])) {
$full_quantity_list[(int) $id_order_detail] += $customizationQtyList[$key];
}
}
}
if ($productList || $customizationList) {
if ($productList) {
$id_cart = Cart::getCartIdByOrderId($order->id);
$customization_quantities = Customization::countQuantityByCart($id_cart);
foreach ($productList as $key => $id_order_detail) {
$qtyCancelProduct = abs($qtyList[$key]);
if (!$qtyCancelProduct) {
$this->errors[] = Tools::displayError('No quantity has been selected for this product.');
}
$order_detail = new OrderDetail($id_order_detail);
$customization_quantity = 0;
if (array_key_exists($order_detail->product_id, $customization_quantities) && array_key_exists($order_detail->product_attribute_id, $customization_quantities[$order_detail->product_id])) {
$customization_quantity = (int) $customization_quantities[$order_detail->product_id][$order_detail->product_attribute_id];
}
if (($order_detail->product_quantity - $customization_quantity - $order_detail->product_quantity_refunded - $order_detail->product_quantity_return) < $qtyCancelProduct) {
$this->errors[] = Tools::displayError('An invalid quantity was selected for this product.');
}
}
}
if ($customizationList) {
$customization_quantities = Customization::retrieveQuantitiesFromIds(array_keys($customizationList));
foreach ($customizationList as $id_customization => $id_order_detail) {
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
$customization_quantity = $customization_quantities[$id_customization];
if (!$qtyCancelProduct) {
$this->errors[] = Tools::displayError('No quantity has been selected for this product.');
}
if ($qtyCancelProduct > ($customization_quantity['quantity'] - ($customization_quantity['quantity_refunded'] + $customization_quantity['quantity_returned']))) {
$this->errors[] = Tools::displayError('An invalid quantity was selected for this product.');
}
}
}
if (!count($this->errors) && $productList) {
foreach ($productList as $key => $id_order_detail) {
$qty_cancel_product = abs($qtyList[$key]);
$order_detail = new OrderDetail((int) ($id_order_detail));
if (!$order->hasBeenDelivered() || ($order->hasBeenDelivered() && Tools::isSubmit('reinjectQuantities')) && $qty_cancel_product > 0) {
$this->reinjectQuantity($order_detail, $qty_cancel_product);
}
$order_detail = new OrderDetail((int) $id_order_detail);
if (!$order->deleteProduct($order, $order_detail, $qty_cancel_product)) {
$this->errors[] = Tools::displayError('An error occurred while attempting to delete the product.') . ' <span class="bold">' . $order_detail->product_name . '</span>';
}
$order_carrier = new OrderCarrier((int) $order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier)) {
$order_carrier->weight = (float) $order->getTotalWeight();
if ($order_carrier->update()) {
$order->weight = sprintf("%.3f " . Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
}
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && StockAvailable::dependsOnStock($order_detail->product_id)) {
StockAvailable::synchronize($order_detail->product_id);
}
Hook::exec('actionProductCancel', array('order' => $order, 'id_order_detail' => (int) $id_order_detail), null, false, true, false, $order->id_shop);
}
}
if (!count($this->errors) && $customizationList) {
foreach ($customizationList as $id_customization => $id_order_detail) {
$order_detail = new OrderDetail((int) ($id_order_detail));
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
if (!$order->deleteCustomization($id_customization, $qtyCancelProduct, $order_detail)) {
$this->errors[] = Tools::displayError('An error occurred while attempting to delete product customization.') . ' ' . $id_customization;
}
}
}
if ((Tools::isSubmit('generateCreditSlip') || Tools::isSubmit('generateDiscount')) && !count($this->errors)) {
$customer = new Customer((int) ($order->id_customer));
$params['{lastname}'] = $customer->lastname;
$params['{firstname}'] = $customer->firstname;
$params['{id_order}'] = $order->id;
$params['{order_name}'] = $order->getUniqReference();
}
if (Tools::isSubmit('generateCreditSlip') && !count($this->errors)) {
$product_list = array();
$amount = $order_detail->unit_price_tax_incl * $full_quantity_list[$id_order_detail];
$choosen = false;
if ((int) Tools::getValue('refund_total_voucher_off') == 1) {
$amount -= $voucher = (float) Tools::getValue('order_discount_price');
} elseif ((int) Tools::getValue('refund_total_voucher_off') == 2) {
$choosen = true;
$amount = $voucher = (float) Tools::getValue('refund_total_voucher_choose');
}
foreach ($full_product_list as $id_order_detail) {
$order_detail = new OrderDetail((int) $id_order_detail);
$product_list[$id_order_detail] = array(
'id_order_detail' => $id_order_detail,
'quantity' => $full_quantity_list[$id_order_detail],
'unit_price' => $order_detail->unit_price_tax_excl,
'amount' => isset($amount) ? $amount : $order_detail->unit_price_tax_incl * $full_quantity_list[$id_order_detail],
);
}
$shipping = Tools::isSubmit('shippingBack') ? null : false;
if (!OrderSlip::create($order, $product_list, $shipping, $voucher, $choosen)) {
$this->errors[] = Tools::displayError('A credit slip cannot be generated. ');
} else {
Hook::exec('actionOrderSlipAdd', array('order' => $order, 'productList' => $full_product_list, 'qtyList' => $full_quantity_list), null, false, true, false, $order->id_shop);
@Mail::Send(
(int) $order->id_lang,
'credit_slip',
Mail::l('New credit slip regarding your order', (int) $order->id_lang),
$params,
$customer->email,
$customer->firstname . ' ' . $customer->lastname,
null,
null,
null,
null,
_PS_MAIL_DIR_,
true,
(int) $order->id_shop
);
}
}
if (Tools::isSubmit('generateDiscount') && !count($this->errors)) {
$cartrule = new CartRule();
$language_ids = Language::getIDs((bool) $order);
$cartrule->description = sprintf($this->l('Credit card slip for order #%d'), $order->id);
foreach ($language_ids as $id_lang) {
$cartrule->name[$id_lang] = 'V0C' . (int) ($order->id_customer) . 'O' . (int) ($order->id);
}
$cartrule->code = 'V0C' . (int) ($order->id_customer) . 'O' . (int) ($order->id);
$cartrule->quantity = 1;
$cartrule->quantity_per_user = 1;
$cartrule->id_customer = $order->id_customer;
$now = time();
$cartrule->date_from = date('Y-m-d H:i:s', $now);
$cartrule->date_to = date('Y-m-d H:i:s', $now + (3600 * 24 * 365.25));
$cartrule->active = 1;
$products = $order->getProducts(false, $full_product_list, $full_quantity_list);
$total = 0;
foreach ($products as $product) {
$total += $product['unit_price_tax_incl'] * $product['product_quantity'];
}
if (Tools::isSubmit('shippingBack')) {
$total += $order->total_shipping;
}
if ((int) Tools::getValue('refund_total_voucher_off') == 1) {
$total -= (float) Tools::getValue('order_discount_price');
} elseif ((int) Tools::getValue('refund_total_voucher_off') == 2) {
$total = (float) Tools::getValue('refund_total_voucher_choose');
}
$cartrule->reduction_amount = $total;
$cartrule->reduction_tax = true;
$cartrule->minimum_amount_currency = $order->id_currency;
$cartrule->reduction_currency = $order->id_currency;
if (!$cartrule->add()) {
$this->errors[] = Tools::displayError('You cannot generate a voucher.');
} else {
foreach ($language_ids as $id_lang) {
$cartrule->name[$id_lang] = 'V' . (int) ($cartrule->id) . 'C' . (int) ($order->id_customer) . 'O' . $order->id;
}
$cartrule->code = 'V' . (int) ($cartrule->id) . 'C' . (int) ($order->id_customer) . 'O' . $order->id;
if (!$cartrule->update()) {
$this->errors[] = Tools::displayError('You cannot generate a voucher.');
} else {
$currency = $this->context->currency;
$params['{voucher_amount}'] = Tools::displayPrice($cartrule->reduction_amount, $currency, false);
$params['{voucher_num}'] = $cartrule->code;
@Mail::Send((int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order #%s', (int) $order->id_lang), $order->reference), $params, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int) $order->id_shop);
}
}
}
} else {
$this->errors[] = Tools::displayError('No product or quantity has been selected.');
}
if (!count($this->errors)) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=31&token=' . $this->token);
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to delete this.');
}
} elseif (Tools::isSubmit('messageReaded')) {
Message::markAsReaded(Tools::getValue('messageReaded'), $this->context->employee->id);
} elseif (Tools::isSubmit('submitAddPayment') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$amount = str_replace(',', '.', Tools::getValue('payment_amount'));
$currency = new Currency(Tools::getValue('payment_currency'));
$order_has_invoice = $order->hasInvoice();
if ($order_has_invoice) {
$order_invoice = new OrderInvoice(Tools::getValue('payment_invoice'));
} else {
$order_invoice = null;
}
if (!Validate::isLoadedObject($order)) {
$this->errors[] = Tools::displayError('The order cannot be found');
} elseif (!Validate::isNegativePrice($amount) || !(float) $amount) {
$this->errors[] = Tools::displayError('The amount is invalid.');
} elseif (!Validate::isGenericName(Tools::getValue('payment_method'))) {
$this->errors[] = Tools::displayError('The selected payment method is invalid.');
} elseif (!Validate::isString(Tools::getValue('payment_transaction_id'))) {
$this->errors[] = Tools::displayError('The transaction ID is invalid.');
} elseif (!Validate::isLoadedObject($currency)) {
$this->errors[] = Tools::displayError('The selected currency is invalid.');
} elseif ($order_has_invoice && !Validate::isLoadedObject($order_invoice)) {
$this->errors[] = Tools::displayError('The invoice is invalid.');
} elseif (!Validate::isDate(Tools::getValue('payment_date'))) {
$this->errors[] = Tools::displayError('The date is invalid');
} else {
if (!$order->addOrderPayment($amount, Tools::getValue('payment_method'), Tools::getValue('payment_transaction_id'), $currency, Tools::getValue('payment_date'), $order_invoice)) {
$this->errors[] = Tools::displayError('An error occurred during payment.');
} else {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token . '&payment_amount=' . $amount);
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitEditNote')) {
$note = Tools::getValue('note');
$order_invoice = new OrderInvoice((int) Tools::getValue('id_order_invoice'));
if (Validate::isLoadedObject($order_invoice) && Validate::isCleanHtml($note)) {
if ($this->tabAccess['edit'] == '1') {
$order_invoice->note = $note;
if ($order_invoice->save()) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order_invoice->id_order . '&vieworder&conf=4&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('The invoice note was not saved.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} else {
$this->errors[] = Tools::displayError('The invoice for edit note was unable to load. ');
}
} elseif (Tools::isSubmit('submitAddOrder') && ($id_cart = Tools::getValue('id_cart')) &&
($module_name = Tools::getValue('payment_module_name')) &&
($id_order_state = Tools::getValue('id_order_state')) && Validate::isModuleName($module_name)) {
if ($this->tabAccess['edit'] == '1') {
if (!Configuration::get('PS_CATALOG_MODE')) {
$payment_module = Module::getInstanceByName($module_name);
} else {
$payment_module = new BoOrder();
}
$cart = new Cart((int) $id_cart);
Context::getContext()->currency = new Currency((int) $cart->id_currency);
Context::getContext()->customer = new Customer((int) $cart->id_customer);
$bad_delivery = false;
if (($bad_delivery = (bool) !Address::isCountryActiveById((int) $cart->id_address_delivery)) || !Address::isCountryActiveById((int) $cart->id_address_invoice)) {
if ($bad_delivery) {
$this->errors[] = Tools::displayError('This delivery address country is not active.');
} else {
$this->errors[] = Tools::displayError('This invoice address country is not active.');
}
} else {
$employee = new Employee((int) Context::getContext()->cookie->id_employee);
$payment_module->validateOrder(
(int) $cart->id,
(int) $id_order_state,
$cart->getOrderTotal(true, Cart::BOTH),
$payment_module->displayName,
$this->l('Manual order -- Employee:') . ' ' .
Tools::substr($employee->firstname, 0, 1) . '. ' . $employee->lastname,
array(),
null,
false,
$cart->secure_key
);
if ($payment_module->currentOrder) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $payment_module->currentOrder . '&vieworder' . '&token=' . $this->token);
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to add this.');
}
} elseif ((Tools::isSubmit('submitAddressShipping') || Tools::isSubmit('submitAddressInvoice')) && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$address = new Address(Tools::getValue('id_address'));
if (Validate::isLoadedObject($address)) {
if (Tools::isSubmit('submitAddressShipping')) {
$order->id_address_delivery = $address->id;
} elseif (Tools::isSubmit('submitAddressInvoice')) {
$order->id_address_invoice = $address->id;
}
$order->update();
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('This address can\'t be loaded');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitChangeCurrency') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
if (Tools::getValue('new_currency') != $order->id_currency && !$order->valid) {
$old_currency = new Currency($order->id_currency);
$currency = new Currency(Tools::getValue('new_currency'));
if (!Validate::isLoadedObject($currency)) {
throw new PrestaShopException('Can\'t load Currency object');
}
foreach ($order->getOrderDetailList() as $row) {
$order_detail = new OrderDetail($row['id_order_detail']);
$fields = array(
'ecotax',
'product_price',
'reduction_amount',
'total_shipping_price_tax_excl',
'total_shipping_price_tax_incl',
'total_price_tax_incl',
'total_price_tax_excl',
'product_quantity_discount',
'purchase_supplier_price',
'reduction_amount',
'reduction_amount_tax_incl',
'reduction_amount_tax_excl',
'unit_price_tax_incl',
'unit_price_tax_excl',
'original_product_price'
);
foreach ($fields as $field) {
$order_detail->{$field} = Tools::convertPriceFull($order_detail->{$field}, $old_currency, $currency);
}
$order_detail->update();
$order_detail->updateTaxAmount($order);
}
$id_order_carrier = (int) $order->getIdOrderCarrier();
if ($id_order_carrier) {
$order_carrier = $order_carrier = new OrderCarrier((int) $order->getIdOrderCarrier());
$order_carrier->shipping_cost_tax_excl = (float) Tools::convertPriceFull($order_carrier->shipping_cost_tax_excl, $old_currency, $currency);
$order_carrier->shipping_cost_tax_incl = (float) Tools::convertPriceFull($order_carrier->shipping_cost_tax_incl, $old_currency, $currency);
$order_carrier->update();
}
$fields = array(
'total_discounts',
'total_discounts_tax_incl',
'total_discounts_tax_excl',
'total_discount_tax_excl',
'total_discount_tax_incl',
'total_paid',
'total_paid_tax_incl',
'total_paid_tax_excl',
'total_paid_real',
'total_products',
'total_products_wt',
'total_shipping',
'total_shipping_tax_incl',
'total_shipping_tax_excl',
'total_wrapping',
'total_wrapping_tax_incl',
'total_wrapping_tax_excl',
);
$invoices = $order->getInvoicesCollection();
if ($invoices) {
foreach ($invoices as $invoice) {
foreach ($fields as $field) {
if (isset($invoice->$field)) {
$invoice->{$field} = Tools::convertPriceFull($invoice->{$field}, $old_currency, $currency);
}
}
$invoice->save();
}
}
foreach ($fields as $field) {
if (isset($order->$field)) {
$order->{$field} = Tools::convertPriceFull($order->{$field}, $old_currency, $currency);
}
}
$order->id_currency = $currency->id;
$order->conversion_rate = (float) $currency->conversion_rate;
$order->update();
} else {
$this->errors[] = Tools::displayError('You cannot change the currency.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitGenerateInvoice') && isset($order)) {
if (!Configuration::get('PS_INVOICE', null, null, $order->id_shop)) {
$this->errors[] = Tools::displayError('Invoice management has been disabled.');
} elseif ($order->hasInvoice()) {
$this->errors[] = Tools::displayError('This order already has an invoice.');
} else {
$order->setInvoice(true);
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token);
}
} elseif (Tools::isSubmit('submitDeleteVoucher') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$order_cart_rule = new OrderCartRule(Tools::getValue('id_order_cart_rule'));
if (Validate::isLoadedObject($order_cart_rule) && $order_cart_rule->id_order == $order->id) {
if ($order_cart_rule->id_order_invoice) {
$order_invoice = new OrderInvoice($order_cart_rule->id_order_invoice);
if (!Validate::isLoadedObject($order_invoice)) {
throw new PrestaShopException('Can\'t load Order Invoice object');
}
$order_invoice->total_discount_tax_excl -= $order_cart_rule->value_tax_excl;
$order_invoice->total_discount_tax_incl -= $order_cart_rule->value;
$order_invoice->total_paid_tax_excl += $order_cart_rule->value_tax_excl;
$order_invoice->total_paid_tax_incl += $order_cart_rule->value;
$order_invoice->update();
}
$order->total_discounts -= $order_cart_rule->value;
$order->total_discounts_tax_incl -= $order_cart_rule->value;
$order->total_discounts_tax_excl -= $order_cart_rule->value_tax_excl;
$order->total_paid += $order_cart_rule->value;
$order->total_paid_tax_incl += $order_cart_rule->value;
$order->total_paid_tax_excl += $order_cart_rule->value_tax_excl;
$order_cart_rule->delete();
$order->update();
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('You cannot edit this cart rule.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitNewVoucher') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
if (!Tools::getValue('discount_name')) {
$this->errors[] = Tools::displayError('You must specify a name in order to create a new discount.');
} else {
if ($order->hasInvoice()) {
if (!Tools::isSubmit('discount_all_invoices')) {
$order_invoice = new OrderInvoice(Tools::getValue('discount_invoice'));
if (!Validate::isLoadedObject($order_invoice)) {
throw new PrestaShopException('Can\'t load Order Invoice object');
}
}
}
$cart_rules = array();
$discount_value = (float) str_replace(',', '.', Tools::getValue('discount_value'));
switch (Tools::getValue('discount_type')) {
case 1:
if ($discount_value < 100) {
if (isset($order_invoice)) {
$cart_rules[$order_invoice->id]['value_tax_incl'] = Tools::ps_round($order_invoice->total_paid_tax_incl * $discount_value / 100, 2);
$cart_rules[$order_invoice->id]['value_tax_excl'] = Tools::ps_round($order_invoice->total_paid_tax_excl * $discount_value / 100, 2);
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
} elseif ($order->hasInvoice()) {
$order_invoices_collection = $order->getInvoicesCollection();
foreach ($order_invoices_collection as $order_invoice) {
$cart_rules[$order_invoice->id]['value_tax_incl'] = Tools::ps_round($order_invoice->total_paid_tax_incl * $discount_value / 100, 2);
$cart_rules[$order_invoice->id]['value_tax_excl'] = Tools::ps_round($order_invoice->total_paid_tax_excl * $discount_value / 100, 2);
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
} else {
$cart_rules[0]['value_tax_incl'] = Tools::ps_round($order->total_paid_tax_incl * $discount_value / 100, 2);
$cart_rules[0]['value_tax_excl'] = Tools::ps_round($order->total_paid_tax_excl * $discount_value / 100, 2);
}
} else {
$this->errors[] = Tools::displayError('The discount value is invalid.');
}
break;
case 2:
if (isset($order_invoice)) {
if ($discount_value > $order_invoice->total_paid_tax_incl) {
$this->errors[] = Tools::displayError('The discount value is greater than the order invoice total.');
} else {
$cart_rules[$order_invoice->id]['value_tax_incl'] = Tools::ps_round($discount_value, 2);
$cart_rules[$order_invoice->id]['value_tax_excl'] = Tools::ps_round($discount_value / (1 + ($order->getTaxesAverageUsed() / 100)), 2);
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
} elseif ($order->hasInvoice()) {
$order_invoices_collection = $order->getInvoicesCollection();
foreach ($order_invoices_collection as $order_invoice) {
if ($discount_value > $order_invoice->total_paid_tax_incl) {
$this->errors[] = Tools::displayError('The discount value is greater than the order invoice total.') . $order_invoice->getInvoiceNumberFormatted(Context::getContext()->language->id, (int) $order->id_shop) . ')';
} else {
$cart_rules[$order_invoice->id]['value_tax_incl'] = Tools::ps_round($discount_value, 2);
$cart_rules[$order_invoice->id]['value_tax_excl'] = Tools::ps_round($discount_value / (1 + ($order->getTaxesAverageUsed() / 100)), 2);
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
}
} else {
if ($discount_value > $order->total_paid_tax_incl) {
$this->errors[] = Tools::displayError('The discount value is greater than the order total.');
} else {
$cart_rules[0]['value_tax_incl'] = Tools::ps_round($discount_value, 2);
$cart_rules[0]['value_tax_excl'] = Tools::ps_round($discount_value / (1 + ($order->getTaxesAverageUsed() / 100)), 2);
}
}
break;
case 3:
if (isset($order_invoice)) {
if ($order_invoice->total_shipping_tax_incl > 0) {
$cart_rules[$order_invoice->id]['value_tax_incl'] = $order_invoice->total_shipping_tax_incl;
$cart_rules[$order_invoice->id]['value_tax_excl'] = $order_invoice->total_shipping_tax_excl;
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
} elseif ($order->hasInvoice()) {
$order_invoices_collection = $order->getInvoicesCollection();
foreach ($order_invoices_collection as $order_invoice) {
if ($order_invoice->total_shipping_tax_incl <= 0) {
continue;
}
$cart_rules[$order_invoice->id]['value_tax_incl'] = $order_invoice->total_shipping_tax_incl;
$cart_rules[$order_invoice->id]['value_tax_excl'] = $order_invoice->total_shipping_tax_excl;
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
} else {
$cart_rules[0]['value_tax_incl'] = $order->total_shipping_tax_incl;
$cart_rules[0]['value_tax_excl'] = $order->total_shipping_tax_excl;
}
break;
default:
$this->errors[] = Tools::displayError('The discount type is invalid.');
}
$res = true;
foreach ($cart_rules as &$cart_rule) {
$cartRuleObj = new CartRule();
$cartRuleObj->date_from = date('Y-m-d H:i:s', strtotime('-1 hour', strtotime($order->date_add)));
$cartRuleObj->date_to = date('Y-m-d H:i:s', strtotime('+1 hour'));
$cartRuleObj->name[Configuration::get('PS_LANG_DEFAULT')] = Tools::getValue('discount_name');
$cartRuleObj->quantity = 0;
$cartRuleObj->quantity_per_user = 1;
if (Tools::getValue('discount_type') == 1) {
$cartRuleObj->reduction_percent = $discount_value;
} elseif (Tools::getValue('discount_type') == 2) {
$cartRuleObj->reduction_amount = $cart_rule['value_tax_excl'];
} elseif (Tools::getValue('discount_type') == 3) {
$cartRuleObj->free_shipping = 1;
}
$cartRuleObj->active = 0;
if ($res = $cartRuleObj->add()) {
$cart_rule['id'] = $cartRuleObj->id;
} else {
break;
}
}
if ($res) {
foreach ($cart_rules as $id_order_invoice => $cart_rule) {
$order_cart_rule = new OrderCartRule();
$order_cart_rule->id_order = $order->id;
$order_cart_rule->id_cart_rule = $cart_rule['id'];
$order_cart_rule->id_order_invoice = $id_order_invoice;
$order_cart_rule->name = Tools::getValue('discount_name');
$order_cart_rule->value = $cart_rule['value_tax_incl'];
$order_cart_rule->value_tax_excl = $cart_rule['value_tax_excl'];
$res &= $order_cart_rule->add();
$order->total_discounts += $order_cart_rule->value;
$order->total_discounts_tax_incl += $order_cart_rule->value;
$order->total_discounts_tax_excl += $order_cart_rule->value_tax_excl;
$order->total_paid -= $order_cart_rule->value;
$order->total_paid_tax_incl -= $order_cart_rule->value;
$order->total_paid_tax_excl -= $order_cart_rule->value_tax_excl;
}
$res &= $order->update();
}
if ($res) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('An error occurred during the OrderCartRule creation');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('sendStateEmail') && Tools::getValue('sendStateEmail') > 0 && Tools::getValue('id_order') > 0) {
if ($this->tabAccess['edit'] == '1') {
$order_state = new OrderState((int) Tools::getValue('sendStateEmail'));
if (!Validate::isLoadedObject($order_state)) {
$this->errors[] = Tools::displayError('An error occurred while loading order status.');
} else {
$history = new OrderHistory((int) Tools::getValue('id_order_history'));
$carrier = new Carrier($order->id_carrier, $order->id_lang);
$templateVars = array();
if ($order_state->id == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number) {
$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));
}
if ($history->sendEmail($order, $templateVars)) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=10&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('An error occurred while sending the e-mail to the customer.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
AdminController::postProcess();
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,808 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class Cart extends CartCore
{
public function getSummaryDetails($id_lang = null, $refresh = false)
{
$summary = $this->getSummaryDetailsInstallment($id_lang, $refresh);
if (!Module::isEnabled('freelivery')) {
return $summary;
}
if (!isset(Context::getContext()->cart)) {
return $summary;
}
$ps_free_price = Tools::convertPrice(Configuration::get('PS_SHIPPING_FREE_PRICE'), Currency::getCurrencyInstance(Context::getContext()->cart->id_currency));
$total = $summary['total_products_wt'];
if ((int) Configuration::get('FREELIVERY_CALCULATION_RULE')) {
$total += $summary['total_discounts'];
}
$ps_remaining = $ps_free_price - $total;
$freelivery_remaining = isset($GLOBALS['freelivery_remaining']) ? $GLOBALS['freelivery_remaining'] : false;
if ($summary['total_shipping'] == 0 || ($total >= $ps_free_price && $ps_free_price > 0)) {
$summary['freelivery_remaining'] = 0;
} elseif ($ps_remaining < $freelivery_remaining && $ps_free_price > 0) {
$summary['freelivery_remaining'] = $ps_remaining;
} else {
$summary['freelivery_remaining'] = (float) $freelivery_remaining;
}
$summary['free_ship'] = $summary['freelivery_remaining'] > 0 ? 0 : 1; // Can't set to true/false because of old 1.6 versions
return $summary;
}
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null)
{
$_GET['id_cart_freelivery'] = $this->id;
return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone);
}
public static function debugBacktraceUrl($start = 0, $limit = null)
{
$backtrace = debug_backtrace();
array_shift($backtrace);
for ($i = 0; $i < $start; ++$i) {
array_shift($backtrace);
}
$data = array();
$i = 0;
foreach ($backtrace as $id => $trace) {
if ((int) $limit && ( ++$i > $limit)) {
break;
}
$relative_file = (isset($trace['file'])) ? 'in /' . ltrim(str_replace(array(_PS_ROOT_DIR_, '\\'), array('', '/'), $trace['file']), '/') : '';
$current_line = (isset($trace['line'])) ? ':' . $trace['line'] : '';
$fileName = ((isset($trace['class'])) ? $trace['class'] : '') . ((isset($trace['type'])) ? $trace['type'] : '') . $trace['function'];
$data[$relative_file] = $fileName;
}
return $data;
}
public function getOrderTotal($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true, $gross = false, $small = false)
{
$address_factory = Adapter_ServiceLocator::get('Adapter_AddressFactory');
$price_calculator = Adapter_ServiceLocator::get('Adapter_ProductPriceCalculator');
$configuration = Adapter_ServiceLocator::get('Core_Business_ConfigurationInterface');
$ps_tax_address_type = $configuration->get('PS_TAX_ADDRESS_TYPE');
$ps_use_ecotax = $configuration->get('PS_USE_ECOTAX');
$ps_round_type = $configuration->get('PS_ROUND_TYPE');
$ps_ecotax_tax_rules_group_id = $configuration->get('PS_ECOTAX_TAX_RULES_GROUP_ID');
$compute_precision = $configuration->get('_PS_PRICE_COMPUTE_PRECISION_');
$backtrace = $this->debug_backtrace_url();
$i = 1;
foreach ($backtrace as $backtracekey => $backtracevalue) {
if ($i == 1 && strpos($backtracekey, '/modules/') !== false && (int) Configuration::get('ACOMPTE_CHOICE') == 1 || $i == 1 && strpos($backtracekey, '/modules/') !== false && isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0) {
$small = true;
}
$i++;
}
if (!$this->id) {
return 0;
}
$type = (int) $type;
$array_type = array(
Cart::ONLY_PRODUCTS,
Cart::ONLY_DISCOUNTS,
Cart::BOTH,
Cart::BOTH_WITHOUT_SHIPPING,
Cart::ONLY_SHIPPING,
Cart::ONLY_WRAPPING,
Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING,
Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING,
);
$virtual_context = Context::getContext()->cloneContext();
$virtual_context->cart = $this;
if (!in_array($type, $array_type)) {
die(Tools::displayError());
}
$with_shipping = in_array($type, array(
Cart::BOTH,
Cart::ONLY_SHIPPING
));
if ($type == Cart::ONLY_DISCOUNTS && !CartRule::isFeatureActive()) {
return 0;
}
$virtual = $this->isVirtualCart();
if ($virtual && $type == Cart::ONLY_SHIPPING) {
return 0;
}
if ($virtual && $type == Cart::BOTH) {
$type = Cart::BOTH_WITHOUT_SHIPPING;
}
if ($with_shipping || $type == Cart::ONLY_DISCOUNTS) {
if (is_null($products) && is_null($id_carrier)) {
$shipping_fees = $this->getTotalShippingCost(null, (bool) $with_taxes);
} else {
$shipping_fees = $this->getPackageShippingCost((int) $id_carrier, (bool) $with_taxes, null, $products);
}
} else {
$shipping_fees = 0;
}
if ($type == Cart::ONLY_SHIPPING) {
return $shipping_fees;
}
if ($type == Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING) {
$type = Cart::ONLY_PRODUCTS;
}
$param_product = true;
if (is_null($products)) {
$param_product = false;
$products = $this->getProducts();
}
if ($type == Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING) {
foreach ($products as $key => $product) {
if ($product['is_virtual']) {
unset($products[$key]);
}
}
$type = Cart::ONLY_PRODUCTS;
}
$order_total = 0;
if (Tax::excludeTaxeOption()) {
$with_taxes = false;
}
$products_total = array();
$ecotax_total = 0;
foreach ($products as $product) {
if ($virtual_context->shop->id != $product['id_shop']) {
$virtual_context->shop = new Shop((int) $product['id_shop']);
}
if ($ps_tax_address_type == 'id_address_invoice') {
$id_address = (int) $this->id_address_invoice;
} else {
$id_address = (int) $product['id_address_delivery'];
} // Get delivery address of the product from the cart
if (!$address_factory->addressExists($id_address)) {
$id_address = null;
}
$null = null;
$price = $price_calculator->getProductPrice((int) $product['id_product'], $with_taxes, (int) $product['id_product_attribute'], 6, null, false, true, $product['cart_quantity'], false, (int) $this->id_customer ? (int) $this->id_customer : null, (int) $this->id, $id_address, $null, $ps_use_ecotax, true, $virtual_context);
$address = $address_factory->findOrCreate($id_address, true);
if ($with_taxes) {
$id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $product['id_product'], $virtual_context);
$tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
} else {
$id_tax_rules_group = 0;
}
if (in_array($ps_round_type, array(
Order::ROUND_ITEM,
Order::ROUND_LINE
))) {
if (!isset($products_total[$id_tax_rules_group])) {
$products_total[$id_tax_rules_group] = 0;
}
} elseif (!isset($products_total[$id_tax_rules_group . '_' . $id_address])) {
$products_total[$id_tax_rules_group . '_' . $id_address] = 0;
}
switch ($ps_round_type) {
case Order::ROUND_TOTAL:
$products_total[$id_tax_rules_group . '_' . $id_address] += $price * (int) $product['cart_quantity'];
break;
case Order::ROUND_LINE:
$product_price = $price * $product['cart_quantity'];
$products_total[$id_tax_rules_group] += Tools::ps_round($product_price, $compute_precision);
break;
case Order::ROUND_ITEM:
default:
$product_price = $price;
$products_total[$id_tax_rules_group] += Tools::ps_round($product_price, $compute_precision) * (int) $product['cart_quantity'];
break;
}
}
foreach ($products_total as $key => $price) {
$order_total += $price;
}
$order_total_products = $order_total;
if ($type == Cart::ONLY_DISCOUNTS) {
$order_total = 0;
}
$wrapping_fees = 0;
$include_gift_wrapping = (!$configuration->get('PS_ATCP_SHIPWRAP') || $type !== Cart::ONLY_PRODUCTS);
if ($this->gift && $include_gift_wrapping) {
$wrapping_fees = Tools::convertPrice(Tools::ps_round($this->getGiftWrappingPrice($with_taxes), $compute_precision), Currency::getCurrencyInstance((int) $this->id_currency));
}
if ($type == Cart::ONLY_WRAPPING) {
return $wrapping_fees;
}
$order_total_discount = 0;
$order_shipping_discount = 0;
if (!in_array($type, array(
Cart::ONLY_SHIPPING,
Cart::ONLY_PRODUCTS
)) && CartRule::isFeatureActive()) {
if ($with_shipping || $type == Cart::ONLY_DISCOUNTS) {
$cart_rules = $this->getCartRules(CartRule::FILTER_ACTION_ALL);
} else {
$cart_rules = $this->getCartRules(CartRule::FILTER_ACTION_REDUCTION);
foreach ($this->getCartRules(CartRule::FILTER_ACTION_GIFT) as $tmp_cart_rule) {
$flag = false;
foreach ($cart_rules as $cart_rule) {
if ($tmp_cart_rule['id_cart_rule'] == $cart_rule['id_cart_rule']) {
$flag = true;
}
}
if (!$flag) {
$cart_rules[] = $tmp_cart_rule;
}
}
}
$id_address_delivery = 0;
if (isset($products[0])) {
$id_address_delivery = (is_null($products) ? $this->id_address_delivery : $products[0]['id_address_delivery']);
}
$package = array(
'id_carrier' => $id_carrier,
'id_address' => $id_address_delivery,
'products' => $products
);
$flag = false;
foreach ($cart_rules as $cart_rule) {
if (($with_shipping || $type == Cart::ONLY_DISCOUNTS) && $cart_rule['obj']->free_shipping && !$flag) {
$order_shipping_discount = (float) Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_SHIPPING, ($param_product ? $package : null), $use_cache), $compute_precision);
$flag = true;
}
if ((int) $cart_rule['obj']->gift_product) {
$in_order = false;
if (is_null($products)) {
$in_order = true;
} else {
foreach ($products as $product) {
if ($cart_rule['obj']->gift_product == $product['id_product'] && $cart_rule['obj']->gift_product_attribute == $product['id_product_attribute']) {
$in_order = true;
}
}
}
if ($in_order) {
$order_total_discount += $cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_GIFT, $package, $use_cache);
}
}
if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0) {
$order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package, $use_cache), $compute_precision);
}
}
$order_total_discount = min(Tools::ps_round($order_total_discount, 2), (float) $order_total_products) + (float) $order_shipping_discount;
$order_total -= $order_total_discount;
}
if ($type == Cart::BOTH) {
$order_total += $shipping_fees + $wrapping_fees;
}
if ($order_total < 0 && $type != Cart::ONLY_DISCOUNTS) {
return 0;
}
if ($type == Cart::ONLY_DISCOUNTS) {
return $order_total_discount;
}
$page_name = Dispatcher::getInstance()->getController();
$pages_name = array();
$controllers = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
foreach ($controllers as $key => $value) {
if ($key != 'orderconfirmation' && $key != 'pagenotfound') {
$pages_name[] = $key;
}
}
$groups = Db::getInstance()->executeS('SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group WHERE id_customer = ' . (int) Context::getContext()->customer->id);
$groupIdsTakenFromDb = Configuration::get('ACOMPTE_GROUP');
$selectedgroups = @unserialize($groupIdsTakenFromDb);
if ($selectedgroups === false && $selectedgroups !== 'b:0;') {
$selectedgroups = array();
}
$group_accepted = false;
foreach ($groups as $group) {
if (in_array($group['id_group'], $selectedgroups)) {
$group_accepted = true;
break;
}
}
$categoryIdsTakenFromDb = Configuration::get('ACOMPTE_CATS');
$selectedcategories = @unserialize($categoryIdsTakenFromDb);
if ($selectedcategories === false && $selectedcategories !== 'b:0;') {
$selectedcategories = array();
}
if ($group_accepted && ($type == Cart::BOTH || ($virtual && $type == Cart::BOTH_WITHOUT_SHIPPING)) && ((float) Configuration::get('ACOMPTE_MIN_AMOUNT') == 0 || $order_total > (float) Configuration::get('ACOMPTE_MIN_AMOUNT'))) {
$pre_commande = true;
if (!is_array($selectedcategories) || empty($selectedcategories)) {
$pre_commande = false;
}
if (is_array($this->_products) && !empty($this->_products)) {
foreach ($this->_products as $product) {
if (!in_array((int) $product['id_category_default'], $selectedcategories)) {
$pre_commande = false;
break;
}
}
}
if ($pre_commande && ((isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0) || (int) Configuration::get('ACOMPTE_CHOICE') == 1 || $page_name == 'installmentpayment')) {
if (((!in_array($page_name, $pages_name) || (($page_name == 'order' && Tools::getValue('step') == 3) || $page_name == 'order-opc')) && !$gross) || $small) {
if ((int) Configuration::get('ACOMPTE_TOTALTYPE') != 0 || (int) Configuration::get('ACOMPTE_SHIPPING') != 0) {
$order_total = 0;
if ((int) Configuration::get('ACOMPTE_TOTALTYPE') == 0) {
foreach ($products_total as $key => $price) {
if (Configuration::get('PS_ROUND_TYPE') == Order::ROUND_TOTAL) {
$tmp = explode('_', $key);
$address = Address::initialize((int) $tmp[1], true);
$tax_calculator = TaxManagerFactory::getManager($address, $tmp[0])->getTaxCalculator();
$order_total += Tools::ps_round($price + $tax_calculator->getTaxesTotalAmount($price), _PS_PRICE_COMPUTE_PRECISION_);
} else {
$order_total += $price;
}
}
} else {
foreach ($products as $product) { // products refer to the cart details
if ($virtual_context->shop->id != $product['id_shop']) {
$virtual_context->shop = new Shop((int) $product['id_shop']);
}
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
$id_address = (int) $this->id_address_invoice;
} else {
$id_address = (int) $product['id_address_delivery']; // Get delivery address of the product from the cart
}
if (!Address::addressExists($id_address)) {
$id_address = null;
}
$specific_price_output = null;
$price = Product::getPriceStatic((int) $product['id_product'], false, (int) $product['id_product_attribute'], 6, null, false, true, $product['cart_quantity'], false, (int) $this->id_customer ? (int) $this->id_customer : null, (int) $this->id, $id_address, $specific_price_output, false, true, $virtual_context);
$order_total += $price * $product['cart_quantity'];
}
}
if ((int) Configuration::get('ACOMPTE_SHIPPING') == 0) {
$order_total += $shipping_fees + $wrapping_fees;
}
} //else
$id_defaultgroup = Db::getInstance()->executeS('SELECT id_default_group FROM ' . _DB_PREFIX_ . 'customer WHERE id_customer = ' . (int) Context::getContext()->customer->id);
if(is_array($id_defaultgroup))
{
$id_defaultgroup = $id_defaultgroup[0]['id_default_group'];
}
$sql = 'SELECT price FROM `' . _DB_PREFIX_ . 'installmentpayment_group` WHERE id_group=' . (int) $id_defaultgroup;
$data = Db::getInstance()->getRow($sql);
if(!empty($data)){
$order_total = $order_total - ($order_total * (100 - $data['price']) / 100);
}
else
{
if ((int) Configuration::get('ACOMPTE_TYPE') == 1) {
if ($order_total > (float) Configuration::get('ACOMPTE_PERCENTAGE')) {
$order_total = (float) Configuration::get('ACOMPTE_PERCENTAGE');
}
} else {
$order_total = $order_total - ($order_total * (100 - Configuration::get('ACOMPTE_PERCENTAGE')) / 100);
}
}
}
if ($page_name == 'installmentpayment' || (isset(Context::getContext()->cookie->installmentpayment_id_order) && !empty(Context::getContext()->cookie->installmentpayment_id_order))) {
if (Tools::getValue('select') != '') {
Context::getContext()->cookie->__set('installmentpayment_id_order', (int) Tools::getValue('select'));
}
$order = new Order((int) Context::getContext()->cookie->installmentpayment_id_order);
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$rest_paid = $installment['rest'];
$order_total = $rest_paid;
}
}
}
}
return Tools::ps_round((float) $order_total, _PS_PRICE_COMPUTE_PRECISION_);
}
public function getOrderTotalGross($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true, $small = false)
{
return $this->getOrderTotal($with_taxes, $type, $products, $id_carrier, $use_cache, true);
}
public function getOrderTotalSmall($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true, $small = true)
{
return $this->getOrderTotal($with_taxes, $type, $products, $id_carrier, $use_cache, true, true);
}
public function getSummaryDetailsInstallment($id_lang = null, $refresh = false)
{
$context = Context::getContext();
if (!$id_lang) {
$id_lang = $context->language->id;
}
$delivery = new Address((int) $this->id_address_delivery);
$invoice = new Address((int) $this->id_address_invoice);
$formatted_addresses = array(
'delivery' => AddressFormat::getFormattedLayoutData($delivery),
'invoice' => AddressFormat::getFormattedLayoutData($invoice)
);
$base_total_tax_inc = $this->getOrderTotalGross(true);
$base_total_tax_exc = $this->getOrderTotalGross(false);
$total_tax = $base_total_tax_inc - $base_total_tax_exc;
if ($total_tax < 0) {
$total_tax = 0;
}
$currency = new Currency($this->id_currency);
$products = $this->getProducts($refresh);
$gift_products = array();
$cart_rules = $this->getCartRules();
$total_shipping = $this->getTotalShippingCost();
$total_shipping_tax_exc = $this->getTotalShippingCost(null, false);
$total_products_wt = $this->getOrderTotalGross(true, Cart::ONLY_PRODUCTS);
$total_products = $this->getOrderTotalGross(false, Cart::ONLY_PRODUCTS);
$total_discounts = $this->getOrderTotalGross(true, Cart::ONLY_DISCOUNTS);
$total_discounts_tax_exc = $this->getOrderTotalGross(false, Cart::ONLY_DISCOUNTS);
foreach ($cart_rules as & $cart_rule) {
if ($cart_rule['free_shipping'] && (empty($cart_rule['code']) || preg_match('/^' . CartRule::BO_ORDER_CODE_PREFIX . '[0-9]+/', $cart_rule['code']))) {
$cart_rule['value_real'] -= $total_shipping;
$cart_rule['value_tax_exc'] -= $total_shipping_tax_exc;
$cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$cart_rule['value_tax_exc'] = Tools::ps_round($cart_rule['value_tax_exc'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
if ($total_discounts > $cart_rule['value_real']) {
$total_discounts -= $total_shipping;
}
if ($total_discounts_tax_exc > $cart_rule['value_tax_exc']) {
$total_discounts_tax_exc -= $total_shipping_tax_exc;
}
$total_shipping = 0;
$total_shipping_tax_exc = 0;
}
if ($cart_rule['gift_product']) {
foreach ($products as $key => & $product) {
if (empty($product['gift']) && $product['id_product'] == $cart_rule['gift_product'] && $product['id_product_attribute'] == $cart_rule['gift_product_attribute']) {
$total_products_wt = Tools::ps_round($total_products_wt - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$total_products = Tools::ps_round($total_products - $product['price'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$total_discounts = Tools::ps_round($total_discounts - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$total_discounts_tax_exc = Tools::ps_round($total_discounts_tax_exc - $product['price'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'] - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$cart_rule['value_tax_exc'] = Tools::ps_round($cart_rule['value_tax_exc'] - $product['price'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$product['total_wt'] = Tools::ps_round($product['total_wt'] - $product['price_wt'], (int) $currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$product['total'] = Tools::ps_round($product['total'] - $product['price'], (int) $currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$product['cart_quantity'] --;
if (!$product['cart_quantity']) {
unset($products[$key]);
}
$gift_product = $product;
$gift_product['cart_quantity'] = 1;
$gift_product['price'] = 0;
$gift_product['price_wt'] = 0;
$gift_product['total_wt'] = 0;
$gift_product['total'] = 0;
$gift_product['gift'] = true;
$gift_products[] = $gift_product;
break; // One gift product per cart rule
}
}
}
}
foreach ($cart_rules as $key => & $cart_rule) {
if ((float) $cart_rule['value_real'] == 0 && (int) $cart_rule['free_shipping'] == 0) {
unset($cart_rules[$key]);
}
}
return array(
'delivery' => $delivery,
'delivery_state' => State::getNameById($delivery->id_state),
'invoice' => $invoice,
'invoice_state' => State::getNameById($invoice->id_state),
'formattedAddresses' => $formatted_addresses,
'products' => array_values($products),
'gift_products' => $gift_products,
'discounts' => array_values($cart_rules),
'is_virtual_cart' => (int) $this->isVirtualCart(),
'total_discounts' => $total_discounts,
'total_discounts_tax_exc' => $total_discounts_tax_exc,
'total_wrapping' => $this->getOrderTotalGross(true, Cart::ONLY_WRAPPING),
'total_wrapping_tax_exc' => $this->getOrderTotalGross(false, Cart::ONLY_WRAPPING),
'total_shipping' => $total_shipping,
'total_shipping_tax_exc' => $total_shipping_tax_exc,
'total_products_wt' => $total_products_wt,
'total_products' => $total_products,
'total_price' => $base_total_tax_inc,
'total_tax' => $total_tax,
'total_price_without_tax' => $base_total_tax_exc,
'is_multi_address_delivery' => $this->isMultiAddressDelivery() || ((int) Tools::getValue('multi-shipping') == 1),
'free_ship' => $total_shipping ? 0 : 1,
'carrier' => new Carrier($this->id_carrier, $id_lang),
);
}
public function getProducts($refresh = false, $id_product = false, $id_country = null)
{
if (Dispatcher::getInstance()->getController() != "pagenotfound" || strpos($_SERVER['REQUEST_URI'], '/modules/paypal') === false) {
return parent::getProducts();
}
if (!$this->id) {
return array();
}
if ($this->_products !== null && !$refresh) {
if (is_int($id_product)) {
foreach ($this->_products as $product) {
if ($product['id_product'] == $id_product) {
return array(
$product
);
}
}
return array();
}
return $this->_products;
}
$sql = new DbQuery();
$sql->select('cp.`id_product_attribute`, cp.`id_product`, cp.`quantity` AS cart_quantity, cp.id_shop, pl.`name`, p.`is_virtual`,
pl.`description_short`, pl.`available_now`, pl.`available_later`, product_shop.`id_category_default`, p.`id_supplier`,
p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`,
product_shop.`available_for_order`, product_shop.`price`, product_shop.`active`, product_shop.`unity`, product_shop.`unit_price_ratio`,
stock.`quantity` AS quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, p.`weight`,
p.`date_add`, p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category,
CONCAT(LPAD(cp.`id_product`, 10, 0), LPAD(IFNULL(cp.`id_product_attribute`, 0), 10, 0), IFNULL(cp.`id_address_delivery`, 0)) AS unique_id, cp.id_address_delivery,
product_shop.advanced_stock_management, ps.product_supplier_reference supplier_reference, IFNULL(sp.`reduction_type`, 0) AS reduction_type');
$sql->from('cart_product', 'cp');
$sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');
$sql->innerJoin('product_shop', 'product_shop', '(product_shop.`id_shop` = cp.`id_shop` AND product_shop.`id_product` = p.`id_product`)');
$sql->leftJoin('product_lang', 'pl', '
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $this->id_lang . Shop::addSqlRestrictionOnLang('pl', 'cp.id_shop'));
$sql->leftJoin('category_lang', 'cl', '
product_shop.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = ' . (int) $this->id_lang . Shop::addSqlRestrictionOnLang('cl', 'cp.id_shop'));
$sql->leftJoin('product_supplier', 'ps', 'ps.`id_product` = cp.`id_product` AND ps.`id_product_attribute` = cp.`id_product_attribute` AND ps.`id_supplier` = p.`id_supplier`');
$sql->leftJoin('specific_price', 'sp', 'sp.`id_product` = cp.`id_product`'); // AND 'sp.`id_shop` = cp.`id_shop`
$sql->join(Product::sqlStock('cp', 'cp'));
$sql->where('cp.`id_cart` = ' . (int) $this->id);
if ($id_product) {
$sql->where('cp.`id_product` = ' . (int) $id_product);
}
$sql->where('p.`id_product` IS NOT NULL');
$sql->groupBy('unique_id');
$sql->orderBy('cp.`date_add`, p.`id_product`, cp.`id_product_attribute` ASC');
if (Customization::isFeatureActive()) {
$sql->select('cu.`id_customization`, cu.`quantity` AS customization_quantity');
$sql->leftJoin('customization', 'cu', 'p.`id_product` = cu.`id_product` AND cp.`id_product_attribute` = cu.`id_product_attribute` AND cu.`id_cart` = ' . (int) $this->id);
} else {
$sql->select('NULL AS customization_quantity, NULL AS id_customization');
}
if (Combination::isFeatureActive()) {
$sql->select('
product_attribute_shop.`price` AS price_attribute, product_attribute_shop.`ecotax` AS ecotax_attr,
IF (IFNULL(pa.`reference`, \'\') = \'\', p.`reference`, pa.`reference`) AS reference,
(p.`weight`+ pa.`weight`) weight_attribute,
IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13,
IF (IFNULL(pa.`upc`, \'\') = \'\', p.`upc`, pa.`upc`) AS upc,
pai.`id_image` as pai_id_image, il.`legend` as pai_legend,
IFNULL(product_attribute_shop.`minimal_quantity`, product_shop.`minimal_quantity`) as minimal_quantity,
IF(product_attribute_shop.wholesale_price > 0, product_attribute_shop.wholesale_price, product_shop.`wholesale_price`) wholesale_price
');
$sql->leftJoin('product_attribute', 'pa', 'pa.`id_product_attribute` = cp.`id_product_attribute`');
$sql->leftJoin('product_attribute_shop', 'product_attribute_shop', '(product_attribute_shop.`id_shop` = cp.`id_shop` AND product_attribute_shop.`id_product_attribute` = pa.`id_product_attribute`)');
$sql->leftJoin('product_attribute_image', 'pai', 'pai.`id_product_attribute` = pa.`id_product_attribute`');
$sql->leftJoin('image_lang', 'il', 'il.`id_image` = pai.`id_image` AND il.`id_lang` = ' . (int) $this->id_lang);
} else {
$sql->select('p.`reference` AS reference, p.`ean13`,
p.`upc` AS upc, product_shop.`minimal_quantity` AS minimal_quantity, product_shop.`wholesale_price` wholesale_price');
}
$result = Db::getInstance()->executeS($sql);
$products_ids = array();
$pa_ids = array();
if ($result) {
foreach ($result as $row) {
$products_ids[] = $row['id_product'];
$pa_ids[] = $row['id_product_attribute'];
}
}
Product::cacheProductsFeatures($products_ids);
Cart::cacheSomeAttributesLists($pa_ids, $this->id_lang);
$this->_products = array();
if (empty($result)) {
return array();
}
$cart_shop_context = Context::getContext()->cloneContext();
foreach ($result as & $row) {
if (isset($row['ecotax_attr']) && $row['ecotax_attr'] > 0) {
$row['ecotax'] = (float) $row['ecotax_attr'];
}
$row['stock_quantity'] = (int) $row['quantity'];
$row['quantity'] = (int) $row['cart_quantity'];
if (isset($row['id_product_attribute']) && (int) $row['id_product_attribute'] && isset($row['weight_attribute'])) {
$row['weight'] = (float) $row['weight_attribute'];
}
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
$address_id = (int) $this->id_address_invoice;
} else {
$address_id = (int) $row['id_address_delivery'];
}
if (!Address::addressExists($address_id)) {
$address_id = null;
}
if ($cart_shop_context->shop->id != $row['id_shop']) {
$cart_shop_context->shop = new Shop((int) $row['id_shop']);
}
$address = Address::initialize($address_id, true);
$id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $row['id_product'], $cart_shop_context);
$tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
if (!Tools::getIsset('specific_price_output')) {
$specific_price_output = array();
}
$row['price'] = Product::getPriceStatic((int) $row['id_product'], false, isset($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null, 6, null, false, true, $row['cart_quantity'], false, (int) $this->id_customer ? (int) $this->id_customer : null, (int) $this->id, $address_id, $specific_price_output, false, true, $cart_shop_context);
switch (Configuration::get('PS_ROUND_TYPE')) {
case Order::ROUND_TOTAL:
$row['total'] = $row['price'] * (int) $row['cart_quantity'];
$row['total_wt'] = $tax_calculator->addTaxes($row['price']) * (int) $row['cart_quantity'];
break;
case Order::ROUND_LINE:
$row['total'] = Tools::ps_round($row['price'] * (int) $row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
$row['total_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['price']) * (int) $row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
break;
case Order::ROUND_ITEM:
default:
$row['total'] = Tools::ps_round($row['price'], _PS_PRICE_COMPUTE_PRECISION_) * (int) $row['cart_quantity'];
$row['total_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['price']), _PS_PRICE_COMPUTE_PRECISION_) * (int) $row['cart_quantity'];
break;
}
$row['price_wt'] = $tax_calculator->addTaxes($row['price']);
$row['description_short'] = Tools::nl2br($row['description_short']);
if (!isset($row['pai_id_image']) || $row['pai_id_image'] == 0) {
$cache_id = 'Cart::getProducts_' . '-pai_id_image-' . (int) $row['id_product'] . '-' . (int) $this->id_lang . '-' . (int) $row['id_shop'];
if (!Cache::isStored($cache_id)) {
$row2 = Db::getInstance()->getRow('
SELECT image_shop.`id_image` id_image, il.`legend`
FROM `' . _DB_PREFIX_ . 'image` i
JOIN `' . _DB_PREFIX_ . 'image_shop` image_shop ON (i.id_image = image_shop.id_image AND image_shop.cover=1 AND image_shop.id_shop=' . (int) $row['id_shop'] . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $this->id_lang . ')
WHERE i.`id_product` = ' . (int) $row['id_product'] . ' AND image_shop.`cover` = 1');
Cache::store($cache_id, $row2);
}
$row2 = Cache::retrieve($cache_id);
if (!$row2) {
$row2 = array(
'id_image' => false,
'legend' => false
);
} else {
$row = array_merge($row, $row2);
}
} else {
$row['id_image'] = $row['pai_id_image'];
$row['legend'] = $row['pai_legend'];
}
$row['reduction_applies'] = ($specific_price_output && (float) $specific_price_output['reduction']);
$row['quantity_discount_applies'] = ($specific_price_output && $row['cart_quantity'] >= (int) $specific_price_output['from_quantity']);
$row['id_image'] = Product::defineProductImage($row, $this->id_lang);
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
$row['features'] = Product::getFeaturesStatic((int) $row['id_product']);
if (array_key_exists($row['id_product_attribute'] . '-' . $this->id_lang, self::$_attributesLists)) {
$row = array_merge($row, self::$_attributesLists[$row['id_product_attribute'] . '-' . $this->id_lang]);
}
$row = Product::getTaxesInformations($row, $cart_shop_context);
$this->_products[] = $row;
}
$categoryIdsTakenFromDb = Configuration::get('ACOMPTE_CATS');
$selectedcategories = @unserialize($categoryIdsTakenFromDb);
if ($selectedcategories === false && $selectedcategories !== 'b:0;') {
$selectedcategories = array();
}
$pre_commande = true;
if (!is_array($selectedcategories) || empty($selectedcategories)) {
$pre_commande = false;
}
if (is_array($this->_products) && count($this->_products) > 0) {
foreach ($this->_products as $product) {
if (!in_array((int) $product['id_category_default'], $selectedcategories)) {
$pre_commande = false;
break;
}
}
}
if (!$pre_commande) {
return parent::getProducts();
}
$price_wt = $this->getOrderTotal(true);
$this->_products = array();
$row['cart_quantity'] = 1;
$row['price_wt'] = $price_wt;
$row['name'] = 'Acompte';
$row['attributes'] = '';
$row['id_product1'] = '';
$id_defaultgroup = Db::getInstance()->executeS('SELECT id_default_group FROM ' . _DB_PREFIX_ . 'customer WHERE id_customer = ' . (int) Context::getContext()->customer->id);
if(is_array($id_defaultgroup))
{
$id_defaultgroup = $id_defaultgroup[0]['id_default_group'];
}
$sql = 'SELECT price FROM `' . _DB_PREFIX_ . 'installmentpayment_group` WHERE id_group=' . (int) $id_defaultgroup;
$data = Db::getInstance()->getRow($sql);
if(!empty($data)){
$row['description_short'] = "Pourcentage " . $data['price'] . '%';
}
else
{
if ((int) Configuration::get('ACOMPTE_TYPE') == 1) {
if ($order_total > (float) Configuration::get('ACOMPTE_PERCENTAGE')) {
$row['description_short'] = "Acompte " . Configuration::get('ACOMPTE_PERCENTAGE');
}
} else {
$row['description_short'] = "Pourcentage " . Configuration::get('ACOMPTE_PERCENTAGE') . '%';
}
}
$this->_products[] = $row;
return $this->_products;
}
public function getTotalShippingCost($delivery_option = null, $use_tax = true, Country $default_country = null)
{
if (Dispatcher::getInstance()->getController() != "pagenotfound") {
return parent::getTotalShippingCost($delivery_option, $use_tax, $default_country);
}
return 0;
}
}

View File

@@ -0,0 +1,132 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class Hook extends HookCore
{
public static function getHookModuleExecList($hook_name = null)
{
$context = Context::getContext();
$cache_id = 'hook_module_exec_list_' . (isset($context->shop->id) ? '_' . $context->shop->id : '') . ((isset($context->customer)) ? '_' . $context->customer->id : '');
if (!Cache::isStored($cache_id) || $hook_name == 'displayPayment' || $hook_name == 'displayBackOfficeHeader') {
$frontend = true;
$groups = array();
$use_groups = Group::isFeatureActive();
if (isset($context->employee)) {
$frontend = false;
} else {
if ($use_groups) {
if (isset($context->customer) && $context->customer->isLogged()) {
$groups = $context->customer->getGroups();
} elseif (isset($context->customer) && $context->customer->isLogged(true)) {
$groups = array((int) Configuration::get('PS_GUEST_GROUP'));
} else {
$groups = array((int) Configuration::get('PS_UNIDENTIFIED_GROUP'));
}
}
}
$sql = new DbQuery();
$sql->select('h.`name` as hook, m.`id_module`, h.`id_hook`, m.`name` as module, h.`live_edit`');
$sql->from('module', 'm');
if ($hook_name != 'displayBackOfficeHeader') {
$sql->join(Shop::addSqlAssociation('module', 'm', true, 'module_shop.enable_device & ' . (int) Context::getContext()->getDevice()));
$sql->innerJoin('module_shop', 'ms', 'ms.`id_module` = m.`id_module`');
}
$sql->innerJoin('hook_module', 'hm', 'hm.`id_module` = m.`id_module`');
$sql->innerJoin('hook', 'h', 'hm.`id_hook` = h.`id_hook`');
if ($hook_name != 'displayPayment') {
$sql->where('h.name != "displayPayment"');
} elseif ($frontend) {
if (Validate::isLoadedObject($context->country)) {
$sql->where('(h.name = "displayPayment" AND (SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country mc WHERE mc.id_module = m.id_module AND id_country = ' . (int) $context->country->id . ' AND id_shop = ' . (int) $context->shop->id . ' LIMIT 1) = ' . (int) $context->country->id . ')');
}
if (Validate::isLoadedObject($context->currency)) {
$sql->where('(h.name = "displayPayment" AND (SELECT id_currency FROM ' . _DB_PREFIX_ . 'module_currency mcr WHERE mcr.id_module = m.id_module AND id_currency IN (' . (int) $context->currency->id . ', -1, -2) LIMIT 1) IN (' . (int) $context->currency->id . ', -1, -2))');
}
}
if (Validate::isLoadedObject($context->shop)) {
$sql->where('hm.id_shop = ' . (int) $context->shop->id);
}
if ($frontend) {
if ($use_groups) {
$sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`');
if (Validate::isLoadedObject($context->shop)) {
$sql->where('mg.id_shop = ' . ((int) $context->shop->id) . (count($groups) ? ' AND mg.`id_group` IN (' . implode(', ', $groups) . ')' : ''));
} elseif (count($groups)) {
$sql->where('mg.`id_group` IN (' . implode(', ', $groups) . ')');
}
}
}
$sql->groupBy('hm.id_hook, hm.id_module');
$sql->orderBy('hm.`position`');
$list = array();
if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql)) {
foreach ($result as $row) {
$enable = true;
if (Db::getInstance()->getValue('SELECT `id_hook` FROM `' . _DB_PREFIX_ . 'hook` WHERE `id_hook` = ' . (int) $row['id_hook'] . ' AND `name` = \'displayPayment\'')) {
if (isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0) {
$paymentIdsTakenFromDb = Configuration::get('ACOMPTE_PAYMENT');
$selectedpayments = @unserialize($paymentIdsTakenFromDb);
if ($selectedpayments === false && $selectedpayments !== 'b:0;') {
$selectedpayments = array();
}
if (!empty($selectedpayments)) {
if (!in_array($row['id_module'], $selectedpayments)) {
$enable = false;
}
}
}
}
if ($enable) {
$row['hook'] = Tools::strtolower($row['hook']);
if (!isset($list[$row['hook']])) {
$list[$row['hook']] = array();
}
$list[$row['hook']][] = array(
'id_hook' => $row['id_hook'],
'module' => $row['module'],
'id_module' => $row['id_module'],
'live_edit' => $row['live_edit'],
);
}
}
}
if ($hook_name != 'displayPayment' && $hook_name != 'displayBackOfficeHeader') {
Cache::store($cache_id, $list);
self::$_hook_modules_cache_exec = $list;
}
} else {
$list = Cache::retrieve($cache_id);
}
if ($hook_name) {
$retro_hook_name = Tools::strtolower(Hook::getRetroHookName($hook_name));
$hook_name = Tools::strtolower($hook_name);
$return = array();
$inserted_modules = array();
if (isset($list[$hook_name])) {
$return = $list[$hook_name];
}
foreach ($return as $module) {
$inserted_modules[] = $module['id_module'];
}
if (isset($list[$retro_hook_name])) {
foreach ($list[$retro_hook_name] as $retro_module_call) {
if (!in_array($retro_module_call['id_module'], $inserted_modules)) {
$return[] = $retro_module_call;
}
}
}
return (count($return) > 0 ? $return : false);
} else {
return $list;
}
}
}

View File

@@ -0,0 +1,665 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
abstract class PaymentModule extends PaymentModuleCore
{
/**
* Validate an order in database
* Function called from a payment module
*
* @param int $id_cart
* @param int $id_order_state
* @param float $amount_paid Amount really paid by customer (in the default currency)
* @param string $payment_method Payment method (eg. 'Credit card')
* @param null $message Message to attach to order
* @param array $extra_vars
* @param null $currency_special
* @param bool $dont_touch_amount
* @param bool $secure_key
* @param Shop $shop
*
* @return bool
* @throws PrestaShopException
*/
public function validateOrder(
$id_cart,
$id_order_state,
$amount_paid,
$payment_method = 'Unknown',
$message = null,
$extra_vars = array(),
$currency_special = null,
$dont_touch_amount = false,
$secure_key = false,
Shop $shop = null
) {
if (isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0 && (int) Configuration::get('ACOMPTE_STATUSES') > 0) {
$id_order_state = (int) Configuration::get('ACOMPTE_STATUSES');
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
}
if (!isset($this->context)) {
$this->context = Context::getContext();
}
$this->context->cart = new Cart($id_cart);
$this->context->customer = new Customer($this->context->cart->id_customer);
$this->context->cart->setTaxCalculationMethod();
$this->context->language = new Language($this->context->cart->id_lang);
$this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop));
ShopUrl::resetMainDomainCache();
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$context_country = $this->context->country;
}
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
if (!Validate::isLoadedObject($order_status)) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t load Order status');
}
if (!$this->active) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
die(Tools::displayError());
}
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
die(Tools::displayError());
}
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
$package_list = $this->context->cart->getPackageList();
$cart_delivery_option = $this->context->cart->getDeliveryOption();
foreach ($delivery_option_list as $id_address => $package) {
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
foreach ($package as $key => $val) {
$cart_delivery_option[$id_address] = $key;
break;
}
}
}
$order_list = array();
$order_detail_list = array();
do {
$reference = Order::generateReference();
} while (Order::getByReference($reference)->count());
$this->currentOrderReference = $reference;
$order_creation_failed = false;
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
foreach ($cart_delivery_option as $id_address => $key_carriers) {
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
foreach ($data['package_list'] as $id_package) {
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
}
}
}
CartRule::cleanCache();
$cart_rules = $this->context->cart->getCartRules();
foreach ($cart_rules as $cart_rule) {
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
if ($error = $rule->checkValidity($this->context, true, true)) {
$this->context->cart->removeCartRule((int) $rule->id);
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
}
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
} else {
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
$error = Tools::displayError(sprintf('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart', (int) $rule->id, $rule_name));
}
}
}
}
foreach ($package_list as $id_address => $packageByAddress) {
foreach ($packageByAddress as $id_package => $package) {
if (isset(Context::getContext()->cookie->installmentpayment_id_order) && !empty(Context::getContext()->cookie->installmentpayment_id_order)) {
$installmentpayment_id_order = Context::getContext()->cookie->installmentpayment_id_order;
$order = new Order($installmentpayment_id_order);
$payment_method = Module::getInstanceByName($this->name);
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$rest_paid = $installment['rest'];
$this->currentOrder = (int) $installmentpayment_id_order;
}
$payment = new OrderPayment();
$payment->order_reference = Tools::substr($order->reference, 0, 9);
$payment->id_currency = $order->id_currency;
$payment->amount = $rest_paid;
if ($order->total_paid != 0) {
$payment->payment_method = $payment_method->displayName;
} else {
$payment->payment_method = null;
}
$payment->conversion_rate = 1;
if (isset($extra_vars['transaction_id'])) {
$transaction_id = $extra_vars['transaction_id'];
} else {
$transaction_id = null;
}
$payment->transaction_id = $transaction_id;
$payment->save();
$id_order_invoice = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_order_invoice`
FROM `' . _DB_PREFIX_ . 'order_invoice`
WHERE number = ' . (int) $order->invoice_number);
$res = Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order`)
VALUES(' . (int) $id_order_invoice . ', ' . (int) $payment->id . ', ' . (int) $installmentpayment_id_order . ')');
$total = $order->total_paid;
$acompte = $total;
$id_cart = $order->id_cart;
$rest = 0;
$data_insert = array(
'id_cart' => (int) $id_cart,
'total' => (float) $total,
'payer' => (float) $acompte,
'rest' => $rest,
'state' => 0,
);
Db::getInstance()->update('installmentpayment', $data_insert, 'id_cart=' . (int) $id_cart);
return true;
} else {
$order = new Order();
}
$order->product_list = $package['product_list'];
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$address = new Address($id_address);
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
if (!$this->context->country->active) {
throw new PrestaShopException('The delivery address country is not active.');
}
}
$carrier = null;
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
$order->id_carrier = (int) $carrier->id;
$id_carrier = (int) $carrier->id;
} else {
$order->id_carrier = 0;
$id_carrier = 0;
}
$order->id_customer = (int) $this->context->cart->id_customer;
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
$order->id_address_delivery = (int) $id_address;
$order->id_currency = (int) $this->context->currency->id;
$order->id_lang = (int) $this->context->cart->id_lang;
$order->id_cart = (int) $this->context->cart->id;
$order->reference = $reference;
$order->id_shop = (int) $this->context->shop->id;
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
$order->payment = $payment_method;
if (isset($this->name)) {
$order->module = $this->name;
}
$order->recyclable = $this->context->cart->recyclable;
$order->gift = (int) $this->context->cart->gift;
$order->gift_message = $this->context->cart->gift_message;
$order->mobile_theme = $this->context->cart->mobile_theme;
$order->conversion_rate = $this->context->currency->conversion_rate;
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
$order->total_paid_real = 0;
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
$order->total_discounts = $order->total_discounts_tax_incl;
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list);
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list);
$order->total_shipping = $order->total_shipping_tax_incl;
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
}
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
$order->total_wrapping = $order->total_wrapping_tax_incl;
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
$total_in_order = $order->total_paid_tax_incl;
$order->total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotalGross(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); //$order->total_paid_tax_incl;
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
$order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00';
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$result = $order->add();
if (!$result) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t save Order');
}
if ($order_status->logable && (number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_))) {
PrestaShopLogger::addLog('lg 235 id_order:' . (int) $order->id . ' M=' . $cart_total_paid . ' H=' . $amount_paid . 'G=' . $total_in_order, 1, null, 'OKKKKKK', (int) $id_cart, true);
}
$order_list[] = $order;
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$order_detail = new OrderDetail(null, null, $this->context);
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
$order_detail_list[] = $order_detail;
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
if (!is_null($carrier)) {
$order_carrier = new OrderCarrier();
$order_carrier->id_order = (int) $order->id;
$order_carrier->id_carrier = (int) $id_carrier;
$order_carrier->weight = (float) $order->getTotalWeight();
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
$order_carrier->add();
}
}
}
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$this->context->country = $context_country;
}
if (!$this->context->country->active) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('The order address country is not active.');
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
if ($order_status->logable) {
if (isset($extra_vars['transaction_id'])) {
$transaction_id = $extra_vars['transaction_id'];
} else {
$transaction_id = null;
}
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t save Order Payment');
} else {
PrestaShopLogger::addLog('PaymentModule::validateOrder - LOG DEV4 ligne 293_' . $amount_paid . '_' . $transaction_id, 3, null, 'Cart', (int) $order->id, true);
}
}
$cart_rule_used = array();
CartRule::cleanCache();
foreach ($order_detail_list as $key => $order_detail) {
$order = $order_list[$key];
if (!$order_creation_failed && isset($order->id)) {
if (!$secure_key) {
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
}
if (isset($message) & !empty($message)) {
$msg = new Message();
$message = strip_tags($message, '<br>');
if (Validate::isCleanHtml($message)) {
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$msg->message = $message;
$msg->id_order = (int) $order->id;
$msg->private = 1;
$msg->add();
}
}
$virtual_product = true;
$product_var_tpl_list = array();
foreach ($order->product_list as $product) {
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
$product_var_tpl = array(
'reference' => $product['reference'],
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
'quantity' => $product['quantity'],
'customization' => array()
);
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart);
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
$product_var_tpl['customization'] = array();
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
$customization_text = '';
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
$customization_text .= $text['name'] . ': ' . $text['value'] . '<br />';
}
}
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
}
$customization_quantity = (int) $product['customization_quantity'];
$product_var_tpl['customization'][] = array(
'customization_text' => $customization_text,
'customization_quantity' => $customization_quantity,
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
);
}
}
$product_var_tpl_list[] = $product_var_tpl;
if (!$product['is_virtual']) {
$virtual_product &= false;
}
} // end foreach ($product)
$product_list_txt = '';
$product_list_html = '';
if (count($product_var_tpl_list) > 0) {
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
}
$cart_rules_list = array();
$total_reduction_value_ti = 0;
$total_reduction_value_tex = 0;
foreach ($cart_rules as $cart_rule) {
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
$values = array(
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
);
if (!$values['tax_excl']) {
continue;
}
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
$voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
unset($voucher->id);
$voucher->code = empty($voucher->code) ? Tools::substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . ((int) $matches[1] + 1), $voucher->code);
}
if ($voucher->reduction_tax) {
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
}
} else {
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
}
}
if ($voucher->reduction_amount <= 0) {
continue;
}
$voucher->id_customer = $order->id_customer;
$voucher->quantity = 1;
$voucher->quantity_per_user = 1;
$voucher->free_shipping = 0;
if ($voucher->add()) {
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
$params = array(
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
'{voucher_num}' => $voucher->code,
'{firstname}' => $this->context->customer->firstname,
'{lastname}' => $this->context->customer->lastname,
'{id_order}' => $order->reference,
'{order_name}' => $order->getUniqReference()
);
Mail::Send(
(int) $order->id_lang,
'voucher',
sprintf(Mail::l('New voucher for your order %s', (int) $order->id_lang), $order->reference),
$params,
$this->context->customer->email,
$this->context->customer->firstname . ' ' . $this->context->customer->lastname,
null,
null,
null,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
}
$total_reduction_value_ti += $values['tax_incl'];
$total_reduction_value_tex += $values['tax_excl'];
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
$cart_rule_used[] = $cart_rule['obj']->id;
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
$cart_rule_to_update->update();
}
$cart_rules_list[] = array(
'voucher_name' => $cart_rule['obj']->name,
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
);
}
$cart_rules_list_txt = '';
$cart_rules_list_html = '';
if (count($cart_rules_list) > 0) {
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
}
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
if ($old_message) {
$update_message = new Message((int) $old_message['id_message']);
$update_message->id_order = (int) $order->id;
$update_message->update();
$customer_thread = new CustomerThread();
$customer_thread->id_contact = 0;
$customer_thread->id_customer = (int) $order->id_customer;
$customer_thread->id_shop = (int) $this->context->shop->id;
$customer_thread->id_order = (int) $order->id;
$customer_thread->id_lang = (int) $this->context->language->id;
$customer_thread->email = $this->context->customer->email;
$customer_thread->status = 'open';
$customer_thread->token = Tools::passwdGen(12);
$customer_thread->add();
$customer_message = new CustomerMessage();
$customer_message->id_customer_thread = $customer_thread->id;
$customer_message->id_employee = 0;
$customer_message->message = $update_message->message;
$customer_message->private = 0;
if (!$customer_message->add()) {
$this->errors[] = Tools::displayError('An error occurred while saving message');
}
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
}
Hook::exec('actionValidateOrder', array(
'cart' => $this->context->cart,
'order' => $order,
'customer' => $this->context->customer,
'currency' => $this->context->currency,
'orderStatus' => $order_status
));
foreach ($this->context->cart->getProducts() as $product) {
if ($order_status->logable) {
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
}
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$new_history = new OrderHistory();
$new_history->id_order = (int) $order->id;
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
$new_history->addWithemail(true, $extra_vars);
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) {
$history = new OrderHistory();
$history->id_order = (int) $order->id;
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
$history->addWithemail();
}
unset($order_detail);
$order = new Order($order->id);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
$invoice = new Address($order->id_address_invoice);
$delivery = new Address($order->id_address_delivery);
$delivery_state = $delivery->id_state ? new State($delivery->id_state) : false;
$invoice_state = $invoice->id_state ? new State($invoice->id_state) : false;
$data = array(
'{firstname}' => $this->context->customer->firstname,
'{lastname}' => $this->context->customer->lastname,
'{email}' => $this->context->customer->email,
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
'firstname' => '<span style="font-weight:bold;">%s</span>',
'lastname' => '<span style="font-weight:bold;">%s</span>'
)),
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
'firstname' => '<span style="font-weight:bold;">%s</span>',
'lastname' => '<span style="font-weight:bold;">%s</span>'
)),
'{delivery_company}' => $delivery->company,
'{delivery_firstname}' => $delivery->firstname,
'{delivery_lastname}' => $delivery->lastname,
'{delivery_address1}' => $delivery->address1,
'{delivery_address2}' => $delivery->address2,
'{delivery_city}' => $delivery->city,
'{delivery_postal_code}' => $delivery->postcode,
'{delivery_country}' => $delivery->country,
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
'{delivery_other}' => $delivery->other,
'{invoice_company}' => $invoice->company,
'{invoice_vat_number}' => $invoice->vat_number,
'{invoice_firstname}' => $invoice->firstname,
'{invoice_lastname}' => $invoice->lastname,
'{invoice_address2}' => $invoice->address2,
'{invoice_address1}' => $invoice->address1,
'{invoice_city}' => $invoice->city,
'{invoice_postal_code}' => $invoice->postcode,
'{invoice_country}' => $invoice->country,
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
'{invoice_other}' => $invoice->other,
'{order_name}' => $order->getUniqReference(),
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
'{payment}' => Tools::substr($order->payment, 0, 32),
'{products}' => $product_list_html,
'{products_txt}' => $product_list_txt,
'{discounts}' => $cart_rules_list_html,
'{discounts_txt}' => $cart_rules_list_txt,
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
'{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false),
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
'{days}' => Configuration::get('ACOMPTE_DAYS'),
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false)
);
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$smartynew = new Smarty;
$smartynew->assign('totalpay', Tools::displayPrice($order->total_paid_tax_incl, $this->context->currency, false));
$smartynew->assign('title', $this->l('Acompte'));
$contentExtra = $smartynew->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/invoice.extra.tpl');
$data['{total_paid}'] = Tools::displayPrice($order->total_paid, $this->context->currency, false) . $contentExtra ;
}
if (is_array($extra_vars)) {
$data = array_merge($data, $extra_vars);
}
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty);
$file_attachement = array();
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['mime'] = 'application/pdf';
} else {
$file_attachement = null;
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
}
if (file_exists(_PS_MODULE_DIR_ . 'installmentpayment/mails/' . Language::getIsoById((int) $this->context->language->id) . '/order_conf.txt') and file_exists(_PS_MODULE_DIR_ .'installmentpayment/mails/' . Language::getIsoById((int) $this->context->language->id) . '/order_conf.html')) {
if (Validate::isEmail($this->context->customer->email)) {
Mail::Send(
(int) $order->id_lang,
'order_conf',
Mail::l('Order confirmation', (int) $order->id_lang),
$data,
$this->context->customer->email,
$this->context->customer->firstname . ' ' . $this->context->customer->lastname,
null,
null,
$file_attachement,
null,
_PS_MODULE_DIR_ . 'installmentpayment/mails/' . Language::getIsoById((int) $this->context->language->id) . '/order_conf.html',
false,
(int) $order->id_shop
);
}
}
else
{
if (Validate::isEmail($this->context->customer->email)) {
Mail::Send(
(int) $order->id_lang,
'order_conf',
Mail::l('Order confirmation', (int) $order->id_lang),
$data,
$this->context->customer->email,
$this->context->customer->firstname . ' ' . $this->context->customer->lastname,
null,
null,
$file_attachement,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
}
}
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$product_list = $order->getProducts();
foreach ($product_list as $product) {
if (StockAvailable::dependsOnStock($product['product_id'])) {
StockAvailable::synchronize($product['product_id'], $order->id_shop);
}
}
}
} else {
$error = Tools::displayError('Order creation failed');
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', (int) $order->id_cart);
die($error);
}
} // End foreach $order_detail_list
foreach ($order->getOrderDetailList() as $detail) {
$order_detail = new OrderDetail($detail['id_order_detail']);
$order_detail->updateTaxAmount($order);
}
if (isset($order) && $order->id) {
$this->currentOrder = (int) $order->id;
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
}
return true;
} else {
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', (int) $this->context->cart->id);
die($error);
}
if ((int) $this->context->cookie->id_cart) {
$this->context->cookie->__unset('id_cart');
}
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,421 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class OrderHistory extends OrderHistoryCore
{
public function addWithemail($autodate = true, $template_vars = false)
{
if (!$this->add($autodate)) {
return false;
}
if (!$this->sendEmail($template_vars)) {
return false;
}
return true;
}
public function sendEmail($template_vars = false)
{
$file_attachement = array();
$context = Context::getContext();
$order = new Order($this->id_order);
$new_order_state = new OrderState($this->id_order_state, Configuration::get('PS_LANG_DEFAULT'));
$result = Db::getInstance()->getRow(
'SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname,
c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`
FROM `' . _DB_PREFIX_ . 'order_history` oh
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state`
AND osl.`id_lang` = o.`id_lang`)
WHERE oh.`id_order_history` = ' . (int) $this->id . ' AND os.`send_email` = 1'
);
if (isset($result['template']) && Validate::isEmail($result['email'])) {
$topic = $result['osname'];
$data = array(
'{lastname}' => $result['lastname'],
'{firstname}' => $result['firstname'],
'{id_order}' => (int) $this->id_order,
'{order_name}' => $order->getUniqReference()
);
if ($template_vars) {
$data = array_merge($data, $template_vars);
}
if ($result['module_name']) {
$module = Module::getInstanceByName($result['module_name']);
if (Validate::isLoadedObject($module) &&
isset($module->extra_mail_vars) &&
is_array($module->extra_mail_vars)) {
$data = array_merge($data, $module->extra_mail_vars);
}
}
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$data['{total_paid}'] = Tools::displayPrice((float) $order->total_paid_tax_incl, new Currency((int) $order->id_currency), false);
} else {
$data['{total_paid}'] = Tools::displayPrice((float) $order->total_paid, new Currency((int) $order->id_currency), false);
}
$data['{order_name}'] = $order->getUniqReference();
$virtual_products = $order->getVirtualProducts();
if ($virtual_products && $new_order_state && $new_order_state->logable) {
$assign = array();
foreach ($virtual_products as $key => $virtual_product) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtual_product['product_id']);
$product_download = new ProductDownload($id_product_download);
if ($product_download->display_filename != '') {
$assign[$key]['name'] = $product_download->display_filename;
$dl_link = $product_download->getTextLink(false, $virtual_product['download_hash'])
. '&id_order=' . $order->id
. '&secure_key=' . $order->secure_key;
$assign[$key]['link'] = $dl_link;
if ($virtual_product['download_deadline'] != '0000-00-00 00:00:00') {
$assign[$key]['deadline'] = Tools::displayDate($virtual_product['download_deadline'], $order->id_lang);
}
if ($product_download->nb_downloadable != 0) {
$assign[$key]['downloadable'] = $product_download->nb_downloadable;
}
}
}
$context->smarty->assign('virtualProducts', $assign);
$context->smarty->assign('id_order', $order->id);
$iso = Language::getIsoById((int) ($order->id_lang));
$links = $context->smarty->fetch(_PS_MAIL_DIR_ . $iso . '/download-product.tpl');
$tmp_array = array('{nbProducts}' => count($virtual_products), '{virtualProducts}' => $links);
$data = array_merge($data, $tmp_array);
if (!empty($assign)) {
Mail::Send(
(int) $order->id_lang,
'download_product',
Mail::l(
'Virtual product to download',
(int) $order->id_lang
),
$data,
$result['email'],
$result['firstname'] . ' ' . $result['lastname'],
null,
null,
null,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
}
if (Validate::isLoadedObject($order)) {
if ((int) $result['id_order_state'] === 2 &&
(int) Configuration::get('PS_INVOICE') &&
$order->invoice_number) {
$context = Context::getContext();
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get(
'PS_INVOICE_PREFIX',
(int) $order->id_lang,
null,
(int) $order->id_shop
)
. sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['mime'] = 'application/pdf';
} else {
$file_attachement = null;
}
$result['email'] = $result['email'];
Mail::Send(
(int) $order->id_lang,
$result['template'],
$topic,
$data,
$result['email'],
$result['firstname'] . ' ' . $result['lastname'],
null,
null,
$file_attachement,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
if (Validate::isLoadedObject($order) && !Tools::getIsset('sendStateEmail')) {
$customerGroupe = Customer::getGroupsStatic($result['id_customer']);
if ((int) $this->id_order_state === (int) Configuration::get('IMPRIMEUR_ORDERSTATE') &&
in_array(7, $customerGroupe) &&
(int) $result['id_order_state'] != 2) {
$context = Context::getContext();
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get(
'PS_INVOICE_PREFIX',
(int) $order->id_lang,
null,
(int) $order->id_shop
)
. sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['mime'] = 'application/pdf';
Mail::Send(
(int) $order->id_lang,
$result['template'],
$topic,
$data,
Configuration::get('IMPRIMEUR_EMAIL'),
$result['firstname'] . ' ' . $result['lastname'],
null,
null,
$file_attachement,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
}
}
return true;
}
/**
* Sets the new state of the given order
*
* @param int $new_order_state
* @param int/object $id_order
* @param bool $use_existing_payment
*/
public function changeIdOrderState($new_order_state, $id_order, $use_existing_payment = false)
{
if (!$new_order_state || !$id_order) {
return;
}
if (!is_object($id_order) && is_numeric($id_order)) {
$order = new Order((int) $id_order);
} elseif (is_object($id_order)) {
$order = $id_order;
} else {
return;
}
ShopUrl::cacheMainDomainForShop((int) $order->id_shop);
$new_os = new OrderState((int) $new_order_state, (int) $order->id_lang);
$old_os = $order->getCurrentOrderState();
if (in_array($new_os->id, array(Configuration::get('PS_OS_PAYMENT'), Configuration::get('PS_OS_WS_PAYMENT')))) {
Hook::exec('actionPaymentConfirmation', array('id_order' => (int) $order->id), null, false, true, false, (int) $order->id_shop);
}
Hook::exec('actionOrderStatusUpdate', array('newOrderStatus' => $new_os, 'id_order' => (int) $order->id), null, false, true, false, (int) $order->id_shop);
if (Validate::isLoadedObject($order) && ($new_os instanceof OrderState)) {
$context = Context::getContext();
$virtual_products = $order->getVirtualProducts();
if ($virtual_products && (!$old_os || !$old_os->logable) && $new_os && $new_os->logable) {
$assign = array();
foreach ($virtual_products as $key => $virtual_product) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtual_product['product_id']);
$product_download = new ProductDownload($id_product_download);
if ($product_download->display_filename != '') {
$assign[$key]['name'] = $product_download->display_filename;
$dl_link = $product_download->getTextLink(false, $virtual_product['download_hash'])
. '&id_order=' . (int) $order->id
. '&secure_key=' . $order->secure_key;
$assign[$key]['link'] = $dl_link;
if (isset($virtual_product['download_deadline']) && $virtual_product['download_deadline'] != '0000-00-00 00:00:00') {
$assign[$key]['deadline'] = Tools::displayDate($virtual_product['download_deadline']);
}
if ($product_download->nb_downloadable != 0) {
$assign[$key]['downloadable'] = (int) $product_download->nb_downloadable;
}
}
}
$customer = new Customer((int) $order->id_customer);
$links = '<ul>';
foreach ($assign as $product) {
$links .= '<li>';
$links .= '<a href="' . $product['link'] . '">' . Tools::htmlentitiesUTF8($product['name']) . '</a>';
if (isset($product['deadline'])) {
$links .= '&nbsp;' . Tools::htmlentitiesUTF8(Tools::displayError('expires on', false)) . '&nbsp;' . $product['deadline'];
}
if (isset($product['downloadable'])) {
$links .= '&nbsp;' . Tools::htmlentitiesUTF8(sprintf(Tools::displayError('downloadable %d time(s)', false), (int) $product['downloadable']));
}
$links .= '</li>';
}
$links .= '</ul>';
$data = array(
'{lastname}' => $customer->lastname,
'{firstname}' => $customer->firstname,
'{id_order}' => (int) $order->id,
'{order_name}' => $order->getUniqReference(),
'{nbProducts}' => count($virtual_products),
'{virtualProducts}' => $links
);
if (!empty($assign)) {
Mail::Send((int) $order->id_lang, 'download_product', Mail::l('The virtual product that you bought is available for download', $order->id_lang), $data, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop);
}
}
$manager = null;
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$manager = StockManagerFactory::getManager();
}
$error_or_canceled_statuses = array(Configuration::get('PS_OS_ERROR'), Configuration::get('PS_OS_CANCELED'));
$employee = null;
if (!(int) $this->id_employee || !Validate::isLoadedObject(($employee = new Employee((int) $this->id_employee)))) {
if (!Validate::isLoadedObject($old_os) && $context != null) {
$employee = $context->employee; // filled if from BO and order created (because no old_os)
if ($employee) {
$this->id_employee = $employee->id;
}
} else {
$employee = null;
}
}
foreach ($order->getProductsDetail() as $product) {
if (Validate::isLoadedObject($old_os)) {
if ($new_os->logable && !$old_os->logable) {
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
if (!Pack::isPack($product['product_id']) &&
in_array($old_os->id, $error_or_canceled_statuses) &&
!StockAvailable::dependsOnStock($product['id_product'], (int) $order->id_shop)) {
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int) $product['product_quantity'], $order->id_shop);
}
} elseif (!$new_os->logable && $old_os->logable) {// if becoming unlogable => removes sale
ProductSale::removeProductSale($product['product_id'], $product['product_quantity']);
if (!Pack::isPack($product['product_id']) &&
in_array($new_os->id, $error_or_canceled_statuses) &&
!StockAvailable::dependsOnStock($product['id_product'])) {
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int) $product['product_quantity'], $order->id_shop);
}
} elseif (!$new_os->logable && !$old_os->logable &&
in_array($new_os->id, $error_or_canceled_statuses) &&
!in_array($old_os->id, $error_or_canceled_statuses) &&
!StockAvailable::dependsOnStock($product['id_product'])) {// if waiting for payment => payment error/canceled
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int) $product['product_quantity'], $order->id_shop);
}
}
if ($new_os->shipped == 1 && (!Validate::isLoadedObject($old_os) || $old_os->shipped == 0) &&
Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') &&
Warehouse::exists($product['id_warehouse']) &&
$manager != null &&
(int) $product['advanced_stock_management'] == 1) {
$warehouse = new Warehouse($product['id_warehouse']);
$manager->removeProduct(
$product['product_id'],
$product['product_attribute_id'],
$warehouse,
($product['product_quantity'] - $product['product_quantity_refunded'] - $product['product_quantity_return']),
Configuration::get('PS_STOCK_CUSTOMER_ORDER_REASON'),
true,
(int) $order->id,
0,
$employee
);
} elseif ($new_os->shipped == 0 && Validate::isLoadedObject($old_os) && $old_os->shipped == 1 &&
Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') &&
Warehouse::exists($product['id_warehouse']) &&
$manager != null &&
(int) $product['advanced_stock_management'] == 1) {// @since.1.5.0 : if the order was shipped, and is not anymore, we need to restock products
if (Pack::isPack($product['product_id'])) {
$pack_products = Pack::getItems($product['product_id'], Configuration::get('PS_LANG_DEFAULT', null, null, $order->id_shop));
foreach ($pack_products as $pack_product) {
if ($pack_product->advanced_stock_management == 1) {
$mvts = StockMvt::getNegativeStockMvts($order->id, $pack_product->id, 0, $pack_product->pack_quantity * $product['product_quantity']);
foreach ($mvts as $mvt) {
$manager->addProduct(
(int) $pack_product->id,
0,
new Warehouse($mvt['id_warehouse']),
$mvt['physical_quantity'],
null,
$mvt['price_te'],
true,
null,
$employee
);
}
if (!StockAvailable::dependsOnStock($product['id_product'])) {
StockAvailable::updateQuantity($pack_product->id, 0, (int) $pack_product->pack_quantity * $product['product_quantity'], $order->id_shop);
}
}
}
} else {// else, it's not a pack, re-stock using the last negative stock mvts
$mvts = StockMvt::getNegativeStockMvts($order->id, $product['product_id'], $product['product_attribute_id'], ($product['product_quantity'] - $product['product_quantity_refunded'] - $product['product_quantity_return']));
foreach ($mvts as $mvt) {
$manager->addProduct(
$product['product_id'],
$product['product_attribute_id'],
new Warehouse($mvt['id_warehouse']),
$mvt['physical_quantity'],
null,
$mvt['price_te'],
true
);
}
}
}
}
}
$this->id_order_state = (int) $new_order_state;
if (!Validate::isLoadedObject($new_os) || !Validate::isLoadedObject($order)) {
die(Tools::displayError('Invalid new order status'));
}
$order->current_state = $this->id_order_state;
$order->valid = $new_os->logable;
$order->update();
if ($new_os->invoice && !$order->invoice_number) {
$order->setInvoice($use_existing_payment);
} elseif ($new_os->delivery && !$order->delivery_number) {
$order->setDeliverySlip();
}
if ($new_os->paid == 1 && (!isset(Context::getContext()->cookie->installmentpayment_type) || (int) Context::getContext()->cookie->installmentpayment_type <= 0)) {
$invoices = $order->getInvoicesCollection();
if ($order->total_paid != 0) {
$payment_method = Module::getInstanceByName($order->module);
}
foreach ($invoices as $invoice) {
$rest_paid = $invoice->getRestPaid();
if ($rest_paid > 0 && (!isset(Context::getContext()->cookie->installmentpayment_type) || (int) Context::getContext()->cookie->installmentpayment_type <= 0)) {
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$rest_paid = $installment['payer'];
}
$payment = new OrderPayment();
$payment->order_reference = Tools::substr($order->reference, 0, 9);
$payment->id_currency = $order->id_currency;
$payment->amount = $rest_paid;
if ($order->total_paid != 0) {
$payment->payment_method = $payment_method->displayName;
} else {
$payment->payment_method = null;
}
if ($payment->id_currency == $order->id_currency) {
$order->total_paid_real += $payment->amount;
} else {
$order->total_paid_real += Tools::ps_round(Tools::convertPrice($payment->amount, $payment->id_currency, false), 2);
}
$order->save();
$payment->conversion_rate = 1;
$payment->save();
Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order`)
VALUES(' . (int) $invoice->id . ', ' . (int) $payment->id . ', ' . (int) $order->id . ')');
}
}
}
if ($new_os->delivery) {
$order->setDelivery();
}
Hook::exec('actionOrderStatusPostUpdate', array('newOrderStatus' => $new_os, 'id_order' => (int) $order->id,), null, false, true, false, $order->id_shop);
ShopUrl::resetMainDomainCache();
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,72 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore
{
public function getHeader()
{
if (Tools::getIsset('installmentpayment')) {
$this->title = HTMLTemplateInvoice::l('Facture acompte n°') . $this->order->id;
}
return parent::getHeader();
}
public function getFilename()
{
if (Tools::getIsset('installmentpayment')) {
$id_lang = Context::getContext()->language->id;
$id_shop = (int) $this->order->id_shop;
return Configuration::get('PS_INVOICE_PREFIX', $id_lang, null, $id_shop) . sprintf('%06d', $this->order->id) . '.pdf';
}
return parent::getFilename();
}
public function getContent()
{
parent::getContent();
$iso_code = Context::getContext()->language->iso_code;
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $this->order->id_cart;
$installmentpayment = Db::getInstance()->getRow($sql);
if (isset($installmentpayment['rest']) && $installmentpayment['rest'] > 0) {
$data = array(
'paid' => $installmentpayment['payer'],
'rest' => $installmentpayment['rest'],
'acompte' => Tools::getIsset('installmentpayment') ? 1 : 0
);
$this->smarty->assign($data);
}
if (Tools::getIsset('installmentpayment')) {
$tpls = array(
'style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')),
'addresses_tab' => $this->smarty->fetch($this->getTemplate('invoice.addresses-tab')),
'summary_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.empty.tpl'),
'tax_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.tax-tab2_' . $iso_code . '.tpl'),
'product_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.empty2.tpl'),
'payment_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.empty2.tpl'),
'total_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.total-tab2_' . $iso_code . '.tpl')
);
} else {
$tpls = array(
'style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')),
'addresses_tab' => $this->smarty->fetch($this->getTemplate('invoice.addresses-tab')),
'summary_tab' => $this->smarty->fetch($this->getTemplate('invoice.summary-tab')),
'product_tab' => $this->smarty->fetch($this->getTemplate('invoice.product-tab')),
'tax_tab' => $this->getTaxTabContent(),
'payment_tab' => $this->smarty->fetch($this->getTemplate('invoice.payment-tab')),
'total_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/invoice.total-tab_' . $iso_code . '.tpl')
);
}
$this->smarty->assign($tpls);
$country = new Country((int) $this->order->id_address_invoice);
return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code));
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,842 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
use PrestaShop\PrestaShop\Adapter\ServiceLocator;
class Cart extends CartCore
{
public function getSummaryDetails($id_lang = null, $refresh = false)
{
$summary = $this->getSummaryDetailsInstallment($id_lang, $refresh);
if (!Module::isEnabled('freelivery')) {
return $summary;
}
if (!isset(Context::getContext()->cart)) {
return $summary;
}
$ps_free_price = Tools::convertPrice(Configuration::get('PS_SHIPPING_FREE_PRICE'), Currency::getCurrencyInstance(Context::getContext()->cart->id_currency));
$total = $summary['total_products_wt'];
if ((int) Configuration::get('FREELIVERY_CALCULATION_RULE')) {
$total += $summary['total_discounts'];
}
$ps_remaining = $ps_free_price - $total;
$freelivery_remaining = isset($GLOBALS['freelivery_remaining']) ? $GLOBALS['freelivery_remaining'] : false;
if ($summary['total_shipping'] == 0 || ($total >= $ps_free_price && $ps_free_price > 0)) {
$summary['freelivery_remaining'] = 0;
} elseif ($ps_remaining < $freelivery_remaining && $ps_free_price > 0) {
$summary['freelivery_remaining'] = $ps_remaining;
} else {
$summary['freelivery_remaining'] = (float) $freelivery_remaining;
}
$summary['free_ship'] = $summary['freelivery_remaining'] > 0 ? 0 : 1; // Can't set to true/false because of old 1.6 versions
return $summary;
}
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null)
{
$_GET['id_cart_freelivery'] = $this->id;
return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone);
}
public static function debugBacktraceUrl($start = 0, $limit = null)
{
$backtrace = debug_backtrace();
array_shift($backtrace);
for ($i = 0; $i < $start; ++$i) {
array_shift($backtrace);
}
$data = array();
$i = 0;
foreach ($backtrace as $id => $trace) {
if ((int) $limit && ( ++$i > $limit)) {
break;
}
$relative_file = (isset($trace['file'])) ? 'in /' . ltrim(str_replace(array(_PS_ROOT_DIR_, '\\'), array('', '/'), $trace['file']), '/') : '';
$current_line = (isset($trace['line'])) ? ':' . $trace['line'] : '';
$fileName = ((isset($trace['class'])) ? $trace['class'] : '') . ((isset($trace['type'])) ? $trace['type'] : '') . $trace['function'];
$data[$relative_file] = $fileName;
}
return $data;
}
/**
* This function returns the total cart amount
*
* Possible values for $type:
* Cart::ONLY_PRODUCTS
* Cart::ONLY_DISCOUNTS
* Cart::BOTH
* Cart::BOTH_WITHOUT_SHIPPING
* Cart::ONLY_SHIPPING
* Cart::ONLY_WRAPPING
* Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING
* Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING
*
* @param bool $withTaxes With or without taxes
* @param int $type Total type
* @param bool $use_cache Allow using cache of the method CartRule::getContextualValue
* @return float Order total
*/
public function getOrderTotal($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true, $gross = false, $small = false)
{
$address_factory = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\AddressFactory');
$price_calculator = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\Product\\PriceCalculator');
$configuration = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Core\\ConfigurationInterface');
$ps_tax_address_type = $configuration->get('PS_TAX_ADDRESS_TYPE');
$ps_use_ecotax = $configuration->get('PS_USE_ECOTAX');
$ps_round_type = $configuration->get('PS_ROUND_TYPE');
$ps_ecotax_tax_rules_group_id = $configuration->get('PS_ECOTAX_TAX_RULES_GROUP_ID');
$compute_precision = $configuration->get('_PS_PRICE_COMPUTE_PRECISION_');
$pre_commande = false;
$backtrace = $this->debugBacktraceUrl();
$i = 1;
foreach ($backtrace as $backtracekey => $backtracevalue) {
if ($i == 1 && strpos($backtracekey, '/modules/') !== false && (int) Configuration::get('ACOMPTE_CHOICE') == 1 || $i == 1 && strpos($backtracekey, '/modules/') !== false && isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0) {
$small = true;
}
$i++;
}
if (!$this->id) {
return 0;
}
$type = (int) $type;
$array_type = array(
Cart::ONLY_PRODUCTS,
Cart::ONLY_DISCOUNTS,
Cart::BOTH,
Cart::BOTH_WITHOUT_SHIPPING,
Cart::ONLY_SHIPPING,
Cart::ONLY_WRAPPING,
Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING,
Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING,
);
$virtual_context = Context::getContext()->cloneContext();
$virtual_context->cart = $this;
if (!in_array($type, $array_type)) {
die(Tools::displayError());
}
$with_shipping = in_array($type, array(Cart::BOTH, Cart::ONLY_SHIPPING));
if ($type == Cart::ONLY_DISCOUNTS && !CartRule::isFeatureActive()) {
return 0;
}
$virtual = $this->isVirtualCart();
if ($virtual && $type == Cart::ONLY_SHIPPING) {
return 0;
}
if ($virtual && $type == Cart::BOTH) {
$type = Cart::BOTH_WITHOUT_SHIPPING;
}
if ($with_shipping || $type == Cart::ONLY_DISCOUNTS) {
if (is_null($products) && is_null($id_carrier)) {
$shipping_fees = $this->getTotalShippingCost(null, (bool) $with_taxes);
} else {
$shipping_fees = $this->getPackageShippingCost((int) $id_carrier, (bool) $with_taxes, null, $products);
}
} else {
$shipping_fees = 0;
}
if ($type == Cart::ONLY_SHIPPING) {
return $shipping_fees;
}
if ($type == Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING) {
$type = Cart::ONLY_PRODUCTS;
}
$param_product = true;
if (is_null($products)) {
$param_product = false;
$products = $this->getProducts();
}
if ($type == Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING) {
foreach ($products as $key => $product) {
if ($product['is_virtual']) {
unset($products[$key]);
}
}
$type = Cart::ONLY_PRODUCTS;
}
$order_total = 0;
if (Tax::excludeTaxeOption()) {
$with_taxes = false;
}
$products_total = array();
$ecotax_total = 0;
foreach ($products as $product) {
if ($virtual_context->shop->id != $product['id_shop']) {
$virtual_context->shop = new Shop((int) $product['id_shop']);
}
if ($ps_tax_address_type == 'id_address_invoice') {
$id_address = (int) $this->id_address_invoice;
} else {
$id_address = (int) $product['id_address_delivery'];
} // Get delivery address of the product from the cart
if (!$address_factory->addressExists($id_address)) {
$id_address = null;
}
$null = null;
$price = $price_calculator->getProductPrice(
(int) $product['id_product'],
$with_taxes,
(int) $product['id_product_attribute'],
6,
null,
false,
true,
$product['cart_quantity'],
false,
(int) $this->id_customer ? (int) $this->id_customer : null,
(int) $this->id,
$id_address,
$null,
$ps_use_ecotax,
true,
$virtual_context
);
$address = $address_factory->findOrCreate($id_address, true);
if ($with_taxes) {
$id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $product['id_product'], $virtual_context);
$tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
} else {
$id_tax_rules_group = 0;
}
if (in_array($ps_round_type, array(Order::ROUND_ITEM, Order::ROUND_LINE))) {
if (!isset($products_total[$id_tax_rules_group])) {
$products_total[$id_tax_rules_group] = 0;
}
} elseif (!isset($products_total[$id_tax_rules_group . '_' . $id_address])) {
$products_total[$id_tax_rules_group . '_' . $id_address] = 0;
}
switch ($ps_round_type) {
case Order::ROUND_TOTAL:
$products_total[$id_tax_rules_group . '_' . $id_address] += $price * (int) $product['cart_quantity'];
break;
case Order::ROUND_LINE:
$product_price = $price * $product['cart_quantity'];
$products_total[$id_tax_rules_group] += Tools::ps_round($product_price, $compute_precision);
break;
case Order::ROUND_ITEM:
default:
$product_price = $price;
$products_total[$id_tax_rules_group] += Tools::ps_round($product_price, $compute_precision) * (int) $product['cart_quantity'];
break;
}
}
foreach ($products_total as $key => $price) {
$order_total += $price;
}
$order_total_products = $order_total;
if ($type == Cart::ONLY_DISCOUNTS) {
$order_total = 0;
}
$wrapping_fees = 0;
$include_gift_wrapping = (!$configuration->get('PS_ATCP_SHIPWRAP') || $type !== Cart::ONLY_PRODUCTS);
if ($this->gift && $include_gift_wrapping) {
$wrapping_fees = Tools::convertPrice(Tools::ps_round($this->getGiftWrappingPrice($with_taxes), $compute_precision), Currency::getCurrencyInstance((int) $this->id_currency));
}
if ($type == Cart::ONLY_WRAPPING) {
return $wrapping_fees;
}
$order_total_discount = 0;
$order_shipping_discount = 0;
if (!in_array($type, array(Cart::ONLY_SHIPPING, Cart::ONLY_PRODUCTS)) && CartRule::isFeatureActive()) {
if ($with_shipping || $type == Cart::ONLY_DISCOUNTS) {
$cart_rules = $this->getCartRules(CartRule::FILTER_ACTION_ALL);
} else {
$cart_rules = $this->getCartRules(CartRule::FILTER_ACTION_REDUCTION);
foreach ($this->getCartRules(CartRule::FILTER_ACTION_GIFT) as $tmp_cart_rule) {
$flag = false;
foreach ($cart_rules as $cart_rule) {
if ($tmp_cart_rule['id_cart_rule'] == $cart_rule['id_cart_rule']) {
$flag = true;
}
}
if (!$flag) {
$cart_rules[] = $tmp_cart_rule;
}
}
}
$id_address_delivery = 0;
if (isset($products[0])) {
$id_address_delivery = (is_null($products) ? $this->id_address_delivery : $products[0]['id_address_delivery']);
}
$package = array('id_carrier' => $id_carrier, 'id_address' => $id_address_delivery, 'products' => $products);
$flag = false;
foreach ($cart_rules as $cart_rule) {
if (($with_shipping || $type == Cart::ONLY_DISCOUNTS) && $cart_rule['obj']->free_shipping && !$flag) {
$order_shipping_discount = (float) Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_SHIPPING, ($param_product ? $package : null), $use_cache), $compute_precision);
$flag = true;
}
if ((int) $cart_rule['obj']->gift_product) {
$in_order = false;
if (is_null($products)) {
$in_order = true;
} else {
foreach ($products as $product) {
if ($cart_rule['obj']->gift_product == $product['id_product'] && $cart_rule['obj']->gift_product_attribute == $product['id_product_attribute']) {
$in_order = true;
}
}
}
if ($in_order) {
$order_total_discount += $cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_GIFT, $package, $use_cache);
}
}
if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0) {
$order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package, $use_cache), $compute_precision);
}
}
$order_total_discount = min(Tools::ps_round($order_total_discount, 2), (float) $order_total_products) + (float) $order_shipping_discount;
$order_total -= $order_total_discount;
}
if ($type == Cart::BOTH) {
$order_total += $shipping_fees + $wrapping_fees;
}
if ($order_total < 0 && $type != Cart::ONLY_DISCOUNTS) {
return 0;
}
if ($type == Cart::ONLY_DISCOUNTS) {
return $order_total_discount;
}
$page_name = Dispatcher::getInstance()->getController();
$pages_name = array();
$controllers = Dispatcher::getControllers(_PS_FRONT_CONTROLLER_DIR_);
foreach ($controllers as $key => $value) {
if ($key != 'orderconfirmation' && $key != 'pagenotfound') {
$pages_name[] = $key;
}
}
$groups = Db::getInstance()->executeS('SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group WHERE id_customer = ' . (int) Context::getContext()->customer->id);
$groupIdsTakenFromDb = Configuration::get('ACOMPTE_GROUP');
$selectedgroups = @unserialize($groupIdsTakenFromDb);
if ($selectedgroups === false && $selectedgroups !== 'b:0;') {
$selectedgroups = array();
}
$group_accepted = false;
foreach ($groups as $group) {
if (in_array($group['id_group'], $selectedgroups)) {
$group_accepted = true;
break;
}
}
$categoryIdsTakenFromDb = Configuration::get('ACOMPTE_CATS');
$selectedcategories = @unserialize($categoryIdsTakenFromDb);
if ($selectedcategories === false && $selectedcategories !== 'b:0;') {
$selectedcategories = array();
}
if ($group_accepted && ($type == Cart::BOTH || ($virtual && $type == Cart::BOTH_WITHOUT_SHIPPING)) && ((float) Configuration::get('ACOMPTE_MIN_AMOUNT') == 0 || $order_total > (float) Configuration::get('ACOMPTE_MIN_AMOUNT')) && !empty($selectedcategories)) {
if (is_array($this->_products) && !empty($this->_products)) {
foreach ($this->_products as $product) {
if (in_array((int) $product['id_category_default'], $selectedcategories)) {
$pre_commande = true;
break;
} else {
/**/
$sql = 'SELECT id_product FROM `' . _DB_PREFIX_ . 'category_product` WHERE `id_product` = ' . (int) $product['id_product'] . ' AND `id_category` IN (';
foreach ($selectedcategories as $category) {
$sql .= (int) $category . ',';
}
$sql = rtrim($sql, ',') . ')';
/**/
if (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql)) {
$pre_commande = true;
break;
}
}
}
}
if ($pre_commande && ((isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0) || (int) Configuration::get('ACOMPTE_CHOICE') == 1 || $page_name == 'installmentpayment')) {
if (((!in_array($page_name, $pages_name) || (($page_name == 'order' && Tools::getValue('step') == 3) || $page_name == 'order-opc')) && !$gross) || $small) {
if ((int) Configuration::get('ACOMPTE_TOTALTYPE') != 0 || (int) Configuration::get('ACOMPTE_SHIPPING') != 0) {
$order_total = 0;
if ((int) Configuration::get('ACOMPTE_TOTALTYPE') == 0) {
foreach ($products_total as $key => $price) {
if (Configuration::get('PS_ROUND_TYPE') == Order::ROUND_TOTAL) {
$tmp = explode('_', $key);
$address = Address::initialize((int) $tmp[1], true);
$tax_calculator = TaxManagerFactory::getManager($address, $tmp[0])->getTaxCalculator();
$order_total += Tools::ps_round($price + $tax_calculator->getTaxesTotalAmount($price), _PS_PRICE_COMPUTE_PRECISION_);
} else {
$order_total += $price;
}
}
} else {
foreach ($products as $product) { // products refer to the cart details
if ($virtual_context->shop->id != $product['id_shop']) {
$virtual_context->shop = new Shop((int) $product['id_shop']);
}
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
$id_address = (int) $this->id_address_invoice;
} else {
$id_address = (int) $product['id_address_delivery']; // Get delivery address of the product from the cart
}
if (!Address::addressExists($id_address)) {
$id_address = null;
}
$price = Product::getPriceStatic(
(int) $product['id_product'],
false,
(int) $product['id_product_attribute'],
6,
null,
false,
true,
$product['cart_quantity'],
false,
(int) $this->id_customer ? (int) $this->id_customer : null,
(int) $this->id,
$id_address,
null,
false,
true,
$virtual_context
);
$order_total += $price * $product['cart_quantity'];
}
}
if ((int) Configuration::get('ACOMPTE_SHIPPING') == 0) {
$order_total += $shipping_fees + $wrapping_fees;
}
}//else
$id_defaultgroup = Db::getInstance()->executeS('SELECT id_default_group FROM ' . _DB_PREFIX_ . 'customer WHERE id_customer = ' . (int) Context::getContext()->customer->id);
if(is_array($id_defaultgroup))
{
$id_defaultgroup = $id_defaultgroup[0]['id_default_group'];
}
$sql = 'SELECT price FROM `' . _DB_PREFIX_ . 'installmentpayment_group` WHERE id_group=' . (int) $id_defaultgroup;
$data = Db::getInstance()->getRow($sql);
if(!empty($data)){
$order_total = $order_total - ($order_total * (100 - $data['price']) / 100);
}
else
{
if ((int) Configuration::get('ACOMPTE_TYPE') == 1) {
if ($order_total > (float) Configuration::get('ACOMPTE_PERCENTAGE')) {
$order_total = (float) Configuration::get('ACOMPTE_PERCENTAGE');
}
} else {
$order_total = $order_total - ($order_total * (100 - Configuration::get('ACOMPTE_PERCENTAGE')) / 100);
}
}
}
if ($page_name == 'installmentpayment' || (isset(Context::getContext()->cookie->installmentpayment_id_order) && !empty(Context::getContext()->cookie->installmentpayment_id_order))) {
if (Tools::getValue('select') != '') {
Context::getContext()->cookie->__set('installmentpayment_id_order', (int) Tools::getValue('select'));
}
$order = new Order((int) Context::getContext()->cookie->installmentpayment_id_order);
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$rest_paid = $installment['rest'];
$order_total = $rest_paid;
}
}
}
}
return Tools::ps_round((float) $order_total, _PS_PRICE_COMPUTE_PRECISION_);
}
public function getOrderTotalGross($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true, $small = false)
{
return $this->getOrderTotal($with_taxes, $type, $products, $id_carrier, $use_cache, true);
}
public function getOrderTotalSmall($with_taxes = true, $type = Cart::BOTH, $products = null, $id_carrier = null, $use_cache = true, $small = true)
{
return $this->getOrderTotal($with_taxes, $type, $products, $id_carrier, $use_cache, true, true);
}
/**
* Return useful informations for cart
*
* @return array Cart details
*/
public function getSummaryDetailsInstallment($id_lang = null, $refresh = false)
{
$context = Context::getContext();
if (!$id_lang) {
$id_lang = $context->language->id;
}
$delivery = new Address((int) $this->id_address_delivery);
$invoice = new Address((int) $this->id_address_invoice);
$formatted_addresses = array(
'delivery' => AddressFormat::getFormattedLayoutData($delivery),
'invoice' => AddressFormat::getFormattedLayoutData($invoice)
);
$base_total_tax_inc = $this->getOrderTotalGross(true);
$base_total_tax_exc = $this->getOrderTotalGross(false);
$total_tax = $base_total_tax_inc - $base_total_tax_exc;
if ($total_tax < 0) {
$total_tax = 0;
}
$currency = new Currency($this->id_currency);
$products = $this->getProducts($refresh);
$gift_products = array();
$cart_rules = $this->getCartRules();
$total_shipping = $this->getTotalShippingCost();
$total_shipping_tax_exc = $this->getTotalShippingCost(null, false);
$total_products_wt = $this->getOrderTotalGross(true, Cart::ONLY_PRODUCTS);
$total_products = $this->getOrderTotalGross(false, Cart::ONLY_PRODUCTS);
$total_discounts = $this->getOrderTotalGross(true, Cart::ONLY_DISCOUNTS);
$total_discounts_tax_exc = $this->getOrderTotalGross(false, Cart::ONLY_DISCOUNTS);
foreach ($cart_rules as &$cart_rule) {
if ($cart_rule['free_shipping'] && (empty($cart_rule['code']) || preg_match('/^' . CartRule::BO_ORDER_CODE_PREFIX . '[0-9]+/', $cart_rule['code']))) {
$cart_rule['value_real'] -= $total_shipping;
$cart_rule['value_tax_exc'] -= $total_shipping_tax_exc;
$cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$cart_rule['value_tax_exc'] = Tools::ps_round($cart_rule['value_tax_exc'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
if ($total_discounts > $cart_rule['value_real']) {
$total_discounts -= $total_shipping;
}
if ($total_discounts_tax_exc > $cart_rule['value_tax_exc']) {
$total_discounts_tax_exc -= $total_shipping_tax_exc;
}
$total_shipping = 0;
$total_shipping_tax_exc = 0;
}
if ($cart_rule['gift_product']) {
foreach ($products as $key => &$product) {
if (empty($product['gift']) && $product['id_product'] == $cart_rule['gift_product'] && $product['id_product_attribute'] == $cart_rule['gift_product_attribute']) {
$total_products_wt = Tools::ps_round($total_products_wt - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$total_products = Tools::ps_round($total_products - $product['price'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$total_discounts = Tools::ps_round($total_discounts - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$total_discounts_tax_exc = Tools::ps_round($total_discounts_tax_exc - $product['price'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$cart_rule['value_real'] = Tools::ps_round($cart_rule['value_real'] - $product['price_wt'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$cart_rule['value_tax_exc'] = Tools::ps_round($cart_rule['value_tax_exc'] - $product['price'], (int) $context->currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$product['total_wt'] = Tools::ps_round($product['total_wt'] - $product['price_wt'], (int) $currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$product['total'] = Tools::ps_round($product['total'] - $product['price'], (int) $currency->decimals * _PS_PRICE_COMPUTE_PRECISION_);
$product['cart_quantity'] --;
if (!$product['cart_quantity']) {
unset($products[$key]);
}
$gift_product = $product;
$gift_product['cart_quantity'] = 1;
$gift_product['price'] = 0;
$gift_product['price_wt'] = 0;
$gift_product['total_wt'] = 0;
$gift_product['total'] = 0;
$gift_product['gift'] = true;
$gift_products[] = $gift_product;
break; // One gift product per cart rule
}
}
}
}
foreach ($cart_rules as $key => &$cart_rule) {
if ((float) $cart_rule['value_real'] == 0 && (int) $cart_rule['free_shipping'] == 0) {
unset($cart_rules[$key]);
}
}
return array(
'delivery' => $delivery,
'delivery_state' => State::getNameById($delivery->id_state),
'invoice' => $invoice,
'invoice_state' => State::getNameById($invoice->id_state),
'formattedAddresses' => $formatted_addresses,
'products' => array_values($products),
'gift_products' => $gift_products,
'discounts' => array_values($cart_rules),
'is_virtual_cart' => (int) $this->isVirtualCart(),
'total_discounts' => $total_discounts,
'total_discounts_tax_exc' => $total_discounts_tax_exc,
'total_wrapping' => $this->getOrderTotalGross(true, Cart::ONLY_WRAPPING),
'total_wrapping_tax_exc' => $this->getOrderTotalGross(false, Cart::ONLY_WRAPPING),
'total_shipping' => $total_shipping,
'total_shipping_tax_exc' => $total_shipping_tax_exc,
'total_products_wt' => $total_products_wt,
'total_products' => $total_products,
'total_price' => $base_total_tax_inc,
'total_tax' => $total_tax,
'total_price_without_tax' => $base_total_tax_exc,
'is_multi_address_delivery' => $this->isMultiAddressDelivery() || ((int) Tools::getValue('multi-shipping') == 1),
'free_ship' => $total_shipping ? 0 : 1,
'carrier' => new Carrier($this->id_carrier, $id_lang),
);
}
/**
* Return cart products
*
* @result array Products
*/
public function getProducts($refresh = false, $id_product = false, $id_country = null, $fullInfos = true)
{
if (Dispatcher::getInstance()->getController() != "pagenotfound" || strpos($_SERVER['REQUEST_URI'], '/modules/paypal') === false) {
return parent::getProducts();
}
if (!$this->id) {
return array();
}
if ($this->_products !== null && !$refresh) {
if (is_int($id_product)) {
foreach ($this->_products as $product) {
if ($product['id_product'] == $id_product) {
return array($product);
}
}
return array();
}
return $this->_products;
}
$sql = new DbQuery();
$sql->select('cp.`id_product_attribute`, cp.`id_product`, cp.`quantity` AS cart_quantity, cp.id_shop, pl.`name`, p.`is_virtual`,
pl.`description_short`, pl.`available_now`, pl.`available_later`, product_shop.`id_category_default`, p.`id_supplier`,
p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`,
product_shop.`available_for_order`, product_shop.`price`, product_shop.`active`, product_shop.`unity`, product_shop.`unit_price_ratio`,
stock.`quantity` AS quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, p.`weight`,
p.`date_add`, p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category,
CONCAT(LPAD(cp.`id_product`, 10, 0), LPAD(IFNULL(cp.`id_product_attribute`, 0), 10, 0), IFNULL(cp.`id_address_delivery`, 0)) AS unique_id, cp.id_address_delivery,
product_shop.advanced_stock_management, ps.product_supplier_reference supplier_reference, IFNULL(sp.`reduction_type`, 0) AS reduction_type');
$sql->from('cart_product', 'cp');
$sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');
$sql->innerJoin('product_shop', 'product_shop', '(product_shop.`id_shop` = cp.`id_shop` AND product_shop.`id_product` = p.`id_product`)');
$sql->leftJoin('product_lang', 'pl', '
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $this->id_lang . Shop::addSqlRestrictionOnLang('pl', 'cp.id_shop'));
$sql->leftJoin('category_lang', 'cl', '
product_shop.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = ' . (int) $this->id_lang . Shop::addSqlRestrictionOnLang('cl', 'cp.id_shop'));
$sql->leftJoin('product_supplier', 'ps', 'ps.`id_product` = cp.`id_product` AND ps.`id_product_attribute` = cp.`id_product_attribute` AND ps.`id_supplier` = p.`id_supplier`');
$sql->leftJoin('specific_price', 'sp', 'sp.`id_product` = cp.`id_product`'); // AND 'sp.`id_shop` = cp.`id_shop`
$sql->join(Product::sqlStock('cp', 'cp'));
$sql->where('cp.`id_cart` = ' . (int) $this->id);
if ($id_product) {
$sql->where('cp.`id_product` = ' . (int) $id_product);
}
$sql->where('p.`id_product` IS NOT NULL');
$sql->groupBy('unique_id');
$sql->orderBy('cp.`date_add`, p.`id_product`, cp.`id_product_attribute` ASC');
if (Customization::isFeatureActive()) {
$sql->select('cu.`id_customization`, cu.`quantity` AS customization_quantity');
$sql->leftJoin('customization', 'cu', 'p.`id_product` = cu.`id_product` AND cp.`id_product_attribute` = cu.`id_product_attribute` AND cu.`id_cart` = ' . (int) $this->id);
} else {
$sql->select('NULL AS customization_quantity, NULL AS id_customization');
}
if (Combination::isFeatureActive()) {
$sql->select('
product_attribute_shop.`price` AS price_attribute, product_attribute_shop.`ecotax` AS ecotax_attr,
IF (IFNULL(pa.`reference`, \'\') = \'\', p.`reference`, pa.`reference`) AS reference,
(p.`weight`+ pa.`weight`) weight_attribute,
IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13,
IF (IFNULL(pa.`upc`, \'\') = \'\', p.`upc`, pa.`upc`) AS upc,
pai.`id_image` as pai_id_image, il.`legend` as pai_legend,
IFNULL(product_attribute_shop.`minimal_quantity`, product_shop.`minimal_quantity`) as minimal_quantity,
IF(product_attribute_shop.wholesale_price > 0, product_attribute_shop.wholesale_price, product_shop.`wholesale_price`) wholesale_price
');
$sql->leftJoin('product_attribute', 'pa', 'pa.`id_product_attribute` = cp.`id_product_attribute`');
$sql->leftJoin('product_attribute_shop', 'product_attribute_shop', '(product_attribute_shop.`id_shop` = cp.`id_shop` AND product_attribute_shop.`id_product_attribute` = pa.`id_product_attribute`)');
$sql->leftJoin('product_attribute_image', 'pai', 'pai.`id_product_attribute` = pa.`id_product_attribute`');
$sql->leftJoin('image_lang', 'il', 'il.`id_image` = pai.`id_image` AND il.`id_lang` = ' . (int) $this->id_lang);
} else {
$sql->select(
'p.`reference` AS reference, p.`ean13`,
p.`upc` AS upc, product_shop.`minimal_quantity` AS minimal_quantity, product_shop.`wholesale_price` wholesale_price'
);
}
$result = Db::getInstance()->executeS($sql);
$products_ids = array();
$pa_ids = array();
if ($result) {
foreach ($result as $row) {
$products_ids[] = $row['id_product'];
$pa_ids[] = $row['id_product_attribute'];
}
}
Product::cacheProductsFeatures($products_ids);
Cart::cacheSomeAttributesLists($pa_ids, $this->id_lang);
$this->_products = array();
if (empty($result)) {
return array();
}
$cart_shop_context = Context::getContext()->cloneContext();
foreach ($result as &$row) {
if (isset($row['ecotax_attr']) && $row['ecotax_attr'] > 0) {
$row['ecotax'] = (float) $row['ecotax_attr'];
}
$row['stock_quantity'] = (int) $row['quantity'];
$row['quantity'] = (int) $row['cart_quantity'];
if (isset($row['id_product_attribute']) && (int) $row['id_product_attribute'] && isset($row['weight_attribute'])) {
$row['weight'] = (float) $row['weight_attribute'];
}
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
$address_id = (int) $this->id_address_invoice;
} else {
$address_id = (int) $row['id_address_delivery'];
}
if (!Address::addressExists($address_id)) {
$address_id = null;
}
if ($cart_shop_context->shop->id != $row['id_shop']) {
$cart_shop_context->shop = new Shop((int) $row['id_shop']);
}
$address = Address::initialize($address_id, true);
$id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int) $row['id_product'], $cart_shop_context);
$tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator();
if (!Tools::getIsset('specific_price_output')) {
$specific_price_output = array();
}
$row['price'] = Product::getPriceStatic(
(int) $row['id_product'],
false,
isset($row['id_product_attribute']) ? (int) $row['id_product_attribute'] : null,
6,
null,
false,
true,
$row['cart_quantity'],
false,
(int) $this->id_customer ? (int) $this->id_customer : null,
(int) $this->id,
$address_id,
$specific_price_output,
false,
true,
$cart_shop_context
);
switch (Configuration::get('PS_ROUND_TYPE')) {
case Order::ROUND_TOTAL:
$row['total'] = $row['price'] * (int) $row['cart_quantity'];
$row['total_wt'] = $tax_calculator->addTaxes($row['price']) * (int) $row['cart_quantity'];
break;
case Order::ROUND_LINE:
$row['total'] = Tools::ps_round($row['price'] * (int) $row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
$row['total_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['price']) * (int) $row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
break;
case Order::ROUND_ITEM:
default:
$row['total'] = Tools::ps_round($row['price'], _PS_PRICE_COMPUTE_PRECISION_) * (int) $row['cart_quantity'];
$row['total_wt'] = Tools::ps_round($tax_calculator->addTaxes($row['price']), _PS_PRICE_COMPUTE_PRECISION_) * (int) $row['cart_quantity'];
break;
}
$row['price_wt'] = $tax_calculator->addTaxes($row['price']);
$row['description_short'] = Tools::nl2br($row['description_short']);
if (!isset($row['pai_id_image']) || $row['pai_id_image'] == 0) {
$cache_id = 'Cart::getProducts_' . '-pai_id_image-' . (int) $row['id_product'] . '-' . (int) $this->id_lang . '-' . (int) $row['id_shop'];
if (!Cache::isStored($cache_id)) {
$row2 = Db::getInstance()->getRow('
SELECT image_shop.`id_image` id_image, il.`legend`
FROM `' . _DB_PREFIX_ . 'image` i
JOIN `' . _DB_PREFIX_ . 'image_shop` image_shop ON (i.id_image = image_shop.id_image AND image_shop.cover=1 AND image_shop.id_shop=' . (int) $row['id_shop'] . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $this->id_lang . ')
WHERE i.`id_product` = ' . (int) $row['id_product'] . ' AND image_shop.`cover` = 1');
Cache::store($cache_id, $row2);
}
$row2 = Cache::retrieve($cache_id);
if (!$row2) {
$row2 = array('id_image' => false, 'legend' => false);
} else {
$row = array_merge($row, $row2);
}
} else {
$row['id_image'] = $row['pai_id_image'];
$row['legend'] = $row['pai_legend'];
}
$row['reduction_applies'] = ($specific_price_output && (float) $specific_price_output['reduction']);
$row['quantity_discount_applies'] = ($specific_price_output && $row['cart_quantity'] >= (int) $specific_price_output['from_quantity']);
$row['id_image'] = Product::defineProductImage($row, $this->id_lang);
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
$row['features'] = Product::getFeaturesStatic((int) $row['id_product']);
if (array_key_exists($row['id_product_attribute'] . '-' . $this->id_lang, self::$_attributesLists)) {
$row = array_merge($row, self::$_attributesLists[$row['id_product_attribute'] . '-' . $this->id_lang]);
}
$row = Product::getTaxesInformations($row, $cart_shop_context);
$this->_products[] = $row;
}
$categoryIdsTakenFromDb = Configuration::get('ACOMPTE_CATS');
$selectedcategories = @unserialize($categoryIdsTakenFromDb);
if ($selectedcategories === false && $selectedcategories !== 'b:0;') {
$selectedcategories = array();
}
$pre_commande = false;
if (is_array($this->_products) && !empty($this->_products)) { //&& count($this->_products)>0
foreach ($this->_products as $product) {
if (in_array((int) $product['id_category_default'], $selectedcategories)) {
$pre_commande = true;
break;
} else {
/**/
$sql = 'SELECT id_product FROM `' . _DB_PREFIX_ . 'category_product` WHERE `id_product` = ' . (int) $product['id_product'] . ' AND `id_category` IN (';
foreach ($selectedcategories as $category) {
$sql .= (int) $category . ',';
}
$sql = rtrim($sql, ',') . ')';
/**/
if (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql)) {
$pre_commande = true;
break;
}
}
}
}
if (!$pre_commande) {
return parent::getProducts();
}
$order_total = $this->getOrderTotal(true);
$price_wt = $this->getOrderTotal(true);
$this->_products = array();
$row['cart_quantity'] = 1;
$row['price_wt'] = $price_wt;
$row['name'] = 'Acompte';
$row['attributes'] = '';
$row['id_product1'] = '';
$id_defaultgroup = Db::getInstance()->executeS('SELECT id_default_group FROM ' . _DB_PREFIX_ . 'customer WHERE id_customer = ' . (int) Context::getContext()->customer->id);
if(is_array($id_defaultgroup))
{
$id_defaultgroup = $id_defaultgroup[0]['id_default_group'];
}
$sql = 'SELECT price FROM `' . _DB_PREFIX_ . 'installmentpayment_group` WHERE id_group=' . (int) $id_defaultgroup;
$data = Db::getInstance()->getRow($sql);
if(!empty($data)){
$row['description_short'] = "Pourcentage " . $data['price'] . '%';
}
else
{
if ((int) Configuration::get('ACOMPTE_TYPE') == 1) {
if ($order_total > (float) Configuration::get('ACOMPTE_PERCENTAGE')) {
$row['description_short'] = "Acompte " . Configuration::get('ACOMPTE_PERCENTAGE');
}
} else {
$row['description_short'] = "Pourcentage " . Configuration::get('ACOMPTE_PERCENTAGE') . '%';
}
}
$this->_products[] = $row;
return $this->_products;
}
/**
* Return shipping total for the cart
*
* @param array $delivery_option Array of the delivery option for each address
* @param booleal $use_tax
* @param Country $default_country
* @return float Shipping total
*/
public function getTotalShippingCost($delivery_option = null, $use_tax = true, Country $default_country = null)
{
if (Dispatcher::getInstance()->getController() != "pagenotfound") {
return parent::getTotalShippingCost($delivery_option, $use_tax, $default_country);
}
return 0;
}
}

View File

@@ -0,0 +1,131 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class Hook extends HookCore
{
public static function getHookModuleExecList($hook_name = null)
{
$context = Context::getContext();
$cache_id = 'hook_module_exec_list_' . (isset($context->shop->id) ? '_' . $context->shop->id : '') . ((isset($context->customer)) ? '_' . $context->customer->id : '');
if (!Cache::isStored($cache_id) || $hook_name == 'displayPayment' || $hook_name == 'displayBackOfficeHeader') {
$frontend = true;
$groups = array();
$use_groups = Group::isFeatureActive();
if (isset($context->employee)) {
$frontend = false;
} else {
if ($use_groups) {
if (isset($context->customer) && $context->customer->isLogged()) {
$groups = $context->customer->getGroups();
} elseif (isset($context->customer) && $context->customer->isLogged(true)) {
$groups = array((int) Configuration::get('PS_GUEST_GROUP'));
} else {
$groups = array((int) Configuration::get('PS_UNIDENTIFIED_GROUP'));
}
}
}
$sql = new DbQuery();
$sql->select('h.`name` as hook, m.`id_module`, h.`id_hook`, m.`name` as module');
$sql->from('module', 'm');
if ($hook_name != 'displayBackOfficeHeader') {
$sql->join(Shop::addSqlAssociation('module', 'm', true, 'module_shop.enable_device & ' . (int) Context::getContext()->getDevice()));
$sql->innerJoin('module_shop', 'ms', 'ms.`id_module` = m.`id_module`');
}
$sql->innerJoin('hook_module', 'hm', 'hm.`id_module` = m.`id_module`');
$sql->innerJoin('hook', 'h', 'hm.`id_hook` = h.`id_hook`');
if ($hook_name != 'displayPayment') {
$sql->where('h.name != "displayPayment"');
} elseif ($frontend) {
if (Validate::isLoadedObject($context->country)) {
$sql->where('(h.name = "displayPayment" AND (SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country mc WHERE mc.id_module = m.id_module AND id_country = ' . (int) $context->country->id . ' AND id_shop = ' . (int) $context->shop->id . ' LIMIT 1) = ' . (int) $context->country->id . ')');
}
if (Validate::isLoadedObject($context->currency)) {
$sql->where('(h.name = "displayPayment" AND (SELECT id_currency FROM ' . _DB_PREFIX_ . 'module_currency mcr WHERE mcr.id_module = m.id_module AND id_currency IN (' . (int) $context->currency->id . ', -1, -2) LIMIT 1) IN (' . (int) $context->currency->id . ', -1, -2))');
}
}
if (Validate::isLoadedObject($context->shop)) {
$sql->where('hm.id_shop = ' . (int) $context->shop->id);
}
if ($frontend) {
if ($use_groups) {
$sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`');
if (Validate::isLoadedObject($context->shop)) {
$sql->where('mg.id_shop = ' . ((int) $context->shop->id) . (count($groups) ? ' AND mg.`id_group` IN (' . implode(', ', $groups) . ')' : ''));
} elseif (count($groups)) {
$sql->where('mg.`id_group` IN (' . implode(', ', $groups) . ')');
}
}
}
$sql->groupBy('hm.id_hook, hm.id_module');
$sql->orderBy('hm.`position`');
$list = array();
if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql)) {
foreach ($result as $row) {
$enable = true;
if (Db::getInstance()->getValue('SELECT `id_hook` FROM `' . _DB_PREFIX_ . 'hook` WHERE `id_hook` = ' . (int) $row['id_hook'] . ' AND `name` = \'displayPayment\'')) {
if (isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0) {
$paymentIdsTakenFromDb = Configuration::get('ACOMPTE_PAYMENT');
$selectedpayments = @unserialize($paymentIdsTakenFromDb);
if ($selectedpayments === false && $selectedpayments !== 'b:0;') {
$selectedpayments = array();
}
if (!empty($selectedpayments)) {
if (!in_array($row['id_module'], $selectedpayments)) {
$enable = false;
}
}
}
}
if ($enable) {
$row['hook'] = Tools::strtolower($row['hook']);
if (!isset($list[$row['hook']])) {
$list[$row['hook']] = array();
}
$list[$row['hook']][] = array(
'id_hook' => $row['id_hook'],
'module' => $row['module'],
'id_module' => $row['id_module'],
);
}
}
}
if ($hook_name != 'displayPayment' && $hook_name != 'displayBackOfficeHeader') {
Cache::store($cache_id, $list);
self::$_hook_modules_cache_exec = $list;
}
} else {
$list = Cache::retrieve($cache_id);
}
if ($hook_name) {
$retro_hook_name = Tools::strtolower(Hook::getRetroHookName($hook_name));
$hook_name = Tools::strtolower($hook_name);
$return = array();
$inserted_modules = array();
if (isset($list[$hook_name])) {
$return = $list[$hook_name];
}
foreach ($return as $module) {
$inserted_modules[] = $module['id_module'];
}
if (isset($list[$retro_hook_name])) {
foreach ($list[$retro_hook_name] as $retro_module_call) {
if (!in_array($retro_module_call['id_module'], $inserted_modules)) {
$return[] = $retro_module_call;
}
}
}
return (count($return) > 0 ? $return : false);
} else {
return $list;
}
}
}

View File

@@ -0,0 +1,665 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
abstract class PaymentModule extends PaymentModuleCore
{
/**
* Validate an order in database
* Function called from a payment module
*
* @param int $id_cart
* @param int $id_order_state
* @param float $amount_paid Amount really paid by customer (in the default currency)
* @param string $payment_method Payment method (eg. 'Credit card')
* @param null $message Message to attach to order
* @param array $extra_vars
* @param null $currency_special
* @param bool $dont_touch_amount
* @param bool $secure_key
* @param Shop $shop
*
* @return bool
* @throws PrestaShopException
*/
/*
* module: installmentpayment
* date: 2019-07-11 18:27:47
* version: 1.0.24
*/
public function validateOrder(
$id_cart,
$id_order_state,
$amount_paid,
$payment_method = 'Unknown',
$message = null,
$extra_vars = array(),
$currency_special = null,
$dont_touch_amount = false,
$secure_key = false,
Shop $shop = null
) {
if (isset(Context::getContext()->cookie->installmentpayment_type) && (int) Context::getContext()->cookie->installmentpayment_type > 0 && (int) Configuration::get('ACOMPTE_STATUSES') > 0) {
$id_order_state = (int) Configuration::get('ACOMPTE_STATUSES');
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
}
if (!isset($this->context)) {
$this->context = Context::getContext();
}
$this->context->cart = new Cart($id_cart);
$this->context->customer = new Customer($this->context->cart->id_customer);
$this->context->cart->setTaxCalculationMethod();
$this->context->language = new Language($this->context->cart->id_lang);
$this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop));
ShopUrl::resetMainDomainCache();
$id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
$this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$context_country = $this->context->country;
}
$order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
if (!Validate::isLoadedObject($order_status)) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t load Order status');
}
if (!$this->active) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
die(Tools::displayError());
}
if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
die(Tools::displayError());
}
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
$package_list = $this->context->cart->getPackageList();
$cart_delivery_option = $this->context->cart->getDeliveryOption();
foreach ($delivery_option_list as $id_address => $package) {
if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
foreach ($package as $key => $val) {
$cart_delivery_option[$id_address] = $key;
break;
}
}
}
$order_list = array();
$order_detail_list = array();
do {
$reference = Order::generateReference();
} while (Order::getByReference($reference)->count());
$this->currentOrderReference = $reference;
$order_creation_failed = false;
$cart_total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
foreach ($cart_delivery_option as $id_address => $key_carriers) {
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
foreach ($data['package_list'] as $id_package) {
$package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
$package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
}
}
}
CartRule::cleanCache();
$cart_rules = $this->context->cart->getCartRules();
foreach ($cart_rules as $cart_rule) {
if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
if ($error = $rule->checkValidity($this->context, true, true)) {
$this->context->cart->removeCartRule((int) $rule->id);
if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
}
Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
} else {
$rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
$error = Tools::displayError(sprintf('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart', (int) $rule->id, $rule_name));
PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
}
}
}
}
foreach ($package_list as $id_address => $packageByAddress) {
foreach ($packageByAddress as $id_package => $package) {
if (isset(Context::getContext()->cookie->installmentpayment_id_order) && !empty(Context::getContext()->cookie->installmentpayment_id_order)) {
$installmentpayment_id_order = Context::getContext()->cookie->installmentpayment_id_order;
$order = new Order($installmentpayment_id_order);
$payment_method = Module::getInstanceByName($this->name);
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$rest_paid = $installment['rest'];
$this->currentOrder = (int) $installmentpayment_id_order;
}
$payment = new OrderPayment();
$payment->order_reference = Tools::substr($order->reference, 0, 9);
$payment->id_currency = $order->id_currency;
$payment->amount = $rest_paid;
if ($order->total_paid != 0) {
$payment->payment_method = $payment_method->displayName;
} else {
$payment->payment_method = null;
}
$payment->conversion_rate = 1;
if (isset($extra_vars['transaction_id'])) {
$transaction_id = $extra_vars['transaction_id'];
} else {
$transaction_id = null;
}
$payment->transaction_id = $transaction_id;
$payment->save();
$id_order_invoice = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_order_invoice`
FROM `' . _DB_PREFIX_ . 'order_invoice`
WHERE number = ' . (int) $order->invoice_number);
PrestaShopLogger::addLog('PaymentModule::validateOrder - LOG DEV4 ligne 158 _' . $payment->amount . '_' . $transaction_id . '_' . $id_order_invoice, 3, null, 'Cart', (int) $order->id, true);
$res = Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order`)
VALUES(' . (int) $id_order_invoice . ', ' . (int) $payment->id . ', ' . (int) $installmentpayment_id_order . ')');
$total = $order->total_paid;
$acompte = $total;
$id_cart = $order->id_cart;
$rest = 0;
$data_insert = array(
'id_cart' => (int) $id_cart,
'total' => $total,
'payer' => $acompte,
'rest' => $rest,
'state' => 0,
);
Db::getInstance()->update('installmentpayment', $data_insert, 'id_cart=' . (int) $id_cart);
return true;
} else {
$order = new Order();
}
$order->product_list = $package['product_list'];
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$address = new Address($id_address);
$this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
if (!$this->context->country->active) {
throw new PrestaShopException('The delivery address country is not active.');
}
}
$carrier = null;
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
$carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
$order->id_carrier = (int) $carrier->id;
$id_carrier = (int) $carrier->id;
} else {
$order->id_carrier = 0;
$id_carrier = 0;
}
$order->id_customer = (int) $this->context->cart->id_customer;
$order->id_address_invoice = (int) $this->context->cart->id_address_invoice;
$order->id_address_delivery = (int) $id_address;
$order->id_currency = $this->context->currency->id;
$order->id_lang = (int) $this->context->cart->id_lang;
$order->id_cart = (int) $this->context->cart->id;
$order->reference = $reference;
$order->id_shop = (int) $this->context->shop->id;
$order->id_shop_group = (int) $this->context->shop->id_shop_group;
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key));
$order->payment = $payment_method;
if (isset($this->name)) {
$order->module = $this->name;
}
$order->recyclable = $this->context->cart->recyclable;
$order->gift = (int) $this->context->cart->gift;
$order->gift_message = $this->context->cart->gift_message;
$order->mobile_theme = $this->context->cart->mobile_theme;
$order->conversion_rate = $this->context->currency->conversion_rate;
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float) $amount_paid, 2) : $amount_paid;
$order->total_paid_real = 0;
$order->total_products = (float) $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
$order->total_products_wt = (float) $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
$order->total_discounts_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
$order->total_discounts_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
$order->total_discounts = $order->total_discounts_tax_incl;
$order->total_shipping_tax_excl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, false, null, $order->product_list);
$order->total_shipping_tax_incl = (float) $this->context->cart->getPackageShippingCost((int) $id_carrier, true, null, $order->product_list);
$order->total_shipping = $order->total_shipping_tax_incl;
if (!is_null($carrier) && Validate::isLoadedObject($carrier)) {
$order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
}
$order->total_wrapping_tax_excl = (float) abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
$order->total_wrapping_tax_incl = (float) abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
$order->total_wrapping = $order->total_wrapping_tax_incl;
$order->total_paid_tax_excl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = (float) Tools::ps_round((float) $this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
$total_in_order = $order->total_paid_tax_incl;
$order->total_paid = (float) Tools::ps_round((float) $this->context->cart->getOrderTotalGross(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_); //$order->total_paid_tax_incl;
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
$order->invoice_date = '0000-00-00 00:00:00';
$order->delivery_date = '0000-00-00 00:00:00';
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$result = $order->add();
if (!$result) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t save Order');
}
if ($order_status->logable && (number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_))) {
PrestaShopLogger::addLog('lg 235 id_order:' . (int) $order->id . ' M=' . $cart_total_paid . ' H=' . $amount_paid . 'G=' . $total_in_order, 1, null, 'OKKKKKK', (int) $id_cart, true);
}
$order_list[] = $order;
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderDetail is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$order_detail = new OrderDetail(null, null, $this->context);
$order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
$order_detail_list[] = $order_detail;
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - OrderCarrier is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
if (!is_null($carrier)) {
$order_carrier = new OrderCarrier();
$order_carrier->id_order = (int) $order->id;
$order_carrier->id_carrier = (int) $id_carrier;
$order_carrier->weight = (float) $order->getTotalWeight();
$order_carrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl;
$order_carrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl;
$order_carrier->add();
}
}
}
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
$this->context->country = $context_country;
}
if (!$this->context->country->active) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('The order address country is not active.');
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
if ($order_status->logable) {
if (isset($extra_vars['transaction_id'])) {
$transaction_id = $extra_vars['transaction_id'];
} else {
$transaction_id = null;
}
if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Cannot save Order Payment', 3, null, 'Cart', (int) $id_cart, true);
throw new PrestaShopException('Can\'t save Order Payment');
} else {
PrestaShopLogger::addLog('PaymentModule::validateOrder - LOG DEV4 ligne 293_' . $amount_paid . '_' . $transaction_id, 3, null, 'Cart', (int) $order->id, true);
}
}
$cart_rule_used = array();
CartRule::cleanCache();
foreach ($order_detail_list as $key => $order_detail) {
$order = $order_list[$key];
if (!$order_creation_failed && isset($order->id)) {
if (!$secure_key) {
$message .= '<br />' . Tools::displayError('Warning: the secure key is empty, check your payment account before validation');
}
if (isset($message) & !empty($message)) {
$msg = new Message();
$message = strip_tags($message, '<br>');
if (Validate::isCleanHtml($message)) {
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Message is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$msg->message = $message;
$msg->id_order = (int) $order->id;
$msg->private = 1;
$msg->add();
}
}
$virtual_product = true;
$product_var_tpl_list = array();
foreach ($order->product_list as $product) {
$price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$price_wt = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt;
$product_var_tpl = array(
'reference' => $product['reference'],
'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''),
'unit_price' => Tools::displayPrice($product_price, $this->context->currency, false),
'price' => Tools::displayPrice($product_price * $product['quantity'], $this->context->currency, false),
'quantity' => $product['quantity'],
'customization' => array()
);
$customized_datas = Product::getAllCustomizedDatas((int) $order->id_cart);
if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) {
$product_var_tpl['customization'] = array();
foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) {
$customization_text = '';
if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) {
foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) {
$customization_text .= $text['name'] . ': ' . $text['value'] . '<br />';
}
}
if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) {
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])) . '<br />';
}
$customization_quantity = (int) $product['customization_quantity'];
$product_var_tpl['customization'][] = array(
'customization_text' => $customization_text,
'customization_quantity' => $customization_quantity,
'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false)
);
}
}
$product_var_tpl_list[] = $product_var_tpl;
if (!$product['is_virtual']) {
$virtual_product &= false;
}
} // end foreach ($product)
$product_list_txt = '';
$product_list_html = '';
if (count($product_var_tpl_list) > 0) {
$product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list);
$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list);
}
$cart_rules_list = array();
$total_reduction_value_ti = 0;
$total_reduction_value_tex = 0;
foreach ($cart_rules as $cart_rule) {
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
$values = array(
'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package),
'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package)
);
if (!$values['tax_excl']) {
continue;
}
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) {
$voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
unset($voucher->id);
$voucher->code = empty($voucher->code) ? Tools::substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2';
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
$voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . ((int) $matches[1] + 1), $voucher->code);
}
if ($voucher->reduction_tax) {
$voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt;
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
$voucher->reduction_amount -= $order->total_shipping_tax_incl;
}
} else {
$voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products;
if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
$voucher->reduction_amount -= $order->total_shipping_tax_excl;
}
}
if ($voucher->reduction_amount <= 0) {
continue;
}
$voucher->id_customer = $order->id_customer;
$voucher->quantity = 1;
$voucher->quantity_per_user = 1;
$voucher->free_shipping = 0;
if ($voucher->add()) {
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
$params = array(
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
'{voucher_num}' => $voucher->code,
'{firstname}' => $this->context->customer->firstname,
'{lastname}' => $this->context->customer->lastname,
'{id_order}' => $order->reference,
'{order_name}' => $order->getUniqReference()
);
Mail::Send(
(int) $order->id_lang,
'voucher',
sprintf(Mail::l('New voucher for your order %s', (int) $order->id_lang), $order->reference),
$params,
$this->context->customer->email,
$this->context->customer->firstname . ' ' . $this->context->customer->lastname,
null,
null,
null,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
$values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti;
$values['tax_excl'] = $order->total_products - $total_reduction_value_tex;
}
$total_reduction_value_ti += $values['tax_incl'];
$total_reduction_value_tex += $values['tax_excl'];
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
$cart_rule_used[] = $cart_rule['obj']->id;
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
$cart_rule_to_update->update();
}
$cart_rules_list[] = array(
'voucher_name' => $cart_rule['obj']->name,
'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false)
);
}
$cart_rules_list_txt = '';
$cart_rules_list_html = '';
if (count($cart_rules_list) > 0) {
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
}
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
if ($old_message) {
$update_message = new Message((int) $old_message['id_message']);
$update_message->id_order = (int) $order->id;
$update_message->update();
$customer_thread = new CustomerThread();
$customer_thread->id_contact = 0;
$customer_thread->id_customer = (int) $order->id_customer;
$customer_thread->id_shop = (int) $this->context->shop->id;
$customer_thread->id_order = (int) $order->id;
$customer_thread->id_lang = (int) $this->context->language->id;
$customer_thread->email = $this->context->customer->email;
$customer_thread->status = 'open';
$customer_thread->token = Tools::passwdGen(12);
$customer_thread->add();
$customer_message = new CustomerMessage();
$customer_message->id_customer_thread = $customer_thread->id;
$customer_message->id_employee = 0;
$customer_message->message = $update_message->message;
$customer_message->private = 0;
if (!$customer_message->add()) {
$this->errors[] = Tools::displayError('An error occurred while saving message');
}
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
}
Hook::exec('actionValidateOrder', array(
'cart' => $this->context->cart,
'order' => $order,
'customer' => $this->context->customer,
'currency' => $this->context->currency,
'orderStatus' => $order_status
));
foreach ($this->context->cart->getProducts() as $product) {
if ($order_status->logable) {
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
}
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
$new_history = new OrderHistory();
$new_history->id_order = (int) $order->id;
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
$new_history->addWithemail(true, $extra_vars);
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) {
$history = new OrderHistory();
$history->id_order = (int) $order->id;
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
$history->addWithemail();
}
unset($order_detail);
$order = new Order($order->id);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
$invoice = new Address($order->id_address_invoice);
$delivery = new Address($order->id_address_delivery);
$delivery_state = $delivery->id_state ? new State($delivery->id_state) : false;
$invoice_state = $invoice->id_state ? new State($invoice->id_state) : false;
$data = array(
'{firstname}' => $this->context->customer->firstname,
'{lastname}' => $this->context->customer->lastname,
'{email}' => $this->context->customer->email,
'{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"),
'{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"),
'{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
'firstname' => '<span style="font-weight:bold;">%s</span>',
'lastname' => '<span style="font-weight:bold;">%s</span>'
)),
'{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
'firstname' => '<span style="font-weight:bold;">%s</span>',
'lastname' => '<span style="font-weight:bold;">%s</span>'
)),
'{delivery_company}' => $delivery->company,
'{delivery_firstname}' => $delivery->firstname,
'{delivery_lastname}' => $delivery->lastname,
'{delivery_address1}' => $delivery->address1,
'{delivery_address2}' => $delivery->address2,
'{delivery_city}' => $delivery->city,
'{delivery_postal_code}' => $delivery->postcode,
'{delivery_country}' => $delivery->country,
'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
'{delivery_other}' => $delivery->other,
'{invoice_company}' => $invoice->company,
'{invoice_vat_number}' => $invoice->vat_number,
'{invoice_firstname}' => $invoice->firstname,
'{invoice_lastname}' => $invoice->lastname,
'{invoice_address2}' => $invoice->address2,
'{invoice_address1}' => $invoice->address1,
'{invoice_city}' => $invoice->city,
'{invoice_postal_code}' => $invoice->postcode,
'{invoice_country}' => $invoice->country,
'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
'{invoice_other}' => $invoice->other,
'{order_name}' => $order->getUniqReference(),
'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
'{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name,
'{payment}' => Tools::substr($order->payment, 0, 32),
'{products}' => $product_list_html,
'{products_txt}' => $product_list_txt,
'{discounts}' => $cart_rules_list_html,
'{discounts_txt}' => $cart_rules_list_txt,
'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
'{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false),
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
'{days}' => Configuration::get('ACOMPTE_DAYS'),
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false)
);
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$smartynew = new Smarty;
$smartynew->assign('totalpay', Tools::displayPrice($order->total_paid_tax_incl, $this->context->currency, false));
$smartynew->assign('title', $this->l('Acompte'));
$contentExtra = $smartynew->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/invoice.extra.tpl');
$data['{total_paid}'] = Tools::displayPrice($order->total_paid, $this->context->currency, false) . $contentExtra ;
}
if (is_array($extra_vars)) {
$data = array_merge($data, $extra_vars);
}
if ((int) Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) {
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty);
$file_attachement = array();
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['mime'] = 'application/pdf';
} else {
$file_attachement = null;
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int) $id_cart, true);
}
if (file_exists(_PS_MODULE_DIR_ . 'installmentpayment/mails/' . Language::getIsoById((int) $this->context->language->id) . '/order_conf.txt') and file_exists(_PS_MODULE_DIR_ .'installmentpayment/mails/' . Language::getIsoById((int) $this->context->language->id) . '/order_conf.html')) {
if (Validate::isEmail($this->context->customer->email)) {
Mail::Send(
(int) $order->id_lang,
'order_conf',
Mail::l('Order confirmation', (int) $order->id_lang),
$data,
$this->context->customer->email,
$this->context->customer->firstname . ' ' . $this->context->customer->lastname,
null,
null,
$file_attachement,
null,
_PS_MODULE_DIR_ . 'installmentpayment/mails/' . Language::getIsoById((int) $this->context->language->id) . '/order_conf.html',
false,
(int) $order->id_shop
);
}
}
else
{
if (Validate::isEmail($this->context->customer->email)) {
Mail::Send(
(int) $order->id_lang,
'order_conf',
Mail::l('Order confirmation', (int) $order->id_lang),
$data,
$this->context->customer->email,
$this->context->customer->firstname . ' ' . $this->context->customer->lastname,
null,
null,
$file_attachement,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
}
}
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$product_list = $order->getProducts();
foreach ($product_list as $product) {
if (StockAvailable::dependsOnStock($product['product_id'])) {
StockAvailable::synchronize($product['product_id'], $order->id_shop);
}
}
}
} else {
$error = Tools::displayError('Order creation failed');
PrestaShopLogger::addLog($error, 4, '0000002', 'Cart', (int) $order->id_cart);
die($error);
}
} // End foreach $order_detail_list
foreach ($order->getOrderDetailList() as $detail) {
$order_detail = new OrderDetail($detail['id_order_detail']);
$order_detail->updateTaxAmount($order);
}
if (isset($order) && $order->id) {
$this->currentOrder = (int) $order->id;
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - End of validateOrder', 1, null, 'Cart', (int) $id_cart, true);
}
return true;
} else {
$error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart');
PrestaShopLogger::addLog($error, 4, '0000001', 'Cart', (int) $this->context->cart->id);
die($error);
}
if ((int) $this->context->cookie->id_cart) {
$this->context->cookie->__unset('id_cart');
}
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,424 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class OrderHistory extends OrderHistoryCore
{
public function addWithemail($autodate = true, $template_vars = false, Context $context = null)
{
$order = new Order($this->id_order);
if (!$this->add($autodate)) {
return false;
}
if (!$this->sendEmail($order, $template_vars)) {
return false;
}
return true;
}
public function sendEmail($order, $template_vars = false)
{
$file_attachement = array();
$context = Context::getContext();
$order = new Order($this->id_order);
$new_order_state = new OrderState($this->id_order_state, Configuration::get('PS_LANG_DEFAULT'));
$result = Db::getInstance()->getRow(
'SELECT osl.`template`, c.`lastname`,c.`id_customer`, c.`firstname`, osl.`name` AS osname,
c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`
FROM `' . _DB_PREFIX_ . 'order_history` oh
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state`
AND osl.`id_lang` = o.`id_lang`)
WHERE oh.`id_order_history` = ' . (int) $this->id . ' AND os.`send_email` = 1'
);
if (isset($result['template']) && Validate::isEmail($result['email'])) {
$topic = $result['osname'];
$data = array(
'{lastname}' => $result['lastname'],
'{firstname}' => $result['firstname'],
'{id_order}' => (int) $this->id_order,
'{order_name}' => $order->getUniqReference()
);
if ($template_vars) {
$data = array_merge($data, $template_vars);
}
if ($result['module_name']) {
$module = Module::getInstanceByName($result['module_name']);
if (Validate::isLoadedObject($module) &&
isset($module->extra_mail_vars) &&
is_array($module->extra_mail_vars)) {
$data = array_merge($data, $module->extra_mail_vars);
}
}
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$data['{total_paid}'] = Tools::displayPrice((float) $order->total_paid_tax_incl, new Currency((int) $order->id_currency), false);
} else {
$data['{total_paid}'] = Tools::displayPrice((float) $order->total_paid, new Currency((int) $order->id_currency), false);
}
$data['{order_name}'] = $order->getUniqReference();
$virtual_products = $order->getVirtualProducts();
if ($virtual_products && $new_order_state && $new_order_state->logable) {
$assign = array();
foreach ($virtual_products as $key => $virtual_product) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtual_product['product_id']);
$product_download = new ProductDownload($id_product_download);
if ($product_download->display_filename != '') {
$assign[$key]['name'] = $product_download->display_filename;
$dl_link = $product_download->getTextLink(false, $virtual_product['download_hash'])
. '&id_order=' . $order->id
. '&secure_key=' . $order->secure_key;
$assign[$key]['link'] = $dl_link;
if ($virtual_product['download_deadline'] != '0000-00-00 00:00:00') {
$assign[$key]['deadline'] = Tools::displayDate($virtual_product['download_deadline'], $order->id_lang);
}
if ($product_download->nb_downloadable != 0) {
$assign[$key]['downloadable'] = $product_download->nb_downloadable;
}
}
}
$context->smarty->assign('virtualProducts', $assign);
$context->smarty->assign('id_order', $order->id);
$iso = Language::getIsoById((int) ($order->id_lang));
$links = $context->smarty->fetch(_PS_MAIL_DIR_ . $iso . '/download-product.tpl');
$tmp_array = array('{nbProducts}' => count($virtual_products), '{virtualProducts}' => $links);
$data = array_merge($data, $tmp_array);
if (!empty($assign)) {
Mail::Send(
(int) $order->id_lang,
'download_product',
Mail::l(
'Virtual product to download',
$order->id_lang
),
$data,
$result['email'],
$result['firstname'] . ' ' . $result['lastname'],
null,
null,
null,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
}
if (Validate::isLoadedObject($order)) {
if ((int) $result['id_order_state'] === 2 &&
(int) Configuration::get('PS_INVOICE') &&
$order->invoice_number) {
$context = Context::getContext();
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get(
'PS_INVOICE_PREFIX',
(int) $order->id_lang,
null,
$order->id_shop
)
. sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['mime'] = 'application/pdf';
} else {
$file_attachement = null;
}
$result['email'] = $result['email'];
Mail::Send(
(int) $order->id_lang,
$result['template'],
$topic,
$data,
$result['email'],
$result['firstname'] . ' ' . $result['lastname'],
null,
null,
$file_attachement,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
if (Validate::isLoadedObject($order) && !Tools::getIsset('sendStateEmail')) {
$customerGroupe = Customer::getGroupsStatic($result['id_customer']);
if ((int) $this->id_order_state === (int) Configuration::get('IMPRIMEUR_ORDERSTATE') &&
in_array(7, $customerGroupe) &&
(int) $result['id_order_state'] != 2) {
$context = Context::getContext();
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get(
'PS_INVOICE_PREFIX',
(int) $order->id_lang,
null,
$order->id_shop
)
. sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['mime'] = 'application/pdf';
Mail::Send(
(int) $order->id_lang,
$result['template'],
$topic,
$data,
Configuration::get('IMPRIMEUR_EMAIL'),
$result['firstname'] . ' ' . $result['lastname'],
null,
null,
$file_attachement,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
}
}
return true;
}
/**
* Sets the new state of the given order
*
* @param int $new_order_state
* @param int/object $id_order
* @param bool $use_existing_payment
*/
public function changeIdOrderState($new_order_state, $id_order, $use_existing_payment = false)
{
if (!$new_order_state || !$id_order) {
return;
}
if (!is_object($id_order) && is_numeric($id_order)) {
$order = new Order((int) $id_order);
} elseif (is_object($id_order)) {
$order = $id_order;
} else {
return;
}
ShopUrl::cacheMainDomainForShop($order->id_shop);
$new_os = new OrderState((int) $new_order_state, $order->id_lang);
$old_os = $order->getCurrentOrderState();
if (in_array($new_os->id, array(Configuration::get('PS_OS_PAYMENT'), Configuration::get('PS_OS_WS_PAYMENT')))) {
Hook::exec('actionPaymentConfirmation', array('id_order' => (int) $order->id), null, false, true, false, $order->id_shop);
}
Hook::exec('actionOrderStatusUpdate', array('newOrderStatus' => $new_os, 'id_order' => (int) $order->id), null, false, true, false, $order->id_shop);
if (Validate::isLoadedObject($order) && ($new_os instanceof OrderState)) {
$context = Context::getContext();
$virtual_products = $order->getVirtualProducts();
if ($virtual_products && (!$old_os || !$old_os->logable) && $new_os && $new_os->logable) {
$assign = array();
foreach ($virtual_products as $key => $virtual_product) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtual_product['product_id']);
$product_download = new ProductDownload($id_product_download);
if ($product_download->display_filename != '') {
$assign[$key]['name'] = $product_download->display_filename;
$dl_link = $product_download->getTextLink(false, $virtual_product['download_hash'])
. '&id_order=' . (int) $order->id
. '&secure_key=' . $order->secure_key;
$assign[$key]['link'] = $dl_link;
if (isset($virtual_product['download_deadline']) && $virtual_product['download_deadline'] != '0000-00-00 00:00:00') {
$assign[$key]['deadline'] = Tools::displayDate($virtual_product['download_deadline']);
}
if ($product_download->nb_downloadable != 0) {
$assign[$key]['downloadable'] = (int) $product_download->nb_downloadable;
}
}
}
$customer = new Customer((int) $order->id_customer);
$links = '<ul>';
foreach ($assign as $product) {
$links .= '<li>';
$links .= '<a href="' . $product['link'] . '">' . Tools::htmlentitiesUTF8($product['name']) . '</a>';
if (isset($product['deadline'])) {
$links .= '&nbsp;' . Tools::htmlentitiesUTF8(Tools::displayError('expires on', false)) . '&nbsp;' . $product['deadline'];
}
if (isset($product['downloadable'])) {
$links .= '&nbsp;' . Tools::htmlentitiesUTF8(sprintf(Tools::displayError('downloadable %d time(s)', false), (int) $product['downloadable']));
}
$links .= '</li>';
}
$links .= '</ul>';
$data = array(
'{lastname}' => $customer->lastname,
'{firstname}' => $customer->firstname,
'{id_order}' => (int) $order->id,
'{order_name}' => $order->getUniqReference(),
'{nbProducts}' => count($virtual_products),
'{virtualProducts}' => $links
);
if (!empty($assign)) {
Mail::Send((int) $order->id_lang, 'download_product', Mail::l('The virtual product that you bought is available for download', $order->id_lang), $data, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $order->id_shop);
}
}
$manager = null;
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$manager = StockManagerFactory::getManager();
}
$error_or_canceled_statuses = array(Configuration::get('PS_OS_ERROR'), Configuration::get('PS_OS_CANCELED'));
$employee = null;
if (!(int) $this->id_employee || !Validate::isLoadedObject(($employee = new Employee((int) $this->id_employee)))) {
if (!Validate::isLoadedObject($old_os) && $context != null) {
$employee = $context->employee; // filled if from BO and order created (because no old_os)
if ($employee) {
$this->id_employee = $employee->id;
}
} else {
$employee = null;
}
}
foreach ($order->getProductsDetail() as $product) {
if (Validate::isLoadedObject($old_os)) {
if ($new_os->logable && !$old_os->logable) {
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
if (!Pack::isPack($product['product_id']) &&
in_array($old_os->id, $error_or_canceled_statuses) &&
!StockAvailable::dependsOnStock($product['id_product'], (int) $order->id_shop)) {
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int) $product['product_quantity'], $order->id_shop);
}
} elseif (!$new_os->logable && $old_os->logable) {// if becoming unlogable => removes sale
ProductSale::removeProductSale($product['product_id'], $product['product_quantity']);
if (!Pack::isPack($product['product_id']) &&
in_array($new_os->id, $error_or_canceled_statuses) &&
!StockAvailable::dependsOnStock($product['id_product'])) {
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int) $product['product_quantity'], $order->id_shop);
}
} elseif (!$new_os->logable && !$old_os->logable &&
in_array($new_os->id, $error_or_canceled_statuses) &&
!in_array($old_os->id, $error_or_canceled_statuses) &&
!StockAvailable::dependsOnStock($product['id_product'])) {// if waiting for payment => payment error/canceled
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int) $product['product_quantity'], $order->id_shop);
}
}
if ($new_os->shipped == 1 && (!Validate::isLoadedObject($old_os) || $old_os->shipped == 0) &&
Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') &&
Warehouse::exists($product['id_warehouse']) &&
$manager != null &&
(int) $product['advanced_stock_management'] == 1) {
$warehouse = new Warehouse($product['id_warehouse']);
$manager->removeProduct(
$product['product_id'],
$product['product_attribute_id'],
$warehouse,
($product['product_quantity'] - $product['product_quantity_refunded'] - $product['product_quantity_return']),
Configuration::get('PS_STOCK_CUSTOMER_ORDER_REASON'),
true,
(int) $order->id,
0,
$employee
);
} elseif ($new_os->shipped == 0 && Validate::isLoadedObject($old_os) && $old_os->shipped == 1 &&
Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') &&
Warehouse::exists($product['id_warehouse']) &&
$manager != null &&
(int) $product['advanced_stock_management'] == 1) {// @since.1.5.0 : if the order was shipped, and is not anymore, we need to restock products
if (Pack::isPack($product['product_id'])) {
$pack_products = Pack::getItems($product['product_id'], Configuration::get('PS_LANG_DEFAULT', null, null, $order->id_shop));
foreach ($pack_products as $pack_product) {
if ($pack_product->advanced_stock_management == 1) {
$mvts = StockMvt::getNegativeStockMvts($order->id, $pack_product->id, 0, $pack_product->pack_quantity * $product['product_quantity']);
foreach ($mvts as $mvt) {
$manager->addProduct(
$pack_product->id,
0,
new Warehouse($mvt['id_warehouse']),
$mvt['physical_quantity'],
null,
$mvt['price_te'],
true,
null,
$employee
);
}
if (!StockAvailable::dependsOnStock($product['id_product'])) {
StockAvailable::updateQuantity($pack_product->id, 0, (int) $pack_product->pack_quantity * $product['product_quantity'], $order->id_shop);
}
}
}
} else {// else, it's not a pack, re-stock using the last negative stock mvts
$mvts = StockMvt::getNegativeStockMvts($order->id, $product['product_id'], $product['product_attribute_id'], ($product['product_quantity'] - $product['product_quantity_refunded'] - $product['product_quantity_return']));
foreach ($mvts as $mvt) {
$manager->addProduct(
$product['product_id'],
$product['product_attribute_id'],
new Warehouse($mvt['id_warehouse']),
$mvt['physical_quantity'],
null,
$mvt['price_te'],
true
);
}
}
}
}
}
$this->id_order_state = (int) $new_order_state;
if (!Validate::isLoadedObject($new_os) || !Validate::isLoadedObject($order)) {
die(Tools::displayError('Invalid new order status'));
}
$order->current_state = $this->id_order_state;
$order->valid = $new_os->logable;
$order->update();
if ($new_os->invoice && !$order->invoice_number) {
$order->setInvoice($use_existing_payment);
} elseif ($new_os->delivery && !$order->delivery_number) {
$order->setDeliverySlip();
}
if ($new_os->paid == 1 && (!isset(Context::getContext()->cookie->installmentpayment_type) || (int) Context::getContext()->cookie->installmentpayment_type <= 0)) {
$invoices = $order->getInvoicesCollection();
if ($order->total_paid != 0) {
$payment_method = Module::getInstanceByName($order->module);
}
foreach ($invoices as $invoice) {
$rest_paid = $invoice->getRestPaid();
if ($rest_paid > 0 && (!isset(Context::getContext()->cookie->installmentpayment_type) || (int) Context::getContext()->cookie->installmentpayment_type <= 0)) {
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $order->id_cart;
$installment = Db::getInstance()->getRow($sql);
if (isset($installment['rest']) && (float) $installment['rest'] > 0) {
$rest_paid = $installment['payer'];
}
$payment = new OrderPayment();
$payment->order_reference = Tools::substr($order->reference, 0, 9);
$payment->id_currency = $order->id_currency;
$payment->amount = $rest_paid;
if ($order->total_paid != 0) {
$payment->payment_method = $payment_method->displayName;
} else {
$payment->payment_method = null;
}
if ($payment->id_currency == $order->id_currency) {
$order->total_paid_real += $payment->amount;
} else {
$order->total_paid_real += Tools::ps_round(Tools::convertPrice($payment->amount, $payment->id_currency, false), 2);
}
$order->save();
$payment->conversion_rate = 1;
$payment->save();
PrestaShopLogger::addLog('ORDERHISTORY::changeIdOrderState - LOG DEV4 ligne 426 _' . $payment->amount . '_', 3, null, 'Cart', (int) $order->id, true);
Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order`)
VALUES(' . (int) $invoice->id . ', ' . (int) $payment->id . ', ' . (int) $order->id . ')');
}
}
}
if ($new_os->delivery) {
$order->setDelivery();
}
Hook::exec('actionOrderStatusPostUpdate', array('newOrderStatus' => $new_os, 'id_order' => (int) $order->id,), null, false, true, false, $order->id_shop);
ShopUrl::resetMainDomainCache();
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,72 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class HTMLTemplateInvoice extends HTMLTemplateInvoiceCore
{
public function getHeader()
{
if (Tools::getIsset('installmentpayment')) {
$this->title = HTMLTemplateInvoice::l('Facture acompte n°') . $this->order->id;
}
return parent::getHeader();
}
public function getFilename()
{
if (Tools::getIsset('installmentpayment')) {
$id_lang = Context::getContext()->language->id;
$id_shop = (int) $this->order->id_shop;
return Configuration::get('PS_INVOICE_PREFIX', $id_lang, null, $id_shop) . sprintf('%06d', $this->order->id) . '.pdf';
}
return parent::getFilename();
}
public function getContent()
{
parent::getContent();
$iso_code = Context::getContext()->language->iso_code;
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'installmentpayment` WHERE id_cart=' . (int) $this->order->id_cart;
$installmentpayment = Db::getInstance()->getRow($sql);
if (isset($installmentpayment['rest']) && $installmentpayment['rest'] > 0) {
$data = array(
'paid' => $installmentpayment['payer'],
'rest' => $installmentpayment['rest'],
'acompte' => Tools::getIsset('installmentpayment') ? 1 : 0
);
$this->smarty->assign($data);
}
if (Tools::getIsset('installmentpayment')) {
$tpls = array(
'style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')),
'addresses_tab' => $this->smarty->fetch($this->getTemplate('invoice.addresses-tab')),
'summary_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.empty.tpl'),
'tax_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.tax-tab2_' . $iso_code . '.tpl'),
'product_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.empty2.tpl'),
'payment_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.empty2.tpl'),
'total_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/pdf/invoice.total-tab2_' . $iso_code . '.tpl')
);
} else {
$tpls = array(
'style_tab' => $this->smarty->fetch($this->getTemplate('invoice.style-tab')),
'addresses_tab' => $this->smarty->fetch($this->getTemplate('invoice.addresses-tab')),
'summary_tab' => $this->smarty->fetch($this->getTemplate('invoice.summary-tab')),
'product_tab' => $this->smarty->fetch($this->getTemplate('invoice.product-tab')),
'tax_tab' => $this->getTaxTabContent(),
'payment_tab' => $this->smarty->fetch($this->getTemplate('invoice.payment-tab')),
'total_tab' => $this->smarty->fetch(_PS_MODULE_DIR_ . 'installmentpayment/views/templates/hook/invoice.total-tab_' . $iso_code . '.tpl')
);
}
$this->smarty->assign($tpls);
$country = new Country((int) $this->order->id_address_invoice);
return $this->smarty->fetch($this->getTemplateByCountry($country->iso_code));
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,944 @@
<?php
/**
* installmentpayment.php, Allows you to set a percentage payment for orders
* @author Magavenue <contact@magavenue.com>
* @copyright Magavenue
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @category modules
*
* @note If you want to customize the module, contact us at contact@magavenue.com
*/
class AdminOrdersController extends AdminOrdersControllerCore
{
public function __construct()
{
$sql = 'UPDATE `' . _DB_PREFIX_ . 'orders` SET total_paid_tax_incl = total_paid';
Db::getInstance()->execute($sql);
parent::__construct();
}
public function postProcess()
{
if (Tools::isSubmit('id_order') && Tools::getValue('id_order') > 0) {
$order = new Order(Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order)) {
$this->errors[] = Tools::displayError('The order cannot be found within your database.');
}
ShopUrl::cacheMainDomainForShop((int) $order->id_shop);
}
if (Tools::isSubmit('submitShippingNumber') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$order_carrier = new OrderCarrier(Tools::getValue('id_order_carrier'));
if (!Validate::isLoadedObject($order_carrier)) {
$this->errors[] = Tools::displayError('The order carrier ID is invalid.');
} elseif (!Validate::isTrackingNumber(Tools::getValue('tracking_number'))) {
$this->errors[] = Tools::displayError('The tracking number is incorrect.');
} else {
$order->shipping_number = Tools::getValue('tracking_number');
$order->update();
$order_carrier->tracking_number = pSQL(Tools::getValue('tracking_number'));
if ($order_carrier->update()) {
$customer = new Customer((int) $order->id_customer);
$carrier = new Carrier((int) $order->id_carrier, $order->id_lang);
if (!Validate::isLoadedObject($customer)) {
throw new PrestaShopException('Can\'t load Customer object');
}
if (!Validate::isLoadedObject($carrier)) {
throw new PrestaShopException('Can\'t load Carrier object');
}
$templateVars = array(
'{followup}' => str_replace('@', $order->shipping_number, $carrier->url),
'{firstname}' => $customer->firstname,
'{lastname}' => $customer->lastname,
'{id_order}' => $order->id,
'{shipping_number}' => $order->shipping_number,
'{order_name}' => $order->getUniqReference()
);
if (@Mail::Send((int) $order->id_lang, 'in_transit', Mail::l('Package in transit', (int) $order->id_lang), $templateVars, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int) $order->id_shop)) {
Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order, 'customer' => $customer, 'carrier' => $carrier), null, false, true, false, $order->id_shop);
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
}
} else {
$this->errors[] = Tools::displayError('The order carrier cannot be updated.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitState') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$order_state = new OrderState(Tools::getValue('id_order_state'));
if (!Validate::isLoadedObject($order_state)) {
$this->errors[] = Tools::displayError('The new order status is invalid.');
} else {
$current_order_state = $order->getCurrentOrderState();
if ($current_order_state->id != $order_state->id) {
$history = new OrderHistory();
$history->id_order = $order->id;
$history->id_employee = (int) $this->context->employee->id;
$use_existings_payment = false;
if (!$order->hasInvoice()) {
$use_existings_payment = true;
}
$history->changeIdOrderState((int) $order_state->id, $order, $use_existings_payment);
$carrier = new Carrier($order->id_carrier, $order->id_lang);
$templateVars = array();
if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number) {
$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));
}
if ($history->addWithemail(true, $templateVars)) {
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
foreach ($order->getProducts() as $product) {
if (StockAvailable::dependsOnStock($product['product_id'])) {
StockAvailable::synchronize($product['product_id'], (int) $product['id_shop']);
}
}
}
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . (int) $order->id . '&vieworder&token=' . $this->token);
}
$this->errors[] = Tools::displayError('An error occurred while changing order status, or we were unable to send an email to the customer.');
} else {
$this->errors[] = Tools::displayError('The order has already been assigned this status.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitMessage') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$customer = new Customer(Tools::getValue('id_customer'));
if (!Validate::isLoadedObject($customer)) {
$this->errors[] = Tools::displayError('The customer is invalid.');
} elseif (!Tools::getValue('message')) {
$this->errors[] = Tools::displayError('The message cannot be blank.');
} else {
$rules = call_user_func(array('Message', 'getValidationRules'), 'Message');
foreach ($rules['required'] as $field) {
if (($value = Tools::getValue($field)) == false && (string) $value != '0') {
if (!Tools::getValue('id_' . $this->table) || $field != 'passwd') {
$this->errors[] = sprintf(Tools::displayError('field %s is required.'), $field);
}
}
}
foreach ($rules['size'] as $field => $maxLength) {
if (Tools::getValue($field) && Tools::strlen(Tools::getValue($field)) > $maxLength) {
$this->errors[] = sprintf(Tools::displayError('field %1$s is too long (%2$d chars max).'), $field, $maxLength);
}
}
foreach ($rules['validate'] as $field => $function) {
if (Tools::getValue($field)) {
if (!Validate::$function(htmlentities(Tools::getValue($field), ENT_COMPAT, 'UTF-8'))) {
$this->errors[] = sprintf(Tools::displayError('field %s is invalid.'), $field);
}
}
}
if (!count($this->errors)) {
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($customer->email, $order->id);
if (!$id_customer_thread) {
$customer_thread = new CustomerThread();
$customer_thread->id_contact = 0;
$customer_thread->id_customer = (int) $order->id_customer;
$customer_thread->id_shop = (int) $this->context->shop->id;
$customer_thread->id_order = (int) $order->id;
$customer_thread->id_lang = (int) $this->context->language->id;
$customer_thread->email = $customer->email;
$customer_thread->status = 'open';
$customer_thread->token = Tools::passwdGen(12);
$customer_thread->add();
} else {
$customer_thread = new CustomerThread((int) $id_customer_thread);
}
$customer_message = new CustomerMessage();
$customer_message->id_customer_thread = $customer_thread->id;
$customer_message->id_employee = (int) $this->context->employee->id;
$customer_message->message = Tools::getValue('message');
$customer_message->private = Tools::getValue('visibility');
if (!$customer_message->add()) {
$this->errors[] = Tools::displayError('An error occurred while saving the message.');
} elseif ($customer_message->private) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . (int) $order->id . '&vieworder&conf=11&token=' . $this->token);
} else {
$message = $customer_message->message;
if (Configuration::get('PS_MAIL_TYPE', null, null, $order->id_shop) != Mail::TYPE_TEXT) {
$message = Tools::nl2br($customer_message->message);
}
$varsTpl = array(
'{lastname}' => $customer->lastname,
'{firstname}' => $customer->firstname,
'{id_order}' => $order->id,
'{order_name}' => $order->getUniqReference(),
'{message}' => $message
);
if (@Mail::Send((int) $order->id_lang, 'order_merchant_comment', Mail::l('New message regarding your order', (int) $order->id_lang), $varsTpl, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int) $order->id_shop)) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=11' . '&token=' . $this->token);
}
}
$this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to delete this.');
}
} elseif (Tools::isSubmit('partialRefund') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
if (Tools::isSubmit('partialRefundProduct') && ($refunds = Tools::getValue('partialRefundProduct')) && is_array($refunds)) {
$amount = 0;
$order_detail_list = array();
$full_quantity_list = array();
foreach ($refunds as $id_order_detail => $amount_detail) {
$quantity = Tools::getValue('partialRefundProductQuantity');
if (!$quantity[$id_order_detail]) {
continue;
}
$full_quantity_list[$id_order_detail] = (int) $quantity[$id_order_detail];
$order_detail_list[$id_order_detail] = array(
'quantity' => (int) $quantity[$id_order_detail],
'id_order_detail' => (int) $id_order_detail
);
$order_detail = new OrderDetail((int) $id_order_detail);
if (empty($amount_detail)) {
$order_detail_list[$id_order_detail]['unit_price'] = (!Tools::getValue('TaxMethod') ? $order_detail->unit_price_tax_excl : $order_detail->unit_price_tax_incl);
$order_detail_list[$id_order_detail]['amount'] = $order_detail->unit_price_tax_incl * $order_detail_list[$id_order_detail]['quantity'];
} else {
$order_detail_list[$id_order_detail]['amount'] = (float) str_replace(',', '.', $amount_detail);
$order_detail_list[$id_order_detail]['unit_price'] = $order_detail_list[$id_order_detail]['amount'] / $order_detail_list[$id_order_detail]['quantity'];
}
$amount += $order_detail_list[$id_order_detail]['amount'];
if (!$order->hasBeenDelivered() || ($order->hasBeenDelivered() && Tools::isSubmit('reinjectQuantities')) && $order_detail_list[$id_order_detail]['quantity'] > 0) {
$this->reinjectQuantity($order_detail, $order_detail_list[$id_order_detail]['quantity']);
}
}
$shipping_cost_amount = (float) str_replace(',', '.', Tools::getValue('partialRefundShippingCost')) ? (float) str_replace(',', '.', Tools::getValue('partialRefundShippingCost')) : false;
if ($amount == 0 && $shipping_cost_amount == 0) {
if (!empty($refunds)) {
$this->errors[] = Tools::displayError('Please enter a quantity to proceed with your refund.');
} else {
$this->errors[] = Tools::displayError('Please enter an amount to proceed with your refund.');
}
return false;
}
$choosen = false;
$voucher = 0;
if ((int) Tools::getValue('refund_voucher_off') == 1) {
$amount -= $voucher = (float) Tools::getValue('order_discount_price');
} elseif ((int) Tools::getValue('refund_voucher_off') == 2) {
$choosen = true;
$amount = $voucher = (float) Tools::getValue('refund_voucher_choose');
}
if ($shipping_cost_amount > 0) {
if (!Tools::getValue('TaxMethod')) {
$tax = new Tax();
$tax->rate = $order->carrier_tax_rate;
$tax_calculator = new TaxCalculator(array($tax));
$amount += $tax_calculator->addTaxes($shipping_cost_amount);
} else {
$amount += $shipping_cost_amount;
}
}
$order_carrier = new OrderCarrier((int) $order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier)) {
$order_carrier->weight = (float) $order->getTotalWeight();
if ($order_carrier->update()) {
$order->weight = sprintf("%.3f " . Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
}
if ($amount >= 0) {
if (!OrderSlip::create($order, $order_detail_list, $shipping_cost_amount, $voucher, $choosen, (Tools::getValue('TaxMethod') ? false : true))) {
$this->errors[] = Tools::displayError('You cannot generate a partial credit slip.');
} else {
Hook::exec('actionOrderSlipAdd', array('order' => $order, 'productList' => $order_detail_list, 'qtyList' => $full_quantity_list), null, false, true, false, $order->id_shop);
$customer = new Customer((int) ($order->id_customer));
$params = array();
$params['{lastname}'] = $customer->lastname;
$params['{firstname}'] = $customer->firstname;
$params['{id_order}'] = $order->id;
$params['{order_name}'] = $order->getUniqReference();
@Mail::Send(
(int) $order->id_lang,
'credit_slip',
Mail::l('New credit slip regarding your order', (int) $order->id_lang),
$params,
$customer->email,
$customer->firstname . ' ' . $customer->lastname,
null,
null,
null,
null,
_PS_MAIL_DIR_,
true,
(int) $order->id_shop
);
}
foreach ($order_detail_list as &$product) {
$order_detail = new OrderDetail((int) $product['id_order_detail']);
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
StockAvailable::synchronize($order_detail->product_id);
}
}
if (Tools::isSubmit('generateDiscountRefund') && !count($this->errors) && $amount > 0) {
$cart_rule = new CartRule();
$cart_rule->description = sprintf($this->l('Credit slip for order #%d'), $order->id);
$language_ids = Language::getIDs(false);
foreach ($language_ids as $id_lang) {
$cart_rule->name[$id_lang] = sprintf('V0C%1$dO%2$d', $order->id_customer, $order->id);
}
$cart_rule->code = sprintf('V0C%1$dO%2$d', $order->id_customer, $order->id);
$cart_rule->quantity = 1;
$cart_rule->quantity_per_user = 1;
$cart_rule->id_customer = $order->id_customer;
$now = time();
$cart_rule->date_from = date('Y-m-d H:i:s', $now);
$cart_rule->date_to = date('Y-m-d H:i:s', strtotime('+1 year'));
$cart_rule->partial_use = 1;
$cart_rule->active = 1;
$cart_rule->reduction_amount = $amount;
$cart_rule->reduction_tax = $order->getTaxCalculationMethod() != PS_TAX_EXC;
$cart_rule->minimum_amount_currency = $order->id_currency;
$cart_rule->reduction_currency = $order->id_currency;
if (!$cart_rule->add()) {
$this->errors[] = Tools::displayError('You cannot generate a voucher.');
} else {
foreach ($language_ids as $id_lang) {
$cart_rule->name[$id_lang] = sprintf('V%1$dC%2$dO%3$d', $cart_rule->id, $order->id_customer, $order->id);
}
$cart_rule->code = sprintf('V%1$dC%2$dO%3$d', $cart_rule->id, $order->id_customer, $order->id);
if (!$cart_rule->update()) {
$this->errors[] = Tools::displayError('You cannot generate a voucher.');
} else {
$currency = $this->context->currency;
$customer = new Customer((int) ($order->id_customer));
$params['{lastname}'] = $customer->lastname;
$params['{firstname}'] = $customer->firstname;
$params['{id_order}'] = $order->id;
$params['{order_name}'] = $order->getUniqReference();
$params['{voucher_amount}'] = Tools::displayPrice($cart_rule->reduction_amount, $currency, false);
$params['{voucher_num}'] = $cart_rule->code;
@Mail::Send((int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order #%s', (int) $order->id_lang), $order->reference), $params, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int) $order->id_shop);
}
}
}
} else {
if (!empty($refunds)) {
$this->errors[] = Tools::displayError('Please enter a quantity to proceed with your refund.');
} else {
$this->errors[] = Tools::displayError('Please enter an amount to proceed with your refund.');
}
}
if (!count($this->errors)) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=30&token=' . $this->token);
}
} else {
$this->errors[] = Tools::displayError('The partial refund data is incorrect.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to delete this.');
}
} elseif (Tools::isSubmit('cancelProduct') && isset($order)) {
if ($this->tabAccess['delete'] == '1') {
if (!Tools::isSubmit('id_order_detail') && !Tools::isSubmit('id_customization')) {
$this->errors[] = Tools::displayError('You must select a product.');
} elseif (!Tools::isSubmit('cancelQuantity') && !Tools::isSubmit('cancelCustomizationQuantity')) {
$this->errors[] = Tools::displayError('You must enter a quantity.');
} else {
$productList = Tools::getValue('id_order_detail');
if ($productList) {
$productList = array_map('intval', $productList);
}
$customizationList = Tools::getValue('id_customization');
if ($customizationList) {
$customizationList = array_map('intval', $customizationList);
}
$qtyList = Tools::getValue('cancelQuantity');
if ($qtyList) {
$qtyList = array_map('intval', $qtyList);
}
$customizationQtyList = Tools::getValue('cancelCustomizationQuantity');
if ($customizationQtyList) {
$customizationQtyList = array_map('intval', $customizationQtyList);
}
$full_product_list = $productList;
$full_quantity_list = $qtyList;
if ($customizationList) {
foreach ($customizationList as $key => $id_order_detail) {
$full_product_list[(int) $id_order_detail] = $id_order_detail;
if (isset($customizationQtyList[$key])) {
$full_quantity_list[(int) $id_order_detail] += $customizationQtyList[$key];
}
}
}
if ($productList || $customizationList) {
if ($productList) {
$id_cart = Cart::getCartIdByOrderId($order->id);
$customization_quantities = Customization::countQuantityByCart($id_cart);
foreach ($productList as $key => $id_order_detail) {
$qtyCancelProduct = abs($qtyList[$key]);
if (!$qtyCancelProduct) {
$this->errors[] = Tools::displayError('No quantity has been selected for this product.');
}
$order_detail = new OrderDetail($id_order_detail);
$customization_quantity = 0;
if (array_key_exists($order_detail->product_id, $customization_quantities) && array_key_exists($order_detail->product_attribute_id, $customization_quantities[$order_detail->product_id])) {
$customization_quantity = (int) $customization_quantities[$order_detail->product_id][$order_detail->product_attribute_id];
}
if (($order_detail->product_quantity - $customization_quantity - $order_detail->product_quantity_refunded - $order_detail->product_quantity_return) < $qtyCancelProduct) {
$this->errors[] = Tools::displayError('An invalid quantity was selected for this product.');
}
}
}
if ($customizationList) {
$customization_quantities = Customization::retrieveQuantitiesFromIds(array_keys($customizationList));
foreach ($customizationList as $id_customization => $id_order_detail) {
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
$customization_quantity = $customization_quantities[$id_customization];
if (!$qtyCancelProduct) {
$this->errors[] = Tools::displayError('No quantity has been selected for this product.');
}
if ($qtyCancelProduct > ($customization_quantity['quantity'] - ($customization_quantity['quantity_refunded'] + $customization_quantity['quantity_returned']))) {
$this->errors[] = Tools::displayError('An invalid quantity was selected for this product.');
}
}
}
if (!count($this->errors) && $productList) {
foreach ($productList as $key => $id_order_detail) {
$qty_cancel_product = abs($qtyList[$key]);
$order_detail = new OrderDetail((int) ($id_order_detail));
if (!$order->hasBeenDelivered() || ($order->hasBeenDelivered() && Tools::isSubmit('reinjectQuantities')) && $qty_cancel_product > 0) {
$this->reinjectQuantity($order_detail, $qty_cancel_product);
}
$order_detail = new OrderDetail((int) $id_order_detail);
if (!$order->deleteProduct($order, $order_detail, $qty_cancel_product)) {
$this->errors[] = Tools::displayError('An error occurred while attempting to delete the product.') . ' <span class="bold">' . $order_detail->product_name . '</span>';
}
$order_carrier = new OrderCarrier((int) $order->getIdOrderCarrier());
if (Validate::isLoadedObject($order_carrier)) {
$order_carrier->weight = (float) $order->getTotalWeight();
if ($order_carrier->update()) {
$order->weight = sprintf("%.3f " . Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight);
}
}
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && StockAvailable::dependsOnStock($order_detail->product_id)) {
StockAvailable::synchronize($order_detail->product_id);
}
Hook::exec('actionProductCancel', array('order' => $order, 'id_order_detail' => (int) $id_order_detail), null, false, true, false, $order->id_shop);
}
}
if (!count($this->errors) && $customizationList) {
foreach ($customizationList as $id_customization => $id_order_detail) {
$order_detail = new OrderDetail((int) ($id_order_detail));
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
if (!$order->deleteCustomization($id_customization, $qtyCancelProduct, $order_detail)) {
$this->errors[] = Tools::displayError('An error occurred while attempting to delete product customization.') . ' ' . $id_customization;
}
}
}
if ((Tools::isSubmit('generateCreditSlip') || Tools::isSubmit('generateDiscount')) && !count($this->errors)) {
$customer = new Customer((int) ($order->id_customer));
$params['{lastname}'] = $customer->lastname;
$params['{firstname}'] = $customer->firstname;
$params['{id_order}'] = $order->id;
$params['{order_name}'] = $order->getUniqReference();
}
if (Tools::isSubmit('generateCreditSlip') && !count($this->errors)) {
$product_list = array();
$amount = $order_detail->unit_price_tax_incl * $full_quantity_list[$id_order_detail];
$choosen = false;
if ((int) Tools::getValue('refund_total_voucher_off') == 1) {
$amount -= $voucher = (float) Tools::getValue('order_discount_price');
} elseif ((int) Tools::getValue('refund_total_voucher_off') == 2) {
$choosen = true;
$amount = $voucher = (float) Tools::getValue('refund_total_voucher_choose');
}
foreach ($full_product_list as $id_order_detail) {
$order_detail = new OrderDetail((int) $id_order_detail);
$product_list[$id_order_detail] = array(
'id_order_detail' => $id_order_detail,
'quantity' => $full_quantity_list[$id_order_detail],
'unit_price' => $order_detail->unit_price_tax_excl,
'amount' => isset($amount) ? $amount : $order_detail->unit_price_tax_incl * $full_quantity_list[$id_order_detail],
);
}
$shipping = Tools::isSubmit('shippingBack') ? null : false;
if (!OrderSlip::create($order, $product_list, $shipping, $voucher, $choosen)) {
$this->errors[] = Tools::displayError('A credit slip cannot be generated. ');
} else {
Hook::exec('actionOrderSlipAdd', array('order' => $order, 'productList' => $full_product_list, 'qtyList' => $full_quantity_list), null, false, true, false, $order->id_shop);
@Mail::Send(
(int) $order->id_lang,
'credit_slip',
Mail::l('New credit slip regarding your order', (int) $order->id_lang),
$params,
$customer->email,
$customer->firstname . ' ' . $customer->lastname,
null,
null,
null,
null,
_PS_MAIL_DIR_,
true,
(int) $order->id_shop
);
}
}
if (Tools::isSubmit('generateDiscount') && !count($this->errors)) {
$cartrule = new CartRule();
$language_ids = Language::getIDs((bool) $order);
$cartrule->description = sprintf($this->l('Credit card slip for order #%d'), $order->id);
foreach ($language_ids as $id_lang) {
$cartrule->name[$id_lang] = 'V0C' . (int) ($order->id_customer) . 'O' . (int) ($order->id);
}
$cartrule->code = 'V0C' . (int) ($order->id_customer) . 'O' . (int) ($order->id);
$cartrule->quantity = 1;
$cartrule->quantity_per_user = 1;
$cartrule->id_customer = $order->id_customer;
$now = time();
$cartrule->date_from = date('Y-m-d H:i:s', $now);
$cartrule->date_to = date('Y-m-d H:i:s', $now + (3600 * 24 * 365.25));
$cartrule->active = 1;
$products = $order->getProducts(false, $full_product_list, $full_quantity_list);
$total = 0;
foreach ($products as $product) {
$total += $product['unit_price_tax_incl'] * $product['product_quantity'];
}
if (Tools::isSubmit('shippingBack')) {
$total += $order->total_shipping;
}
if ((int) Tools::getValue('refund_total_voucher_off') == 1) {
$total -= (float) Tools::getValue('order_discount_price');
} elseif ((int) Tools::getValue('refund_total_voucher_off') == 2) {
$total = (float) Tools::getValue('refund_total_voucher_choose');
}
$cartrule->reduction_amount = $total;
$cartrule->reduction_tax = true;
$cartrule->minimum_amount_currency = $order->id_currency;
$cartrule->reduction_currency = $order->id_currency;
if (!$cartrule->add()) {
$this->errors[] = Tools::displayError('You cannot generate a voucher.');
} else {
foreach ($language_ids as $id_lang) {
$cartrule->name[$id_lang] = 'V' . (int) ($cartrule->id) . 'C' . (int) ($order->id_customer) . 'O' . $order->id;
}
$cartrule->code = 'V' . (int) ($cartrule->id) . 'C' . (int) ($order->id_customer) . 'O' . $order->id;
if (!$cartrule->update()) {
$this->errors[] = Tools::displayError('You cannot generate a voucher.');
} else {
$currency = $this->context->currency;
$params['{voucher_amount}'] = Tools::displayPrice($cartrule->reduction_amount, $currency, false);
$params['{voucher_num}'] = $cartrule->code;
@Mail::Send((int) $order->id_lang, 'voucher', sprintf(Mail::l('New voucher for your order #%s', (int) $order->id_lang), $order->reference), $params, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int) $order->id_shop);
}
}
}
} else {
$this->errors[] = Tools::displayError('No product or quantity has been selected.');
}
if (!count($this->errors)) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=31&token=' . $this->token);
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to delete this.');
}
} elseif (Tools::isSubmit('messageReaded')) {
Message::markAsReaded(Tools::getValue('messageReaded'), $this->context->employee->id);
} elseif (Tools::isSubmit('submitAddPayment') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$amount = str_replace(',', '.', Tools::getValue('payment_amount'));
$currency = new Currency(Tools::getValue('payment_currency'));
$order_has_invoice = $order->hasInvoice();
if ($order_has_invoice) {
$order_invoice = new OrderInvoice(Tools::getValue('payment_invoice'));
} else {
$order_invoice = null;
}
if (!Validate::isLoadedObject($order)) {
$this->errors[] = Tools::displayError('The order cannot be found');
} elseif (!Validate::isNegativePrice($amount) || !(float) $amount) {
$this->errors[] = Tools::displayError('The amount is invalid.');
} elseif (!Validate::isGenericName(Tools::getValue('payment_method'))) {
$this->errors[] = Tools::displayError('The selected payment method is invalid.');
} elseif (!Validate::isString(Tools::getValue('payment_transaction_id'))) {
$this->errors[] = Tools::displayError('The transaction ID is invalid.');
} elseif (!Validate::isLoadedObject($currency)) {
$this->errors[] = Tools::displayError('The selected currency is invalid.');
} elseif ($order_has_invoice && !Validate::isLoadedObject($order_invoice)) {
$this->errors[] = Tools::displayError('The invoice is invalid.');
} elseif (!Validate::isDate(Tools::getValue('payment_date'))) {
$this->errors[] = Tools::displayError('The date is invalid');
} else {
if (!$order->addOrderPayment($amount, Tools::getValue('payment_method'), Tools::getValue('payment_transaction_id'), $currency, Tools::getValue('payment_date'), $order_invoice)) {
$this->errors[] = Tools::displayError('An error occurred during payment.');
} else {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token . '&payment_amount=' . $amount);
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitEditNote')) {
$note = Tools::getValue('note');
$order_invoice = new OrderInvoice((int) Tools::getValue('id_order_invoice'));
if (Validate::isLoadedObject($order_invoice) && Validate::isCleanHtml($note)) {
if ($this->tabAccess['edit'] == '1') {
$order_invoice->note = $note;
if ($order_invoice->save()) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order_invoice->id_order . '&vieworder&conf=4&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('The invoice note was not saved.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} else {
$this->errors[] = Tools::displayError('The invoice for edit note was unable to load. ');
}
} elseif (Tools::isSubmit('submitAddOrder') && ($id_cart = Tools::getValue('id_cart')) &&
($module_name = Tools::getValue('payment_module_name')) &&
($id_order_state = Tools::getValue('id_order_state')) && Validate::isModuleName($module_name)) {
if ($this->tabAccess['edit'] == '1') {
if (!Configuration::get('PS_CATALOG_MODE')) {
$payment_module = Module::getInstanceByName($module_name);
} else {
$payment_module = new BoOrder();
}
$cart = new Cart((int) $id_cart);
Context::getContext()->currency = new Currency((int) $cart->id_currency);
Context::getContext()->customer = new Customer((int) $cart->id_customer);
$bad_delivery = false;
if (($bad_delivery = (bool) !Address::isCountryActiveById((int) $cart->id_address_delivery)) || !Address::isCountryActiveById((int) $cart->id_address_invoice)) {
if ($bad_delivery) {
$this->errors[] = Tools::displayError('This delivery address country is not active.');
} else {
$this->errors[] = Tools::displayError('This invoice address country is not active.');
}
} else {
$employee = new Employee((int) Context::getContext()->cookie->id_employee);
$payment_module->validateOrder(
(int) $cart->id,
(int) $id_order_state,
$cart->getOrderTotal(true, Cart::BOTH),
$payment_module->displayName,
$this->l('Manual order -- Employee:') . ' ' .
Tools::substr($employee->firstname, 0, 1) . '. ' . $employee->lastname,
array(),
null,
false,
$cart->secure_key
);
if ($payment_module->currentOrder) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $payment_module->currentOrder . '&vieworder' . '&token=' . $this->token);
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to add this.');
}
} elseif ((Tools::isSubmit('submitAddressShipping') || Tools::isSubmit('submitAddressInvoice')) && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$address = new Address(Tools::getValue('id_address'));
if (Validate::isLoadedObject($address)) {
if (Tools::isSubmit('submitAddressShipping')) {
$order->id_address_delivery = $address->id;
} elseif (Tools::isSubmit('submitAddressInvoice')) {
$order->id_address_invoice = $address->id;
}
$order->update();
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('This address can\'t be loaded');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitChangeCurrency') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
if (Tools::getValue('new_currency') != $order->id_currency && !$order->valid) {
$old_currency = new Currency($order->id_currency);
$currency = new Currency(Tools::getValue('new_currency'));
if (!Validate::isLoadedObject($currency)) {
throw new PrestaShopException('Can\'t load Currency object');
}
foreach ($order->getOrderDetailList() as $row) {
$order_detail = new OrderDetail($row['id_order_detail']);
$fields = array(
'ecotax',
'product_price',
'reduction_amount',
'total_shipping_price_tax_excl',
'total_shipping_price_tax_incl',
'total_price_tax_incl',
'total_price_tax_excl',
'product_quantity_discount',
'purchase_supplier_price',
'reduction_amount',
'reduction_amount_tax_incl',
'reduction_amount_tax_excl',
'unit_price_tax_incl',
'unit_price_tax_excl',
'original_product_price'
);
foreach ($fields as $field) {
$order_detail->{$field} = Tools::convertPriceFull($order_detail->{$field}, $old_currency, $currency);
}
$order_detail->update();
$order_detail->updateTaxAmount($order);
}
$id_order_carrier = (int) $order->getIdOrderCarrier();
if ($id_order_carrier) {
$order_carrier = $order_carrier = new OrderCarrier((int) $order->getIdOrderCarrier());
$order_carrier->shipping_cost_tax_excl = (float) Tools::convertPriceFull($order_carrier->shipping_cost_tax_excl, $old_currency, $currency);
$order_carrier->shipping_cost_tax_incl = (float) Tools::convertPriceFull($order_carrier->shipping_cost_tax_incl, $old_currency, $currency);
$order_carrier->update();
}
$fields = array(
'total_discounts',
'total_discounts_tax_incl',
'total_discounts_tax_excl',
'total_discount_tax_excl',
'total_discount_tax_incl',
'total_paid',
'total_paid_tax_incl',
'total_paid_tax_excl',
'total_paid_real',
'total_products',
'total_products_wt',
'total_shipping',
'total_shipping_tax_incl',
'total_shipping_tax_excl',
'total_wrapping',
'total_wrapping_tax_incl',
'total_wrapping_tax_excl',
);
$invoices = $order->getInvoicesCollection();
if ($invoices) {
foreach ($invoices as $invoice) {
foreach ($fields as $field) {
if (isset($invoice->$field)) {
$invoice->{$field} = Tools::convertPriceFull($invoice->{$field}, $old_currency, $currency);
}
}
$invoice->save();
}
}
foreach ($fields as $field) {
if (isset($order->$field)) {
$order->{$field} = Tools::convertPriceFull($order->{$field}, $old_currency, $currency);
}
}
$order->id_currency = $currency->id;
$order->conversion_rate = (float) $currency->conversion_rate;
$order->update();
} else {
$this->errors[] = Tools::displayError('You cannot change the currency.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitGenerateInvoice') && isset($order)) {
if (!Configuration::get('PS_INVOICE', null, null, $order->id_shop)) {
$this->errors[] = Tools::displayError('Invoice management has been disabled.');
} elseif ($order->hasInvoice()) {
$this->errors[] = Tools::displayError('This order already has an invoice.');
} else {
$order->setInvoice(true);
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token);
}
} elseif (Tools::isSubmit('submitDeleteVoucher') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
$order_cart_rule = new OrderCartRule(Tools::getValue('id_order_cart_rule'));
if (Validate::isLoadedObject($order_cart_rule) && $order_cart_rule->id_order == $order->id) {
if ($order_cart_rule->id_order_invoice) {
$order_invoice = new OrderInvoice($order_cart_rule->id_order_invoice);
if (!Validate::isLoadedObject($order_invoice)) {
throw new PrestaShopException('Can\'t load Order Invoice object');
}
$order_invoice->total_discount_tax_excl -= $order_cart_rule->value_tax_excl;
$order_invoice->total_discount_tax_incl -= $order_cart_rule->value;
$order_invoice->total_paid_tax_excl += $order_cart_rule->value_tax_excl;
$order_invoice->total_paid_tax_incl += $order_cart_rule->value;
$order_invoice->update();
}
$order->total_discounts -= $order_cart_rule->value;
$order->total_discounts_tax_incl -= $order_cart_rule->value;
$order->total_discounts_tax_excl -= $order_cart_rule->value_tax_excl;
$order->total_paid += $order_cart_rule->value;
$order->total_paid_tax_incl += $order_cart_rule->value;
$order->total_paid_tax_excl += $order_cart_rule->value_tax_excl;
$order_cart_rule->delete();
$order->update();
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('You cannot edit this cart rule.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitNewVoucher') && isset($order)) {
if ($this->tabAccess['edit'] == '1') {
if (!Tools::getValue('discount_name')) {
$this->errors[] = Tools::displayError('You must specify a name in order to create a new discount.');
} else {
if ($order->hasInvoice()) {
if (!Tools::isSubmit('discount_all_invoices')) {
$order_invoice = new OrderInvoice(Tools::getValue('discount_invoice'));
if (!Validate::isLoadedObject($order_invoice)) {
throw new PrestaShopException('Can\'t load Order Invoice object');
}
}
}
$cart_rules = array();
$discount_value = (float) str_replace(',', '.', Tools::getValue('discount_value'));
switch (Tools::getValue('discount_type')) {
case 1:
if ($discount_value < 100) {
if (isset($order_invoice)) {
$cart_rules[$order_invoice->id]['value_tax_incl'] = Tools::ps_round($order_invoice->total_paid_tax_incl * $discount_value / 100, 2);
$cart_rules[$order_invoice->id]['value_tax_excl'] = Tools::ps_round($order_invoice->total_paid_tax_excl * $discount_value / 100, 2);
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
} elseif ($order->hasInvoice()) {
$order_invoices_collection = $order->getInvoicesCollection();
foreach ($order_invoices_collection as $order_invoice) {
$cart_rules[$order_invoice->id]['value_tax_incl'] = Tools::ps_round($order_invoice->total_paid_tax_incl * $discount_value / 100, 2);
$cart_rules[$order_invoice->id]['value_tax_excl'] = Tools::ps_round($order_invoice->total_paid_tax_excl * $discount_value / 100, 2);
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
} else {
$cart_rules[0]['value_tax_incl'] = Tools::ps_round($order->total_paid_tax_incl * $discount_value / 100, 2);
$cart_rules[0]['value_tax_excl'] = Tools::ps_round($order->total_paid_tax_excl * $discount_value / 100, 2);
}
} else {
$this->errors[] = Tools::displayError('The discount value is invalid.');
}
break;
case 2:
if (isset($order_invoice)) {
if ($discount_value > $order_invoice->total_paid_tax_incl) {
$this->errors[] = Tools::displayError('The discount value is greater than the order invoice total.');
} else {
$cart_rules[$order_invoice->id]['value_tax_incl'] = Tools::ps_round($discount_value, 2);
$cart_rules[$order_invoice->id]['value_tax_excl'] = Tools::ps_round($discount_value / (1 + ($order->getTaxesAverageUsed() / 100)), 2);
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
} elseif ($order->hasInvoice()) {
$order_invoices_collection = $order->getInvoicesCollection();
foreach ($order_invoices_collection as $order_invoice) {
if ($discount_value > $order_invoice->total_paid_tax_incl) {
$this->errors[] = Tools::displayError('The discount value is greater than the order invoice total.') . $order_invoice->getInvoiceNumberFormatted(Context::getContext()->language->id, (int) $order->id_shop) . ')';
} else {
$cart_rules[$order_invoice->id]['value_tax_incl'] = Tools::ps_round($discount_value, 2);
$cart_rules[$order_invoice->id]['value_tax_excl'] = Tools::ps_round($discount_value / (1 + ($order->getTaxesAverageUsed() / 100)), 2);
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
}
} else {
if ($discount_value > $order->total_paid_tax_incl) {
$this->errors[] = Tools::displayError('The discount value is greater than the order total.');
} else {
$cart_rules[0]['value_tax_incl'] = Tools::ps_round($discount_value, 2);
$cart_rules[0]['value_tax_excl'] = Tools::ps_round($discount_value / (1 + ($order->getTaxesAverageUsed() / 100)), 2);
}
}
break;
case 3:
if (isset($order_invoice)) {
if ($order_invoice->total_shipping_tax_incl > 0) {
$cart_rules[$order_invoice->id]['value_tax_incl'] = $order_invoice->total_shipping_tax_incl;
$cart_rules[$order_invoice->id]['value_tax_excl'] = $order_invoice->total_shipping_tax_excl;
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
} elseif ($order->hasInvoice()) {
$order_invoices_collection = $order->getInvoicesCollection();
foreach ($order_invoices_collection as $order_invoice) {
if ($order_invoice->total_shipping_tax_incl <= 0) {
continue;
}
$cart_rules[$order_invoice->id]['value_tax_incl'] = $order_invoice->total_shipping_tax_incl;
$cart_rules[$order_invoice->id]['value_tax_excl'] = $order_invoice->total_shipping_tax_excl;
$this->applyDiscountOnInvoice($order_invoice, $cart_rules[$order_invoice->id]['value_tax_incl'], $cart_rules[$order_invoice->id]['value_tax_excl']);
}
} else {
$cart_rules[0]['value_tax_incl'] = $order->total_shipping_tax_incl;
$cart_rules[0]['value_tax_excl'] = $order->total_shipping_tax_excl;
}
break;
default:
$this->errors[] = Tools::displayError('The discount type is invalid.');
}
$res = true;
foreach ($cart_rules as &$cart_rule) {
$cartRuleObj = new CartRule();
$cartRuleObj->date_from = date('Y-m-d H:i:s', strtotime('-1 hour', strtotime($order->date_add)));
$cartRuleObj->date_to = date('Y-m-d H:i:s', strtotime('+1 hour'));
$cartRuleObj->name[Configuration::get('PS_LANG_DEFAULT')] = Tools::getValue('discount_name');
$cartRuleObj->quantity = 0;
$cartRuleObj->quantity_per_user = 1;
if (Tools::getValue('discount_type') == 1) {
$cartRuleObj->reduction_percent = $discount_value;
} elseif (Tools::getValue('discount_type') == 2) {
$cartRuleObj->reduction_amount = $cart_rule['value_tax_excl'];
} elseif (Tools::getValue('discount_type') == 3) {
$cartRuleObj->free_shipping = 1;
}
$cartRuleObj->active = 0;
if ($res = $cartRuleObj->add()) {
$cart_rule['id'] = $cartRuleObj->id;
} else {
break;
}
}
if ($res) {
foreach ($cart_rules as $id_order_invoice => $cart_rule) {
$order_cart_rule = new OrderCartRule();
$order_cart_rule->id_order = $order->id;
$order_cart_rule->id_cart_rule = $cart_rule['id'];
$order_cart_rule->id_order_invoice = $id_order_invoice;
$order_cart_rule->name = Tools::getValue('discount_name');
$order_cart_rule->value = $cart_rule['value_tax_incl'];
$order_cart_rule->value_tax_excl = $cart_rule['value_tax_excl'];
$res &= $order_cart_rule->add();
$order->total_discounts += $order_cart_rule->value;
$order->total_discounts_tax_incl += $order_cart_rule->value;
$order->total_discounts_tax_excl += $order_cart_rule->value_tax_excl;
$order->total_paid -= $order_cart_rule->value;
$order->total_paid_tax_incl -= $order_cart_rule->value;
$order->total_paid_tax_excl -= $order_cart_rule->value_tax_excl;
}
$res &= $order->update();
}
if ($res) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=4&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('An error occurred during the OrderCartRule creation');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('sendStateEmail') && Tools::getValue('sendStateEmail') > 0 && Tools::getValue('id_order') > 0) {
if ($this->tabAccess['edit'] == '1') {
$order_state = new OrderState((int) Tools::getValue('sendStateEmail'));
if (!Validate::isLoadedObject($order_state)) {
$this->errors[] = Tools::displayError('An error occurred while loading order status.');
} else {
$history = new OrderHistory((int) Tools::getValue('id_order_history'));
$carrier = new Carrier($order->id_carrier, $order->id_lang);
$templateVars = array();
if ($order_state->id == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number) {
$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));
}
if ($history->sendEmail($order, $templateVars)) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $order->id . '&vieworder&conf=10&token=' . $this->token);
} else {
$this->errors[] = Tools::displayError('An error occurred while sending the e-mail to the customer.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
AdminController::postProcess();
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,10 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{installmentpayment}prestashop>installmentpayment_3adbdb3ac060038aa0e6e6c138ef9873'] = 'Categories';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_03937134cedab9078be39a77ee3a48a0'] = 'Groups';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_8da143e10941d8bd96516bbeecf6ed2e'] = 'Total amount taken in consideration';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_f01390a0b796aab97beed915df1cdd63'] = 'With VAT';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_90d64eeba8247d656ef6b4800ec0f52f'] = 'Without VAT';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_c453a4b8e8d98e82f35b67f433e3b4da'] = 'Means of payment';

View File

@@ -0,0 +1,196 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{installmentpayment}prestashop>installmentpayment_6b4e72e7cf9c59d33fdb4e72a164baad'] = 'Module de paiement d\'acompte';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_61d24f97a9fa7ccbffeb38888d303425'] = 'Ce module vous permet de définir un pourcentage d\'acompte à demander à vos clients pour la prise en compte de leur commande.';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_876f23178c29dc2552c0b48bf23cd9bd'] = 'Etes-vous sûr de vouloir désinstaller le module ?';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_6af91e35dff67a43ace060d1d57d5d1a'] = 'Votre configuration a été mise à jour.';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_578705d477a712220be516121eff456d'] = 'Etat par défaut du module';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_f4f70727dc34561dfde1a3c529b6205c'] = 'Configuration';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_e0ea5e1ae01232d801ccd4772f0010b3'] = 'Si vous voulez voir le manuel du module,';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_1d7f3e2b36a4394dfab58efdfdec94b0'] = 'cliquez-ici.';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_c99a316f9b60b5eeb720d8b5c954081f'] = 'Montant de l\'acompte';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_7bc20f2c044911c5a8444ee34ee40d29'] = 'Indiquez ici, le montant ou le % d\'acompte que vous souhaitez et sélectionnez le ci-dessous.';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_3914440fc300e40caa9a75aa3cd88cf4'] = 'Type';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_37be07209f53a5d636d5c904ca9ae64c'] = 'Pourcentage';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_b2f40690858b404ed10e62bdf422c704'] = 'Montant';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_3adbdb3ac060038aa0e6e6c138ef9873'] = 'Catégories';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_dbb88b79ca56585629de938414af7d07'] = 'Vous pouvez limiter l\'acompte au produits de certaines catégories.';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_03937134cedab9078be39a77ee3a48a0'] = 'Groupes';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_6355279e6b0a8e99ae7e7913cbc516cb'] = 'Vous pouvez limiter l\'acompte à certains groupes';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_62c4a09c770b4e36f0e7edf1b5cb208c'] = 'Etats';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_641ef4a69057dbf3bb82c5675b7e35de'] = 'Vous pouvez choisir un état qui sera appliqué pour le paiement final.';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_8da143e10941d8bd96516bbeecf6ed2e'] = 'Montant total pris en compte';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_47fa8ab681a52c8ccf51cd8e05e936eb'] = 'Souhaitez-vous baser l\'acompte sur le montant HT ou TTC.';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_f01390a0b796aab97beed915df1cdd63'] = 'TTC';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_90d64eeba8247d656ef6b4800ec0f52f'] = 'HT';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_9f06b28a40790c4c4df5739bce3c1eb0'] = 'Frais de Tranport';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_6f6d8dc32a175256ac38c409bd38fa29'] = 'Souhaitez-vous prendre en compte les frais de port dans le calcul.';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_370964eec07cba8c52acb1ce1b35ab6a'] = 'Avec';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_0586e7e1f27bc4035f1f33c73f80f984'] = 'Sans';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_e3476e1cff8e3e52db7563f3e63c3713'] = 'Choisir le type de paiement';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_af20c0b338d1876e94506fb69cd671cf'] = 'Indiquez ici, si vous souhaitez que le client puisse choisir de payer l\'acompte ou la totalité de la commande, ou seulement l\'acompte.';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_93cba07454f06a4a960172bbd6e2a435'] = 'Oui';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_bafd7322c6e97d25b6299b5d6fe8920b'] = 'Non';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_221aac76f3a53a27b63ce7461b0c9360'] = 'Minimum de commande';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_08e4cc80835a4959e32dbdf4754fd182'] = 'Indiquez ici, a parir de quel montant de commande l\'acompte sera proposé. Mettez 0 si vous ne voulez pas de minimum de commande.';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_e23cc294d74f5f6c261686343d06027a'] = 'Nb de jours mail de solde';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_392b039922e571cab88af4d68d3eeb42'] = 'Indiquez ici le nombre de jours avant l\'envoi du mail au client pour le paiement du solde de la commande.';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_c453a4b8e8d98e82f35b67f433e3b4da'] = 'Moyens de paiements';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_cb26f7a7514ff6858aed43b4b763e2d2'] = 'Si vous le souhaitez, vous pouvez indiquer ici les moyens de paiements qui seront affichés si le client décide de payer un acompte (utiliser CTRL + clic pour en sélectionner plusieurs).';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_c9cc8cce247e49bae79f15173ce97354'] = 'Enregistrer';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_ad0ce8711cd6fdf52c43ff7a4606c5a9'] = 'Indiquez ici le montant du pourcentage d\'acompte pour le groupe ';
$_MODULE['<{installmentpayment}prestashop>installmentpayment_7e0df229121f7a77d570c7f3e48b5926'] = 'Il reste à payer pour la commande n°';
$_MODULE['<{installmentpayment}prestashop>paymentmodule_448bd0e2ddbe48835ef390d8a9472853'] = 'Acompte';
$_MODULE['<{installmentpayment}prestashop>adminorderscontroller_d201284604b35aa9392cb9c1acc434a6'] = 'Avoir pour la commande #%d';
$_MODULE['<{installmentpayment}prestashop>adminorderscontroller_bbee72681d2c075d95355d3d9ccefb4e'] = 'Avoir CB pour la commande #%d';
$_MODULE['<{installmentpayment}prestashop>adminorderscontroller_e49701f123af735cf327227e8ab09bac'] = 'Commande manuelle - Employé :';
$_MODULE['<{installmentpayment}prestashop>checkout_1ae8d8e07fca970e307f47121f630e75'] = 'Sélectionné ci-dessous le moyen de paiement pour payer le solde de votre commande ';
$_MODULE['<{installmentpayment}prestashop>checkout_91b442d385b54e1418d81adc34871053'] = 'Sélectionné';
$_MODULE['<{installmentpayment}prestashop>checkout_961f2247a2070bedff9f9cd8d64e2650'] = 'Choisissez';
$_MODULE['<{installmentpayment}prestashop>checkout_97b72d419a22e2d1144b2fb05ee26901'] = 'Malheureusement, il n\'y a pas de moyens de paiements disponibles.';
$_MODULE['<{installmentpayment}prestashop>checkout_5486191906ec27c1c4bb5bd3e46b3442'] = 'Commande avec une obligation de paiement';
$_MODULE['<{installmentpayment}prestashop>order-payment-classic_f75550dbc21dca3c61c279f2349908e9'] = 'Sélectionnez ci-dessous votre moyen de paiement pour régler le solde de';
$_MODULE['<{installmentpayment}prestashop>order-payment-classic_4472184f5ce2a12c761b8812ea55b653'] = 'pour votre commande';
$_MODULE['<{installmentpayment}prestashop>order-payment-classic_8e1263b23607508e7ba8ff39aec8031d'] = 'Aucun module de paiement n\'a été installé.';
$_MODULE['<{installmentpayment}prestashop>cart-empty_300225ee958b6350abc51805dab83c24'] = 'Choisir d\'autres produits';
$_MODULE['<{installmentpayment}prestashop>cart-empty_6ff063fbc860a79759a7369ac32cee22'] = 'Terminer';
$_MODULE['<{installmentpayment}prestashop>order-confirmation_7f21696f11929f5ed55ca5bcb15d2fc1'] = 'Votre commande est confirmé';
$_MODULE['<{installmentpayment}prestashop>order-confirmation_b8627ccd34529880156129d02a9ca37d'] = 'Un mail a été envoyé à votre adresse %email%.';
$_MODULE['<{installmentpayment}prestashop>order-confirmation_f5d74ea75357b5e139854c14f8e24fe3'] = 'Détails de commande';
$_MODULE['<{installmentpayment}prestashop>order-confirmation_00cd7d0890cd975da95799c32764c9ce'] = 'N° de commande : %reference%';
$_MODULE['<{installmentpayment}prestashop>order-confirmation_e120387480bc284c5347ae1baa480670'] = 'Méthode de paiement : %method%';
$_MODULE['<{installmentpayment}prestashop>order-confirmation_080753487a8bc0bb9a5275bcb9951516'] = 'Livraison : %method%';
$_MODULE['<{installmentpayment}prestashop>order-confirmation_cc6f3e2192d71f54d7b181d91f04d165'] = 'Pour gagner du temps sur votre prochiane commande, enregistrez-vous';
$_MODULE['<{installmentpayment}prestashop>cart_b75443a19207ed3a3552edda86536857'] = 'Panier';
$_MODULE['<{installmentpayment}prestashop>cart_300225ee958b6350abc51805dab83c24'] = 'Choisir d\'autres produits';
$_MODULE['<{installmentpayment}prestashop>customer-form_2fdfd506efea08144c0794c32ca8250a'] = 'Créer un compte';
$_MODULE['<{installmentpayment}prestashop>customer-form_f53d1cd25e03173ba9eaa4e493636769'] = '(optionnel)';
$_MODULE['<{installmentpayment}prestashop>customer-form_c8334d474f091b12e87cf4f8632269f3'] = 'Et gagnez du temps sur votre prochainne commande !';
$_MODULE['<{installmentpayment}prestashop>customer-form_a0bfb8e59e6c13fc8d990781f77694fe'] = 'Continuer';
$_MODULE['<{installmentpayment}prestashop>order-final-summary-table_e3e83a01990288b492a11a955723343d'] = '%product_count% produit dans votre panier';
$_MODULE['<{installmentpayment}prestashop>order-final-summary-table_3f5cb84c95c577127e3f9e96d405d21b'] = '%product_count% produits dans votre panier';
$_MODULE['<{installmentpayment}prestashop>cart-voucher_3111382b0f345f39639de6e580a94933'] = 'Avez-vous un code de remise ?';
$_MODULE['<{installmentpayment}prestashop>cart-voucher_0ab608f7e0d1501be457f7646c1e57c0'] = 'Code remise';
$_MODULE['<{installmentpayment}prestashop>cart-voucher_ec211f7c20af43e742bf2570c3cb84f9'] = 'Ajouter';
$_MODULE['<{installmentpayment}prestashop>cart-voucher_12a7a93d72ded50311b52c7d0a853e3c'] = 'Obtenir les avantages de notre offre exclusive :';
$_MODULE['<{installmentpayment}prestashop>footer_9fcba387b581ec9abcbff15e62317da5'] = 'Logiciel e-commerce par';
$_MODULE['<{installmentpayment}prestashop>cart-detailed-product-line_54c02ba7929b1fda4847991a45b58a48'] = 'Personnalisation produit';
$_MODULE['<{installmentpayment}prestashop>cart-detailed-product-line_0d9175fe89fb80d815e7d03698b6e83a'] = 'Cadeau';
$_MODULE['<{installmentpayment}prestashop>cart-detailed_2f0dca8966242e58b83e0afc012b178b'] = 'Il n\'y a pas plus de produits dans votre panier ';
$_MODULE['<{installmentpayment}prestashop>login-form_a0bfb8e59e6c13fc8d990781f77694fe'] = 'Continuer';
$_MODULE['<{installmentpayment}prestashop>header_96d6f2e7e1f705ab5e59c84a6dc009b2'] = 'logo';
$_MODULE['<{installmentpayment}prestashop>address-form_5c74d926c4b89517ad64133990d04413'] = 'Utiliser cette adresse pour la facturation aussi';
$_MODULE['<{installmentpayment}prestashop>address-form_c9cc8cce247e49bae79f15173ce97354'] = 'Enregistrer';
$_MODULE['<{installmentpayment}prestashop>address-form_ea4788705e6873b424c65e91c2846b19'] = 'Annuler';
$_MODULE['<{installmentpayment}prestashop>address-form_a0bfb8e59e6c13fc8d990781f77694fe'] = 'Continuer';
$_MODULE['<{installmentpayment}prestashop>cart-summary_acb0f29bb6d39aaabc7d2d62aaa4a57d'] = 'Voir les détails';
$_MODULE['<{installmentpayment}prestashop>address-selector-block_7dce122004969d56ae2e0245cb754d35'] = 'Edition';
$_MODULE['<{installmentpayment}prestashop>address-selector-block_f2a6c498fb90ee345d997f888fce3b18'] = 'Supprimer';
$_MODULE['<{installmentpayment}prestashop>address-selector-block_c9cc8cce247e49bae79f15173ce97354'] = 'Enregistrer';
$_MODULE['<{installmentpayment}prestashop>order-final-summary_7ce3a11073ffba68bd1e83e243aaabf7'] = 'Contrôlez votre commande avant de payer';
$_MODULE['<{installmentpayment}prestashop>order-final-summary_284b47b0bb63ae2df3b29f0e691d6fcf'] = 'Adresses';
$_MODULE['<{installmentpayment}prestashop>order-final-summary_f2a5a4ccf14820292a27cca1c8cab12e'] = 'Votre adresse de livraison';
$_MODULE['<{installmentpayment}prestashop>order-final-summary_baa63a898921164abe2d1d532ab27e79'] = 'Votre adresse de facturation';
$_MODULE['<{installmentpayment}prestashop>order-final-summary_49ffd9480effff979143d2e8d38931c4'] = 'Méthode de livraison';
$_MODULE['<{installmentpayment}prestashop>order-confirmation-table_2cee9edacddde0856a46d7db6aff9110'] = 'Détails commande';
$_MODULE['<{installmentpayment}prestashop>order-confirmation-table_54c02ba7929b1fda4847991a45b58a48'] = 'Personnalisation produit';
$_MODULE['<{installmentpayment}prestashop>shipping_9193b58520051d8b59ca64a5cc5353ff'] = 'J\'aimerais recevoir ma commande dans un emballage reciclé.';
$_MODULE['<{installmentpayment}prestashop>shipping_bf46d59ab4c5096d169c1a5eb39cc0c1'] = 'Si vous le souhaitez, vous pouvez ajouter un message :';
$_MODULE['<{installmentpayment}prestashop>shipping_a0bfb8e59e6c13fc8d990781f77694fe'] = 'Continuer';
$_MODULE['<{installmentpayment}prestashop>shipping_9a605fc0e1667ebdbd0ac37cf9f90789'] = 'Malheureusement, il n\'y a pas de transporteurs qui livrent à cette adresse.';
$_MODULE['<{installmentpayment}prestashop>payment_91b442d385b54e1418d81adc34871053'] = 'Sélectionner';
$_MODULE['<{installmentpayment}prestashop>payment_961f2247a2070bedff9f9cd8d64e2650'] = 'Choisissez';
$_MODULE['<{installmentpayment}prestashop>payment_97b72d419a22e2d1144b2fb05ee26901'] = 'Malheureusement, il n\'y a pas de méthode de paiement disponible.';
$_MODULE['<{installmentpayment}prestashop>payment_9ea465e939c30ceba6e0d46810913142'] = 'En confirmant cette commande, vous certifiez avoir lu et être en accord avec toutes les conditions suivantes :';
$_MODULE['<{installmentpayment}prestashop>payment_5486191906ec27c1c4bb5bd3e46b3442'] = 'Commande avec une obligation de paiement';
$_MODULE['<{installmentpayment}prestashop>addresses_48974cc3df177e6b565c39aa155458cd'] = 'Adresse de livraison';
$_MODULE['<{installmentpayment}prestashop>addresses_56d0ed7cd789dd772be59aa6b1e437de'] = 'L\'adresse sélectionné sera utilisé à la fois comme comme votre adresse personnelle (pour la facture) et comme votre adresse de livraison.';
$_MODULE['<{installmentpayment}prestashop>addresses_dc024b376ebf01abd90cf4d5e4dca1c7'] = 'L\'adresse sélectionné sera utilisé comme votre adresse personnelle (pour la facture).';
$_MODULE['<{installmentpayment}prestashop>addresses_e512598333dceaaaf22889038b89a4a4'] = 'Ajouter une nouvelle adresse';
$_MODULE['<{installmentpayment}prestashop>addresses_313d7cbfa2b3c25f09d69ad7e40974a7'] = 'L\'adresse de facturation est différente de l\'adresse de livraison';
$_MODULE['<{installmentpayment}prestashop>addresses_baa63a898921164abe2d1d532ab27e79'] = 'Votre adresse de facturation';
$_MODULE['<{installmentpayment}prestashop>addresses_a0bfb8e59e6c13fc8d990781f77694fe'] = 'Continuer';
$_MODULE['<{installmentpayment}prestashop>personal-information_3e0b39c8cd14dd15fff36eecf9c19861'] = 'Si vous vous déconnectez maintenant, votre panier sera vidé.';
$_MODULE['<{installmentpayment}prestashop>personal-information_c1fc8e1c54652420d0822e0614089df6'] = 'Commande comme invité';
$_MODULE['<{installmentpayment}prestashop>personal-information_2fdfd506efea08144c0794c32ca8250a'] = 'Créer un compte';
$_MODULE['<{installmentpayment}prestashop>personal-information_b6d4223e60986fa4c9af77ee5f7149c5'] = 'Enregistrer';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_es_b0f79042ac83c64f3ccc42268c8ade26'] = 'Total produits';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_es_a5e35abc0c9e2d2784d0ef619b36448b'] = 'Montant de la livraison';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_es_b00b85425e74ed2c85dc3119b78ff2c3'] = 'Frais gratuit';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_es_dd704458c6b79d0e86d171f1523918c3'] = 'Total des remises';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_es_b94cb106eaa958b2ab473da305e57977'] = 'Total HT';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_es_ced2da7b2baf942c0ffd4b8e45ec0fad'] = 'Frais d\'emballage';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_es_b602e0d0c6a72053d0a5be60cb2f8126'] = 'Montant TVA';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_es_776a4f1f391ad4e2173fd4647c442783'] = 'Total TTC';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_es_02faedbf7db64bd67d05c55841f17d02'] = 'Total déjà payé';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_es_72f33f76e6b98d751c62d21b1606f965'] = 'Reste à payer';
$_MODULE['<{installmentpayment}prestashop>order_installment_6b4e72e7cf9c59d33fdb4e72a164baad'] = 'Paiement de l\'acompte';
$_MODULE['<{installmentpayment}prestashop>order_installment_e0010a0a1a3259ab5c06a19bad532851'] = 'Payé';
$_MODULE['<{installmentpayment}prestashop>order_installment_65e8800b5c6800aad896f888b2a62afc'] = 'Reste à payer';
$_MODULE['<{installmentpayment}prestashop>order_installment_96b0141273eabab320119c467cdcaf17'] = 'Total';
$_MODULE['<{installmentpayment}prestashop>order_installment_694ae897645ed4f6c18dd496f0916e2d'] = 'Email envoyé avec succès';
$_MODULE['<{installmentpayment}prestashop>order_installment_803138044f8a43e9dcb5a76722ee06d0'] = 'Demande du solde';
$_MODULE['<{installmentpayment}prestashop>order_detail_6b4e72e7cf9c59d33fdb4e72a164baad'] = 'Paiement de l\'acompte';
$_MODULE['<{installmentpayment}prestashop>order_detail_e0010a0a1a3259ab5c06a19bad532851'] = 'Payé';
$_MODULE['<{installmentpayment}prestashop>order_detail_55276c10d84e1df7713b441e76e141f9'] = 'Reste à payer';
$_MODULE['<{installmentpayment}prestashop>order_detail_96b0141273eabab320119c467cdcaf17'] = 'Total';
$_MODULE['<{installmentpayment}prestashop>installment_chose1_7_1c789452d8f2bf58762061b6182bc9ab'] = 'Vous souhaitez payer un acompte ou le total de la commande ?';
$_MODULE['<{installmentpayment}prestashop>installment_chose1_7_379cf9468747cda20a137a08f013cd36'] = 'Type de paiement :';
$_MODULE['<{installmentpayment}prestashop>installment_chose1_7_96b0141273eabab320119c467cdcaf17'] = 'Le total';
$_MODULE['<{installmentpayment}prestashop>installment_chose1_7_aba473bd185007b5cb12488b3c9bfe14'] = 'Un acompte';
$_MODULE['<{installmentpayment}prestashop>installment_chose1_7_b4e3854000631e313ae27cf32eca04b0'] = 'Sélectionnez ci-dessous le moyen de paiement pour régler l\'acompte de %s €.';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_fr_b0f79042ac83c64f3ccc42268c8ade26'] = 'Total des produits';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_fr_a5e35abc0c9e2d2784d0ef619b36448b'] = 'Frais de livraison';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_fr_b00b85425e74ed2c85dc3119b78ff2c3'] = 'Livraison gratuite';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_fr_dd704458c6b79d0e86d171f1523918c3'] = 'Total des remises';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_fr_b94cb106eaa958b2ab473da305e57977'] = 'Montant HT';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_fr_ced2da7b2baf942c0ffd4b8e45ec0fad'] = 'Frais d\'emballage';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_fr_b602e0d0c6a72053d0a5be60cb2f8126'] = 'Montant de la TVA';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_fr_776a4f1f391ad4e2173fd4647c442783'] = 'Total TTC';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_fr_02faedbf7db64bd67d05c55841f17d02'] = 'Total déjà payé';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_fr_72f33f76e6b98d751c62d21b1606f965'] = 'Reste à payer';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_en_b0f79042ac83c64f3ccc42268c8ade26'] = 'Total des produits';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_en_a5e35abc0c9e2d2784d0ef619b36448b'] = 'Frais de livraisons';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_en_b00b85425e74ed2c85dc3119b78ff2c3'] = 'Port gratuit';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_en_dd704458c6b79d0e86d171f1523918c3'] = 'Total des remises';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_en_ced2da7b2baf942c0ffd4b8e45ec0fad'] = 'Frais d\'emballage';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_en_b94cb106eaa958b2ab473da305e57977'] = 'Montant HT';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_en_b602e0d0c6a72053d0a5be60cb2f8126'] = 'Montant de la TVA';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_en_96b0141273eabab320119c467cdcaf17'] = 'Montant';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_en_e910dabc81357f81e33ea7eb8a6201c0'] = 'Montant payé';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab_en_92dd44d0d34d56a69dbdb0fdab52b9af'] = 'Reste à payer';
$_MODULE['<{installmentpayment}prestashop>invoice_installment_288b31f318ea3f08abe5b9c438a6e05c'] = 'Déjà payé';
$_MODULE['<{installmentpayment}prestashop>invoice_installment_2191d22b3afef4bdce659da08547d6ba'] = 'Reste à régler';
$_MODULE['<{installmentpayment}prestashop>installment_chose_1c789452d8f2bf58762061b6182bc9ab'] = 'Vous souhaitez payer un acompte ou la totalité ?';
$_MODULE['<{installmentpayment}prestashop>installment_chose_379cf9468747cda20a137a08f013cd36'] = 'Type de paiement :';
$_MODULE['<{installmentpayment}prestashop>installment_chose_96b0141273eabab320119c467cdcaf17'] = 'Totalité';
$_MODULE['<{installmentpayment}prestashop>installment_chose_aba473bd185007b5cb12488b3c9bfe14'] = 'Un acompte';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_en_b0f79042ac83c64f3ccc42268c8ade26'] = 'Total des produits';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_en_dd704458c6b79d0e86d171f1523918c3'] = 'Total des remises';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_en_ced2da7b2baf942c0ffd4b8e45ec0fad'] = 'Coût de l\'emballage';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_en_b94cb106eaa958b2ab473da305e57977'] = 'Total HT';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_en_b602e0d0c6a72053d0a5be60cb2f8126'] = 'Montant des taxes';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_en_96b0141273eabab320119c467cdcaf17'] = 'Total';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_en_e910dabc81357f81e33ea7eb8a6201c0'] = 'Montant payé';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_en_92dd44d0d34d56a69dbdb0fdab52b9af'] = 'Reste à payer';
$_MODULE['<{installmentpayment}prestashop>invoice.tax-tab2_fr_023f66b09075fa1cc29e74bed9f5ac40'] = 'Détail des taxes';
$_MODULE['<{installmentpayment}prestashop>invoice.tax-tab2_fr_8fe77c2601e54f1aaef28cfde997bbad'] = 'Taux de taxe';
$_MODULE['<{installmentpayment}prestashop>invoice.tax-tab2_fr_ad0d28cdd9113d3ce911bc064b137cde'] = 'Prix de base';
$_MODULE['<{installmentpayment}prestashop>invoice.tax-tab2_fr_b602e0d0c6a72053d0a5be60cb2f8126'] = 'Total Taxe';
$_MODULE['<{installmentpayment}prestashop>invoice.tax-tab2_fr_459f93c30d7bc374abe95e0d8a1c66b0'] = 'Acompte';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_fr_b0f79042ac83c64f3ccc42268c8ade26'] = 'Total des produits';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_fr_dd704458c6b79d0e86d171f1523918c3'] = 'Total des remises';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_fr_ced2da7b2baf942c0ffd4b8e45ec0fad'] = 'Total de l\'emballage';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_fr_b94cb106eaa958b2ab473da305e57977'] = 'Montant HT';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_fr_b602e0d0c6a72053d0a5be60cb2f8126'] = 'Montant TVA';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_fr_96b0141273eabab320119c467cdcaf17'] = 'Montant';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_fr_e910dabc81357f81e33ea7eb8a6201c0'] = 'Montant payé';
$_MODULE['<{installmentpayment}prestashop>invoice.total-tab2_fr_92dd44d0d34d56a69dbdb0fdab52b9af'] = 'Reste à payer';
$_MODULE['<{installmentpayment}prestashop>invoice.tax-tab2_en_023f66b09075fa1cc29e74bed9f5ac40'] = 'Détail des taxes';
$_MODULE['<{installmentpayment}prestashop>invoice.tax-tab2_en_8fe77c2601e54f1aaef28cfde997bbad'] = 'Taux de taxe';
$_MODULE['<{installmentpayment}prestashop>invoice.tax-tab2_en_ad0d28cdd9113d3ce911bc064b137cde'] = 'Prix de base';
$_MODULE['<{installmentpayment}prestashop>invoice.tax-tab2_en_b602e0d0c6a72053d0a5be60cb2f8126'] = 'Total TVA';
$_MODULE['<{installmentpayment}prestashop>invoice.tax-tab2_en_459f93c30d7bc374abe95e0d8a1c66b0'] = 'Acompte';
$_MODULE['<{installmentpayment}prestashop>invoice.empty_472c2bcc791460c61bc6dd007df8bfce'] = 'Acompte sur commande n° ';

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,172 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<!doctype html>
<html lang="{$language.iso_code|escape:'htmlall':'UTF-8'}">
<head>
{block name='head'}
{include file='_partials/head.tpl'}
{/block}
</head>
<body id="checkout" class="{$page.body_classes|classnames}">
{hook h='displayAfterBodyOpeningTag'}
<header id="header">
{block name='header'}
{include file='checkout/_partials/header.tpl'}
{/block}
</header>
{block name='notifications'}
{include file='_partials/notifications.tpl'}
{/block}
<section id="wrapper" style="min-height:500px;">
<div class="container">
{block name='content'}
<section id="content">
<div class="row">
<div class="payment-options col-md-8">
<p>{l s='Select below, your mean of payment for payed the balance of your order ' mod='installmentpayment'}{$reference|escape:'htmlall':'UTF-8'}</p>
{foreach from=$payment_options item="module_options"}
{foreach from=$module_options item="option"}
<div style="margin-bottom:20px;">
<div id="{$option.id|escape:'htmlall':'UTF-8'}-container" class="payment-option clearfix">
{* This is the way an option should be selected when Javascript is enabled *}
<span class="custom-radio pull-xs-left">
<input
class="ps-shown-by-js {if $option.binary} binary {/if}"
id="{$option.id|escape:'htmlall':'UTF-8'}"
data-module-name="{$option.module_name|escape:'htmlall':'UTF-8'}"
name="payment-option"
type="radio"
required
{if $selected_payment_option == $option.id} checked {/if}
>
<span></span>
</span>
{* This is the way an option should be selected when Javascript is disabled *}
<form method="GET" class="ps-hidden-by-js">
{if $option.id === $selected_payment_option}
{l s='Selected' d='Shop.Theme.Checkout' mod='installmentpayment'}
{else}
<button class="ps-hidden-by-js" type="submit" name="select_payment_option" value="{$option.id|escape:'htmlall':'UTF-8'}">
{l s='Choose' d='Shop.Theme.Actions' mod='installmentpayment'}
</button>
{/if}
</form>
<label for="{$option.id|escape:'htmlall':'UTF-8'}">
<span>{$option.call_to_action_text|escape:'htmlall':'UTF-8'}</span>
{if $option.logo}
<img src="{$option.logo|escape:'htmlall':'UTF-8'}">
{/if}
</label>
</div>
</div>
{if $option.additionalInformation}
<div
id="{$option.id|escape:'htmlall':'UTF-8'}-additional-information"
class="js-additional-information definition-list additional-information{if $option.id != $selected_payment_option} ps-hidden {/if}"
>
{$option.additionalInformation nofilter}{* HTML comment, no escape necessary *}
</div>
{/if}
<div
id="pay-with-{$option.id|escape:'htmlall':'UTF-8'}-form"
class="js-payment-option-form {if $option.id != $selected_payment_option} ps-hidden {/if}"
>
{if $option.form}
{$option.form|escape:'htmlall':'UTF-8'}
{else}
<form id="payment-form" method="POST" action="{$option.action|escape:'htmlall':'UTF-8'}">
{foreach from=$option.inputs item=input}
<input type="{$input.type|escape:'htmlall':'UTF-8'}" name="{$input.name|escape:'htmlall':'UTF-8'}" value="{$input.value|escape:'htmlall':'UTF-8'}">
{/foreach}
<button style="display:none" id="pay-with-{$option.id|escape:'htmlall':'UTF-8'}" type="submit"></button>
</form>
{/if}
</div>
{/foreach}
{foreachelse}
<p class="alert alert-danger">{l s='Unfortunately, there are no payment method available.' d='Shop.Theme.Checkout' mod='installmentpayment'}</p>
{/foreach}
</div>
<div class="col-md-4">
{include file='checkout/_partials/cart-summary.tpl' cart = $cart}
{hook h='displayReassurance'}
</div>
<div class="ps-shown-by-js col-md-12">
{literal}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(function(){
$('.ps-shown-by-js').on('change', function(){
$('.main-button').attr('id', $(this).attr('id'));
});
$('.main-button').on('click', function(){
var buttonpay = $(this).attr('id');
$('#pay-with-'+buttonpay).click();
});
});
</script>
{/literal}
<button type="submit" {if !$selected_payment_option} disabled {/if} class="btn btn-primary center-block main-button">
{l s='Order with an obligation to pay' d='Shop.Theme.Checkout' mod='installmentpayment'}
</button>
</div>
</div>
</div>
</section>
{/block}
</div>
</section>
<footer id="footer">
{block name='footer'}
{include file='checkout/_partials/footer.tpl'}
{/block}
</footer>
{block name='javascript_bottom'}
{include file="_partials/javascript.tpl" javascript=$javascript.bottom}
{/block}
{hook h='displayBeforeBodyClosingTag'}
</body>
</html>

View File

@@ -0,0 +1,61 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file='customer/_partials/address-form.tpl'}
{block name='form_field'}
{if $field.name eq "alias"}
{* we don't ask for alias here *}
{else}
{$smarty.block.parent|escape:'htmlall':'UTF-8'}
{/if}
{/block}
{block name='form_fields' append}
<input type="hidden" name="saveAddress" value="{$type|escape:'htmlall':'UTF-8'}">
{if $type === "delivery"}
<div class="form-group row">
<div class="col-md-9 col-md-offset-3">
<input name = "use_same_address" type = "checkbox" value = "1" {if $use_same_address} checked {/if}>
<label>{l s='Use this address for invoice too' d='Shop.Theme.Checkout' mod='installmentpayment'}</label>
</div>
</div>
{/if}
{/block}
{block name='form_buttons'}
{if !$form_has_continue_button}
<button type="submit" class="btn btn-primary pull-xs-right">{l s='Save' d='Shop.Theme.Actions' mod='installmentpayment'}</button>
<a class="js-cancel-address cancel-address pull-xs-right" href="?cancelAddress={$type|escape:'htmlall':'UTF-8'}">{l s='Cancel' d='Shop.Theme.Actions' mod='installmentpayment'}</a>
{else}
<form>
<button type="submit" class="continue btn btn-primary pull-xs-right" name="confirm-addresses" value="1">
{l s='Continue' d='Shop.Theme.Actions' mod='installmentpayment'}
</button>
{if $customer.addresses|count > 0}
<a class="js-cancel-address cancel-address pull-xs-right" href="?cancelAddress={$type|escape:'htmlall':'UTF-8'}">{l s='Cancel' d='Shop.Theme.Actions' mod='installmentpayment'}</a>
{/if}
</form>
{/if}
{/block}

View File

@@ -0,0 +1,70 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{foreach $addresses as $address}
<article
class="address-item{if $address.id == $selected} selected{/if}"
id="{$name|classname}-address-{$address.id|escape:'htmlall':'UTF-8'}"
>
<header class="h4">
<label class="radio-block">
<span class="custom-radio">
<input
type="radio"
name="{$name|escape:'htmlall':'UTF-8'}"
value="{$address.id|escape:'htmlall':'UTF-8'}"
{if $address.id == $selected}checked{/if}
>
<span></span>
</span>
<span class="address-alias h4">{$address.alias|escape:'htmlall':'UTF-8'}</span>
<div class="address">{$address.formatted nofilter|escape:'htmlall':'UTF-8'}</div>
</label>
</header>
<hr>
<footer class="address-footer">
{if $interactive}
<a
class="edit-address text-muted"
data-link-action="edit-address"
href="{url entity='order' params=['id_address' => $address.id, 'editAddress' => $type, 'token' => $token]}"
>
<i class="material-icons edit">&#xE254;</i>{l s='Edit' d='Shop.Theme.Actions' mod='installmentpayment'}
</a>
<a
class="delete-address text-muted"
data-link-action="delete-address"
href="{url entity='order' params=['id_address' => $address.id, 'deleteAddress' => true, 'token' => $token]}"
>
<i class="material-icons delete">&#xE872;</i>{l s='Delete' d='Shop.Theme.Actions' mod='installmentpayment'}
</a>
{/if}
</footer>
</article>
{/foreach}
{if $interactive}
<p>
<button class="ps-hidden-by-js form-control-submit center-block" type="submit">{l s='Save' d='Shop.Theme.Actions' mod='installmentpayment'}</button>
</p>
{/if}

View File

@@ -0,0 +1,39 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="checkout cart-detailed-actions card-block">
{if $cart.minimalPurchaseRequired}
<div class="alert alert-warning" role="alert">
{$cart.minimalPurchaseRequired|escape:'htmlall':'UTF-8'}
</div>
<div class="text-xs-center">
<button type="button" class="btn btn-primary disabled" disabled>{l s='Checkout' d='Shop.Theme.Actions' mod='installmentpayment'}</button>
</div>
{else}
<div class="text-xs-center">
<a href="{$urls.pages.order|escape:'htmlall':'UTF-8'}" class="btn btn-primary">{l s='Checkout' d='Shop.Theme.Actions' mod='installmentpayment'}</a>
{hook h='displayExpressCheckout'}
</div>
{/if}
</div>

View File

@@ -0,0 +1,153 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="product-line-grid">
<!-- product left content: image-->
<div class="product-line-grid-left col-md-3 col-xs-4">
<span class="product-image media-middle">
<img src="{$product.cover.bySize.cart_default.url|escape:'htmlall':'UTF-8'}" alt="{$product.name|escape:'quotes'}">
</span>
</div>
<!-- product left body: description -->
<div class="product-line-grid-body col-md-4 col-xs-8">
<div class="product-line-info">
<a class="label" href="{$product.url|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'}</a>
</div>
<div class="product-line-info">
<span class="value">{$product.price|escape:'htmlall':'UTF-8'}</span>
{if $product.unit_price_full}
<div class="unit-price-cart">{$product.unit_price_full|escape:'htmlall':'UTF-8'}</div>
{/if}
</div>
<br/>
{foreach from=$product.attributes key="attribute" item="value"}
<div class="product-line-info">
<span class="label">{$attribute|escape:'htmlall':'UTF-8'}:</span>
<span class="value">{$value|escape:'htmlall':'UTF-8'}</span>
</div>
{/foreach}
{if $product.customizations|count}
<br/>
{foreach from=$product.customizations item="customization"}
<a href="#" data-toggle="modal" data-target="#product-customizations-modal-{$customization.id_customization|escape:'htmlall':'UTF-8'}">{l s='Product customization' d='Shop.Theme.Catalog' mod='installmentpayment'}</a>
<div class="modal fade customization-modal" id="product-customizations-modal-{$customization.id_customization|escape:'htmlall':'UTF-8'}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">{l s='Product customization' d='Shop.Theme.Catalog' mod='installmentpayment'}</h4>
</div>
<div class="modal-body">
{foreach from=$customization.fields item="field"}
<div class="product-customization-line row">
<div class="col-sm-3 col-xs-4 label">
{$field.label|escape:'htmlall':'UTF-8'}
</div>
<div class="col-sm-9 col-xs-8 value">
{if $field.type == 'text'}
{if (int)$field.id_module}
{$field.text nofilter|escape:'htmlall':'UTF-8'}
{else}
{$field.text|escape:'htmlall':'UTF-8'}
{/if}
{elseif $field.type == 'image'}
<img src="{$field.image.small.url|escape:'htmlall':'UTF-8'}">
{/if}
</div>
</div>
{/foreach}
</div>
</div>
</div>
</div>
{/foreach}
{/if}
</div>
<!-- product left body: description -->
<div class="product-line-grid-right product-line-actions col-md-5 col-xs-12">
<div class="row">
<div class="col-xs-4 hidden-md-up"></div>
<div class="col-md-10 col-xs-6">
<div class="row">
<div class="col-md-6 col-xs-6 qty">
{if isset($product.is_gift) && $product.is_gift}
<span class="gift-quantity">{$product.quantity|escape:'htmlall':'UTF-8'}</span>
{else}
<input
class="js-cart-line-product-quantity"
data-down-url="{$product.down_quantity_url|escape:'htmlall':'UTF-8'}"
data-up-url="{$product.up_quantity_url|escape:'htmlall':'UTF-8'}"
data-update-url="{$product.update_quantity_url|escape:'htmlall':'UTF-8'}"
data-product-id="{$product.id_product|escape:'htmlall':'UTF-8'}"
type="text"
value="{$product.quantity|escape:'htmlall':'UTF-8'}"
name="product-quantity-spin"
min="{$product.minimal_quantity|escape:'htmlall':'UTF-8'}"
/>
{/if}
</div>
<div class="col-md-6 col-xs-2 price">
<span class="product-price">
<strong>
{if isset($product.is_gift) && $product.is_gift}
<span class="gift">{l s='Gift' d='Shop.Theme.Checkout' mod='installmentpayment'}</span>
{else}
{$product.total|escape:'htmlall':'UTF-8'}
{/if}
</strong>
</span>
</div>
</div>
</div>
<div class="col-md-2 col-xs-2 text-xs-right">
<div class="cart-line-product-actions ">
<a
class = "remove-from-cart"
rel = "nofollow"
href = "{$product.remove_from_cart_url|escape:'htmlall':'UTF-8'}"
data-link-action = "delete-from-cart"
data-id-product = "{$product.id_product|escape:'javascript'}"
data-id-product-attribute = "{$product.id_product_attribute|escape:'javascript'}"
data-id-customization = "{$product.id_customization|escape:'javascript'}"
>
{if !isset($product.is_gift) || !$product.is_gift}
<i class="material-icons pull-xs-left">delete</i>
{/if}
</a>
{hook h='displayCartExtraProductActions' product=$product}
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
</div>

View File

@@ -0,0 +1,66 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="cart-detailed-totals">
<div class="card-block">
{foreach from=$cart.subtotals item="subtotal"}
{if $subtotal.value && $subtotal.type !== 'tax'}
<div class="cart-summary-line" id="cart-subtotal-{$subtotal.type|escape:'htmlall':'UTF-8'}">
<span class="label{if 'products' === $subtotal.type} js-subtotal{/if}">
{if 'products' == $subtotal.type}
{$cart.summary_string|escape:'htmlall':'UTF-8'}
{else}
{$subtotal.label|escape:'htmlall':'UTF-8'}
{/if}
</span>
<span class="value">{$subtotal.value|escape:'htmlall':'UTF-8'}</span>
{if $subtotal.type === 'shipping'}
<div><small class="value">{hook h='displayCheckoutSubtotalDetails' subtotal=$subtotal}</small></div>
{/if}
</div>
{/if}
{/foreach}
</div>
{block name='cart_voucher'}
{include file='checkout/_partials/cart-voucher.tpl'}
{/block}
<hr>
<div class="card-block">
<div class="cart-summary-line cart-total">
<span class="label">{$cart.totals.total.label|escape:'htmlall':'UTF-8'} {$cart.labels.tax_short|escape:'htmlall':'UTF-8'}</span>
<span class="value">{$cart.totals.total.value|escape:'htmlall':'UTF-8'}</span>
</div>
<div class="cart-summary-line">
<small class="label">{$cart.subtotals.tax.label|escape:'htmlall':'UTF-8'}</small>
<small class="value">{$cart.subtotals.tax.value|escape:'htmlall':'UTF-8'}</small>
</div>
</div>
<hr>
</div>

View File

@@ -0,0 +1,38 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="cart-overview js-cart" data-refresh-url="{url entity='cart' params=['ajax' => true, 'action' => 'refresh']}">
{if $cart.products}
<ul class="cart-items">
{foreach from=$cart.products item=product}
<li class="cart-item">{include file='checkout/_partials/cart-detailed-product-line.tpl' product=$product}</li>
{if $product.customizations|count >1}
<hr>
{/if}
{/foreach}
</ul>
{else}
<span class="no-items">{l s='There are no more items in your cart' d='Shop.Theme.Checkout' mod='installmentpayment'}</span>
{/if}
</div>

View File

@@ -0,0 +1,28 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="card-block cart-summary-line cart-summary-items-subtotal clearfix" id="items-subtotal">
<span class="label">{$cart.summary_string|escape:'htmlall':'UTF-8'}</span>
<span class="value">{$cart.subtotals.products.amount|escape:'htmlall':'UTF-8'}</span>
</div>

View File

@@ -0,0 +1,35 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="media-left">
<a href="{$product.url|escape:'htmlall':'UTF-8'}" title="{$product.name|escape:'htmlall':'UTF-8'}">
<img class="media-object" src="{$product.cover.small.url|escape:'htmlall':'UTF-8'}" alt="{$product.name|escape:'htmlall':'UTF-8'}">
</a>
</div>
<div class="media-body">
<span class="product-name">{$product.name|escape:'htmlall':'UTF-8'}</span>
<span class="product-quantity">x{$product.quantity|escape:'htmlall':'UTF-8'}</span>
<span class="product-price pull-xs-right">{$product.price|escape:'htmlall':'UTF-8'}</span>
{hook h='displayProductPriceBlock' product=$product type="unit_price"}
</div>

View File

@@ -0,0 +1,41 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="card-block cart-summary-totals">
{block name='cart_summary_total'}
<div class="cart-summary-line cart-total">
<span class="label">{$cart.totals.total.label|escape:'htmlall':'UTF-8'} {$cart.labels.tax_short|escape:'htmlall':'UTF-8'}</span>
<span class="value">{$cart.totals.total.value|escape:'htmlall':'UTF-8'}</span>
</div>
{/block}
{block name='cart_summary_tax'}
<div class="cart-summary-line">
<span class="label sub">{$cart.subtotals.tax.label|escape:'htmlall':'UTF-8'}</span>
<span class="value sub">{$cart.subtotals.tax.value|escape:'htmlall':'UTF-8'}</span>
</div>
{/block}
</div>

View File

@@ -0,0 +1,74 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<section id="js-checkout-summary" class="card js-cart" data-refresh-url="{$urls.pages.cart|escape:'htmlall':'UTF-8'}?ajax=1">
<div class="card-block">
{hook h='displayCheckoutSummaryTop'}
{block name='cart_summary_products'}
<div class="cart-summary-products">
<p>{$cart.summary_string|escape:'htmlall':'UTF-8'}</p>
<p>
<a href="#" data-toggle="collapse" data-target="#cart-summary-product-list">
{l s='show details' d='Shop.Theme.Actions' mod='installmentpayment'}
</a>
</p>
{block name='cart_summary_product_list'}
<div class="collapse" id="cart-summary-product-list">
<ul class="media-list">
{foreach from=$cart.products item=product}
<li class="media">{include file='checkout/_partials/cart-summary-product-line.tpl' product=$product}</li>
{/foreach}
</ul>
</div>
{/block}
</div>
{/block}
{block name='cart_summary_subtotals'}
{foreach from=$cart.subtotals item="subtotal"}
{if $subtotal && $subtotal.type !== 'tax'}
<div class="cart-summary-line cart-summary-subtotals" id="cart-subtotal-{$subtotal.type|escape:'htmlall':'UTF-8'}">
<span class="label">{$subtotal.label|escape:'htmlall':'UTF-8'}</span>
<span class="value">{$subtotal.value|escape:'htmlall':'UTF-8'}</span>
</div>
{/if}
{/foreach}
{/block}
</div>
{block name='cart_summary_voucher'}
{include file='checkout/_partials/cart-voucher.tpl'}
{/block}
<hr>
{block name='cart_summary_totals'}
{include file='checkout/_partials/cart-summary-totals.tpl' cart=$cart}
{/block}
</section>

View File

@@ -0,0 +1,71 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{if $cart.vouchers.allowed}
<div class="block-promo">
<div class="cart-voucher">
{if $cart.vouchers.added}
<ul class="promo-name card-block">
{foreach from=$cart.vouchers.added item=voucher}
<li class="cart-summary-line">
<span class="label">{$voucher.name|escape:'htmlall':'UTF-8'}</span>
<a href="{$voucher.delete_url|escape:'htmlall':'UTF-8'}" data-link-action="remove-voucher"><i class="material-icons">&#xE872;</i></a>
<div class="pull-xs-right">
{$voucher.reduction_formatted|escape:'htmlall':'UTF-8'}
</div>
</li>
{/foreach}
</ul>
{/if}
<p>
<a class="collapse-button promo-code-button" data-toggle="collapse" href="#promo-code" aria-expanded="false" aria-controls="promo-code">
{l s='Have a promo code?' d='Shop.Theme.Checkout' mod='installmentpayment'}
</a>
</p>
<div class="promo-code collapse{if $cart.discounts|count > 0} in{/if}" id="promo-code">
<form action="{$urls.pages.cart|escape:'htmlall':'UTF-8'}" data-link-action="add-voucher" method="post">
<input type="hidden" name="token" value="{$static_token|escape:'htmlall':'UTF-8'}">
<input type="hidden" name="addDiscount" value="1">
<input class="promo-input" type="text" name="discount_name" placeholder="{l s='Promo code' d='Shop.Theme.Checkout' mod='installmentpayment'}">
<button type="submit" class="btn btn-primary"><span>{l s='Add' d='Shop.Theme.Actions' mod='installmentpayment'}</span></button>
</form>
<div class="alert alert-danger js-error" role="alert">
<i class="material-icons">&#xE001;</i><span class="m-l-1 js-error-text"></span>
</div>
</div>
{if $cart.discounts|count > 0}
<p class="block-promo promo-highlighted">
{l s='Take advantage of our exclusive offers:' d='Shop.Theme.Actions' mod='installmentpayment'}
</p>
<ul class="js-discount card-block promo-discounts">
{foreach from=$cart.discounts item=discount}
<li class="cart-summary-line">
<span class="label"><span class="code">{$discount.code|escape:'htmlall':'UTF-8'}</span> - {$discount.name|escape:'htmlall':'UTF-8'}</span>
</li>
{/foreach}
</ul>
{/if}
</div>
</div>
{/if}

View File

@@ -0,0 +1,50 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends "customer/_partials/customer-form.tpl"}
{block "form_field"}
{if $field.name === 'password' and $guest_allowed}
<p>
<span class="font-weight-bold">{l s='Create an account' d='Shop.Theme.Checkout' mod='installmentpayment'}</span> <span class="font-italic">{l s='(optional)' d='Shop.Theme.Checkout' mod='installmentpayment'}</span>
<br>
<span class="text-muted">{l s='And save time on your next order!' d='Shop.Theme.Checkout' mod='installmentpayment'}</span>
</p>
{$smarty.block.parent|escape:'htmlall':'UTF-8'}
{else}
{$smarty.block.parent|escape:'htmlall':'UTF-8'}
{/if}
{/block}
{block "form_buttons"}
<button
class="continue btn btn-primary pull-xs-right"
name="continue"
data-link-action="register-new-customer"
type="submit"
value="1"
>
{l s='Continue' d='Shop.Theme.Actions' mod='installmentpayment'}
</button>
{/block}

View File

@@ -0,0 +1,25 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<div class="text-xs-center"><i class="material-icons">&#xE90C;</i> 2016 - <strong>CLASSIC</strong> - {l s='Ecommerce software by' d='Shop.Theme' mod='installmentpayment'} <strong>PrestaShop<sup>TM</sup></strong></div>

View File

@@ -0,0 +1,73 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{block name='header_nav'}
<nav class="header-nav">
<div class="container">
<div class="row">
<div class="col-md-6 hidden-sm-down" id="_desktop_logo">
<a href="{$urls.base_url|escape:'htmlall':'UTF-8'}">
<img class="logo img-responsive" src="{$shop.logo|escape:'htmlall':'UTF-8'}" alt="{$shop.name|escape:'htmlall':'UTF-8'} {l s='logo' d='Shop.Theme' mod='installmentpayment'}">
</a>
</div>
<div class="col-md-6 text-xs-right hidden-sm-down">
{hook h='displayNav1'}
</div>
<div class="hidden-md-up text-xs-center mobile">
{hook h='displayNav2'}
<div class="pull-xs-left" id="menu-icon">
<i class="material-icons">&#xE5D2;</i>
</div>
<div class="pull-xs-right" id="_mobile_cart"></div>
<div class="pull-xs-right" id="_mobile_user_info"></div>
<div class="top-logo" id="_mobile_logo"></div>
<div class="clearfix"></div>
</div>
</div>
</div>
</nav>
{/block}
{block name='header_top'}
<div class="header-top hidden-md-up">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="row">
{hook h='displayTop'}
<div class="clearfix"></div>
</div>
</div>
</div>
<div id="mobile_top_menu_wrapper" class="row hidden-md-up" style="display:none;">
<div class="js-top-menu mobile" id="_mobile_top_menu"></div>
<div class="js-top-menu-bottom">
<div id="_mobile_currency_selector"></div>
<div id="_mobile_language_selector"></div>
<div id="_mobile_contact_link"></div>
</div>
</div>
</div>
</div>
{/block}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,37 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file='customer/_partials/login-form.tpl'}
{block name='form_buttons'}
<button
class="continue btn btn-primary pull-xs-right"
name="continue"
data-link-action="sign-in"
type="submit"
value="1"
>
{l s='Continue' d='Shop.Theme.Actions' mod='installmentpayment'}
</button>
{/block}

View File

@@ -0,0 +1,114 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{block name='order-items-table-head'}
<div id="order-items" class="col-md-8">
<h3 class="card-title h3">{l s='Order items' d='Shop.Theme.Checkout' mod='installmentpayment'}</h3>
{/block}
<div class="order-confirmation-table">
<table class="table">
{foreach from=$products item=product}
<div class="order-line row">
<div class="col-sm-2 col-xs-3">
<span class="image">
<img src="{$product.cover.medium.url|escape:'htmlall':'UTF-8'}" />
</span>
</div>
<div class="col-sm-4 col-xs-9 details">
{if $add_product_link}<a href="{$product.url|escape:'htmlall':'UTF-8'}" target="_blank">{/if}
<span>{$product.name|escape:'htmlall':'UTF-8'}</span>
{if $add_product_link}</a>{/if}
{if $product.customizations|count}
{foreach from=$product.customizations item="customization"}
<div class="customizations">
<a href="#" data-toggle="modal" data-target="#product-customizations-modal-{$customization.id_customization|escape:'htmlall':'UTF-8'}">{l s='Product customization' d='Shop.Theme.Catalog' mod='installmentpayment'}</a>
</div>
<div class="modal fade customization-modal" id="product-customizations-modal-{$customization.id_customization|escape:'htmlall':'UTF-8'}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">{l s='Product customization' d='Shop.Theme.Catalog' mod='installmentpayment'}</h4>
</div>
<div class="modal-body">
{foreach from=$customization.fields item="field"}
<div class="product-customization-line row">
<div class="col-sm-3 col-xs-4 label">
{$field.label|escape:'htmlall':'UTF-8'}
</div>
<div class="col-sm-9 col-xs-8 value">
{if $field.type == 'text'}
{if (int)$field.id_module}
{$field.text nofilter|escape:'htmlall':'UTF-8'}
{else}
{$field.text|escape:'htmlall':'UTF-8'}
{/if}
{elseif $field.type == 'image'}
<img src="{$field.image.small.url|escape:'htmlall':'UTF-8'}">
{/if}
</div>
</div>
{/foreach}
</div>
</div>
</div>
</div>
{/foreach}
{/if}
{hook h='displayProductPriceBlock' product=$product type="unit_price"}
</div>
<div class="col-sm-6 col-xs-12 qty">
<div class="row">
<div class="col-xs-5 text-sm-right text-xs-left">{$product.price|escape:'htmlall':'UTF-8'}</div>
<div class="col-xs-2">{$product.quantity|escape:'htmlall':'UTF-8'}</div>
<div class="col-xs-5 text-xs-right bold">{$product.total|escape:'htmlall':'UTF-8'}</div>
</div>
</div>
</div>
{/foreach}
<hr />
<table>
{foreach $subtotals as $subtotal}
{if $subtotal.type !== 'tax'}
<tr>
<td>{$subtotal.label|escape:'htmlall':'UTF-8'}</td>
<td>{$subtotal.value|escape:'htmlall':'UTF-8'}</td>
</tr>
{/if}
{/foreach}
{if $subtotals.tax.label !== null}
<tr class="sub">
<td>{$subtotals.tax.label|escape:'htmlall':'UTF-8'}</td>
<td>{$subtotals.tax.value|escape:'htmlall':'UTF-8'}</td>
</tr>
{/if}
<tr class="font-weight-bold">
<td><span class="text-uppercase">{$totals.total.label|escape:'htmlall':'UTF-8'}</span> {$labels.tax_short|escape:'htmlall':'UTF-8'}</td>
<td>{$totals.total.value|escape:'htmlall':'UTF-8'}</td>
</tr>
</table>
</div>
</div>

View File

@@ -0,0 +1,37 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file='checkout/_partials/order-confirmation-table.tpl'}
{block name='order-items-table-head'}
<div id="order-items" class="col-md-12">
<h3 class="card-title h3">
{if $products_count == 1}
{l s='%product_count% item in your cart' sprintf=['%product_count%' => $products_count] d='Shop.Theme.Checkout' mod='installmentpayment'}
{else}
{l s='%products_count% items in your cart' sprintf=['%products_count%' => $products_count] d='Shop.Theme.Checkout' mod='installmentpayment'}
{/if}
<a href="{url entity=cart params=['action' => 'show']}"><span class="step-edit"><i class="material-icons edit">mode_edit</i> edit</span></a>
</h3>
{/block}

View File

@@ -0,0 +1,103 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<section id="order-summary-content" class="page-content page-order-confirmation">
<div class="row">
<div class="col-md-12">
<h4 class="h4 black">{l s='Please check your order before payment' d='Shop.Theme.Checkout' mod='installmentpayment'}</h4>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h4 class="h4">
{l s='Addresses' d='Shop.Theme.Checkout' mod='installmentpayment'}
<span class="step-edit step-to-addresses js-edit-addresses"><i class="material-icons edit">mode_edit</i> edit</span>
</h4>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="card noshadow">
<div class="card-block">
<h4 class="h5 black addresshead">{l s='Your Delivery Address' d='Shop.Theme.Checkout' mod='installmentpayment'}</h4>
{$customer.addresses[$cart.id_address_delivery]['formatted'] nofilter|escape:'htmlall':'UTF-8'}
</div>
</div>
</div>
<div class="col-md-6">
<div class="card noshadow">
<div class="card-block">
<h4 class="h5 black addresshead">{l s='Your Invoice Address' d='Shop.Theme.Checkout' mod='installmentpayment'}</h4>
{$customer.addresses[$cart.id_address_invoice]['formatted'] nofilter|escape:'htmlall':'UTF-8'}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h4 class="h4">
{l s='Shipping Method' d='Shop.Theme.Checkout' mod='installmentpayment'}
<span class="step-edit step-to-delivery js-edit-delivery"><i class="material-icons edit">mode_edit</i> edit</span>
</h4>
<div class="col-md-12 summary-selected-carrier">
<div class="row">
<div class="col-md-2">
<div class="logo-container">
{if $selected_delivery_option.logo}
<img src="{$selected_delivery_option.logo|escape:'htmlall':'UTF-8'}" alt="{$selected_delivery_option.name|escape:'htmlall':'UTF-8'}">
{else}
&nbsp;
{/if}
</div>
</div>
<div class="col-md-4">
<span class="carrier-name">{$selected_delivery_option.name|escape:'htmlall':'UTF-8'}</span>
</div>
<div class="col-md-4">
<span class="carrier-delay">{$selected_delivery_option.delay|escape:'htmlall':'UTF-8'}</span>
</div>
<div class="col-md-2">
<span class="carrier-price">{$selected_delivery_option.price|escape:'htmlall':'UTF-8'}</span>
</div>
</div>
</div>
</div>
</div>
<div class="row">
{block name='order_confirmation_table'}
{include file='checkout/_partials/order-final-summary-table.tpl'
products=$cart.products
products_count=$cart.products_count
subtotals=$cart.subtotals
totals=$cart.totals
labels=$cart.labels
add_product_link=true
}
{/block}
</div>
</section>

View File

@@ -0,0 +1,124 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file='checkout/_partials/steps/checkout-step.tpl'}
{block name='step_content'}
<div class="js-address-form">
<form
method="POST"
action="{$urls.pages.order|escape:'htmlall':'UTF-8'}"
data-refresh-url="{url entity='order' params=['ajax' => 1, 'action' => 'addressForm']}"
>
{if !$use_same_address}
<h2 class="h4">{l s='Shipping Address' d='Shop.Theme.Checkout' mod='installmentpayment'}</h2>
{/if}
{if $use_same_address && !$cart.is_virtual}
<p>
{l s='The selected address will be used both as your personal address (for invoice) and as your delivery address.' d='Shop.Theme.Checkout' mod='installmentpayment'}
</p>
{elseif $use_same_address && $cart.is_virtual}
<p>
{l s='The selected address will be used as your personal address (for invoice).' d='Shop.Theme.Checkout' mod='installmentpayment'}
</p>
{/if}
{if $show_delivery_address_form}
<div id="delivery-address">
{render file = 'checkout/_partials/address-form.tpl'
ui = $address_form
use_same_address = $use_same_address
type = "delivery"
form_has_continue_button = $form_has_continue_button
}
</div>
{elseif $customer.addresses|count > 0}
<div id="delivery-addresses" class="address-selector js-address-selector">
{include file = 'checkout/_partials/address-selector-block.tpl'
addresses = $customer.addresses
name = "id_address_delivery"
selected = $id_address_delivery
type = "delivery"
interactive = !$show_delivery_address_form and !$show_invoice_address_form
}
</div>
<p class="add-address">
<a href="{$new_address_delivery_url|escape:'htmlall':'UTF-8'}"><i class="material-icons">&#xE145;</i>{l s='add new address' d='Shop.Theme.Actions' mod='installmentpayment'}</a>
</p>
{if $use_same_address && !$cart.is_virtual}
<p>
<a data-link-action="different-invoice-address" href="{$use_different_address_url|escape:'htmlall':'UTF-8'}">
{l s='Billing address differs from shipping address' d='Shop.Theme.Checkout' mod='installmentpayment'}
</a>
</p>
{/if}
{/if}
{if !$use_same_address}
<h2 class="h4">{l s='Your Invoice Address' d='Shop.Theme.Checkout' mod='installmentpayment'}</h2>
{if $show_invoice_address_form}
<div id="invoice-address">
{render file = 'checkout/_partials/address-form.tpl'
ui = $address_form
use_same_address = $use_same_address
type = "invoice"
form_has_continue_button = $form_has_continue_button
}
</div>
{else}
<div id="invoice-addresses" class="address-selector js-address-selector">
{include file = 'checkout/_partials/address-selector-block.tpl'
addresses = $customer.addresses
name = "id_address_invoice"
selected = $id_address_invoice
type = "invoice"
interactive = !$show_delivery_address_form and !$show_invoice_address_form
}
</div>
<p class="add-address">
<a href="{$new_address_invoice_url|escape:'htmlall':'UTF-8'}"><i class="material-icons">&#xE145;</i>{l s='add new address' d='Shop.Theme.Actions' mod='installmentpayment'}</a>
</p>
{/if}
{/if}
{if !$form_has_continue_button}
<div class="clearfix">
<button type="submit" class="btn btn-primary continue pull-xs-right" name="confirm-addresses" value="1">
{l s='Continue' d='Shop.Theme.Actions' mod='installmentpayment'}
</button>
</div>
{/if}
</form>
</div>
{/block}

View File

@@ -0,0 +1,44 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<section id = "{$identifier|escape:'htmlall':'UTF-8'}"
class = "{[
'checkout-step' => true,
'-current' => $step_is_current,
'-reachable' => $step_is_reachable,
'-complete' => $step_is_complete,
'js-current-step' => $step_is_current
]|classnames}"
>
<h1 class="step-title h3">
<i class="material-icons done">&#xE876;</i>
<span class="step-number">{$position|escape:'htmlall':'UTF-8'}</span>
{$title|escape:'htmlall':'UTF-8'}
<span class="step-edit text-muted"><i class="material-icons edit">mode_edit</i> edit</span>
</h1>
<div class="content">
{block name='step_content'}DUMMY STEP CONTENT{/block}
</div>
</section>

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,175 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file='checkout/_partials/steps/checkout-step.tpl'}
{block name='step_content'}
{hook h='displayPaymentTop'}
<div class="payment-options">
{foreach from=$payment_options item="module_options"}
{foreach from=$module_options item="option"}
<div>
<div id="{$option.id|escape:'htmlall':'UTF-8'}-container" class="payment-option clearfix">
{* This is the way an option should be selected when Javascript is enabled *}
<span class="custom-radio pull-xs-left">
<input
class="ps-shown-by-js {if $option.binary} binary {/if}"
id="{$option.id|escape:'htmlall':'UTF-8'}"
data-module-name="{$option.module_name|escape:'htmlall':'UTF-8'}"
name="payment-option"
type="radio"
required
{if $selected_payment_option == $option.id} checked {/if}
>
<span></span>
</span>
{* This is the way an option should be selected when Javascript is disabled *}
<form method="GET" class="ps-hidden-by-js">
{if $option.id === $selected_payment_option}
{l s='Selected' d='Shop.Theme.Checkout' mod='installmentpayment'}
{else}
<button class="ps-hidden-by-js" type="submit" name="select_payment_option" value="{$option.id|escape:'htmlall':'UTF-8'}">
{l s='Choose' d='Shop.Theme.Actions' mod='installmentpayment'}
</button>
{/if}
</form>
<label for="{$option.id|escape:'htmlall':'UTF-8'}">
<span>{$option.call_to_action_text|escape:'htmlall':'UTF-8'}</span>
{if $option.logo}
<img src="{$option.logo|escape:'htmlall':'UTF-8'}">
{/if}
</label>
</div>
</div>
{if $option.additionalInformation}
<div
id="{$option.id|escape:'htmlall':'UTF-8'}-additional-information"
class="js-additional-information definition-list additional-information{if $option.id != $selected_payment_option} ps-hidden {/if}"
>
{$option.additionalInformation nofilter|escape:'htmlall':'UTF-8'}
</div>
{/if}
<div
id="pay-with-{$option.id|escape:'htmlall':'UTF-8'}-form"
class="js-payment-option-form {if $option.id != $selected_payment_option} ps-hidden {/if}"
>
{if $option.form}
{$option.form nofilter|escape:'htmlall':'UTF-8'}
{else}
<form id="payment-form" method="POST" action="{$option.action nofilter|escape:'htmlall':'UTF-8'}">
{foreach from=$option.inputs item=input}
<input type="{$input.type|escape:'htmlall':'UTF-8'}" name="{$input.name|escape:'htmlall':'UTF-8'}" value="{$input.value|escape:'htmlall':'UTF-8'}">
{/foreach}
<button style="display:none" id="pay-with-{$option.id|escape:'htmlall':'UTF-8'}" type="submit"></button>
</form>
{/if}
</div>
{/foreach}
{foreachelse}
<p class="alert alert-danger">{l s='Unfortunately, there are no payment method available.' d='Shop.Theme.Checkout' mod='installmentpayment'}</p>
{/foreach}
</div>
{if $conditions_to_approve|count}
<p class="ps-hidden-by-js">
{* At the moment, we're not showing the checkboxes when JS is disabled
because it makes ensuring they were checked very tricky and overcomplicates
the template. Might change later.
*}
{l s='By confirming the order, you certify that you have read and agree with all of the conditions below:' d='Shop.Theme.Checkout' mod='installmentpayment'}
</p>
<form id="conditions-to-approve" method="GET">
<ul>
{foreach from=$conditions_to_approve item="condition" key="condition_name"}
<li>
<div class="pull-xs-left">
<span class="custom-checkbox">
<input id = "conditions_to_approve[{$condition_name|escape:'htmlall':'UTF-8'}]"
name = "conditions_to_approve[{$condition_name|escape:'htmlall':'UTF-8'}]"
required
type = "checkbox"
value = "1"
class = "ps-shown-by-js"
>
<span><i class="material-icons checkbox-checked">&#xE5CA;</i></span>
</span>
</div>
<div class="condition-label">
<label class="js-terms" for="conditions_to_approve[{$condition_name|escape:'htmlall':'UTF-8'}]">
{$condition nofilter|escape:'htmlall':'UTF-8'}
</label>
</div>
</li>
{/foreach}
</ul>
</form>
{/if}
{if $show_final_summary}
{include file='checkout/_partials/order-final-summary.tpl'}
{/if}
<div id="payment-confirmation">
<div class="ps-shown-by-js">
<button type="submit" {if !$selected_payment_option} disabled {/if} class="btn btn-primary center-block">
{l s='Order with an obligation to pay' d='Shop.Theme.Checkout' mod='installmentpayment'}
</button>
{if $show_final_summary}
<article class="alert alert-danger m-t-2 js-alert-payment-conditions" role="alert" data-alert="danger">
{l
s='Please make sure you\'ve chosen a [1]payment method[/1] and accepted the [2]terms and conditions[/2].'
sprintf=[
'[1]' => '<a href="#checkout-payment-step">',
'[/1]' => '</a>',
'[2]' => '<a href="#conditions-to-approve">',
'[/2]' => '</a>'
]
d='Shop.Theme.Checkout'
}
</article>
{/if}
</div>
<div class="ps-hidden-by-js">
{if $selected_payment_option and $all_conditions_approved}
<label for="pay-with-{$selected_payment_option|escape:'htmlall':'UTF-8'}">{l s='Order with an obligation to pay' d='Shop.Theme.Checkout' mod='installmentpayment'}</label>
{/if}
</div>
</div>
{hook h='displayPaymentByBinaries'}
<div class="modal fade" id="modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
</div>
</div>
</div>
{/block}

View File

@@ -0,0 +1,96 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file='checkout/_partials/steps/checkout-step.tpl'}
{block name='step_content'}
{if $customer.is_logged && !$customer.is_guest}
<p class="identity">
{* [1][/1] is for a HTML tag. *}
{l s='Connected as [1]%firstname% %lastname%[/1].'
d='Shop.Theme.CustomerAccount'
sprintf=[
'[1]' => "<a href="{$urls.pages.identity|escape:'htmlall':'UTF-8'}">",
'[/1]' => "</a>",
'%firstname%' => $customer.firstname,
'%lastname%' => $customer.lastname
]
}
</p>
<p>
{* [1][/1] is for a HTML tag. *}
{l
s='Not you? [1]Log out[/1]'
d='Shop.Theme.CustomerAccount'
sprintf=[
'[1]' => "<a href="{$urls.actions.logout|escape:'htmlall':'UTF-8'}">",
'[/1]' => "</a>"
]
}
</p>
<p><small>{l s='If you sign out now, your cart will be emptied.' d='Shop.Theme.Checkout' mod='installmentpayment'}</small></p>
{else}
<ul class="nav nav-inline m-y-2">
<li class="nav-item">
<a class="nav-link {if !$show_login_form}active{/if}" data-toggle="tab" href="#checkout-guest-form" role="tab">
{if $guest_allowed}
{l s='Order as a guest' d='Shop.Theme.Checkout' mod='installmentpayment'}
{else}
{l s='Create an account' d='Shop.Theme.CustomerAccount' mod='installmentpayment'}
{/if}
</a>
</li>
<li class="nav-item">
<span href="nav-separator"> | </span>
</li>
<li class="nav-item">
<a
class="nav-link {if $show_login_form}active{/if}"
data-link-action="show-login-form"
data-toggle="tab"
href="#checkout-login-form"
role="tab"
>
{l s='Sign in' d='Shop.Theme.Actions' mod='installmentpayment'}
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane {if !$show_login_form}active{/if}" id="checkout-guest-form" role="tabpanel">
{render file='checkout/_partials/customer-form.tpl' ui=$register_form guest_allowed=$guest_allowed}
</div>
<div class="tab-pane {if $show_login_form}active{/if}" id="checkout-login-form" role="tabpanel">
{render file='checkout/_partials/login-form.tpl' ui=$login_form}
</div>
</div>
{/if}
{/block}

View File

@@ -0,0 +1,123 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file='checkout/_partials/steps/checkout-step.tpl'}
{block name='step_content'}
<div id="hook-display-before-carrier">
{$hookDisplayBeforeCarrier nofilter|escape:'htmlall':'UTF-8'}
</div>
<div class="delivery-options-list">
{if $delivery_options|count}
<form
class="clearfix"
id="js-delivery"
data-url-update="{url entity='order' params=['ajax' => 1, 'action' => 'selectDeliveryOption']}"
method="post"
>
<div class="form-fields">
{block name='delivery_options'}
<div class="delivery-options">
{foreach from=$delivery_options item=carrier key=carrier_id}
<div class="delivery-option">
<div class="col-sm-1">
<span class="custom-radio pull-xs-left">
<input type="radio" name="delivery_option[{$id_address|escape:'htmlall':'UTF-8'}]" id="delivery_option_{$carrier.id|escape:'htmlall':'UTF-8'}" value="{$carrier_id|escape:'htmlall':'UTF-8'}"{if $delivery_option == $carrier_id} checked{/if}>
<span></span>
</span>
</div>
<label for="delivery_option_{$carrier.id|escape:'htmlall':'UTF-8'}" class="col-sm-11 delivery-option-2">
<div class="row">
<div class="col-sm-5 col-xs-12">
<div class="row">
{if $carrier.logo}
<div class="col-xs-3">
<img src="{$carrier.logo|escape:'htmlall':'UTF-8'}" alt="{$carrier.name|escape:'htmlall':'UTF-8'}" />
</div>
{/if}
<div class="{if $carrier.logo}col-xs-9{else}col-xs-12{/if}">
<span class="h6 carrier-name">{$carrier.name|escape:'htmlall':'UTF-8'}</span>
</div>
</div>
</div>
<div class="col-sm-4 col-xs-12">
<span class="carrier-delay">{$carrier.delay|escape:'htmlall':'UTF-8'}</span>
</div>
<div class="col-sm-3 col-xs-12">
<span class="carrier-price">{$carrier.price|escape:'htmlall':'UTF-8'}</span>
</div>
</div>
</label>
<div class="col-md-12 carrier-extra-content"{if $delivery_option != $carrier_id} style="display:none;"{/if}>
{$carrier.extraContent nofilter|escape:'htmlall':'UTF-8'}
</div>
<div class="clearfix"></div>
</div>
{/foreach}
</div>
{/block}
<div class="order-options">
{if $recyclablePackAllowed}
<label>
<input type="checkbox" name="recyclable" value="1" {if $recyclable} checked {/if}>
<span>{l s='I would like to receive my order in recycled packaging.' d='Shop.Theme.Checkout' mod='installmentpayment'}</span>
</label>
{/if}
{if $gift.allowed}
<span class="custom-checkbox">
<input
class="js-gift-checkbox"
name="gift"
type="checkbox"
value="1"
{if $gift.isGift}checked="checked"{/if}
>
<span><i class="material-icons checkbox-checked">&#xE5CA;</i></span>
<label>{$gift.label|escape:'htmlall':'UTF-8'}</label >
</span>
<div id="gift" class="collapse{if $gift.isGift} in{/if}">
<label for="gift_message">{l s='If you\'d like, you can add a note to the gift:' d='Shop.Theme.Checkout' mod='installmentpayment'}</label>
<textarea rows="2" cols="120" id="gift_message" name="gift_message">{$gift.message|escape:'htmlall':'UTF-8'}</textarea>
</div>
{/if}
</div>
</div>
<button type="submit" class="continue btn btn-primary pull-xs-right" name="confirmDeliveryOption" value="1">
{l s='Continue' d='Shop.Theme.Actions' mod='installmentpayment'}
</button>
</form>
{else}
<p class="alert alert-danger">{l s='Unfortunately, there are no carriers available for your delivery address.' d='Shop.Theme.Checkout' mod='installmentpayment'}</p>
{/if}
</div>
<div id="hook-display-after-carrier">
{$hookDisplayAfterCarrier nofilter|escape:'htmlall':'UTF-8'}
</div>
<div id="extra_carrier"></div>
{/block}

View File

@@ -0,0 +1,29 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<section class="checkout-step -unreachable" id="{$identifier|escape:'htmlall':'UTF-8'}">
<h1 class="step-title h3">
<span class="step-number">{$position|escape:'htmlall':'UTF-8'}</span> {$title|escape:'htmlall':'UTF-8'}
</h1>
</section>

View File

@@ -0,0 +1,45 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file='checkout/cart.tpl'}
{block name='content' append}
{hook h='displayCrossSellingShoppingCart'}
{/block}
{block name='continue_shopping' append}
<a class="label" href="{$urls.pages.index|escape:'htmlall':'UTF-8'}">
<i class="material-icons">chevron_left</i>{l s='Continue shopping' d='Shop.Theme.Actions' mod='installmentpayment'}
</a>
{/block}
{block name='cart_actions'}
<div class="checkout text-xs-center card-block">
<button type="button" class="btn btn-primary disabled" disabled>{l s='Checkout' d='Shop.Theme.Actions' mod='installmentpayment'}</button>
</div>
{/block}
{block name='continue_shopping'}{/block}
{block name='cart_voucher'}{/block}
{block name='display_reassurance'}{/block}

View File

@@ -0,0 +1,85 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{extends file=$layout}
{block name='content'}
<section id="main">
<div class="cart-grid row">
<!-- Left Block: cart product informations & shpping -->
<div class="cart-grid-body col-xs-12 col-lg-8">
<!-- cart products detailed -->
<div class="card cart-container">
<div class="card-block">
<h1 class="h1">{l s='Shopping Cart' d='Shop.Theme.Checkout' mod='installmentpayment'}</h1>
</div>
<hr>
{block name='cart_overview'}
{include file='checkout/_partials/cart-detailed.tpl' cart=$cart}
{/block}
</div>
{block name='continue_shopping'}
<a class="label" href="{$urls.pages.index|escape:'htmlall':'UTF-8'}">
<i class="material-icons">chevron_left</i>{l s='Continue shopping' d='Shop.Theme.Actions' mod='installmentpayment'}
</a>
{/block}
<!-- shipping informations -->
<div>
{hook h='displayShoppingCartFooter'}
</div>
</div>
<!-- Right Block: cart subtotal & cart total -->
<div class="cart-grid-right col-xs-12 col-lg-4">
{block name='cart_summary'}
<div class="card cart-summary">
{hook h='displayShoppingCart'}
{block name='cart_totals'}
{include file='checkout/_partials/cart-detailed-totals.tpl' cart=$cart}
{/block}
{block name='cart_actions'}
{include file='checkout/_partials/cart-detailed-actions.tpl' cart=$cart}
{/block}
</div>
{/block}
{block name='display_reassurance'}
{hook h='displayReassurance'}
{/block}
</div>
</div>
</section>
{/block}

View File

@@ -0,0 +1,30 @@
{**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{foreach from=$steps item="step" key="index"}
{render identifier = $step.identifier
position = ($index + 1)
ui = $step.ui
}
{/foreach}

Some files were not shown because too many files have changed in this diff Show More