first commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2021 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This module is not a free module and all rights are reserved. It is prohibited to sell or redistribute this module for any purpose. Each license can be used only in one website. For multishop environment, a new license is required for each e-shop managed.
|
||||
*
|
||||
* 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 MEG Venture <info@megventure.com>
|
||||
* @copyright 2007-2021 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;
|
||||
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2021 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:
|
||||
* https://opensource.org/licenses/OSL-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 http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2021 PrestaShop SA
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class CartController extends CartControllerCore
|
||||
{
|
||||
/**
|
||||
* This process add or update a product in the cart.
|
||||
*/
|
||||
protected function processChangeProductInCart()
|
||||
{
|
||||
$mode = (Tools::getIsset('update') && $this->id_product) ? 'update' : 'add';
|
||||
$index = Configuration::get('WD_CUSTOMIZATION_INDEX');
|
||||
$customization_added_to_cart = Db::getInstance()->executeS('SELECT *
|
||||
FROM `' . _DB_PREFIX_ . 'customized_data`
|
||||
WHERE `id_customization` = ' . (int) $this->customization_id);
|
||||
$ErrorKey = ('update' === $mode) ? 'updateOperationError' : 'errors';
|
||||
$cart_update = Configuration::get('squaremeter_cartupdate');
|
||||
if ($cart_update == 'off') {
|
||||
if ($mode == 'update' && $this->customization_id !== 0 && $customization_added_to_cart[0]['index'] == $index) {
|
||||
$product = new Product($this->id_product, true, $this->context->language->id);
|
||||
if ($this->shouldAvailabilityErrorBeRaised($product, $customization_added_to_cart[0]['total_dimension']) == 1) {
|
||||
$this->{$ErrorKey}[] = $this->trans(
|
||||
'The product is no longer available in this quantity.',
|
||||
array(),
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
return;
|
||||
parent::processChangeProductInCart();
|
||||
}
|
||||
if (Shop::isFeatureActive()) {
|
||||
$idShop = (int) Context::getContext()->shop->id;
|
||||
} else {
|
||||
$idShop = 1;
|
||||
}
|
||||
$dimension_data = Db::getInstance()->executeS('SELECT *
|
||||
FROM `' . _DB_PREFIX_ . 'squaremeteradmin` pa
|
||||
WHERE pa.`id_product` = ' . (int) $this->id_product . ' AND
|
||||
pa.`id_shop` = ' . (int) $idShop);
|
||||
$this->{$ErrorKey}[] = $this->trans(
|
||||
'You can not update the customizable product in cart. Please go to the product page and update the dimension.',
|
||||
array(),
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
return;
|
||||
parent::processChangeProductInCart();
|
||||
}
|
||||
}
|
||||
if (Tools::getIsset('group')) {
|
||||
$this->id_product_attribute = (int) Product::getIdProductAttributeByIdAttributes(
|
||||
$this->id_product,
|
||||
Tools::getValue('group')
|
||||
);
|
||||
}
|
||||
if ($this->qty == 0) {
|
||||
$this->{$ErrorKey}[] = $this->trans(
|
||||
'Null quantity.',
|
||||
[],
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
} elseif (!$this->id_product) {
|
||||
$this->{$ErrorKey}[] = $this->trans(
|
||||
'Product not found',
|
||||
[],
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
}
|
||||
$product = new Product($this->id_product, true, $this->context->language->id);
|
||||
if (!$product->id || !$product->active || !$product->checkAccess($this->context->cart->id_customer)) {
|
||||
$this->{$ErrorKey}[] = $this->trans(
|
||||
'This product (%product%) is no longer available.',
|
||||
['%product%' => $product->name],
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!$this->id_product_attribute && $product->hasAttributes()) {
|
||||
$minimum_quantity = ($product->out_of_stock == 2)
|
||||
? !Configuration::get('PS_ORDER_OUT_OF_STOCK')
|
||||
: !$product->out_of_stock;
|
||||
$this->id_product_attribute = Product::getDefaultAttribute($product->id, $minimum_quantity);
|
||||
if (!$this->id_product_attribute) {
|
||||
Tools::redirectAdmin($this->context->link->getProductLink($product));
|
||||
}
|
||||
}
|
||||
$qty_to_check = $this->qty;
|
||||
$cart_products = $this->context->cart->getProducts();
|
||||
if (is_array($cart_products)) {
|
||||
foreach ($cart_products as $cart_product) {
|
||||
if ($this->productInCartMatchesCriteria($cart_product)) {
|
||||
$qty_to_check = $cart_product['cart_quantity'];
|
||||
if (Tools::getValue('op', 'up') == 'down') {
|
||||
$qty_to_check -= $this->qty;
|
||||
} else {
|
||||
$qty_to_check += $this->qty;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ('update' !== $mode && $this->shouldAvailabilityErrorBeRaised($product, $qty_to_check)) {
|
||||
$this->{$ErrorKey}[] = $this->trans(
|
||||
'The product is no longer available in this quantity.',
|
||||
[],
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
}
|
||||
$customization_added_to_cart = Db::getInstance()->executeS('SELECT *
|
||||
FROM `' . _DB_PREFIX_ . 'customized_data`
|
||||
WHERE `id_customization` = ' . (int) $this->customization_id);
|
||||
if (((Tools::getValue('op', 'up') == 'down') && ($this->customization_id !== 0) && ($customization_added_to_cart[0]['index'] == $index)) == false) {
|
||||
if (!$this->id_product_attribute) {
|
||||
if ($qty_to_check < $product->minimal_quantity) {
|
||||
$this->errors[] = $this->trans(
|
||||
'The minimum purchase order quantity for the product %product% is %quantity%.',
|
||||
['%product%' => $product->name, '%quantity%' => $product->minimal_quantity],
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$combination = new Combination($this->id_product_attribute);
|
||||
if ($qty_to_check < $combination->minimal_quantity) {
|
||||
$this->errors[] = $this->trans(
|
||||
'The minimum purchase order quantity for the product %product% is %quantity%.',
|
||||
['%product%' => $product->name, '%quantity%' => $combination->minimal_quantity],
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$this->errors) {
|
||||
if (!$this->context->cart->id) {
|
||||
if (Context::getContext()->cookie->id_guest) {
|
||||
$guest = new Guest(Context::getContext()->cookie->id_guest);
|
||||
$this->context->cart->mobile_theme = $guest->mobile_theme;
|
||||
}
|
||||
$this->context->cart->add();
|
||||
if ($this->context->cart->id) {
|
||||
$this->context->cookie->id_cart = (int) $this->context->cart->id;
|
||||
}
|
||||
}
|
||||
if (!$product->hasAllRequiredCustomizableFields() && !$this->customization_id) {
|
||||
$this->{$ErrorKey}[] = $this->trans(
|
||||
'Please fill in all of the required fields, and then save your customizations.',
|
||||
[],
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
}
|
||||
if (!$this->errors) {
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
$available_cart_rules = CartRule::getCustomerCartRules(
|
||||
$this->context->language->id,
|
||||
(isset($this->context->customer->id) ? $this->context->customer->id : 0),
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
$this->context->cart,
|
||||
false,
|
||||
true
|
||||
);
|
||||
$update_quantity = $this->context->cart->updateQty(
|
||||
$this->qty,
|
||||
$this->id_product,
|
||||
$this->id_product_attribute,
|
||||
$this->customization_id,
|
||||
Tools::getValue('op', 'up'),
|
||||
$this->id_address_delivery,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
);
|
||||
if ($update_quantity < 0) {
|
||||
$minimal_quantity = ($this->id_product_attribute)
|
||||
? Attribute::getAttributeMinimalQty($this->id_product_attribute)
|
||||
: $product->minimal_quantity;
|
||||
$this->{$ErrorKey}[] = $this->trans(
|
||||
'You must add %quantity% minimum quantity',
|
||||
['%quantity%' => $minimal_quantity],
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
} elseif (!$update_quantity) {
|
||||
$this->errors[] = $this->trans(
|
||||
'You already have the maximum quantity available for this product.',
|
||||
[],
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
} elseif ($this->shouldAvailabilityErrorBeRaised($product, $qty_to_check)) {
|
||||
$this->{$ErrorKey}[] = $this->trans(
|
||||
'The product is no longer available in this quantity.',
|
||||
[],
|
||||
'Shop.Notifications.Error'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$removed = CartRule::autoRemoveFromCart();
|
||||
CartRule::autoAddToCart();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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 Open Software License (OSL 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/OSL-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/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
class OrderController extends OrderControllerCore
|
||||
{
|
||||
public function initContent()
|
||||
{
|
||||
$index = Configuration::get('WD_CUSTOMIZATION_INDEX');
|
||||
$presented_cart = $this->cart_presenter->present($this->context->cart, true);
|
||||
$customization_added_to_cart = array();
|
||||
$dimension_data = array();
|
||||
$temp = array();
|
||||
$dimension_data_temp = array();
|
||||
foreach ($presented_cart['products'] as $product) {
|
||||
$id_customization = $product['id_customization'];
|
||||
$temp = Db::getInstance()->executeS('SELECT *
|
||||
FROM `' . _DB_PREFIX_ . 'customized_data`
|
||||
WHERE `id_customization` = ' . (int) $id_customization);
|
||||
|
||||
if ($temp) {
|
||||
$customization_added_to_cart[$id_customization] = $temp;
|
||||
}
|
||||
|
||||
if ($temp) {
|
||||
if (($id_customization !== 0) && ($customization_added_to_cart[$id_customization][0]['index'] == $index)) {
|
||||
if (Shop::isFeatureActive()) {
|
||||
$idShop = (int) Context::getContext()->shop->id;
|
||||
} else {
|
||||
$idShop = 1;
|
||||
}
|
||||
|
||||
$dimension_data_temp = Db::getInstance()->executeS('SELECT *
|
||||
FROM `' . _DB_PREFIX_ . 'squaremeteradmin` pa
|
||||
WHERE pa.`id_product` = ' . (int) $product['id'] . ' AND
|
||||
pa.`id_shop` = ' . (int) $idShop);
|
||||
|
||||
$dimension_data[$id_customization] = $dimension_data_temp;
|
||||
|
||||
$this->context->smarty->assign([
|
||||
'customization_added_to_cart' => $customization_added_to_cart,
|
||||
'dimension_data' => $dimension_data,
|
||||
'module_dir' => _PS_MODULE_DIR_ . 'squaremeter/',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->context->smarty->assign([
|
||||
'module_dir' => _PS_MODULE_DIR_ . 'squaremeter/',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
use PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter;
|
||||
|
||||
class ProductController extends ProductControllerCore
|
||||
{
|
||||
public function initContent()
|
||||
{
|
||||
$index = Configuration::get('WD_CUSTOMIZATION_INDEX');
|
||||
$presenter = new CartPresenter();
|
||||
$presented_cart = $presenter->present($this->context->cart, $shouldSeparateGifts = true);
|
||||
$customization_added_to_cart = array();
|
||||
$dimension_data = array();
|
||||
$temp = array();
|
||||
$dimension_data_temp = array();
|
||||
if ($presented_cart) {
|
||||
foreach ($presented_cart['products'] as $product) {
|
||||
$id_customization = $product['id_customization'];
|
||||
$temp = Db::getInstance()->executeS('SELECT *
|
||||
FROM `' . _DB_PREFIX_ . 'customized_data`
|
||||
WHERE `id_customization` = ' . (int) $id_customization);
|
||||
if ($temp) {
|
||||
$customization_added_to_cart[$id_customization] = $temp;
|
||||
}
|
||||
if ($temp) {
|
||||
if (($id_customization !== 0) && ($customization_added_to_cart[$id_customization][0]['index'] == $index)) {
|
||||
if (Shop::isFeatureActive()) {
|
||||
$idShop = (int) Context::getContext()->shop->id;
|
||||
} else {
|
||||
$idShop = 1;
|
||||
}
|
||||
$dimension_data_temp = Db::getInstance()->executeS('SELECT *
|
||||
FROM `' . _DB_PREFIX_ . 'squaremeteradmin` pa
|
||||
WHERE pa.`id_product` = ' . (int) $product['id'] . ' AND
|
||||
pa.`id_shop` = ' . (int) $idShop);
|
||||
$dimension_data[$id_customization] = $dimension_data_temp;
|
||||
$this->context->smarty->assign([
|
||||
'customization_added_to_cart' => $customization_added_to_cart,
|
||||
'dimension_data' => $dimension_data,
|
||||
'module_dir' => _PS_MODULE_DIR_ . 'squaremeter/',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$this->context->smarty->assign([
|
||||
'module_dir' => _PS_MODULE_DIR_ . 'squaremeter/',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2021 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This module is not a free module and all rights are reserved. It is prohibited to sell or redistribute this module for any purpose. Each license can be used only in one website. For multishop environment, a new license is required for each e-shop managed.
|
||||
*
|
||||
* 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 MEG Venture <info@megventure.com>
|
||||
* @copyright 2007-2021 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;
|
||||
29
modules/squaremeter_bckp/override/controllers/index.php
Normal file
29
modules/squaremeter_bckp/override/controllers/index.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2021 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This module is not a free module and all rights are reserved. It is prohibited to sell or redistribute this module for any purpose. Each license can be used only in one website. For multishop environment, a new license is required for each e-shop managed.
|
||||
*
|
||||
* 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 MEG Venture <info@megventure.com>
|
||||
* @copyright 2007-2021 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;
|
||||
Reference in New Issue
Block a user