Initial commit

This commit is contained in:
2020-10-07 10:37:15 +02:00
commit ce5f440392
28157 changed files with 4429172 additions and 0 deletions

1427
modules/ps_shoppingcart/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>ps_shoppingcart</name>
<displayName><![CDATA[Sopping cart]]></displayName>
<version><![CDATA[2.0.3]]></version>
<description><![CDATA[Adds a block containing the customer&#039;s shopping cart.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>ps_shoppingcart</name>
<displayName><![CDATA[Panier]]></displayName>
<version><![CDATA[2.0.3]]></version>
<description><![CDATA[Ajoute un bloc avec le contenu du panier du client]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,56 @@
<?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
*/
class Ps_ShoppingcartAjaxModuleFrontController extends ModuleFrontController
{
public $ssl = true;
/**
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$modal = null;
if (Tools::getValue('action') === 'add-to-cart') {
$modal = $this->module->renderModal(
$this->context->cart,
(int) Tools::getValue('id_product'),
(int) Tools::getValue('id_product_attribute'),
(int) Tools::getValue('id_customization')
);
}
ob_end_clean();
header('Content-Type: application/json');
die(json_encode([
'preview' => $this->module->renderWidget(null, ['cart' => $this->context->cart]),
'modal' => $modal,
]));
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

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;

BIN
modules/ps_shoppingcart/logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -0,0 +1,8 @@
<div id="blockcart-modal" data-close-on-click="true">
<div>
<section>
<h1>{l s='Product Successfully Added to Your Shopping Cart' d='Shop.Theme.Checkout'}</h1>
{$product.name}
</section>
</div>
</div>

View File

@@ -0,0 +1,34 @@
<span class="product-quantity">{$product.quantity}</span>
<span class="product-name">{$product.name}</span>
<span class="product-price">{$product.price}</span>
<a class="remove-from-cart"
rel="nofollow"
href="{$product.remove_from_cart_url}"
data-link-action="remove-from-cart"
>
{l s="Remove" d="Shop.Theme.Actions"}
</a>
{if $product.customizations|count}
<div class="customizations">
<ul>
{foreach from=$product.customizations item="customization"}
<li>
<span class="product-quantity">{$customization.quantity}</span>
<a href="{$customization.remove_from_cart_url}" class="remove-from-cart" rel="nofollow">{l s='Remove' d="Shop.Theme.Actions"}</a>
<ul>
{foreach from=$customization.fields item="field"}
<li>
<label>{$field.label}</label>
{if $field.type == 'text'}
<span>{$field.text}</span>
{elseif $field.type == 'image'}
<img src="{$field.image.small.url}">
{/if}
</li>
{/foreach}
</ul>
</li>
{/foreach}
</ul>
</div>
{/if}

View File

@@ -0,0 +1,59 @@
/* global $, prestashop */
/**
* This module exposes an extension point in the form of the `showModal` function.
*
* If you want to override the way the modal window is displayed, simply define:
*
* prestashop.blockcart = prestashop.blockcart || {};
* prestashop.blockcart.showModal = function myOwnShowModal (modalHTML) {
* // your own code
* // please not that it is your responsibility to handle closing the modal too
* };
*
* Attention: your "override" JS needs to be included **before** this file.
* The safest way to do so is to place your "override" inside the theme's main JS file.
*
*/
$(document).ready(function () {
prestashop.blockcart = prestashop.blockcart || {};
var showModal = prestashop.blockcart.showModal || function (modal) {
var $body = $('body');
$body.append(modal);
$body.one('click', '#blockcart-modal', function (event) {
if (event.target.id === 'blockcart-modal') {
$(event.target).remove();
}
});
};
prestashop.on(
'updateCart',
function (event) {
var refreshURL = $('.blockcart').data('refresh-url');
var requestData = {};
if (event && event.reason && typeof event.resp !== 'undefined' && !event.resp.hasError) {
requestData = {
id_customization: event.reason.idCustomization,
id_product_attribute: event.reason.idProductAttribute,
id_product: event.reason.idProduct,
action: event.reason.linkAction
};
$.post(refreshURL, requestData).then(function (resp) {
$('.blockcart').replaceWith($(resp.preview).find('.blockcart'));
if (resp.modal) {
showModal(resp.modal);
}
}).fail(function (resp) {
prestashop.emit('handleError', { eventType: 'updateShoppingCart', resp: resp });
});
}
if (event && event.resp && event.resp.hasError) {
prestashop.emit('showErrorNextToAddtoCartButton', { errorMessage: event.resp.errors.join('<br/>')});
}
}
);
});

View File

@@ -0,0 +1,211 @@
<?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
*/
use PrestaShop\PrestaShop\Adapter\Cart\CartPresenter;
if (!defined('_PS_VERSION_')) {
exit;
}
use PrestaShop\PrestaShop\Core\Module\WidgetInterface;
class Ps_Shoppingcart extends Module implements WidgetInterface
{
public function __construct()
{
$this->name = 'ps_shoppingcart';
$this->tab = 'front_office_features';
$this->version = '2.0.3';
$this->author = 'PrestaShop';
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->trans('Shopping cart', array(), 'Modules.Shoppingcart.Admin');
$this->description = $this->trans('Adds a block containing the customer\'s shopping cart.', array(), 'Modules.Shoppingcart.Admin');
$this->ps_versions_compliancy = array('min' => '1.7.1.0', 'max' => _PS_VERSION_);
$this->controllers = array('ajax');
}
public function hookHeader()
{
if (Configuration::isCatalogMode()) {
return;
}
if (Configuration::get('PS_BLOCK_CART_AJAX')) {
$this->context->controller->registerJavascript('modules-shoppingcart', 'modules/' . $this->name . '/ps_shoppingcart.js', ['position' => 'bottom', 'priority' => 150]);
}
}
private function getCartSummaryURL()
{
return $this->context->link->getPageLink(
'cart',
null,
$this->context->language->id,
array(
'action' => 'show',
),
false,
null,
true
);
}
public function getWidgetVariables($hookName, array $params)
{
$cart_url = $this->getCartSummaryURL();
return array(
'cart' => (new CartPresenter())->present(isset($params['cart']) ? $params['cart'] : $this->context->cart),
'refresh_url' => $this->context->link->getModuleLink('ps_shoppingcart', 'ajax', array(), null, null, null, true),
'cart_url' => $cart_url,
);
}
public function renderWidget($hookName, array $params)
{
if (Configuration::isCatalogMode()) {
return;
}
$this->smarty->assign($this->getWidgetVariables($hookName, $params));
return $this->fetch('module:ps_shoppingcart/ps_shoppingcart.tpl');
}
public function renderModal(Cart $cart, $id_product, $id_product_attribute, $id_customization)
{
$data = (new CartPresenter())->present($cart);
$product = null;
foreach ($data['products'] as $p) {
if ((int) $p['id_product'] == $id_product &&
(int) $p['id_product_attribute'] == $id_product_attribute &&
(int) $p['id_customization'] == $id_customization) {
$product = $p;
break;
}
}
$this->smarty->assign(array(
'product' => $product,
'cart' => $data,
'cart_url' => $this->getCartSummaryURL(),
));
return $this->fetch('module:ps_shoppingcart/modal.tpl');
}
public function getContent()
{
$output = '';
if (Tools::isSubmit('submitBlockCart')) {
$ajax = Tools::getValue('PS_BLOCK_CART_AJAX');
if ($ajax != 0 && $ajax != 1) {
$output .= $this->displayError($this->trans('Ajax: Invalid choice.', array(), 'Modules.Shoppingcart.Admin'));
} else {
Configuration::updateValue('PS_BLOCK_CART_AJAX', (int) ($ajax));
}
}
return $output . $this->renderForm();
}
public function install()
{
return
parent::install()
&& $this->registerHook('header')
&& $this->registerHook('displayTop')
&& Configuration::updateValue('PS_BLOCK_CART_AJAX', 1);
}
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->trans('Settings', array(), 'Admin.Global'),
'icon' => 'icon-cogs',
),
'input' => array(
array(
'type' => 'switch',
'label' => $this->trans('Ajax cart', array(), 'Modules.Shoppingcart.Admin'),
'name' => 'PS_BLOCK_CART_AJAX',
'is_bool' => true,
'desc' => $this->trans('Activate Ajax mode for the cart (compatible with the default theme).', array(), 'Modules.Shoppingcart.Admin'),
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->trans('Enabled', array(), 'Admin.Global'),
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->trans('Disabled', array(), 'Admin.Global'),
),
),
),
),
'submit' => array(
'title' => $this->trans('Save', array(), 'Admin.Actions'),
),
),
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$this->fields_form = array();
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitBlockCart';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab
. '&module_name=' . $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id,
);
return $helper->generateForm(array($fields_form));
}
public function getConfigFieldsValues()
{
return array(
'PS_BLOCK_CART_AJAX' => (bool) Tools::getValue('PS_BLOCK_CART_AJAX', Configuration::get('PS_BLOCK_CART_AJAX')),
);
}
}

View File

@@ -0,0 +1,29 @@
<div id="blockcart-wrapper">
<div class="blockcart cart-preview" data-refresh-url="{$refresh_url}">
<div class="header">
<a rel="nofollow" href="{$cart_url}">
<span>{l s='Cart' d='Shop.Theme.Actions'}</span>
<span>{$cart.summary_string}</span>
</a>
</div>
<div class="body">
<ul>
{foreach from=$cart.products item=product}
<li>{include 'module:ps_shoppingcart/ps_shoppingcart-product-line.tpl' product=$product}</li>
{/foreach}
</ul>
<div class="cart-subtotals">
{foreach from=$cart.subtotals item="subtotal"}
<div class="{$subtotal.type}">
<span class="label">{$subtotal.label}</span>
<span class="value">{$subtotal.amount}</span>
</div>
{/foreach}
</div>
<div class="cart-total">
<span class="label">{$cart.totals.total.label}</span>
<span class="value">{$cart.totals.total.amount}</span>
</div>
</div>
</div>
</div>

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;