Initial commit: is_shoppingcart out of the box. V3.0.1

This commit is contained in:
Isabelle Anno
2025-11-19 13:23:49 +01:00
commit 8135ee3594
70 changed files with 7864 additions and 0 deletions

View File

@ -0,0 +1,78 @@
<?php
use PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter;
class Is_ShoppingcartAjaxModuleFrontController extends ModuleFrontController
{
/**
* @var bool
*/
public $ssl = true;
/**
* @see FrontController::displayAjax()
*
* @return void
*/
public function displayAjax(): void
{
$modal = null;
if ($this->module instanceof Is_Shoppingcart && Tools::getValue('action') === 'add-to-cart') {
$modal = $this->renderModal(
$this->context->cart,
(int) Tools::getValue('id_product'),
(int) Tools::getValue('id_product_attribute'),
(int) Tools::getValue('id_customization')
);
}
$this->ajaxRender(json_encode([
'preview' => $this->module instanceof Is_Shoppingcart ? $this->module->hookDisplayTop(['cart' => $this->context->cart]) : '',
'modal' => $modal,
]));
}
/**
* @param Cart $cart
* @param int $id_product
* @param int $id_product_attribute
* @param int $id_customization
*
* @return string
*
* @throws Exception
*/
private 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->context->smarty->assign([
'product' => $product,
'cart' => $data,
'cart_url' => $this->context->link->getPageLink(
'cart',
null,
$this->context->language->id,
[
'action' => 'show',
],
false,
null,
true
),
]);
return $this->module->fetch("module:{$this->module->name}/views/templates/front/modal.tpl");
}
}

View File

@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* 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 https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
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;