first commit

This commit is contained in:
2024-11-11 18:46:54 +01:00
commit a630d17338
25634 changed files with 4923715 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
<?php
/**
* 2010-2020 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2020 Webkul IN
* @license https://store.webkul.com/license.html
*/
class WkOnePageCheckoutDb
{
public function createTables()
{
if ($sql = $this->getModuleSql()) {
foreach ($sql as $query) {
if ($query) {
if (!Db::getInstance()->execute(trim($query))) {
return false;
}
}
}
}
return true;
}
public function getModuleSql()
{
return array(
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."wk_checkout_save_later` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id_product` int(11) unsigned NOT NULL DEFAULT 0,
`id_product_attribute` int(11) unsigned NOT NULL DEFAULT 0,
`id_cart` int(11) unsigned NOT NULL,
`quantity` int(11) unsigned NOT NULL DEFAULT 0,
`id_customer` int(11) unsigned NOT NULL,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8"
);
}
/**
* Delete module tables
*
* @return bool
*/
public function deleteTables()
{
return Db::getInstance()->execute('
DROP TABLE IF EXISTS
`'._DB_PREFIX_.'wk_checkout_save_later`;
');
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2010-2020 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2020 Webkul IN
* @license https://store.webkul.com/license.html
*/
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,160 @@
<?php
/**
* 2010-2020 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2020 Webkul IN
* @license https://store.webkul.com/license.html
*/
use PrestaShop\PrestaShop\Core\Module\WidgetInterface;
use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever;
use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter;
use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter;
use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever;
class WkOnePageCheckoutHelper extends ObjectModel
{
public static function getModuleIdByName($hook_name)
{
$hook_name = Tools::strtolower($hook_name);
if (!Validate::isHookName($hook_name)) {
return false;
}
return Db::getInstance()->getValue(
'SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = \''.pSQL($hook_name).'\''
);
}
public static function checkCountryRestrictionByIdModule($idModule, $idCountry)
{
return Db::getInstance()->getValue(
'SELECT `id_module` FROM `'._DB_PREFIX_.'module_country`
WHERE `id_module` = '.(int) $idModule.'
AND `id_country` = '.(int) $idCountry
);
}
public static function checkCarrierRestrictionByIdModule($idModule, $idCarrier)
{
return Db::getInstance()->getValue(
'SELECT `id_module` FROM `'._DB_PREFIX_.'module_carrier`
WHERE `id_module` = '.(int) $idModule.'
AND `id_reference` = '.(int) $idCarrier
);
}
public static function getOrderProducts(array $productIds = array())
{
$context = Context::getContext();
$q_orders = 'SELECT o.`id_order` FROM '._DB_PREFIX_.'orders o
LEFT JOIN '._DB_PREFIX_.'order_detail od ON (od.id_order = o.id_order) WHERE o.valid = 1
AND od.product_id IN ('.implode(',', $productIds).')';
$orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($q_orders);
if (0 < count($orders)) {
$list = '';
foreach ($orders as $order) {
$list .= (int)$order['id_order'].',';
}
$list = rtrim($list, ',');
$list_product_ids = join(',', $productIds);
if (Group::isFeatureActive()) {
$sql_groups_join = '
LEFT JOIN `'._DB_PREFIX_.'category_product` cp
ON (cp.`id_category` = product_shop.id_category_default AND cp.id_product = product_shop.id_product)
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cp.`id_category` = cg.`id_category`)';
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups_where = 'AND cg.`id_group` '. (count($groups) ? '
IN ('.implode(',', $groups) . ')' : '=' . (int)Group::getCurrent()->id);
}
$order_products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'SELECT DISTINCT od.product_id
FROM '._DB_PREFIX_.'order_detail od
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
'.Shop::addSqlAssociation('product', 'p').
(
Combination::isFeatureActive() ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
ON (p.`id_product` = pa.`id_product`)
' . Shop::addSqlAssociation(
'product_attribute',
'pa',
false,
'product_attribute_shop.`default_on` = 1'
).'
' . Product::sqlStock(
'p',
'product_attribute_shop',
false,
$context->shop
) : Product::sqlStock(
'p',
'product',
false,
$context->shop
)
).'
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id' .
Shop::addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = product_shop.id_category_default'
.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id)
'.(Group::isFeatureActive() ? $sql_groups_join : '').'
WHERE od.id_order IN (\''.pSQL($list).'\')
AND pl.id_lang = '.(int) $context->language->id.'
AND cl.id_lang = '.(int) $context->language->id.'
AND od.product_id NOT IN (\''.pSQL($list_product_ids).'\')
AND i.cover = 1
AND product_shop.active = 1
'.(Group::isFeatureActive() ? $sql_groups_where : '').'
ORDER BY RAND()
LIMIT '.(int) Configuration::get('WK_CHECKOUT_ALSO_BOUGHT_NUMBER')
);
}
if (!empty($order_products)) {
$assembler = new ProductAssembler($context);
$presenterFactory = new ProductPresenterFactory($context);
$presentationSettings = $presenterFactory->getPresentationSettings();
$presenter = new ProductListingPresenter(
new ImageRetriever(
$context->link
),
$context->link,
new PriceFormatter(),
new ProductColorsRetriever(),
$context->getTranslator()
);
$productsForTemplate = array();
$presentationSettings->showPrices = true;
if (is_array($order_products)) {
foreach ($order_products as $productId) {
$productsForTemplate[] = $presenter->present(
$presentationSettings,
$assembler->assembleProduct(array('id_product' => $productId['product_id'])),
$context->language
);
}
}
return $productsForTemplate;
}
return false;
}
}

View File

@@ -0,0 +1,87 @@
<?php
/**
* 2010-2020 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2020 Webkul IN
* @license https://store.webkul.com/license.html
*/
class WkOnePageCheckOutSaveCart extends ObjectModel
{
public $id_product;
public $id_product_attribute;
public $id_cart;
public $quantity;
public $id_customer;
public $date_add;
public $date_upd;
public static $definition = array(
'table' => 'wk_checkout_save_later',
'primary' => 'id',
'fields' => array(
'id_product' => array('type' => self::TYPE_INT, 'required' => true),
'id_product_attribute' => array('type' => self::TYPE_INT, 'required' => true),
'id_cart' => array('type' => self::TYPE_INT, 'required' => true),
'quantity' => array('type' => self::TYPE_INT, 'required' => true),
'id_customer' => array('type' => self::TYPE_INT,'required' => true),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'required' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'required' => false),
),
);
public static function isExist($idProduct, $idProductAttribute, $idCart)
{
return Db::getInstance()->getValue(
'SELECT `id` FROM `'._DB_PREFIX_.'wk_checkout_save_later` WHERE
`id_product` = '.(int) $idProduct.' AND
`id_product_attribute` = '.(int) $idProductAttribute.' AND
`id_cart` = '.(int) $idCart
);
}
public static function getAllCart($idCustomer)
{
return Db::getInstance()->executeS(
'SELECT * FROM '._DB_PREFIX_.'wk_checkout_save_later WHERE `id_customer` = '.(int) $idCustomer
);
}
public static function removeSavedCart($idCustomer, $idProduct, $idProductAttribute)
{
return Db::getInstance()->delete(
'wk_checkout_save_later',
'id_product = '.(int) $idProduct.' AND
`id_product_attribute` ='.(int) $idProductAttribute.' AND
`id_customer` = '.(int) $idCustomer
);
}
public function deleteSavedCartByIdProduct($idProduct)
{
return Db::getInstance()->delete(
'wk_checkout_save_later',
'id_product = '.(int) $idProduct
);
}
public function deleteSavedCartByIdCustomer($idCustomer)
{
return Db::getInstance()->delete(
'wk_checkout_save_later',
'`id_customer` = '.(int) $idCustomer
);
}
}