first commit

This commit is contained in:
2024-12-17 13:43:22 +01:00
commit 8e6cd8b410
21292 changed files with 3514826 additions and 0 deletions

10
override/.htaccess Normal file
View File

@@ -0,0 +1,10 @@
# Apache 2.2
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

453
override/classes/Cart.php Normal file
View File

@@ -0,0 +1,453 @@
<?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 Cart extends CartCore
{
/*
* module: squaremeter
* date: 2021-11-19 11:36:06
* version: 5.5.0
*/
public function updateQty(
$quantity,
$id_product,
$id_product_attribute = null,
$id_customization = false,
$operator = 'up',
$id_address_delivery = 0,
Shop $shop = null,
$auto_add_cart_rule = true,
$skipAvailabilityCheckOutOfStock = false,
bool $preserveGiftRemoval = true,
bool $useOrderPrices = false
) {
$cartProductQuantity = parent::getProductQuantity(
$id_product,
$id_product_attribute,
$id_customization,
$id_address_delivery
);
$index = Configuration::get('WD_CUSTOMIZATION_INDEX');
$customization_added_to_cart = Db::getInstance()->executeS('SELECT *
FROM `' . _DB_PREFIX_ . 'customized_data`
WHERE `id_customization` = ' . (int) $id_customization);
if (!$shop) {
$shop = Context::getContext()->shop;
}
$dimension_data = Db::getInstance()->executeS('SELECT *
FROM `' . _DB_PREFIX_ . 'squaremeteradmin` pa
WHERE pa.`id_product` = ' . (int) $id_product . ' AND
pa.`id_shop` = ' . (int) $shop->id);
if ($dimension_data[0]['displaycalculator'] != 1) {
parent::updateQty(
$quantity,
$id_product,
$id_product_attribute,
$id_customization,
$operator,
$id_address_delivery,
$shop,
$auto_add_cart_rule,
$skipAvailabilityCheckOutOfStock,
$preserveGiftRemoval,
$useOrderPrices
);
return true;
} else {
if (Validate::isLoadedObject(Context::getContext()->customer)) {
if ($id_address_delivery == 0 && (int) $this->id_address_delivery) {
$id_address_delivery = $this->id_address_delivery;
} elseif ($id_address_delivery == 0) {
$id_address_delivery = (int) Address::getFirstCustomerAddressId(
(int) Context::getContext()->customer->id
);
} elseif (!Customer::customerHasAddress(Context::getContext()->customer->id, $id_address_delivery)) {
$id_address_delivery = 0;
}
} else {
$id_address_delivery = 0;
}
$quantity = (int) $quantity;
$id_product = (int) $id_product;
$id_product_attribute = (int) $id_product_attribute;
$product = new Product($id_product, false, Configuration::get('PS_LANG_DEFAULT'), $shop->id);
if ($id_product_attribute) {
$combination = new Combination((int) $id_product_attribute);
if ($combination->id_product != $id_product) {
return false;
}
}
if (!empty($id_product_attribute)) {
$minimal_quantity = (int) Attribute::getAttributeMinimalQty($id_product_attribute);
} else {
$minimal_quantity = (int) $product->minimal_quantity;
}
if (!Validate::isLoadedObject($product)) {
die(Tools::displayError());
}
if (isset(self::$_nbProducts[$this->id])) {
unset(self::$_nbProducts[$this->id]);
}
if (isset(self::$_totalWeight[$this->id])) {
unset(self::$_totalWeight[$this->id]);
}
$data = array(
'cart' => $this,
'product' => $product,
'id_product_attribute' => $id_product_attribute,
'id_customization' => $id_customization,
'quantity' => $quantity,
'operator' => $operator,
'id_address_delivery' => $id_address_delivery,
'shop' => $shop,
'auto_add_cart_rule' => $auto_add_cart_rule,
);
Hook::exec('actionCartUpdateQuantityBefore', $data);
if (Tools::getValue('cartsource')) {
$suffix = '_' . Tools::getValue('id_product');
} else {
$suffix = '';
}
if ($dimension_data) {
$qty_type = (($dimension_data[0]['displayquantity'] == 'decimalok') || ($dimension_data[0]['displayquantity'] == 'calcvisible') || ($dimension_data[0]['displayquantity'] == 'calcinvisible')) ? 'qty_type_float' : 'qty_type_integer';
$calculation_type = $dimension_data[0]['calculationtype'];
if ($dimension_data[0]['step'] == 0) {
$dimension_data[0]['step'] = 0.1;
}
}
if (isset($calculation_type)) {
switch ($calculation_type) {
case "weight":
$minimum_customization_quantity = $dimension_data[0]['minweight'];
break;
default:
$minimum_customization_quantity = $dimension_data[0]['minwidth'];
}
}
if ((int) $quantity <= 0) {
if ((_PS_VERSION_ >= '1.7.0.0') && (_PS_VERSION_ < '1.7.7.0')) {
return parent::deleteProduct((int) $id_product, (int) $id_product_attribute, (int) $id_customization);
} elseif (_PS_VERSION_ >= '1.7.7.0') {
return parent::deleteProduct((int) $id_product, (int) $id_product_attribute, (int) $id_customization, (int) $id_address_delivery, $preserveGiftRemoval);
}
}
if (!$product->available_for_order
|| (Configuration::isCatalogMode()
&& !defined('_PS_ADMIN_DIR_'))
) {
return false;
}
if (empty(Tools::getValue('discretion')) && Tools::getValue('dim' . $suffix) && $id_customization) {
$id_customization = 0;
} elseif (Tools::getValue('discretion') && Tools::getValue('dim' . $suffix) && $id_customization) {
$cartProductQuantity = parent::getProductQuantity(
$id_product,
$id_product_attribute,
(int) $id_customization,
(int) $id_address_delivery
);
if (!empty($cartProductQuantity['quantity'])) {
$sql = 'select id_customization from ' . pSQL(_DB_PREFIX_) . 'customized_data ORDER BY id_customization DESC LIMIT 1';
$latestcustomization = Db::getInstance()->executeS($sql);
$id_customization = $latestcustomization[0]['id_customization'];
$id_customization = $id_customization + 1;
}
}
$cartProductQuantity = parent::getProductQuantity(
$id_product,
$id_product_attribute,
(int) $id_customization,
(int) $id_address_delivery
);
if (!empty($cartProductQuantity['quantity'])) {
if (($dimension_data) && ($qty_type == 'qty_type_float')) {
$customization_added_to_cart = Db::getInstance()->executeS('SELECT *
FROM `' . _DB_PREFIX_ . 'customized_data`
WHERE `id_customization` = ' . (int) $id_customization);
if ($customization_added_to_cart) {
$oldProductQuantity = $customization_added_to_cart[0]['converted_ea'];
$oldTotalDimension = $customization_added_to_cart[0]['total_dimension'];
}
}
$productQuantity = Product::getQuantity($id_product, $id_product_attribute, null, $this); //Available quantity
$availableOutOfStock = Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock($product->id));
if ($operator == 'up') {
$updateQuantity = '+ ' . $quantity; //+ 1
if (($dimension_data) && ($qty_type == 'qty_type_float')) {
if (($dimension_data[0]['displayquantity'] == 'calcvisible') || ($dimension_data[0]['displayquantity'] == 'calcinvisible')) {
$newProductQuantity = $productQuantity - $quantity; //This will be the new stock available
$newDimensionQuantity = $cartProductQuantity['quantity'] + $quantity;
} else {
$newProductQuantity = $productQuantity - $dimension_data[0]['step'];
$newDimensionQuantity = $customization_added_to_cart[0]['total_dimension'] + $dimension_data[0]['step'];
}
} else {
$newProductQuantity = $productQuantity - $quantity;
}
if ($newProductQuantity < 0 && !$availableOutOfStock && !$skipAvailabilityCheckOutOfStock) {
return false;
}
} elseif ($operator == 'down') {
$cartFirstLevelProductQuantity = parent::getProductQuantity(
(int) $id_product,
(int) $id_product_attribute,
$id_customization
);
$updateQuantity = '- ' . $quantity;
if ((_PS_VERSION_ >= '1.7.6.0') && (_PS_VERSION_ < '1.7.7.0')) {
if (($dimension_data) && ($qty_type == 'qty_type_float')) {
if (($dimension_data[0]['displayquantity'] == 'calcvisible') || ($dimension_data[0]['displayquantity'] == 'calcinvisible')) {
$newProductQuantity = $productQuantity + $quantity;
$newDimensionQuantity = $cartProductQuantity['quantity'] - $quantity;
} else {
$newProductQuantity = $customization_added_to_cart[0]['total_dimension'] + $dimension_data[0]['step'];
$newDimensionQuantity = $customization_added_to_cart[0]['total_dimension'] - $dimension_data[0]['step'];
}
} else {
$newProductQuantity = $productQuantity + $quantity;
}
} else {
if ($dimension_data) {
if (($dimension_data[0]['displayquantity'] == 'calcvisible') || ($dimension_data[0]['displayquantity'] == 'calcinvisible')) {
$newProductQuantity = $productQuantity + $quantity;
$newDimensionQuantity = $cartProductQuantity['quantity'] - $quantity;
} else {
$newProductQuantity = $customization_added_to_cart[0]['total_dimension'] + $dimension_data[0]['step'];
$newDimensionQuantity = $customization_added_to_cart[0]['total_dimension'] - $dimension_data[0]['step'];
}
}
}
if (($dimension_data) && ($qty_type == 'qty_type_float') && (($dimension_data[0]['displayquantity'] != 'calcvisible') && ($dimension_data[0]['displayquantity'] != 'calcinvisible'))) {
if ($newProductQuantity < $minimum_customization_quantity) {
if ((_PS_VERSION_ >= '1.7.0.0') && (_PS_VERSION_ < '1.7.7.0')) {
return parent::deleteProduct((int) $id_product, (int) $id_product_attribute, (int) $id_customization);
} elseif (_PS_VERSION_ >= '1.7.7.0') {
return parent::deleteProduct((int) $id_product, (int) $id_product_attribute, (int) $id_customization, (int) $id_address_delivery, $preserveGiftRemoval);
}
}
} else {
if ($cartFirstLevelProductQuantity['quantity'] <= 1
|| $cartProductQuantity['quantity'] - $quantity <= 0) {
if ((_PS_VERSION_ >= '1.7.0.0') && (_PS_VERSION_ < '1.7.7.0')) {
return parent::deleteProduct((int) $id_product, (int) $id_product_attribute, (int) $id_customization);
} elseif (_PS_VERSION_ >= '1.7.7.0') {
return parent::deleteProduct((int) $id_product, (int) $id_product_attribute, (int) $id_customization, (int) $id_address_delivery, $preserveGiftRemoval);
}
}
}
} else {
return false;
}
if (($dimension_data) && ($qty_type == 'qty_type_float')) {
if ($dimension_data[0]['displaystartingprice'] == null) {
$dimension_data[0]['displaystartingprice'] = 0;
}
if ($dimension_data[0]['displayreserve'] == null) {
$dimension_data[0]['displayreserve'] = 0;
}
if ($customization_added_to_cart[0]['extra_fee'] == null) {
$customization_added_to_cart[0]['extra_fee'] = 0;
}
$old_price = $customization_added_to_cart[0]['price'] - $dimension_data[0]['displaystartingprice'] - $customization_added_to_cart[0]['extra_fee'];
$old_unit_price = round(($old_price / $oldProductQuantity), 2);
if ($customization_added_to_cart[0]['grand_total_dimension'] != 0) {
$conversion_rate = round(($customization_added_to_cart[0]['converted_ea'] / $customization_added_to_cart[0]['grand_total_dimension']), 2);
$newGrandTotalDimension = round((($newDimensionQuantity * $customization_added_to_cart[0]['grand_total_dimension']) / $oldProductQuantity), 2);
$newConvertedEa = $newDimensionQuantity;
$newDimensionQuantity = $newGrandTotalDimension;
} else {
$newConvertedEa = round((($newDimensionQuantity * $oldProductQuantity) / $oldTotalDimension), 2);
}
$new_price = $newConvertedEa * $old_unit_price + $dimension_data[0]['displaystartingprice'] + $customization_added_to_cart[0]['extra_fee'];
if ($dimension_data[0]['displayreserve'] > $new_price) {
$new_price = $dimension_data[0]['displayreserve'];
}
if (($dimension_data[0]['displayquantity'] == 'calcvisible') || ($dimension_data[0]['displayquantity'] == 'calcinvisible')) {
$update = '`quantity` ' . $updateQuantity;
$new_dimension_text = '(Total ' . $newDimensionQuantity . ' ' . $dimension_data[0]['conversionunit'] . ')';
} else {
$new_dimension_text = '(Total ' . $newDimensionQuantity . ' ' . $dimension_data[0]['conversionunit'] . ')';
$update = $quantity;
}
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'customized_data`
SET `price` = ' . (float) $new_price . ',
`value` = "' . pSQL($new_dimension_text) . '",
`total_dimension` = ' . (float) $newDimensionQuantity . ',
`grand_total_dimension` = ' . (float) $newGrandTotalDimension . ',
`converted_ea` = ' . (float) $newConvertedEa . '
WHERE `id_customization` = ' . (int) $id_customization . '
LIMIT 1'
);
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'cart_product`
SET `quantity` = ' . (int) $update . '
WHERE `id_product` = ' . (int) $id_product .
' AND `id_customization` = ' . (int) $id_customization .
(!empty($id_product_attribute) ? ' AND `id_product_attribute` = ' . (int) $id_product_attribute : '') . '
AND `id_cart` = ' . (int) $this->id . (Configuration::get('PS_ALLOW_MULTISHIPPING') && parent::isMultiAddressDelivery() ? ' AND `id_address_delivery` = ' . (int) $id_address_delivery : '') . '
LIMIT 1'
);
} else {
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'cart_product`
SET `quantity` = `quantity` ' . (int) $updateQuantity . '
WHERE `id_product` = ' . (int) $id_product .
' AND `id_customization` = ' . (int) $id_customization .
(!empty($id_product_attribute) ? ' AND `id_product_attribute` = ' . (int) $id_product_attribute : '') . '
AND `id_cart` = ' . (int) $this->id . (Configuration::get('PS_ALLOW_MULTISHIPPING') && parent::isMultiAddressDelivery() ? ' AND `id_address_delivery` = ' . (int) $id_address_delivery : '') . '
LIMIT 1'
);
}
} elseif ($operator == 'up') {
$sql = 'SELECT stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity
FROM ' . _DB_PREFIX_ . 'product p
' . Product::sqlStock('p', $id_product_attribute, true, $shop) . '
WHERE p.id_product = ' . $id_product;
$result2 = Db::getInstance()->getRow($sql);
if (Pack::isPack($id_product)) {
$result2['quantity'] = Pack::getQuantity($id_product, $id_product_attribute, null, $this);
}
if (!Product::isAvailableWhenOutOfStock((int) $result2['out_of_stock']) && !$skipAvailabilityCheckOutOfStock) {
if ((int) $quantity > $result2['quantity']) {
return false;
}
}
if ((int) $quantity < $minimal_quantity) {
return -1;
}
$result_add = Db::getInstance()->insert('cart_product', array(
'id_product' => (int) $id_product,
'id_product_attribute' => (int) $id_product_attribute,
'id_cart' => (int) $this->id,
'id_address_delivery' => (int) $id_address_delivery,
'id_shop' => $shop->id,
'quantity' => (int) $quantity,
'date_add' => date('Y-m-d H:i:s'),
'id_customization' => (int) $id_customization,
));
if (!$result_add) {
return false;
}
}
$this->_products = parent::getProducts(true);
parent::update();
$context = Context::getContext()->cloneContext();
$context->cart = $this;
Cache::clean('getContextualValue_*');
CartRule::autoRemoveFromCart();
if ($auto_add_cart_rule) {
CartRule::autoAddToCart($context);
}
if (($product->customizable) || (Tools::getValue('dim' . $suffix))) {
$sql = 'select id_customization from ' . pSQL(_DB_PREFIX_) . 'customized_data ORDER BY id_customization DESC LIMIT 1';
$latestcustomization = Db::getInstance()->executeS($sql);
$id_customization = $latestcustomization[0]['id_customization'];
return parent::_updateCustomizationQuantity(
(int) $quantity,
(int) $id_customization,
(int) $id_product,
(int) $id_product_attribute,
(int) $id_address_delivery,
$operator
);
}
return true;
}
}
/**
* Add customization item to database.
*
* @param int $id_product Product ID
* @param int $id_product_attribute ProductAttribute ID
* @param int $index Index
* @param int $type Type enum
* - Product::CUSTOMIZE_FILE
* - Product::CUSTOMIZE_TEXTFIELD
* @param string $field Field
* @param int $quantity Quantity
*
* @return bool Success
*/
/*
* module: squaremeter
* date: 2021-11-19 11:36:06
* version: 5.5.0
*/
public function _addCustomization2($id_product, $id_product_attribute, $index, $type, $field, $quantity, $dimension_price)
{
$id_customization = 0;
$exising_customization = Db::getInstance()->executeS(
'SELECT cu.`id_customization`, cd.`index`, cd.`value`, cd.`type` FROM `' . _DB_PREFIX_ . 'customization` cu
LEFT JOIN `' . _DB_PREFIX_ . 'customized_data` cd
ON cu.`id_customization` = cd.`id_customization`
WHERE cu.id_cart = ' . (int) $this->id . '
AND cu.id_product = ' . (int) $id_product . '
AND in_cart = 0'
);
if ($exising_customization) {
foreach ($exising_customization as $customization) {
if ($customization['type'] == $type && $customization['index'] == $index) {
Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'customized_data`
WHERE id_customization = ' . (int) $customization['id_customization'] . '
AND type = ' . (int) $customization['type'] . '
AND `index` = ' . (int) $customization['index']);
if ($type == Product::CUSTOMIZE_FILE) {
@unlink(_PS_UPLOAD_DIR_ . $customization['value']);
@unlink(_PS_UPLOAD_DIR_ . $customization['value'] . '_small');
}
break;
}
}
$id_customization = $exising_customization[0]['id_customization'];
} else {
if ($this->id) {
Db::getInstance()->execute(
'INSERT INTO `' . _DB_PREFIX_ . 'customization` (`id_cart`, `id_product`, `id_product_attribute`, `quantity`)
VALUES (' . (int) $this->id . ', ' . (int) $id_product . ', ' . (int) $id_product_attribute . ', ' . (int) $quantity . ')'
);
$id_customization = Db::getInstance()->Insert_ID();
}
}
if ($id_customization) {
$query = 'INSERT INTO `' . _DB_PREFIX_ . 'customized_data` (`id_customization`, `type`, `index`, `value`, `dimension_price`)
VALUES (' . (int) $id_customization . ', ' . (int) $type . ', ' . (int) $index . ', \'' . pSQL($field) . '\'' . ', ' . (float) $dimension_price . ')';
if (!Db::getInstance()->execute($query)) {
return false;
}
}
return true;
}
/*
* module: squaremeter
* date: 2021-11-19 11:36:06
* version: 5.5.0
*/
public function addTextFieldToProductOverride($id_product, $id_product_attribute, $index, $type, $text_value, $dimension_price, $quantity = 0)
{
return $this->_addCustomization2($id_product, $id_product_attribute, $index, $type, $text_value, $quantity, $dimension_price);
}
}

95
override/classes/Hook.php Normal file
View File

@@ -0,0 +1,95 @@
<?php
/**
* ISC License
*
* Copyright (c) 2024 idnovate.com
* idnovate is a Registered Trademark & Property of idnovate.com, innovación y desarrollo SCP
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* @author idnovate
* @copyright 2024 idnovate
* @license https://www.isc.org/licenses/ https://opensource.org/licenses/ISC ISC License
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class Hook extends HookCore
{
/*
* module: cookiesplus
* date: 2024-03-27 08:06:58
* version: 1.6.0
*/
public static function getHookModuleExecList($hookName = null)
{
$modulesToInvoke = parent::getHookModuleExecList($hookName);
if (Module::isEnabled('cookiesplus')) {
$cookiesPlus = Module::getInstanceByName('cookiesplus');
$modulesToInvoke = $cookiesPlus->blockModuleCache($modulesToInvoke, $hookName);
}
return !empty($modulesToInvoke) ? $modulesToInvoke : false;
}
/*
* module: cookiesplus
* date: 2024-03-27 08:06:58
* version: 1.6.0
*/
public static function coreCallHook($module, $method, $params)
{
$headersBeforeExecution = headers_list();
$display = parent::coreCallHook($module, $method, $params);
if (Module::isEnabled('cookiesplus')) {
$forceDisplay = false;
$cookiesPlus = Module::getInstanceByName('cookiesplus');
$cookiesPlus->blockModuleCode([
'display' => &$display,
'module' => &$module,
'hookName' => &$method,
'params' => &$params,
'forceDisplay' => &$forceDisplay,
'headersBeforeExecution' => $headersBeforeExecution,
]);
if ($forceDisplay) {
return $display;
}
}
return $display;
}
/*
* module: cookiesplus
* date: 2024-03-27 08:06:58
* version: 1.6.0
*/
public static function coreRenderWidget($module, $hook_name, $params)
{
$headersBeforeExecution = headers_list();
$display = parent::coreRenderWidget($module, $hook_name, $params);
if (Module::isEnabled('cookiesplus')) {
$forceDisplay = false;
$cookiesPlus = Module::getInstanceByName('cookiesplus');
$cookiesPlus->blockModuleCode([
'display' => &$display,
'module' => &$module,
'hookName' => &$hook_name,
'params' => &$params,
'forceDisplay' => &$forceDisplay,
'headersBeforeExecution' => $headersBeforeExecution,
]);
if ($forceDisplay) {
return $display;
}
}
return $display;
}
}

View File

@@ -0,0 +1,290 @@
<?php
/*
* @package gmcrop
* @author Dariusz Tryba (contact@greenmousestudio.com)
* @copyright Copyright (c) Green Mouse Studio (http://www.greenmousestudio.com)
* @license http://greenmousestudio.com/paid-license.txt
*/
class ImageManager extends ImageManagerCore
{
/*
* module: gmcrop
* date: 2021-06-22 17:10:23
* version: 1.2.3
*/
public static function resize($sourceFile, $destinationFile, $destinationWidth = null, $destinationHeight = null,
$fileType = 'jpg', $forceType = false, &$error = 0, &$targetWidth = null,
&$targetHeight = null, $quality = 5, &$sourceWidth = null, &$sourceHeight = null)
{
clearstatcache(true, $sourceFile);
if (!file_exists($sourceFile) || !filesize($sourceFile)) {
return !($error = self::ERROR_FILE_NOT_EXIST);
}
list($tmpWidth, $tmpHeight, $type) = getimagesize($sourceFile);
$rotate = 0;
if (function_exists('exif_read_data') && function_exists('mb_strtolower')) {
$exif = @exif_read_data($sourceFile);
if ($exif && isset($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 3:
$sourceWidth = $tmpWidth;
$sourceHeight = $tmpHeight;
$rotate = 180;
break;
case 6:
$sourceWidth = $tmpHeight;
$sourceHeight = $tmpWidth;
$rotate = -90;
break;
case 8:
$sourceWidth = $tmpHeight;
$sourceHeight = $tmpWidth;
$rotate = 90;
break;
default:
$sourceWidth = $tmpWidth;
$sourceHeight = $tmpHeight;
}
} else {
$sourceWidth = $tmpWidth;
$sourceHeight = $tmpHeight;
}
} else {
$sourceWidth = $tmpWidth;
$sourceHeight = $tmpHeight;
}
$srcImage = ImageManager::create($type, $sourceFile);
if (Module::isEnabled('gmcrop')) {
if (function_exists('imagecropauto')) {
if (Configuration::get('GMCROP_CROPBG')) {
$cropped = imagecropauto($srcImage, IMG_CROP_THRESHOLD, 0.25, 16777215);
if ($cropped !== false) {
imagedestroy($srcImage);
$srcImage = $cropped;
$sourceWidth = imagesx($srcImage);
$sourceHeight = imagesy($srcImage);
}
}
}
$keepProportions = false;
$fittedImageTypes = explode(',', Configuration::get('GMCROP_FITTEDTYPES'));
if (is_array($fittedImageTypes) && (count($fittedImageTypes) > 0)) {
foreach ($fittedImageTypes as $fittedImageType) {
if (strlen($fittedImageType) > 1) {
if (strpos($destinationFile, $fittedImageType) !== false) {
$keepProportions = true;
}
}
}
}
if ($keepProportions) {
$widthRatio = $destinationWidth / $sourceWidth;
$heightRatio = $destinationHeight / $sourceHeight;
if (($widthRatio < 1) || ($heightRatio < 1)) {
if ($widthRatio < $heightRatio) {
$destinationWidth = $sourceWidth * $widthRatio;
$destinationHeight = $sourceHeight * $widthRatio;
} else {
$destinationWidth = $sourceWidth * $heightRatio;
$destinationHeight = $sourceHeight * $heightRatio;
}
} else {
$destinationWidth = $sourceWidth;
$destinationHeight = $sourceHeight;
}
}
}
if (Configuration::get('PS_IMAGE_QUALITY') == 'png_all' || (Configuration::get('PS_IMAGE_QUALITY') == 'png' && $type
== IMAGETYPE_PNG) && !$forceType) {
$fileType = 'png';
}
if (!$sourceWidth) {
return !($error = self::ERROR_FILE_WIDTH);
}
if (!$destinationWidth) {
$destinationWidth = $sourceWidth;
}
if (!$destinationHeight) {
$destinationHeight = $sourceHeight;
}
$widthDiff = $destinationWidth / $sourceWidth;
$heightDiff = $destinationHeight / $sourceHeight;
$rgb = ImageManager::hex2rgb(Configuration::get('GMCROP_BGCOLOR'));
$red = $rgb[0];
$green = $rgb[1];
$blue = $rgb[2];
$crop = false;
if (Module::isEnabled('gmcrop')) {
$croppedImageTypes = explode(',', Configuration::get('GMCROP_CROPPEDTYPES'));
if (is_array($croppedImageTypes) && (count($croppedImageTypes) > 0)) {
foreach ($croppedImageTypes as $croppedImageType) {
if (strlen($croppedImageType) > 1) {
if (strpos($destinationFile, $croppedImageType) !== false) {
$crop = true;
}
}
}
}
} else {
$red = $green = $blue = 255;
}
if (!$crop) {
$psImageGenerationMethod = Configuration::get('PS_IMAGE_GENERATION_METHOD');
if ($widthDiff > 1 && $heightDiff > 1) {
$nextWidth = $sourceWidth;
$nextHeight = $sourceHeight;
} else {
if ($psImageGenerationMethod == 2 || (!$psImageGenerationMethod && $widthDiff > $heightDiff)) {
$nextHeight = $destinationHeight;
$nextWidth = round(($sourceWidth * $nextHeight) / $sourceHeight);
$destinationWidth = (int) (!$psImageGenerationMethod ? $destinationWidth : $nextWidth);
} else {
$nextWidth = $destinationWidth;
$nextHeight = round($sourceHeight * $destinationWidth / $sourceWidth);
$destinationHeight = (int) (!$psImageGenerationMethod ? $destinationHeight : $nextHeight);
}
}
if (!ImageManager::checkImageMemoryLimit($sourceFile)) {
return !($error = self::ERROR_MEMORY_LIMIT);
}
$targetWidth = $destinationWidth;
$targetHeight = $destinationHeight;
$destImage = imagecreatetruecolor($destinationWidth, $destinationHeight);
if ($fileType == 'png' && $type == IMAGETYPE_PNG) {
imagealphablending($destImage, false);
imagesavealpha($destImage, true);
$transparent = imagecolorallocatealpha($destImage, $red, $green, $blue, 127);
imagefilledrectangle($destImage, 0, 0, $destinationWidth, $destinationHeight, $transparent);
} else {
$white = imagecolorallocate($destImage, $red, $green, $blue);
imagefilledrectangle($destImage, 0, 0, $destinationWidth, $destinationHeight, $white);
}
if ($rotate) {
$srcImage = imagerotate($srcImage, $rotate, 0);
}
if ($destinationWidth >= $sourceWidth && $destinationHeight >= $sourceHeight) {
imagecopyresized($destImage, $srcImage, (int) (($destinationWidth - $nextWidth) / 2),
(int) (($destinationHeight - $nextHeight) / 2), 0, 0, $nextWidth, $nextHeight, $sourceWidth,
$sourceHeight);
} else {
ImageManager::imagecopyresampled($destImage, $srcImage, (int) (($destinationWidth - $nextWidth) / 2),
(int) (($destinationHeight - $nextHeight) / 2), 0, 0, $nextWidth, $nextHeight, $sourceWidth,
$sourceHeight, $quality);
}
$writeFile = ImageManager::write($fileType, $destImage, $destinationFile);
@imagedestroy($srcImage);
return $writeFile;
} else {
$psImageGenerationMethod = Configuration::get('PS_IMAGE_GENERATION_METHOD');
if ($widthDiff > 1 && $heightDiff > 1) {
$nextWidth = $sourceWidth;
$nextHeight = $sourceHeight;
} else {
if ($psImageGenerationMethod == 2 || (!$psImageGenerationMethod && $widthDiff < $heightDiff)) {
$nextHeight = $destinationHeight;
$nextWidth = round(($sourceWidth * $nextHeight) / $sourceHeight);
$destinationWidth = (int) (!$psImageGenerationMethod ? $destinationWidth : $nextWidth);
} else {
$nextWidth = $destinationWidth;
$nextHeight = round($sourceHeight * $destinationWidth / $sourceWidth);
$destinationHeight = (int) (!$psImageGenerationMethod ? $destinationHeight : $nextHeight);
}
}
if (!ImageManager::checkImageMemoryLimit($sourceFile)) {
return !($error = self::ERROR_MEMORY_LIMIT);
}
$targetWidth = $destinationWidth;
$targetHeight = $destinationHeight;
$destImage = imagecreatetruecolor($destinationWidth, $destinationHeight);
if ($fileType == 'png' && $type == IMAGETYPE_PNG) {
imagealphablending($destImage, false);
imagesavealpha($destImage, true);
$transparent = imagecolorallocatealpha($destImage, $red, $green, $blue, 127);
imagefilledrectangle($destImage, 0, 0, $destinationWidth, $destinationHeight, $transparent);
} else {
$white = imagecolorallocate($destImage, $red, $green, $blue);
imagefilledrectangle($destImage, 0, 0, $destinationWidth, $destinationHeight, $white);
}
if ($rotate) {
$srcImage = imagerotate($srcImage, $rotate, 0);
}
$originConfig = Configuration::get('GMCROP_ORIGIN');
switch ($originConfig) {
case 0:
$originX = 0;
$originY = 0;
break;
case 1:
$originX = (int) (($destinationWidth - $nextWidth) / 2);
$originY = 0;
break;
case 2:
$originX = (int) ($destinationWidth - $nextWidth);
$originY = 0;
break;
case 3:
$originX = 0;
$originY = (int) (($destinationHeight - $nextHeight) / 2);
break;
case 4:
$originX = (int) (($destinationWidth - $nextWidth) / 2);
$originY = (int) (($destinationHeight - $nextHeight) / 2);
break;
case 5:
$originX = (int) ($destinationWidth - $nextWidth);
$originY = (int) (($destinationHeight - $nextHeight) / 2);
break;
case 6:
$originX = 0;
$originY = (int) (($destinationHeight - $nextHeight));
break;
case 7:
$originX = (int) (($destinationWidth - $nextWidth) / 2);
$originY = (int) (($destinationHeight - $nextHeight));
break;
case 8:
$originX = (int) ($destinationWidth - $nextWidth);
$originY = (int) (($destinationHeight - $nextHeight));
break;
default:
$originX = (int) (($destinationWidth - $nextWidth) / 2);
$originY = (int) (($destinationHeight - $nextHeight) / 2);
break;
}
if ($destinationWidth >= $sourceWidth && $destinationHeight >= $sourceHeight) {
imagecopyresized($destImage, $srcImage, $originX, $originY, 0, 0, $nextWidth, $nextHeight, $sourceWidth,
$sourceHeight);
} else {
ImageManager::imagecopyresampled($destImage, $srcImage, $originX, $originY, 0, 0, $nextWidth,
$nextHeight, $sourceWidth, $sourceHeight, $quality);
}
$writeFile = ImageManager::write($fileType, $destImage, $destinationFile);
Hook::exec('actionOnImageResizeAfter', array('dst_file' => $destinationFile, 'file_type' => $fileType));
@imagedestroy($srcImage);
file_put_contents(
dirname($destinationFile).DIRECTORY_SEPARATOR.'fileType', $fileType
);
return $writeFile;
}
}
/*
* module: gmcrop
* date: 2021-06-22 17:10:23
* version: 1.2.3
*/
public static function hex2rgb($hex)
{
$hex = str_replace("#", "", $hex);
if (strlen($hex) == 3) {
$r = hexdec(substr($hex, 0, 1).substr($hex, 0, 1));
$g = hexdec(substr($hex, 1, 1).substr($hex, 1, 1));
$b = hexdec(substr($hex, 2, 1).substr($hex, 2, 1));
} else {
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
}
$rgb = array($r, $g, $b);
return $rgb; // returns an array with the rgb values
}
}

View File

@@ -0,0 +1,321 @@
<?php
use \Group as G;
class Product extends ProductCore
{
/*
* module: squaremeter
* date: 2021-11-19 11:36:06
* version: 5.5.0
*/
public static function priceCalculation(
$id_shop,
$id_product,
$id_product_attribute,
$id_country,
$id_state,
$zipcode,
$id_currency,
$id_group,
$quantity,
$use_tax,
$decimals,
$only_reduc,
$use_reduc,
$with_ecotax,
&$specific_price,
$use_group_reduction,
$id_customer = 0,
$use_customer_price = true,
$id_cart = 0,
$real_quantity = 0,
$id_customization = 0
) {
static $address = null;
static $context = null;
if ($context == null) {
$context = Context::getContext()->cloneContext();
}
if ($address === null) {
if (is_object($context->cart) && $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} != null) {
$id_address = $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
$address = new Address($id_address);
} else {
$address = new Address();
}
}
if ($id_shop !== null && $context->shop->id != (int) $id_shop) {
$context->shop = new Shop((int) $id_shop);
}
if (!$use_customer_price) {
$id_customer = 0;
}
if ($id_product_attribute === null) {
$id_product_attribute = Product::getDefaultAttribute($id_product);
}
$cache_id = (int) $id_product . '-' . (int) $id_shop . '-' . (int) $id_currency . '-' . (int) $id_country . '-' . $id_state . '-' . $zipcode . '-' . (int) $id_group .
'-' . (int) $quantity . '-' . (int) $id_product_attribute . '-' . (int) $id_customization .
'-' . (int) $with_ecotax . '-' . (int) $id_customer . '-' . (int) $use_group_reduction . '-' . (int) $id_cart . '-' . (int) $real_quantity .
'-' . ($only_reduc ? '1' : '0') . '-' . ($use_reduc ? '1' : '0') . '-' . ($use_tax ? '1' : '0') . '-' . (int) $decimals;
$specific_price = SpecificPrice::getSpecificPrice(
(int) $id_product,
$id_shop,
$id_currency,
$id_country,
$id_group,
$quantity,
$id_product_attribute,
$id_customer,
$id_cart,
$real_quantity
);
if (isset(self::$_prices[$cache_id])) {
return self::$_prices[$cache_id];
}
$cache_id_2 = $id_product . '-' . $id_shop;
if (!isset(self::$_pricesLevel2[$cache_id_2])) {
$sql = new DbQuery();
$sql->select('product_shop.`price`, product_shop.`ecotax`');
$sql->from('product', 'p');
$sql->innerJoin('product_shop', 'product_shop', '(product_shop.id_product=p.id_product AND product_shop.id_shop = ' . (int) $id_shop . ')');
$sql->where('p.`id_product` = ' . (int) $id_product);
if (Combination::isFeatureActive()) {
$sql->select('IFNULL(product_attribute_shop.id_product_attribute,0) id_product_attribute, product_attribute_shop.`price` AS attribute_price, product_attribute_shop.default_on');
$sql->leftJoin('product_attribute_shop', 'product_attribute_shop', '(product_attribute_shop.id_product = p.id_product AND product_attribute_shop.id_shop = ' . (int) $id_shop . ')');
} else {
$sql->select('0 as id_product_attribute');
}
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (is_array($res) && count($res)) {
foreach ($res as $row) {
$array_tmp = array(
'price' => $row['price'],
'ecotax' => $row['ecotax'],
'attribute_price' => (isset($row['attribute_price']) ? $row['attribute_price'] : null),
);
self::$_pricesLevel2[$cache_id_2][(int) $row['id_product_attribute']] = $array_tmp;
if (isset($row['default_on']) && $row['default_on'] == 1) {
self::$_pricesLevel2[$cache_id_2][0] = $array_tmp;
}
}
}
}
if (!isset(self::$_pricesLevel2[$cache_id_2][(int) $id_product_attribute])) {
return;
}
$result = self::$_pricesLevel2[$cache_id_2][(int) $id_product_attribute];
if (!$specific_price || $specific_price['price'] < 0) {
$price = (float) $result['price'];
} else {
$price = (float) $specific_price['price'];
}
if (!$specific_price || !($specific_price['price'] >= 0 && $specific_price['id_currency'])) {
$price = Tools::convertPrice($price, $id_currency);
if (isset($specific_price['price']) && $specific_price['price'] >= 0) {
$specific_price['price'] = $price;
}
}
if (is_array($result) && (!$specific_price || !$specific_price['id_product_attribute'] || $specific_price['price'] < 0)) {
$attribute_price = Tools::convertPrice($result['attribute_price'] !== null ? (float) $result['attribute_price'] : 0, $id_currency);
if ($id_product_attribute !== false) {
$price += $attribute_price;
}
}
$original_price_before_mod = $price; // We keep the original price to detect the effects with the customization price
$sql = '
SELECT `index`
FROM `' . _DB_PREFIX_ . 'customized_data`
WHERE `id_customization` = ' . (int) $id_customization;
$check_multiple_customization = array();
$check_multiple_customization = Db::getInstance()->executeS($sql);
if (sizeof($check_multiple_customization) > 1) {
foreach ($check_multiple_customization as $index) {
$product_customization_index = $index['index'];
if ((int) $id_customization) {
if ($product_customization_index == Configuration::get('WD_CUSTOMIZATION_INDEX')) {
if ($quantity == 1) {
$price = Tools::convertPrice(Customization::getCustomizationPrice($id_customization), $id_currency);
}
} else {
$price += Tools::convertPrice(Customization::getCustomizationPrice($id_customization), $id_currency);
}
}
}
} else {
$product_customization_index = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
if ((int) $id_customization) {
if ($product_customization_index == Configuration::get('WD_CUSTOMIZATION_INDEX')) {
if ($quantity == 1) {
$price = Tools::convertPrice(Customization::getCustomizationPrice($id_customization), $id_currency);
}
} else {
$price += Tools::convertPrice(Customization::getCustomizationPrice($id_customization), $id_currency);
}
}
}
$address->id_country = $id_country;
$address->id_state = $id_state;
$address->postcode = $zipcode;
$tax_manager = TaxManagerFactory::getManager($address, Product::getIdTaxRulesGroupByIdProduct((int) $id_product, $context));
$product_tax_calculator = $tax_manager->getTaxCalculator();
if ((int) $id_customer > 0) {
$customer = new Customer((int) $id_customer);
if (!Validate::isLoadedObject($customer)) {
die(Tools::displayError());
}
$id_group_found = $customer->id_default_group;
} else {
$id_group_found = $id_group;
}
$sql = '
SELECT `price_display_method`
FROM `' . _DB_PREFIX_ . 'group`
WHERE `id_group` = ' . (int) $id_group_found;
$display_method = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
if (($id_customization) && ($quantity == 1) && ($display_method == 0)) {
if ($product_customization_index == Configuration::get('WD_CUSTOMIZATION_INDEX')) {
$price = $product_tax_calculator->removeTaxes($price);
}
}
if ($use_tax) {
if ($product_customization_index == Configuration::get('WD_CUSTOMIZATION_INDEX')) {
$price = $product_tax_calculator->addTaxes($price);
$original_price_before_mod = $product_tax_calculator->addTaxes($original_price_before_mod);
} else {
$price = $product_tax_calculator->addTaxes($price);
}
}
if (($result['ecotax'] || isset($result['attribute_ecotax'])) && $with_ecotax) {
$ecotax = $result['ecotax'];
if (isset($result['attribute_ecotax']) && $result['attribute_ecotax'] > 0) {
$ecotax = $result['attribute_ecotax'];
}
if ($id_currency) {
$ecotax = Tools::convertPrice($ecotax, $id_currency);
}
if ($use_tax) {
static $psEcotaxTaxRulesGroupId = null;
if ($psEcotaxTaxRulesGroupId === null) {
$psEcotaxTaxRulesGroupId = (int) Configuration::get('PS_ECOTAX_TAX_RULES_GROUP_ID');
}
$tax_manager = TaxManagerFactory::getManager(
$address,
$psEcotaxTaxRulesGroupId
);
$ecotax_tax_calculator = $tax_manager->getTaxCalculator();
$price += $ecotax_tax_calculator->addTaxes($ecotax);
if ($product_customization_index == Configuration::get('WD_CUSTOMIZATION_INDEX')) {
$original_price_before_mod += $ecotax_tax_calculator->addTaxes($ecotax);
}
} else {
if ($product_customization_index == Configuration::get('WD_CUSTOMIZATION_INDEX')) {
$original_price_before_mod += $ecotax;
}
$price += $ecotax;
}
}
$specific_price_reduction = 0;
if (($only_reduc || $use_reduc) && $specific_price) {
if ($specific_price['reduction_type'] == 'amount') {
$reduction_amount = $specific_price['reduction'];
if (!$specific_price['id_currency']) {
$reduction_amount = Tools::convertPrice($reduction_amount, $id_currency);
}
$specific_price_reduction = $reduction_amount;
if (!$use_tax && $specific_price['reduction_tax']) {
$specific_price_reduction = $product_tax_calculator->removeTaxes($specific_price_reduction);
}
if ($use_tax && !$specific_price['reduction_tax']) {
$specific_price_reduction = $product_tax_calculator->addTaxes($specific_price_reduction);
}
} else {
if ($product_customization_index == Configuration::get('WD_CUSTOMIZATION_INDEX')) {
if ($original_price_before_mod == $price) {
$specific_price_reduction = $price * $specific_price['reduction'];
}
} else {
$specific_price_reduction = $price * $specific_price['reduction'];
}
}
}
if ($use_reduc) {
if ($product_customization_index == Configuration::get('WD_CUSTOMIZATION_INDEX')) {
if ($original_price_before_mod == $price) {
$price -= $specific_price_reduction;
$original_price_before_mod = $price;
}
} else {
$price -= $specific_price_reduction;
}
}
if ((int) $id_customization) {
if ($product_customization_index == Configuration::get('WD_CUSTOMIZATION_INDEX')) {
if ($quantity == 1) {
if (!$use_reduc) {
$specific_price_reduction = 0;
if (($only_reduc || $use_reduc) && $specific_price) {
if ($specific_price['reduction_type'] == 'amount') {
$reduction_amount = $specific_price['reduction'];
if (!$specific_price['id_currency']) {
$reduction_amount = Tools::convertPrice($reduction_amount, $id_currency);
}
$specific_price_reduction = $reduction_amount;
if (!$use_tax && $specific_price['reduction_tax']) {
$specific_price_reduction = $product_tax_calculator->removeTaxes($specific_price_reduction);
}
if ($use_tax && !$specific_price['reduction_tax']) {
$specific_price_reduction = $product_tax_calculator->addTaxes($specific_price_reduction);
}
} else {
$specific_price_reduction = $price * $specific_price['reduction'];
}
$price += $specific_price_reduction;
}
}
}
}
}
if ($use_group_reduction) {
$reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group);
if ($reduction_from_category !== false) {
$group_reduction = $price * (float) $reduction_from_category;
} else { // apply group reduction if there is no group reduction for this category
$group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0;
}
if ($product_customization_index == Configuration::get('WD_CUSTOMIZATION_INDEX')) {
if ($original_price_before_mod == $price) {
$price -= $group_reduction;
$original_price_before_mod = $price;
}
} else {
$price -= $group_reduction;
}
}
if ($only_reduc) {
return Tools::ps_round($specific_price_reduction, $decimals);
}
$price = Tools::ps_round($price, $decimals);
if ($price < 0) {
$price = 0;
}
self::$_prices[$cache_id] = $price;
return self::$_prices[$cache_id];
}
/*
* module: squaremeter
* date: 2021-11-19 11:36:06
* version: 5.5.0
*/
public static function addProductCustomizationPrice(&$product, &$customized_datas)
{
parent::addProductCustomizationPrice($product, $customized_datas);
if ($product['total'] == 0) {
$product['total'] = $product['total_price_tax_excl'];
$product['total_wt'] = $product['total_price_tax_incl'];
}
}
}

View File

@@ -0,0 +1,35 @@
<?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)
*/
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
/**
* 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)
*/
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;

35
override/classes/cache/index.php vendored Normal file
View File

@@ -0,0 +1,35 @@
<?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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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,41 @@
<?php
/**
* 2007-2021 ETS-Soft
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* 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 contact us for extra customization service at an affordable price
*
* @author ETS-Soft <etssoft.jsc@gmail.com>
* @copyright 2007-2021 ETS-Soft
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of ETS-Soft
*/
class FrontController extends FrontControllerCore
{
/*
* module: ets_cfultimate
* date: 2021-06-28 11:05:17
* version: 1.1.1
*/
public function smartyOutputContent($content)
{
if (version_compare(_PS_VERSION_, '1.7.0', '<')) {
ob_start();
parent::smartyOutputContent($content);
$html = ob_get_contents();
ob_clean();
Hook::exec('actionOutputHTMLBefore', array('html' => &$html));
echo $html;
} else
return parent::smartyOutputContent($content);
}
}

View File

@@ -0,0 +1,35 @@
<?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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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,688 @@
<?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)
*/
use PrestaShop\PrestaShop\Adapter\MailTemplate\MailPartialTemplateRenderer;
use PrestaShop\PrestaShop\Adapter\StockManager as StockManagerAdapter;
use PrestaShop\PrestaShop\Core\Stock\StockManager;
class OrderHistoryCore extends ObjectModel
{
/** @var int Order id */
public $id_order;
/** @var int Order status id */
public $id_order_state;
/** @var int Employee id for this history entry */
public $id_employee;
/** @var string Object creation date */
public $date_add;
/** @var string Object last modification date */
public $date_upd;
/**
* @see ObjectModel::$definition
*/
public static $definition = [
'table' => 'order_history',
'primary' => 'id_order_history',
'fields' => [
'id_order' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_order_state' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_employee' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
],
];
/**
* @see ObjectModel::$webserviceParameters
*/
protected $webserviceParameters = [
'objectsNodeName' => 'order_histories',
'fields' => [
'id_employee' => ['xlink_resource' => 'employees'],
'id_order_state' => ['required' => true, 'xlink_resource' => 'order_states'],
'id_order' => ['xlink_resource' => 'orders'],
],
'objectMethods' => [
'add' => 'addWs',
],
];
/**
* 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();
$old_os_id = $old_os->id;
$new_os_id = $new_os->id;
//file_put_contents( _PS_IMG_DIR_.'wycinek/kupione/'.'tt.txt' , $old_os->id." ".$new_os->id);
if ( ($old_os_id == 1 || $old_os_id == 10 || $old_os_id == 14 || $old_os_id == 15) && ($new_os_id == 2 || $new_os_id == 3 || $new_os_id == 4) ){
$id_cart = $order->id_cart;
$order_reference = $order->reference;
$cur_cart = new Cart((int) $id_cart);
$productList = $cur_cart->getProducts();
$counter_start = 0;
foreach ($productList as $product) {
for ($x = $counter_start; $x <= 25; $x++) {
$id_product = $product['id_product'];
$txt_name2 = $id_cart."_".$id_product."_".$x.".txt";
$txt_dir2 = _PS_IMG_DIR_.'wycinek/'.$txt_name2;
$quantity = $product['cart_quantity'];
if (file_exists($txt_dir2)){
$txt_content2 = file_get_contents($txt_dir2);
$txt_content2 .= "QUANTITY:".$quantity."\n";
$txt_content2 .= "ORDER_REFERENCE:".$order_reference."\n";
file_put_contents($txt_dir2,$txt_content2);
$source_img_dir = _PS_IMG_DIR_.'wycinek/'.$id_cart."_".$id_product."_".$x.".jpg";
$copy_img_dir = _PS_IMG_DIR_.'wycinek/kupione/'.$order_reference."_".$id_product."_".$x.".jpg";
$source_txt_dir = _PS_IMG_DIR_.'wycinek/'.$id_cart."_".$id_product."_".$x.".txt";
$copy_txt_dir = _PS_IMG_DIR_.'wycinek/kupione/'.$order_reference."_".$id_product."_".$x.".txt";
$source_img_content = file_get_contents($source_img_dir);
file_put_contents($copy_img_dir,$source_img_content);
$source_txt_content = file_get_contents($source_txt_dir);
file_put_contents($copy_txt_dir,$source_txt_content);
break;
}
}
$counter_start++;
}
}
// executes hook
if (in_array($new_os->id, [Configuration::get('PS_OS_PAYMENT'), Configuration::get('PS_OS_WS_PAYMENT')])) {
Hook::exec('actionPaymentConfirmation', ['id_order' => (int) $order->id], null, false, true, false, $order->id_shop);
}
// executes hook
Hook::exec('actionOrderStatusUpdate', ['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();
// An email is sent the first time a virtual item is validated
$virtual_products = $order->getVirtualProducts();
if ($virtual_products && (!$old_os || !$old_os->logable) && $new_os && $new_os->logable) {
$assign = [];
foreach ($virtual_products as $key => $virtual_product) {
$id_product_download = ProductDownload::getIdFromIdProduct($virtual_product['product_id']);
$product_download = new ProductDownload($id_product_download);
// If this virtual item has an associated file, we'll provide the link to download the file in the email
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 = [];
foreach ($assign as $product) {
$complementaryText = [];
if (isset($product['deadline'])) {
$complementaryText[] = $this->trans('expires on %s.', [$product['deadline']], 'Admin.Orderscustomers.Notification');
}
if (isset($product['downloadable'])) {
$complementaryText[] = $this->trans('downloadable %d time(s)', [(int) $product['downloadable']], 'Admin.Orderscustomers.Notification');
}
$links[] = [
'text' => Tools::htmlentitiesUTF8($product['name']),
'url' => $product['link'],
'complementary_text' => implode(' ', $complementaryText),
];
}
$context = Context::getContext();
$partialRenderer = new MailPartialTemplateRenderer($context->smarty);
$links_txt = $partialRenderer->render('download_product_virtual_products.txt', $context->language, $links, true);
$links_html = $partialRenderer->render('download_product_virtual_products.tpl', $context->language, $links);
$data = [
'{lastname}' => $customer->lastname,
'{firstname}' => $customer->firstname,
'{id_order}' => (int) $order->id,
'{order_name}' => $order->getUniqReference(),
'{nbProducts}' => count($virtual_products),
'{virtualProducts}' => $links_html,
'{virtualProductsTxt}' => $links_txt,
];
// If there is at least one downloadable file
if (!empty($assign)) {
$orderLanguage = new Language((int) $order->id_lang);
Mail::Send(
(int) $order->id_lang,
'download_product',
Context::getContext()->getTranslator()->trans(
'The virtual product that you bought is available for download',
[],
'Emails.Subject',
$orderLanguage->locale
),
$data,
$customer->email,
$customer->firstname . ' ' . $customer->lastname,
null,
null,
null,
null,
_PS_MAIL_DIR_,
false,
(int) $order->id_shop
);
}
}
/** @since 1.5.0 : gets the stock manager */
$manager = null;
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$manager = StockManagerFactory::getManager();
}
$error_or_canceled_statuses = [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) {
// First OrderHistory, there is no $old_os, so $employee is null before here
$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 products of the order
foreach ($order->getProductsDetail() as $product) {
if (Validate::isLoadedObject($old_os)) {
// if becoming logable => adds sale
if ($new_os->logable && !$old_os->logable) {
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
// @since 1.5.0 - Stock Management
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']);
// @since 1.5.0 - Stock Management
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);
}
}
// From here, there is 2 cases : $old_os exists, and we can test shipped state evolution,
// Or old_os does not exists, and we should consider that initial shipped state is 0 (to allow decrease of stocks)
// @since 1.5.0 : if the order is being shipped and this products uses the advanced stock management :
// decrements the physical stock using $id_warehouse
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) {
// gets the warehouse
$warehouse = new Warehouse($product['id_warehouse']);
// decrements the stock (if it's a pack, the StockManager does what is needed)
$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 the product is a pack, we restock every products in the pack using the last negative stock mvts
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
);
}
}
}
// Save movement if :
// not Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')
// new_os->shipped != old_os->shipped
if (Validate::isLoadedObject($old_os) && Validate::isLoadedObject($new_os) && $new_os->shipped != $old_os->shipped && !Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$product_quantity = (int) ($product['product_quantity'] - $product['product_quantity_refunded'] - $product['product_quantity_return']);
if ($product_quantity > 0) {
$current_shop_context_type = Context::getContext()->shop->getContextType();
if ($current_shop_context_type !== Shop::CONTEXT_SHOP) {
//change to order shop context
$current_shop_group_id = Context::getContext()->shop->getContextShopGroupID();
Context::getContext()->shop->setContext(Shop::CONTEXT_SHOP, $order->id_shop);
}
(new StockManager())->saveMovement(
(int) $product['product_id'],
(int) $product['product_attribute_id'],
(int) $product_quantity * ($new_os->shipped == 1 ? -1 : 1),
[
'id_order' => $order->id,
'id_stock_mvt_reason' => ($new_os->shipped == 1 ? Configuration::get('PS_STOCK_CUSTOMER_ORDER_REASON') : Configuration::get('PS_STOCK_CUSTOMER_ORDER_CANCEL_REASON')),
]
);
//back to current shop context
if ($current_shop_context_type !== Shop::CONTEXT_SHOP) {
Context::getContext()->shop->setContext($current_shop_context_type, $current_shop_group_id);
}
}
}
}
}
$this->id_order_state = (int) $new_order_state;
// changes invoice number of order ?
if (!Validate::isLoadedObject($new_os) || !Validate::isLoadedObject($order)) {
die(Tools::displayError($this->trans('Invalid new order status', [], 'Admin.Orderscustomers.Notification')));
}
// the order is valid if and only if the invoice is available and the order is not cancelled
$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();
}
// set orders as paid
if ($new_os->paid == 1) {
$invoices = $order->getInvoicesCollection();
if ($order->total_paid != 0) {
$payment_method = Module::getInstanceByName($order->module);
}
foreach ($invoices as $invoice) {
/** @var OrderInvoice $invoice */
$rest_paid = $invoice->getRestPaid();
if ($rest_paid > 0) {
$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;
}
// Update total_paid_real value for backward compatibility reasons
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), Context::getContext()->getComputingPrecision());
}
$order->save();
$payment->conversion_rate = ($order ? $order->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 . ')');
}
}
}
// updates delivery date even if it was already set by another state change
if ($new_os->delivery) {
$order->setDelivery();
}
// executes hook
Hook::exec('actionOrderStatusPostUpdate', ['newOrderStatus' => $new_os, 'id_order' => (int) $order->id], null, false, true, false, $order->id_shop);
// sync all stock
(new StockManagerAdapter())->updatePhysicalProductQuantity(
(int) $order->id_shop,
(int) Configuration::get('PS_OS_ERROR'),
(int) Configuration::get('PS_OS_CANCELED'),
null,
(int) $order->id
);
ShopUrl::resetMainDomainCache();
}
/**
* Returns the last order status.
*
* @param int $id_order
*
* @return OrderState|bool
*
* @deprecated 1.5.0.4
* @see Order->current_state
*/
public static function getLastOrderState($id_order)
{
Tools::displayAsDeprecated();
$id_order_state = Db::getInstance()->getValue('
SELECT `id_order_state`
FROM `' . _DB_PREFIX_ . 'order_history`
WHERE `id_order` = ' . (int) $id_order . '
ORDER BY `date_add` DESC, `id_order_history` DESC');
// returns false if there is no state
if (!$id_order_state) {
return false;
}
// else, returns an OrderState object
return new OrderState($id_order_state, Configuration::get('PS_LANG_DEFAULT'));
}
/**
* @param bool $autodate Optional
* @param array $template_vars Optional
* @param Context $context Deprecated
*
* @return bool
*/
public function addWithemail($autodate = true, $template_vars = false, Context $context = null)
{
$order = new Order($this->id_order);
if (!$this->add($autodate)) {
return false;
}
Order::cleanHistoryCache();
if (!$this->sendEmail($order, $template_vars)) {
return false;
}
return true;
}
public function sendEmail($order, $template_vars = false)
{
$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'])) {
ShopUrl::cacheMainDomainForShop($order->id_shop);
$topic = $result['osname'];
$carrierUrl = '';
if (Validate::isLoadedObject($carrier = new Carrier((int) $order->id_carrier, $order->id_lang))) {
$carrierUrl = $carrier->url;
}
$data = [
'{lastname}' => $result['lastname'],
'{firstname}' => $result['firstname'],
'{id_order}' => (int) $this->id_order,
'{order_name}' => $order->getUniqReference(),
'{followup}' => str_replace('@', $order->getWsShippingNumber(), $carrierUrl),
'{shipping_number}' => $order->getWsShippingNumber(),
];
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);
}
}
if (is_array($template_vars)) {
$data = array_merge($data, $template_vars);
}
$context = Context::getContext();
$data['{total_paid}'] = Tools::getContextLocale($context)->formatPrice((float) $order->total_paid, Currency::getIsoCodeById((int) $order->id_currency));
if (Validate::isLoadedObject($order)) {
// Attach invoice and / or delivery-slip if they exists and status is set to attach them
if (($result['pdf_invoice'] || $result['pdf_delivery'])) {
$invoice = $order->getInvoicesCollection();
$file_attachement = [];
if ($result['pdf_invoice'] && (int) Configuration::get('PS_INVOICE') && $order->invoice_number) {
Hook::exec('actionPDFInvoiceRender', ['order_invoice_list' => $invoice]);
$pdf = new PDF($invoice, PDF::TEMPLATE_INVOICE, $context->smarty);
$file_attachement['invoice']['content'] = $pdf->render(false);
$file_attachement['invoice']['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['invoice']['mime'] = 'application/pdf';
}
if ($result['pdf_delivery'] && $order->delivery_number) {
$pdf = new PDF($invoice, PDF::TEMPLATE_DELIVERY_SLIP, $context->smarty);
$file_attachement['delivery']['content'] = $pdf->render(false);
$file_attachement['delivery']['name'] = Configuration::get('PS_DELIVERY_PREFIX', Context::getContext()->language->id, null, $order->id_shop) . sprintf('%06d', $order->delivery_number) . '.pdf';
$file_attachement['delivery']['mime'] = 'application/pdf';
}
} else {
$file_attachement = null;
}
if (!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
)) {
return false;
}
}
ShopUrl::resetMainDomainCache();
}
return true;
}
public function add($autodate = true, $null_values = false)
{
if (!parent::add($autodate)) {
return false;
}
$order = new Order((int) $this->id_order);
// Update id_order_state attribute in Order
$order->current_state = $this->id_order_state;
$order->update();
Hook::exec('actionOrderHistoryAddAfter', ['order_history' => $this], null, false, true, false, $order->id_shop);
return true;
}
/**
* @return int
*/
public function isValidated()
{
return Db::getInstance()->getValue('
SELECT COUNT(oh.`id_order_history`) AS nb
FROM `' . _DB_PREFIX_ . 'order_state` os
LEFT JOIN `' . _DB_PREFIX_ . 'order_history` oh ON (os.`id_order_state` = oh.`id_order_state`)
WHERE oh.`id_order` = ' . (int) $this->id_order . '
AND os.`logable` = 1');
}
/**
* Add method for webservice create resource Order History
* If sendemail=1 GET parameter is present sends email to customer otherwise does not.
*
* @return bool
*/
public function addWs()
{
$sendemail = (bool) Tools::getValue('sendemail', false);
$this->changeIdOrderState($this->id_order_state, $this->id_order);
if ($sendemail) {
//Mail::Send requires link object on context and is not set when getting here
$context = Context::getContext();
if ($context->link == null) {
$protocol_link = (Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
$protocol_content = (Tools::usingSecureMode() && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
$context->link = new Link($protocol_link, $protocol_content);
}
return $this->addWithemail();
} else {
return $this->add();
}
}
}

View File

@@ -0,0 +1,35 @@
<?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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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
/**
* 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)
*/
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,933 @@
<?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)
*/
use PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter;
class CartControllerCore extends FrontController
{
public $php_self = 'cart';
protected $id_product;
protected $id_product_attribute;
protected $id_address_delivery;
protected $customization_id;
protected $qty;
/**
* To specify if you are in the preview mode or not.
*
* @var bool
*/
protected $preview;
public $ssl = true;
/**
* An array of errors, in case the update action of product is wrong.
*
* @var string[]
*/
protected $updateOperationError = [];
/**
* This is not a public page, so the canonical redirection is disabled.
*
* @param string $canonicalURL
*/
public function canonicalRedirection($canonicalURL = '')
{
}
/**
* Initialize cart controller.
*
* @see FrontController::init()
*/
public function init()
{
parent::init();
// Send noindex to avoid ghost carts by bots
header('X-Robots-Tag: noindex, nofollow', true);
// Get page main parameters
$this->id_product = (int) Tools::getValue('id_product', null);
$this->id_product_attribute = (int) Tools::getValue('id_product_attribute', Tools::getValue('ipa'));
$this->customization_id = (int) Tools::getValue('id_customization');
$this->qty = abs(Tools::getValue('qty', 1));
$this->id_address_delivery = (int) Tools::getValue('id_address_delivery');
$this->preview = ('1' === Tools::getValue('preview'));
/* Check if the products in the cart are available */
if ('show' === Tools::getValue('action')) {
$isAvailable = $this->areProductsAvailable();
if (Tools::getIsset('checkout')) {
return Tools::redirect($this->context->link->getPageLink('order'));
}
if (true !== $isAvailable) {
$this->errors[] = $isAvailable;
}
}
}
/**
* @see FrontController::initContent()
*/
public function initContent()
{
if (Configuration::isCatalogMode() && Tools::getValue('action') === 'show') {
Tools::redirect('index.php');
}
/*
* Check that minimal quantity conditions are respected for each product in the cart
* (this is to be applied only on page load, not for ajax calls)
*/
if (!Tools::getValue('ajax')) {
$this->checkCartProductsMinimalQuantities();
}
$presenter = new CartPresenter();
$presented_cart = $presenter->present($this->context->cart, $shouldSeparateGifts = true);
$this->context->smarty->assign([
'cart' => $presented_cart,
'static_token' => Tools::getToken(false),
]);
if (count($presented_cart['products']) > 0) {
$this->setTemplate('checkout/cart');
} else {
$this->context->smarty->assign([
'allProductsLink' => $this->context->link->getCategoryLink(Configuration::get('PS_HOME_CATEGORY')),
]);
$this->setTemplate('checkout/cart-empty');
}
parent::initContent();
}
public function displayAjaxUpdate()
{
if (Configuration::isCatalogMode()) {
return;
}
$productsInCart = $this->context->cart->getProducts();
$updatedProducts = array_filter($productsInCart, [$this, 'productInCartMatchesCriteria']);
$updatedProduct = reset($updatedProducts);
$productQuantity = $updatedProduct['quantity'];
if (!$this->errors) {
$cartPresenter = new CartPresenter();
$presentedCart = $cartPresenter->present($this->context->cart);
// filter product output
$presentedCart['products'] = $this->get('prestashop.core.filter.front_end_object.product_collection')
->filter($presentedCart['products']);
$this->ajaxRender(Tools::jsonEncode([
'success' => true,
'id_product' => $this->id_product,
'id_product_attribute' => $this->id_product_attribute,
'id_customization' => $this->customization_id,
'quantity' => $productQuantity,
'cart' => $presentedCart,
'errors' => empty($this->updateOperationError) ? '' : reset($this->updateOperationError),
]));
return;
} else {
$this->ajaxRender(Tools::jsonEncode([
'hasError' => true,
'errors' => $this->errors,
'quantity' => $productQuantity,
]));
return;
}
}
public function displayAjaxRefresh()
{
if (Configuration::isCatalogMode()) {
return;
}
ob_end_clean();
header('Content-Type: application/json');
$this->ajaxRender(Tools::jsonEncode([
'cart_detailed' => $this->render('checkout/_partials/cart-detailed'),
'cart_detailed_totals' => $this->render('checkout/_partials/cart-detailed-totals'),
'cart_summary_items_subtotal' => $this->render('checkout/_partials/cart-summary-items-subtotal'),
'cart_summary_subtotals_container' => $this->render('checkout/_partials/cart-summary-subtotals'),
'cart_summary_totals' => $this->render('checkout/_partials/cart-summary-totals'),
'cart_detailed_actions' => $this->render('checkout/_partials/cart-detailed-actions'),
'cart_voucher' => $this->render('checkout/_partials/cart-voucher'),
]));
}
/**
* @deprecated 1.7.3.1 the product link is now accessible
* in #quantity_wanted[data-url-update]
*/
public function displayAjaxProductRefresh()
{
if ($this->id_product) {
$idProductAttribute = 0;
$groups = Tools::getValue('group');
if (!empty($groups)) {
$idProductAttribute = (int) Product::getIdProductAttributeByIdAttributes(
$this->id_product,
$groups,
true
);
}
$url = $this->context->link->getProductLink(
$this->id_product,
null,
null,
null,
$this->context->language->id,
null,
$idProductAttribute,
false,
false,
true,
[
'quantity_wanted' => (int) $this->qty,
'preview' => $this->preview,
]
);
} else {
$url = false;
}
ob_end_clean();
header('Content-Type: application/json');
$this->ajaxRender(Tools::jsonEncode([
'success' => true,
'productUrl' => $url,
]));
}
public function postProcess()
{
$this->updateCart();
}
protected function updateCart()
{
// Update the cart ONLY if $this->cookies are available, in order to avoid ghost carts created by bots
if ($this->context->cookie->exists()
&& !$this->errors
&& !($this->context->customer->isLogged() && !$this->isTokenValid())
) {
if (Tools::getIsset('add') || Tools::getIsset('update')) {
$this->processChangeProductInCart();
} elseif (Tools::getIsset('delete')) {
$this->processDeleteProductInCart();
} elseif (CartRule::isFeatureActive()) {
if (Tools::getIsset('addDiscount')) {
if (!($code = trim(Tools::getValue('discount_name')))) {
$this->errors[] = $this->trans(
'You must enter a voucher code.',
[],
'Shop.Notifications.Error'
);
} elseif (!Validate::isCleanHtml($code)) {
$this->errors[] = $this->trans(
'The voucher code is invalid.',
[],
'Shop.Notifications.Error'
);
} else {
if (($cartRule = new CartRule(CartRule::getIdByCode($code)))
&& Validate::isLoadedObject($cartRule)
) {
if ($error = $cartRule->checkValidity($this->context, false, true)) {
$this->errors[] = $error;
} else {
$this->context->cart->addCartRule($cartRule->id);
}
} else {
$this->errors[] = $this->trans(
'This voucher does not exist.',
[],
'Shop.Notifications.Error'
);
}
}
} elseif (($id_cart_rule = (int) Tools::getValue('deleteDiscount'))
&& Validate::isUnsignedId($id_cart_rule)
) {
$this->context->cart->removeCartRule($id_cart_rule);
CartRule::autoAddToCart($this->context);
}
}
} elseif (!$this->isTokenValid() && Tools::getValue('action') !== 'show' && !Tools::getValue('ajax')) {
Tools::redirect('index.php');
}
}
/**
* This process delete a product from the cart.
*/
protected function processDeleteProductInCart()
{
$customization_product = Db::getInstance()->executeS(
'SELECT * FROM `' . _DB_PREFIX_ . 'customization`'
. ' WHERE `id_cart` = ' . (int) $this->context->cart->id
. ' AND `id_product` = ' . (int) $this->id_product
. ' AND `id_customization` != ' . (int) $this->customization_id
. ' AND `in_cart` = 1'
. ' AND `quantity` > 0'
);
if (count($customization_product)) {
$product = new Product((int) $this->id_product);
if ($this->id_product_attribute > 0) {
$minimal_quantity = (int) Attribute::getAttributeMinimalQty($this->id_product_attribute);
} else {
$minimal_quantity = (int) $product->minimal_quantity;
}
$total_quantity = 0;
foreach ($customization_product as $custom) {
$total_quantity += $custom['quantity'];
}
if ($total_quantity < $minimal_quantity) {
$this->errors[] = $this->trans(
'You must add %quantity% minimum quantity',
['%quantity%' => $minimal_quantity],
'Shop.Notifications.Error'
);
return false;
}
}
$data = [
'id_cart' => (int) $this->context->cart->id,
'id_product' => (int) $this->id_product,
'id_product_attribute' => (int) $this->id_product_attribute,
'customization_id' => (int) $this->customization_id,
'id_address_delivery' => (int) $this->id_address_delivery,
];
Hook::exec('actionObjectProductInCartDeleteBefore', $data, null, true);
if ($this->context->cart->deleteProduct(
$this->id_product,
$this->id_product_attribute,
$this->customization_id,
$this->id_address_delivery
)) {
Hook::exec('actionObjectProductInCartDeleteAfter', $data);
if (!Cart::getNbProducts((int) $this->context->cart->id)) {
$this->context->cart->setDeliveryOption(null);
$this->context->cart->gift = 0;
$this->context->cart->gift_message = '';
$this->context->cart->update();
}
$isAvailable = $this->areProductsAvailable();
if (true !== $isAvailable) {
$this->updateOperationError[] = $isAvailable;
}
}
CartRule::autoRemoveFromCart();
CartRule::autoAddToCart();
}
/**
* This process add or update a product in the cart.
*/
protected function processChangeProductInCart()
{
/* MEG Venture */
$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();
}
}
/* MEG Venture */
$mode = (Tools::getIsset('update') && $this->id_product) ? 'update' : 'add';
$ErrorKey = ('update' === $mode) ? 'updateOperationError' : 'errors';
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'
);
}
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;
}
}
$cur_cart = $this->context->cart;
$id_product = $this->id_product;
$fixed_price = $_POST['fixed_price'];
$productList = $cur_cart->getProducts();
$next_product_number = count($productList);
/*
if (isset($_POST['fixed_price'])){
$remove_old_specific_price = Db::getInstance()->executeS(
'DELETE FROM `' . _DB_PREFIX_ . 'specific_price`'
. ' WHERE (`id_cart` = ' . (int) $cur_cart->id . ' OR `id_cart` = 0)'
. ' AND `id_product` = ' . (int) $id_product
);
}
if (isset($_POST['fixed_price'])){
$specific_price_rule = new SpecificPriceRule();
$specific_price_rule->name = 'Indywidualna cena wycinka';
$specific_price_rule->id_shop = (int)$this->context->shop->id;
$specific_price_rule->id_currency = 0;
$specific_price_rule->id_country = 0;
$specific_price_rule->id_group = 0;
$specific_price_rule->from_quantity = 1;
$specific_price_rule->price = $fixed_price;
$specific_price_rule->reduction = 0;
$specific_price_rule->reduction_tax = 0;
$specific_price_rule->reduction_type = 'amount';
$specific_price_rule->from = date("Y-m-d H:i:s");
$specific_price_rule->to = date("Y-m-d").' 23:59:59';
$specific_price_rule->add();
$specific_price = new SpecificPrice();
$specific_price->id_product = (int)$id_product; // choosen product id
$specific_price->id_product_attribute = $id_customization;
$specific_price->id_cart = (int)$cur_cart->id;
$specific_price->id_shop = (int)$this->context->shop->id;
$specific_price->id_currency = 0;
$specific_price->id_country = 0;
$specific_price->id_group = 0;
$specific_price->id_customer = 0;
$specific_price->from_quantity = 1;
$specific_price->price = $fixed_price;
$specific_price->reduction_type = 'amount';
$specific_price->reduction_tax = 1;
$specific_price->reduction = 0;
$specific_price->from = date("Y-m-d").' 00:00:00';
$specific_price->to = date("Y-m-d").' 23:59:59'; // or set date x days from now
$specific_price->id_specific_price_rule = $specific_price_rule->id;
$specific_price->add();
}
*/
$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);
// @todo do something better than a redirect admin !!
if (!$this->id_product_attribute) {
Tools::redirectAdmin($this->context->link->getProductLink($product));
}
}
$combination = new Combination((int) $this->id_product_attribute);
$attributes = $combination->getAttributesName((int) $this->context->language->id);
$id_combination = $attributes[0]["id_attribute"];
$id_lang = $this->context->language->id;
$attributesGroups = Db::getInstance()->ExecuteS('
SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name,
a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, pai.id_image AS combination_image, pa.*
FROM `'._DB_PREFIX_.'product_attribute` pa
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute`
LEFT JOIN `'._DB_PREFIX_.'product_attribute_image` AS pai ON pai.`id_product_attribute` = pa.`id_product_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group`
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON a.`id_attribute` = al.`id_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group`
WHERE pa.`id_product` = '.$id_product.'
AND a.`id_attribute` = '.$id_combination.'
ORDER BY agl.`public_name`, al.`name`');
$combination_image_id = $attributesGroups[0]["combination_image"];
$result2 = new Image($combination_image_id);
$url = _PS_BASE_URL_._THEME_PROD_DIR_.$result2->getExistingImgPath().".jpg";
/*
$id_attributes = Db::getInstance()->executeS('SELECT `id_attribute` FROM `' . _DB_PREFIX_ . 'product_attribute_combination`
WHERE `id_product_attribute` = 9');
*/
if (count($combination_image_id) == 0){
$id_image = Product::getCover($id_product);
if ($id_image > 0)
{
$image = new Image($id_image['id_image']);
$url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().'.jpg';
}
}
if (isset($_POST['fixed_price'])){
$name = $cur_cart->id."_".$id_product."_".$next_product_number.".jpg";
$img = _PS_IMG_DIR_.'wycinek/'.$name;
file_put_contents($img, file_get_contents($url));
}
if ($_POST["is_reflection"] == 1){
$im0 = imagecreatefromjpeg($img);
imageflip($im0, IMG_FLIP_HORIZONTAL);
imagejpeg($im0, $img);
imagedestroy($im0);
}
$img_name = $product->name;
$combination = new Combination($this->id_product_attribute);
$img_name = $combination->reference;
$material_final = $attributes[1]["name"];
if ($_POST["is_crop"] == 1){
$im = imagecreatefromjpeg($img);
$crop_width = $_POST["crop_width"];
$crop_height = $_POST["crop_height"];
$crop_pos_x = $_POST["crop_pos_x"];
$crop_pos_y = $_POST["crop_pos_y"];
$crop_pos_x = intval($crop_pos_x);
$img_width = imagesx($im);
$img_height = imagesy($im);
$real_crop_pos_x = $crop_pos_x * $img_width / 500;
$real_crop_pos_y = $crop_pos_y * $img_height / 300;
$real_crop_width = $crop_width / 500 * $img_width;
$real_crop_height = $crop_height / 300 * $img_height;
$im2 = imagecrop($im, ['x' => $real_crop_pos_x, 'y' => $real_crop_pos_y, 'width' => $real_crop_width, 'height' => $real_crop_height]);
if ($im2 !== FALSE) {
imagejpeg($im2, $img);
imagedestroy($im2);
}
imagedestroy($im);
$txt_content = "";
$txt_content .= "X:".$crop_pos_x."\n";
$txt_content .= "Y:".$crop_pos_y."\n";
$txt_content .= "WIDTH:".$crop_width."\n";
$txt_content .= "HEIGHT:".$crop_height."\n";
$txt_content .= "IMAGE_WIDTH:500"."\n";
$txt_content .= "IMAGE_HEIGHT:300"."\n";
$txt_content .= "CART_ID:".$cur_cart->id."\n";
$txt_content .= "PRODUCT_ID:".$id_product."\n";
$txt_content .= "MATERIAL:".$material_final."\n";
$txt_content .= "IMAGE_NAME:".$img_name."\n";
$txt_content .= "COMBINATION_ID:".$this->id_product_attribute."\n";
$txt_content .= "MIRROR_REFLECTION:".$_POST["is_reflection"]."\n";
$txt_name = $cur_cart->id."_".$id_product."_".$next_product_number.".txt";
$txt_dir = _PS_IMG_DIR_.'wycinek/'.$txt_name;
file_put_contents($txt_dir,$txt_content);
}
$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;
}
}
}
// Check product quantity availability
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'
);
}
/* MEG Venture */
$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;
}
}
}
// // Check minimal_quantity
// 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 (isset($_POST['fixed_price'])){
// $cur_cart->updateQty(-1, $id_product, $id_customization);
// }
/* MEG Venture */
// If no errors, process product addition
if (!$this->errors) {
// Add cart if no cart found
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;
}
}
// Check customizable fields
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) {
// If product has attribute, minimal quantity is set with minimal quantity of attribute
$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)) {
// check quantity after cart quantity update
$this->{$ErrorKey}[] = $this->trans(
'The product is no longer available in this quantity.',
[],
'Shop.Notifications.Error'
);
}
}
}
$removed = CartRule::autoRemoveFromCart();
CartRule::autoAddToCart();
}
/**
* @param $productInCart
*
* @return bool
*/
public function productInCartMatchesCriteria($productInCart)
{
return (
!isset($this->id_product_attribute) ||
(
$productInCart['id_product_attribute'] == $this->id_product_attribute &&
$productInCart['id_customization'] == $this->customization_id
)
) && isset($this->id_product) && $productInCart['id_product'] == $this->id_product;
}
public function getTemplateVarPage()
{
$page = parent::getTemplateVarPage();
$presenter = new CartPresenter();
$presented_cart = $presenter->present($this->context->cart);
if (count($presented_cart['products']) == 0) {
$page['body_classes']['cart-empty'] = true;
}
return $page;
}
/**
* Check product quantity availability to acknowledge whether
* an availability error should be raised.
*
* If shop has been configured to oversell, answer is no.
* If there is no items available (no stock), answer is yes.
* If there is items available, but the Cart already contains more than the quantity,
* answer is yes.
*
* @param Product $product
* @param int $qtyToCheck
*
* @return bool
*/
protected function shouldAvailabilityErrorBeRaised($product, $qtyToCheck)
{
if (($this->id_product_attribute)) {
return !Product::isAvailableWhenOutOfStock($product->out_of_stock)
&& !Attribute::checkAttributeQty($this->id_product_attribute, $qtyToCheck);
} elseif (Product::isAvailableWhenOutOfStock($product->out_of_stock)) {
return false;
}
// Check if this product is out-of-stock
$availableProductQuantity = StockAvailable::getQuantityAvailableByProduct(
$this->id_product,
$this->id_product_attribute
);
if ($availableProductQuantity <= 0) {
return true;
}
// Check if this product is out-of-stock after cart quantities have been removed from stock
// Be aware that Product::getQuantity() returns the available quantity after decreasing products in cart
$productQuantityAvailableAfterCartItemsHaveBeenRemovedFromStock = Product::getQuantity(
$this->id_product,
$this->id_product_attribute,
null,
$this->context->cart,
$this->customization_id
);
return $productQuantityAvailableAfterCartItemsHaveBeenRemovedFromStock < 0;
}
/**
* Check if the products in the cart are available.
*
* @return bool|string
*/
protected function areProductsAvailable()
{
$products = $this->context->cart->getProducts();
foreach ($products as $product) {
$currentProduct = new Product();
$currentProduct->hydrate($product);
if ($currentProduct->hasAttributes() && $product['id_product_attribute'] === '0') {
return $this->trans(
'The item %product% in your cart is now a product with attributes. Please delete it and choose one of its combinations to proceed with your order.',
['%product%' => $product['name']],
'Shop.Notifications.Error'
);
}
}
$product = $this->context->cart->checkQuantities(true);
if (true === $product || !is_array($product)) {
return true;
}
if ($product['active']) {
return $this->trans(
'The item %product% in your cart is no longer available in this quantity. You cannot proceed with your order until the quantity is adjusted.',
['%product%' => $product['name']],
'Shop.Notifications.Error'
);
}
return $this->trans(
'This product (%product%) is no longer available.',
['%product%' => $product['name']],
'Shop.Notifications.Error'
);
}
/**
* Check that minimal quantity conditions are respected for each product in the cart
*/
private function checkCartProductsMinimalQuantities()
{
$productList = $this->context->cart->getProducts();
foreach ($productList as $product) {
if ($product['minimal_quantity'] > $product['cart_quantity']) {
// display minimal quantity warning error message
$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'
);
}
}
}
}

View File

@@ -0,0 +1,210 @@
<?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)
*/
use PrestaShop\PrestaShop\Adapter\Presenter\Order\OrderPresenter;
class OrderConfirmationControllerCore extends FrontController
{
public $ssl = true;
public $php_self = 'order-confirmation';
public $id_cart;
public $id_module;
public $id_order;
public $reference;
public $secure_key;
public $order_presenter;
/**
* Initialize order confirmation controller.
*
* @see FrontController::init()
*/
public function init()
{
FrontController::init();
if (Configuration::get('freeorderconfirmation_oc') == 1) {
$cart = $this->context->cart;
if (true === (bool)Tools::getValue('free_order')) {
$this->checkFreeOrder();
$this->id_cart = (int)$this->context->cart->id;
$this->id_order = Order::getIdByCartId((int)($this->id_cart));
$this->secure_key = Tools::getValue('key', false);
$order = new Order((int)($this->id_order));
$this->reference = $order->reference;
$freeorderconfirmation = Module::getInstanceByName('freeorderconfirmation');
$redirectLink = $freeorderconfirmation::getOrderConfirmationPage($this->id_order);
if ($redirectLink != false) {
Tools::redirect($redirectLink);
}
$this->order_presenter = new OrderPresenter();
} elseif (Tools::getValue('id_order', 'false') != 'false') {
$this->id_order = Tools::getValue('id_order');
$order = new Order($this->id_order);
$this->id_cart = (int)$order->id_cart;
$this->order = $order;
$this->customer = $this->context->customer;
if ($this->context->customer->id == $this->order->id_customer) {
$this->order_presenter = new OrderPresenter();
} else {
parent::init();
}
} else {
parent::init();
}
} else {
parent::init();
}
}
/**
* Assign template vars related to page content.
*
* @see FrontController::initContent()
*/
public function initContent()
{
if (Configuration::isCatalogMode()) {
Tools::redirect('index.php');
}
$order = new Order(Order::getIdByCartId((int) ($this->id_cart)));
$presentedOrder = $this->order_presenter->present($order);
$register_form = $this
->makeCustomerForm()
->setGuestAllowed(false)
->fillWith(Tools::getAllValues());
parent::initContent();
$this->context->smarty->assign([
'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation($order),
'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn($order),
'order' => $presentedOrder,
'register_form' => $register_form,
]);
if ($this->context->customer->is_guest) {
/* If guest we clear the cookie for security reason */
$this->context->customer->mylogout();
}
$this->setTemplate('checkout/order-confirmation');
}
/**
* Execute the hook displayPaymentReturn.
*/
public function displayPaymentReturn($order)
{
if (!Validate::isUnsignedId($this->id_module)) {
return false;
}
return Hook::exec('displayPaymentReturn', ['order' => $order], $this->id_module);
}
/**
* Execute the hook displayOrderConfirmation.
*/
public function displayOrderConfirmation($order)
{
/*
$id_cart = $this->id_cart;
$order_object = new Order($this->id_order);
$order_reference = $order_object->reference;
$cur_cart = new Cart((int) $id_cart);
$productList = $cur_cart->getProducts();
foreach ($productList as $product) {
$id_product = $product['id_product'];
$txt_name2 = $id_cart."_".$id_product.".txt";
$txt_dir2 = _PS_IMG_DIR_.'wycinek/'.$txt_name2;
$quantity = $product['cart_quantity'];
if (file_exists($txt_dir2)){
$txt_content2 = file_get_contents($txt_dir2);
$txt_content2 .= "QUANTITY:".$quantity."\n";
$txt_content2 .= "ORDER_REFERENCE:".$order_reference."\n";
file_put_contents($txt_dir2,$txt_content2);
$source_img_dir = _PS_IMG_DIR_.'wycinek/'.$id_cart."_".$id_product.".jpg";
$copy_img_dir = _PS_IMG_DIR_.'wycinek/kupione/'.$id_cart."_".$id_product.".jpg";
$source_txt_dir = _PS_IMG_DIR_.'wycinek/'.$id_cart."_".$id_product.".txt";
$copy_txt_dir = _PS_IMG_DIR_.'wycinek/kupione/'.$id_cart."_".$id_product.".txt";
$source_img_content = file_get_contents($source_img_dir);
file_put_contents($copy_img_dir,$source_img_content);
$source_txt_content = file_get_contents($source_txt_dir);
file_put_contents($copy_txt_dir,$source_txt_content);
}
}
*/
return Hook::exec('displayOrderConfirmation', ['order' => $order]);
}
/**
* Check if an order is free and create it.
*/
protected function checkFreeOrder()
{
$cart = $this->context->cart;
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0) {
Tools::redirect($this->context->link->getPageLink('order'));
}
$customer = new Customer($cart->id_customer);
if (!Validate::isLoadedObject($customer)) {
Tools::redirect($this->context->link->getPageLink('order'));
}
$total = (float) $cart->getOrderTotal(true, Cart::BOTH);
if ($total > 0) {
Tools::redirect($this->context->link->getPageLink('order'));
}
$order = new PaymentFree();
$order->validateOrder(
$cart->id,
Configuration::get('PS_OS_PAYMENT'),
0,
$this->trans('Free order', [], 'Admin.Orderscustomers.Feature'),
null,
[],
null,
false,
$cart->secure_key
);
}
}

View File

@@ -0,0 +1,82 @@
<?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
{
/*
* module: squaremeter
* date: 2021-11-19 11:36:06
* version: 5.5.0
*/
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();
}
}

View File

@@ -0,0 +1,35 @@
<?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)
*/
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
/**
* 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)
*/
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;

35
override/index.php Normal file
View File

@@ -0,0 +1,35 @@
<?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)
*/
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
/**
* 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)
*/
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,66 @@
<?php
/**
* 2007-2021 PrestaShop and Contributors
*
* 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.txt.
* 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.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2021 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class Ps_ShoppingcartAjaxModuleFrontController extends ModuleFrontController
{
/**
* @var bool
*/
public $ssl = true;
/**
* @see FrontController::initContent()
*
* @return void
*/
public function initContent()
{
parent::initContent();
$modal = null;
if ($this->module instanceof Ps_Shoppingcart && Tools::getValue('action') === 'add-to-cart') {
$existing_customization = Db::getInstance()->executeS('
SELECT id_customization FROM `' . pSQL(_DB_PREFIX_) . 'customization`
WHERE id_cart = ' . (int) $this->context->cart->id . '
AND id_product = ' . (int) Tools::getValue("id_product") . '
AND id_product_attribute = ' . (int) Tools::getValue("id_product_attribute") . '
ORDER BY `id_customization` ASC LIMIT 1');
if ((Tools::getValue('id_customization') == 0) && ($existing_customization[0]['id_customization'] > 0)) {
$id_customization = $existing_customization[0]['id_customization'];
} else {
$id_customization = 0;
}
$modal = $this->module->renderModal(
$this->context->cart,
(int) Tools::getValue('id_product'),
(int) Tools::getValue('id_product_attribute'),
(int) $id_customization
);
}
ob_end_clean();
header('Content-Type: application/json');
die(json_encode([
'preview' => $this->module instanceof Ps_Shoppingcart ? $this->module->renderWidget(null, ['cart' => $this->context->cart]) : '',
'modal' => $modal,
]));
}
}

View 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;

View 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;

View 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;