Merge branch 'main' of http://91.189.216.43:3000/jacek.pyziak/masimmo.pl
This commit is contained in:
1208
.vscode/ftp-kr.sync.cache.json
vendored
1208
.vscode/ftp-kr.sync.cache.json
vendored
File diff suppressed because it is too large
Load Diff
@@ -447,6 +447,11 @@ class ProductControllerCore extends ProductPresentingFrontControllerCore
|
|||||||
$this->setQuickViewMode();
|
$this->setQuickViewMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$id_product = (int)$product['id_product'];
|
||||||
|
$id_product_attribute = (int)$product['id_product_attribute'];
|
||||||
|
$quantity = StockAvailable::getQuantityAvailableByProduct($id_product, $id_product_attribute);
|
||||||
|
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
$this->ajaxRender(Tools::jsonEncode([
|
$this->ajaxRender(Tools::jsonEncode([
|
||||||
@@ -486,6 +491,12 @@ class ProductControllerCore extends ProductPresentingFrontControllerCore
|
|||||||
$this->getTemplateVarPage()['meta'] ?? []
|
$this->getTemplateVarPage()['meta'] ?? []
|
||||||
),
|
),
|
||||||
'is_quick_view' => $isQuickView,
|
'is_quick_view' => $isQuickView,
|
||||||
|
'product_delivery_time' => $this->render('catalog/_partials/product-delivery-time',
|
||||||
|
[
|
||||||
|
'quantity' => $quantity,
|
||||||
|
'product' => $product,
|
||||||
|
]
|
||||||
|
),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
// https://pacyga.pl/wp-content/uploads/woo-feed/custom/xml/komplet-produktow-3.xml
|
// https://pacyga.pl/wp-content/uploads/woo-feed/custom/xml/komplet-produktow-3.xml
|
||||||
|
|
||||||
// Include PrestaShop configuration
|
// Include PrestaShop configuration
|
||||||
$config['update_price'] = false;
|
|
||||||
include(dirname(__FILE__).'/config/config.inc.php');
|
include(dirname(__FILE__).'/config/config.inc.php');
|
||||||
include(dirname(__FILE__).'/init.php');
|
include(dirname(__FILE__).'/init.php');
|
||||||
|
|
||||||
// Load XML file
|
$context = Context::getContext();
|
||||||
$xml = simplexml_load_file('komplet-produktow-3.xml') or die("Error: Cannot create object");
|
|
||||||
|
// Sprawdzenie trybu działania na podstawie parametrów URL
|
||||||
|
$modeAdd = (Tools::getValue('add') === 'true');
|
||||||
|
$modeUpdate = (Tools::getValue('update') === 'true');
|
||||||
|
|
||||||
|
if (!$modeAdd && !$modeUpdate) {
|
||||||
|
die('Brak akcji. Dodaj do adresu ?add=true lub ?update=true');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Plik logu aktualizacji cen
|
||||||
|
$logFile = __DIR__ . '/update_price_log.csv';
|
||||||
|
|
||||||
|
// Wczytanie XML
|
||||||
|
$xmlUrl = 'https://pacyga.pl/wp-content/uploads/woo-feed/custom/xml/komplet-produktow-3.xml';
|
||||||
|
$xml = simplexml_load_file($xmlUrl) or die("Error: Cannot create object");
|
||||||
|
|
||||||
|
// === FUNKCJE POMOCNICZE ===
|
||||||
|
|
||||||
// Function to find attribute group by name
|
// Function to find attribute group by name
|
||||||
function findAttributeGroupByName($name) {
|
function findAttributeGroupByName($name) {
|
||||||
$id_lang = Context::getContext()->language->id;
|
$id_lang = Context::getContext()->language->id;
|
||||||
$result = Db::getInstance()->getRow('SELECT `id_attribute_group` FROM `'._DB_PREFIX_.'attribute_group_lang` WHERE `name` = \''.pSQL($name).'\' AND `id_lang` = '.(int)$id_lang);
|
$sql = 'SELECT `id_attribute_group`
|
||||||
|
FROM `'._DB_PREFIX_.'attribute_group_lang`
|
||||||
|
WHERE `name` = \''.pSQL($name).'\'
|
||||||
|
AND `id_lang` = '.(int)$id_lang;
|
||||||
|
$result = Db::getInstance()->getRow($sql);
|
||||||
return $result ? new AttributeGroup($result['id_attribute_group']) : false;
|
return $result ? new AttributeGroup($result['id_attribute_group']) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,8 +40,11 @@ function findAttributeByName($id_attribute_group, $name) {
|
|||||||
$id_lang = Context::getContext()->language->id;
|
$id_lang = Context::getContext()->language->id;
|
||||||
$sql = 'SELECT a.`id_attribute`
|
$sql = 'SELECT a.`id_attribute`
|
||||||
FROM `'._DB_PREFIX_.'attribute` a
|
FROM `'._DB_PREFIX_.'attribute` a
|
||||||
JOIN `'._DB_PREFIX_.'attribute_lang` al ON a.`id_attribute` = al.`id_attribute`
|
JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||||
WHERE al.`name` = \''.pSQL($name).'\' AND al.`id_lang` = '.(int)$id_lang.' AND a.`id_attribute_group` = '.(int)$id_attribute_group;
|
ON a.`id_attribute` = al.`id_attribute`
|
||||||
|
WHERE al.`name` = \''.pSQL($name).'\'
|
||||||
|
AND al.`id_lang` = '.(int)$id_lang.'
|
||||||
|
AND a.`id_attribute_group` = '.(int)$id_attribute_group;
|
||||||
$result = Db::getInstance()->getRow($sql);
|
$result = Db::getInstance()->getRow($sql);
|
||||||
return $result ? new Attribute($result['id_attribute']) : false;
|
return $result ? new Attribute($result['id_attribute']) : false;
|
||||||
}
|
}
|
||||||
@@ -55,7 +78,7 @@ function createMultiLangField($field) {
|
|||||||
$languages = Language::getLanguages(false);
|
$languages = Language::getLanguages(false);
|
||||||
$res = [];
|
$res = [];
|
||||||
foreach ($languages as $lang) {
|
foreach ($languages as $lang) {
|
||||||
$res[$lang['id_lang']] = $field;
|
$res[(int)$lang['id_lang']] = $field;
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
@@ -66,16 +89,16 @@ function createLinkRewrite($field) {
|
|||||||
$res = [];
|
$res = [];
|
||||||
$linkRewrite = Tools::link_rewrite($field); // PrestaShop's function to create valid link_rewrite
|
$linkRewrite = Tools::link_rewrite($field); // PrestaShop's function to create valid link_rewrite
|
||||||
foreach ($languages as $lang) {
|
foreach ($languages as $lang) {
|
||||||
$res[$lang['id_lang']] = $linkRewrite;
|
$res[(int)$lang['id_lang']] = $linkRewrite;
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to get category ID from name
|
// Function to get category ID from name (nieużywana, ale poprawiona)
|
||||||
function getCategoryId($categoryName) {
|
function getCategoryId($categoryName) {
|
||||||
$category = Category::searchByName(1, $categoryName); // 1 for default language id
|
$result = Category::searchByName(1, $categoryName); // 1 for default language id
|
||||||
if (!empty($category)) {
|
if (!empty($result) && isset($result[0]['id_category'])) {
|
||||||
return $category['id_category'];
|
return (int)$result[0]['id_category'];
|
||||||
} else {
|
} else {
|
||||||
// Create category if not exists
|
// Create category if not exists
|
||||||
$category = new Category();
|
$category = new Category();
|
||||||
@@ -83,7 +106,7 @@ function getCategoryId($categoryName) {
|
|||||||
$category->link_rewrite = createLinkRewrite($categoryName);
|
$category->link_rewrite = createLinkRewrite($categoryName);
|
||||||
$category->id_parent = 2; // Default parent category
|
$category->id_parent = 2; // Default parent category
|
||||||
$category->add();
|
$category->add();
|
||||||
return $category->id;
|
return (int)$category->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +114,7 @@ function getCategoryId($categoryName) {
|
|||||||
function addProductImage($productId, $imageUrl)
|
function addProductImage($productId, $imageUrl)
|
||||||
{
|
{
|
||||||
$image = new Image();
|
$image = new Image();
|
||||||
$image->id_product = $productId;
|
$image->id_product = (int)$productId;
|
||||||
$image->position = Image::getHighestPosition($productId) + 1;
|
$image->position = Image::getHighestPosition($productId) + 1;
|
||||||
$image->cover = true; // Set the first image as cover
|
$image->cover = true; // Set the first image as cover
|
||||||
$image->add();
|
$image->add();
|
||||||
@@ -105,7 +128,12 @@ function addProductImage($productId, $imageUrl)
|
|||||||
|
|
||||||
$imageTypes = ImageType::getImagesTypes('products');
|
$imageTypes = ImageType::getImagesTypes('products');
|
||||||
foreach ($imageTypes as $imageType) {
|
foreach ($imageTypes as $imageType) {
|
||||||
ImageManager::resize($imagePath . '.jpg', $imagePath . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height']);
|
ImageManager::resize(
|
||||||
|
$imagePath . '.jpg',
|
||||||
|
$imagePath . '-' . stripslashes($imageType['name']) . '.jpg',
|
||||||
|
(int)$imageType['width'],
|
||||||
|
(int)$imageType['height']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -113,24 +141,38 @@ function addProductImage($productId, $imageUrl)
|
|||||||
|
|
||||||
// Function to find product by reference
|
// Function to find product by reference
|
||||||
function findProductByReference($reference) {
|
function findProductByReference($reference) {
|
||||||
$result = Db::getInstance()->getRow('SELECT `id_product` FROM `'._DB_PREFIX_.'product` WHERE `reference` = \''.pSQL($reference).'\'');
|
$sql = 'SELECT `id_product`
|
||||||
return $result ? new Product($result['id_product']) : false;
|
FROM `'._DB_PREFIX_.'product`
|
||||||
|
WHERE `reference` = \''.pSQL($reference).'\'';
|
||||||
|
$result = Db::getInstance()->getRow($sql);
|
||||||
|
return $result ? new Product((int)$result['id_product']) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to find combination by product ID and attribute IDs
|
// Function to find combination by product ID and attribute IDs
|
||||||
function findCombinationByAttributes($id_product, $attributeIds) {
|
function findCombinationByAttributes($id_product, $attributeIds) {
|
||||||
|
if (empty($attributeIds)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sort($attributeIds);
|
sort($attributeIds);
|
||||||
|
$conditions = [];
|
||||||
|
foreach ($attributeIds as $id_attr) {
|
||||||
|
$conditions[] = 'pac.`id_attribute` = '.(int)$id_attr;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'SELECT c.`id_product_attribute`
|
$sql = 'SELECT c.`id_product_attribute`
|
||||||
FROM `'._DB_PREFIX_.'product_attribute` c
|
FROM `'._DB_PREFIX_.'product_attribute` c
|
||||||
JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON c.`id_product_attribute` = pac.`id_product_attribute`
|
JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||||
|
ON c.`id_product_attribute` = pac.`id_product_attribute`
|
||||||
WHERE c.`id_product` = '.(int)$id_product.'
|
WHERE c.`id_product` = '.(int)$id_product.'
|
||||||
GROUP BY c.`id_product_attribute`
|
GROUP BY c.`id_product_attribute`
|
||||||
HAVING SUM(pac.`id_attribute` = '.implode(' OR pac.`id_attribute` = ', array_map('intval', $attributeIds)).') = '.count($attributeIds);
|
HAVING SUM('.implode(' OR ', $conditions).') = '.count($attributeIds);
|
||||||
|
|
||||||
$result = Db::getInstance()->getRow($sql);
|
$result = Db::getInstance()->getRow($sql);
|
||||||
return $result ? new Combination($result['id_product_attribute']) : false;
|
return $result ? new Combination((int)$result['id_product_attribute']) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse XML and group products by Symbol
|
// === GRUPOWANIE PRODUKTÓW PO SYMBOLU ===
|
||||||
$productsBySymbol = [];
|
$productsBySymbol = [];
|
||||||
foreach ($xml->product as $productData) {
|
foreach ($xml->product as $productData) {
|
||||||
$symbol = (string)$productData->item_group_id;
|
$symbol = (string)$productData->item_group_id;
|
||||||
@@ -140,7 +182,117 @@ foreach ($xml->product as $productData) {
|
|||||||
$productsBySymbol[$symbol][] = $productData;
|
$productsBySymbol[$symbol][] = $productData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create or update products with combinations based on grouped data
|
// =======================================
|
||||||
|
// =========== TRYB AKTUALIZACJI =========
|
||||||
|
// =======================================
|
||||||
|
if ($modeUpdate) {
|
||||||
|
|
||||||
|
$today = date('Y-m-d');
|
||||||
|
$updatedToday = [];
|
||||||
|
|
||||||
|
// Wczytanie logu aktualizacji
|
||||||
|
if (file_exists($logFile)) {
|
||||||
|
$lines = file($logFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
$parts = explode(';', $line);
|
||||||
|
if (count($parts) >= 3) {
|
||||||
|
$logDate = trim($parts[0]);
|
||||||
|
$logType = trim($parts[1]); // np. 'product'
|
||||||
|
$logRef = trim($parts[2]);
|
||||||
|
if ($logDate === $today) {
|
||||||
|
$updatedToday[$logType.'_'.$logRef] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$updatedSomething = false;
|
||||||
|
|
||||||
|
foreach ($productsBySymbol as $symbol => $products) {
|
||||||
|
if (empty($products)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Główny produkt – referencja z pierwszego elementu grupy
|
||||||
|
$mainProductData = $products[0];
|
||||||
|
$reference = (string)$mainProductData->sku;
|
||||||
|
$key = 'product_'.$reference;
|
||||||
|
|
||||||
|
// Jeśli już zaktualizowany dzisiaj – pomijamy
|
||||||
|
if (isset($updatedToday[$key])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$product = findProductByReference($reference);
|
||||||
|
if (!$product) {
|
||||||
|
// produkt nie istnieje w Presta - pomijamy w trybie update
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nowa cena z XML
|
||||||
|
$newPrice = floatval(str_replace(',', '', (string)$mainProductData->price));
|
||||||
|
if ($newPrice <= 0) {
|
||||||
|
// brak sensownej ceny – pomiń
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aktualizacja ceny produktu
|
||||||
|
$product->price = $newPrice;
|
||||||
|
|
||||||
|
// Sprawdź kategorię domyślną – jeśli "Strona główna", zamień na "Meble" (ID 107)
|
||||||
|
$id_lang = (int)$context->language->id;
|
||||||
|
$defaultCategory = new Category($product->id_category_default, $id_lang);
|
||||||
|
|
||||||
|
if (Validate::isLoadedObject($defaultCategory) && $defaultCategory->name == 'Strona główna') {
|
||||||
|
$newCategoryId = 107; // Meble
|
||||||
|
|
||||||
|
// Ustaw nową kategorię domyślną
|
||||||
|
$product->id_category_default = (int)$newCategoryId;
|
||||||
|
|
||||||
|
// Podmień kategorie produktu (zachowując ewentualne inne)
|
||||||
|
$categories = $product->getCategories();
|
||||||
|
// Usuń starą kategorię domyślną, jeśli istnieje w tablicy
|
||||||
|
$categories = array_diff($categories, [(int)$defaultCategory->id]);
|
||||||
|
$categories[] = (int)$newCategoryId;
|
||||||
|
$categories = array_unique(array_map('intval', $categories));
|
||||||
|
|
||||||
|
$product->updateCategories($categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zapis produktu
|
||||||
|
if ($product->update()) {
|
||||||
|
// Zapis do logu – że ten produkt został dziś zaktualizowany
|
||||||
|
$logLine = $today.';product;'.$reference.';'.$product->id.PHP_EOL;
|
||||||
|
file_put_contents($logFile, $logLine, FILE_APPEND);
|
||||||
|
|
||||||
|
echo '<p>Zaktualizowano produkt: '.htmlspecialchars((string)$mainProductData->title).' ('.$reference.')</p>';
|
||||||
|
echo '<p>Nowa cena: '.$newPrice.'</p>';
|
||||||
|
|
||||||
|
$updatedSomething = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aktualizujemy tylko jeden produkt na jedno wywołanie
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($updatedSomething) {
|
||||||
|
// Odśwież stronę, żeby przy kolejnym wywołaniu zaktualizować następny produkt
|
||||||
|
echo '<script>setTimeout(function(){ location.reload(); }, 250);</script>';
|
||||||
|
} else {
|
||||||
|
echo '<p>Brak produktów do aktualizacji na dzisiaj (wszystkie z XML zostały już zaktualizowane).</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================
|
||||||
|
// =========== TRYB DODAWANIA ============
|
||||||
|
// =======================================
|
||||||
|
|
||||||
|
$productAdded = false;
|
||||||
|
$combinationAdded = false;
|
||||||
|
|
||||||
|
// Tworzenie lub aktualizacja produktów z kombinacjami (dodawanie)
|
||||||
foreach ($productsBySymbol as $symbol => $products) {
|
foreach ($productsBySymbol as $symbol => $products) {
|
||||||
if (empty($products)) {
|
if (empty($products)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -150,23 +302,24 @@ foreach ($productsBySymbol as $symbol => $products) {
|
|||||||
$mainProductData = $products[0];
|
$mainProductData = $products[0];
|
||||||
$mainProduct = findProductByReference((string)$mainProductData->sku);
|
$mainProduct = findProductByReference((string)$mainProductData->sku);
|
||||||
|
|
||||||
$productAdded = false;
|
|
||||||
if (!$mainProduct) {
|
if (!$mainProduct) {
|
||||||
// Create a new product if it doesn't exist
|
// Create a new product if it doesn't exist
|
||||||
$mainProduct = new Product();
|
$mainProduct = new Product();
|
||||||
$mainProduct->name = createMultiLangField((string)$mainProductData->title);
|
$mainProduct->name = createMultiLangField((string)$mainProductData->title);
|
||||||
|
|
||||||
$description = (string)$mainProductData->description;
|
$description = (string)$mainProductData->description;
|
||||||
$description = str_replace("\n", "<br>", $description);
|
$description = str_replace("\n", "<br>", $description);
|
||||||
$mainProduct->description = createMultiLangField($description);
|
$mainProduct->description = createMultiLangField($description);
|
||||||
$mainProduct->price = floatval(str_replace(',','',$mainProductData->price));
|
|
||||||
|
$mainProduct->price = floatval(str_replace(',', '', (string)$mainProductData->price));
|
||||||
$mainProduct->reference = (string)$mainProductData->sku;
|
$mainProduct->reference = (string)$mainProductData->sku;
|
||||||
$mainProduct->id_category_default = 2;
|
$mainProduct->id_category_default = 2; // np. Strona główna
|
||||||
$mainProduct->link_rewrite = createLinkRewrite((string)$mainProductData->title);
|
$mainProduct->link_rewrite = createLinkRewrite((string)$mainProductData->title);
|
||||||
$mainProduct->add();
|
$mainProduct->add();
|
||||||
|
|
||||||
// Add images to the product
|
// Add images to the product
|
||||||
if (!empty($mainProductData->image)) {
|
if (!empty($mainProductData->image)) {
|
||||||
addProductImage($mainProduct->id, $mainProductData->image);
|
addProductImage($mainProduct->id, (string)$mainProductData->image);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 1; $i <= 10; $i++) {
|
for ($i = 1; $i <= 10; $i++) {
|
||||||
@@ -177,15 +330,6 @@ foreach ($productsBySymbol as $symbol => $products) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$productAdded = true;
|
$productAdded = true;
|
||||||
} else {
|
|
||||||
// Update existing product price and description
|
|
||||||
if ( $config['update_price'] == true ) {
|
|
||||||
$mainProduct->price = floatval(str_replace(',','',$mainProductData->price));
|
|
||||||
$description = (string)$mainProductData->description;
|
|
||||||
$description = str_replace("\n", "<br>", $description);
|
|
||||||
$mainProduct->description = createMultiLangField($description);
|
|
||||||
$mainProduct->update();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the product is saved before adding combinations
|
// Ensure the product is saved before adding combinations
|
||||||
@@ -198,14 +342,13 @@ foreach ($productsBySymbol as $symbol => $products) {
|
|||||||
$addedCombinations = [];
|
$addedCombinations = [];
|
||||||
|
|
||||||
// Add or update combinations for each product in the group
|
// Add or update combinations for each product in the group
|
||||||
$combinationAdded = false;
|
|
||||||
foreach ($products as $productData) {
|
foreach ($products as $productData) {
|
||||||
$attributes = [
|
$attributes = [
|
||||||
'Kolor' => (string)$productData->Kolor,
|
'Kolor' => (string)$productData->Kolor,
|
||||||
'Dlugosc' => (string)$productData->Dlugosc,
|
'Dlugosc' => (string)$productData->Dlugosc,
|
||||||
'Szerokosc' => (string)$productData->Szerokosc,
|
'Szerokosc' => (string)$productData->Szerokosc,
|
||||||
'Glebokosc' => (string)$productData->Glebokosc,
|
'Glebokosc' => (string)$productData->Glebokosc,
|
||||||
'Wysokosc' => (string)$productData->Wysokosc,
|
'Wysokosc' => (string)$productData->Wysokosc,
|
||||||
];
|
];
|
||||||
|
|
||||||
$attributeIds = [];
|
$attributeIds = [];
|
||||||
@@ -214,7 +357,7 @@ foreach ($productsBySymbol as $symbol => $products) {
|
|||||||
$attributeGroupId = createAttribute($name, [$value]);
|
$attributeGroupId = createAttribute($name, [$value]);
|
||||||
$attribute = findAttributeByName($attributeGroupId, $value);
|
$attribute = findAttributeByName($attributeGroupId, $value);
|
||||||
if ($attribute) {
|
if ($attribute) {
|
||||||
$attributeIds[] = $attribute->id;
|
$attributeIds[] = (int)$attribute->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,12 +367,12 @@ foreach ($productsBySymbol as $symbol => $products) {
|
|||||||
$key = implode('-', $attributeIds);
|
$key = implode('-', $attributeIds);
|
||||||
|
|
||||||
// Add or update combination if it is unique
|
// Add or update combination if it is unique
|
||||||
if (!empty($attributeIds)) {
|
if (!empty($attributeIds) && !isset($addedCombinations[$key])) {
|
||||||
$combination = findCombinationByAttributes($mainProduct->id, $attributeIds);
|
$combination = findCombinationByAttributes($mainProduct->id, $attributeIds);
|
||||||
if (!$combination) {
|
if (!$combination) {
|
||||||
// Create new combination
|
// Create new combination
|
||||||
$combination = new Combination();
|
$combination = new Combination();
|
||||||
$combination->id_product = $mainProduct->id;
|
$combination->id_product = (int)$mainProduct->id;
|
||||||
$combination->quantity = 100; // Default quantity, you can adjust this
|
$combination->quantity = 100; // Default quantity, you can adjust this
|
||||||
$combination->reference = (string)$productData->sku;
|
$combination->reference = (string)$productData->sku;
|
||||||
$combination->add();
|
$combination->add();
|
||||||
@@ -256,18 +399,19 @@ foreach ($productsBySymbol as $symbol => $products) {
|
|||||||
Product::updateDefaultAttribute($mainProduct->id);
|
Product::updateDefaultAttribute($mainProduct->id);
|
||||||
|
|
||||||
if ($productAdded || $combinationAdded) {
|
if ($productAdded || $combinationAdded) {
|
||||||
if ($productAdded) {
|
if ($productAdded) {
|
||||||
echo "<p>Dodałem produkt: " . (string)$mainProductData->title . "</p>";
|
echo "<p>Dodałem produkt: " . htmlspecialchars((string)$mainProductData->title) . "</p>";
|
||||||
}
|
}
|
||||||
if ($combinationAdded) {
|
if ($combinationAdded) {
|
||||||
echo "<p>Dodałem kombinację: " . (string)$mainProductData->title . "</p>";
|
echo "<p>Dodałem kombinację: " . htmlspecialchars((string)$mainProductData->title) . "</p>";
|
||||||
}
|
}
|
||||||
break; // Break if a new product or combination was added
|
break; // Break if a new product or combination was added
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// reload page after 1s if product or combination was added
|
|
||||||
|
// reload page after 250ms if product or combination was added (dla trybu add)
|
||||||
if ($productAdded || $combinationAdded) {
|
if ($productAdded || $combinationAdded) {
|
||||||
echo "<script>setTimeout(function(){location.reload();}, 250);</script>";
|
echo "<script>setTimeout(function(){location.reload();}, 250);</script>";
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -18,9 +18,7 @@
|
|||||||
*}
|
*}
|
||||||
|
|
||||||
<div class="blockreassurance_product" t="1">
|
<div class="blockreassurance_product" t="1">
|
||||||
|
{* {if $product.delivery_in_stock}
|
||||||
|
|
||||||
{if $product.delivery_in_stock}
|
|
||||||
<div class="item-999 item-custom">
|
<div class="item-999 item-custom">
|
||||||
<span class="item-product">
|
<span class="item-product">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" data-img-url="/modules/blockreassurance/views/img/img_perso/Package.svg" class="svg replaced-svg">
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" data-img-url="/modules/blockreassurance/views/img/img_perso/Package.svg" class="svg replaced-svg">
|
||||||
@@ -41,8 +39,9 @@
|
|||||||
|
|
||||||
<span class="block-title" style="color:#000000;">Darmowa wysyłka w:</span>
|
<span class="block-title" style="color:#000000;">Darmowa wysyłka w:</span>
|
||||||
<p class="block-description" style="color:#000000;">{$product.delivery_in_stock}</p>
|
<p class="block-description" style="color:#000000;">{$product.delivery_in_stock}</p>
|
||||||
|
<p class="block-description" style="color:#000000; display:none;">{$product.delivery_out_stock}</p>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if} *}
|
||||||
|
|
||||||
|
|
||||||
{foreach from=$blocks item=$block key=$key}
|
{foreach from=$blocks item=$block key=$key}
|
||||||
|
|||||||
@@ -461,9 +461,15 @@ class ProductLazyArray extends AbstractLazyArray
|
|||||||
|
|
||||||
if ($show_price && $this->product['reduction']) {
|
if ($show_price && $this->product['reduction']) {
|
||||||
if ($this->product['discount_type'] === 'percentage') {
|
if ($this->product['discount_type'] === 'percentage') {
|
||||||
|
$discountLabel = $this->product['discount_percentage'];
|
||||||
|
$num = floatval(str_replace(',', '.', preg_replace('/[^0-9,.-]/', '', $discountLabel)));
|
||||||
|
$rounded = round($num);
|
||||||
|
$discountLabel = sprintf('-%d%%', abs($rounded));
|
||||||
|
|
||||||
$flags['discount'] = [
|
$flags['discount'] = [
|
||||||
'type' => 'discount',
|
'type' => 'discount',
|
||||||
'label' => $this->product['discount_percentage'],
|
// 'label' => $this->product['discount_percentage'],
|
||||||
|
'label' => $discountLabel,
|
||||||
];
|
];
|
||||||
} elseif ($this->product['discount_type'] === 'amount') {
|
} elseif ($this->product['discount_type'] === 'amount') {
|
||||||
$flags['discount'] = [
|
$flags['discount'] = [
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -447,3 +447,50 @@ if (isEditing()) return;
|
|||||||
window.addEventListener('popstate', onNav);
|
window.addEventListener('popstate', onNav);
|
||||||
})();
|
})();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
function toggleChatWidget(isOpen) {
|
||||||
|
var $widget = $('div[data-testid="widgetButtonFrame"]');
|
||||||
|
var $scrollBox = $('.scroll-brn-box')
|
||||||
|
|
||||||
|
if ($widget.length) {
|
||||||
|
if (isOpen) {
|
||||||
|
$widget.hide();
|
||||||
|
$scrollBox.hide();
|
||||||
|
} else {
|
||||||
|
$widget.show();
|
||||||
|
$scrollBox.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkCartState() {
|
||||||
|
var $cart = $('.elementor-cart__container');
|
||||||
|
var isOpen = $cart.hasClass('elementor-cart--shown');
|
||||||
|
toggleChatWidget(isOpen);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('a[href*="koszyk"][class*="elementor-button"]').on('click', function () {
|
||||||
|
setTimeout(checkCartState, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.elementor-cart__close-button', function () {
|
||||||
|
setTimeout(checkCartState, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.elementor-cart__container.elementor-lightbox.elementor-cart--shown', function (e) {
|
||||||
|
if (e.target === this) {
|
||||||
|
setTimeout(checkCartState, 300);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const cartContainer = document.querySelector('.elementor-cart__container');
|
||||||
|
if (cartContainer) {
|
||||||
|
const observer = new MutationObserver(() => checkCartState());
|
||||||
|
observer.observe(cartContainer, { attributes: true, attributeFilter: ['class'] });
|
||||||
|
}
|
||||||
|
|
||||||
|
checkCartState();
|
||||||
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -88,4 +88,25 @@
|
|||||||
{$HOOK_HEADER nofilter}
|
{$HOOK_HEADER nofilter}
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
{block name='hook_extra'}{/block}
|
{block name='hook_extra'}{/block}
|
||||||
|
{literal}
|
||||||
|
<script type="text/javascript">
|
||||||
|
var _smartsupp = _smartsupp || {};
|
||||||
|
_smartsupp.key = '0d334d3fee8a20124724fb0e40e42cb00d98a537';
|
||||||
|
_smartsupp.color = '#e78c32';
|
||||||
|
_smartsupp.offsetX = 40; // move along the X axis by 100 pixels
|
||||||
|
_smartsupp.offsetY = 38;
|
||||||
|
|
||||||
|
window.smartsupp||(function(d) {
|
||||||
|
var s,c,o=smartsupp=function(){ o._.push(arguments) };
|
||||||
|
o._=[];
|
||||||
|
s=d.getElementsByTagName('script')[0];
|
||||||
|
c=d.createElement('script');
|
||||||
|
c.type='text/javascript';
|
||||||
|
c.charset='utf-8';
|
||||||
|
c.async=true;
|
||||||
|
c.src='https://www.smartsuppchat.com/loader.js?';
|
||||||
|
s.parentNode.insertBefore(c,s);
|
||||||
|
})(document);
|
||||||
|
</script>
|
||||||
|
{/literal}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<div class="product-delivery-tile">
|
||||||
|
<span class="item-product">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" data-img-url="/modules/blockreassurance/views/img/img_perso/Package.svg" class="svg replaced-svg">
|
||||||
|
<g clip-path="url(#clip0_6241_8999)">
|
||||||
|
<path d="M12 12.1016V21.7466" stroke="#462D26" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" style="fill: rgb(241, 157, 118);"></path>
|
||||||
|
<path d="M3.06641 7.21094L12.0008 12.1009L20.9352 7.21094" stroke="#462D26" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" style="fill: rgb(241, 157, 118);"></path>
|
||||||
|
<path d="M20.61 17.1415L12.36 21.6584C12.2496 21.7188 12.1258 21.7504 12 21.7504C11.8742 21.7504 11.7504 21.7188 11.64 21.6584L3.39 17.1415C3.2722 17.077 3.17386 16.9821 3.10526 16.8667C3.03666 16.7513 3.0003 16.6195 3 16.4853V7.51713C3.0003 7.38284 3.03666 7.25111 3.10526 7.13567C3.17386 7.02023 3.2722 6.92533 3.39 6.86088L11.64 2.344C11.7504 2.28361 11.8742 2.25195 12 2.25195C12.1258 2.25195 12.2496 2.28361 12.36 2.344L20.61 6.86088C20.7278 6.92533 20.8261 7.02023 20.8947 7.13567C20.9633 7.25111 20.9997 7.38284 21 7.51713V16.4834C21 16.618 20.9638 16.7501 20.8952 16.8659C20.8266 16.9817 20.7281 17.0769 20.61 17.1415Z" stroke="#462D26" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" style="fill: rgb(241, 157, 118);"></path>
|
||||||
|
<path d="M7.64648 4.5293L16.5002 9.37523V14.2502" stroke="#462D26" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" style="fill: rgb(241, 157, 118);"></path>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_6241_8999">
|
||||||
|
<rect width="24" height="24" fill="white"></rect>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="block-title" style="color:#000000;">Darmowa wysyłka w:</span>
|
||||||
|
{if $quantity > 0}
|
||||||
|
<p class="block-description" style="color:#000000;">{$product.delivery_in_stock}</p>
|
||||||
|
{else}
|
||||||
|
<p class="block-description" style="color:#000000;">{$product.delivery_out_stock}</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
@@ -16,10 +16,39 @@
|
|||||||
{if $is_free}
|
{if $is_free}
|
||||||
<p>{l s='No payment needed for this order' d='Shop.Theme.Checkout'}</p>
|
<p>{l s='No payment needed for this order' d='Shop.Theme.Checkout'}</p>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="payment-options {if $is_free}hidden-xs-up{/if}">
|
|
||||||
|
{* MARK: Własne ustawienia opcje płatności *}
|
||||||
|
{assign var='customPaymentOptions' value=[
|
||||||
|
'paynow' => [
|
||||||
|
'img' => '/modules/paynow/views/img/logo-paynow.png',
|
||||||
|
'label' => 'BLIK, karty, szybkie przelewy'
|
||||||
|
],
|
||||||
|
'ps_wirepayment' => [
|
||||||
|
'label' => 'Przelew bankowy'
|
||||||
|
],
|
||||||
|
'caraty' => [
|
||||||
|
'label' => 'Raty CA'
|
||||||
|
],
|
||||||
|
'santandercredit' => [
|
||||||
|
'label' => 'Raty Santander'
|
||||||
|
],
|
||||||
|
'payment-option-4' => [
|
||||||
|
'img' => '/modules/raty/alior.gif',
|
||||||
|
'label' => 'Raty Alior'
|
||||||
|
],
|
||||||
|
'ps_cashondelivery' => [
|
||||||
|
'label' => 'Płatność przy odbiorze'
|
||||||
|
]
|
||||||
|
]}
|
||||||
|
|
||||||
|
<div class="payment-options payment-options-custom {if $is_free}hidden-xs-up{/if}">
|
||||||
|
<p class="payment-option-title payment-option-title-1">Szybkie płatności</p>
|
||||||
|
<p class="payment-option-title payment-option-title-2">Metody finansowania</p>
|
||||||
|
<p class="payment-option-title payment-option-title-3">Płatność tradycyjna</p>
|
||||||
|
|
||||||
{foreach from=$payment_options item="module_options"}
|
{foreach from=$payment_options item="module_options"}
|
||||||
{foreach from=$module_options item="option"}
|
{foreach from=$module_options item="option"}
|
||||||
<div>
|
<div class="payment-item" option-name="{if $option.module_name}{$option.module_name}{else}{$option.id}{/if}">
|
||||||
<div id="{$option.id}-container" class="payment-option clearfix">
|
<div id="{$option.id}-container" class="payment-option clearfix">
|
||||||
{* This is the way an option should be selected when Javascript is enabled *}
|
{* This is the way an option should be selected when Javascript is enabled *}
|
||||||
<span class="custom-radio float-xs-left">
|
<span class="custom-radio float-xs-left">
|
||||||
@@ -44,13 +73,32 @@
|
|||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
{assign var='key' value=$option.module_name|default:$option.id}
|
||||||
|
|
||||||
<label for="{$option.id}">
|
{if isset($customPaymentOptions[$key])}
|
||||||
|
<label for="{$option.id}" class="custom-payment-label">
|
||||||
|
{if $customPaymentOptions[$key].img}
|
||||||
|
<img src="{$customPaymentOptions[$key].img}" alt="{$customPaymentOptions[$key].label}" class="custom-payment-icon">
|
||||||
|
{/if}
|
||||||
|
<span>{$customPaymentOptions[$key].label}</span>
|
||||||
|
</label>
|
||||||
|
{else}
|
||||||
|
<label for="{$option.id}">
|
||||||
|
<span>{$option.call_to_action_text}</span>
|
||||||
|
{if $option.logo}
|
||||||
|
<img src="{$option.logo}" loading="lazy">
|
||||||
|
{/if}
|
||||||
|
</label>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
|
{* <label for="{$option.id}">
|
||||||
<span>{$option.call_to_action_text}</span>
|
<span>{$option.call_to_action_text}</span>
|
||||||
{if $option.logo}
|
{if $option.logo}
|
||||||
<img src="{$option.logo}" loading="lazy">
|
<img src="{$option.logo}" loading="lazy">
|
||||||
{/if}
|
{/if}
|
||||||
</label>
|
</label> *}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -67,7 +115,7 @@
|
|||||||
<div
|
<div
|
||||||
id="pay-with-{$option.id}-form"
|
id="pay-with-{$option.id}-form"
|
||||||
class="js-payment-option-form {if $option.id != $selected_payment_option} ps-hidden {/if}"
|
class="js-payment-option-form {if $option.id != $selected_payment_option} ps-hidden {/if}"
|
||||||
>
|
>
|
||||||
{if $option.form}
|
{if $option.form}
|
||||||
{$option.form nofilter}
|
{$option.form nofilter}
|
||||||
{else}
|
{else}
|
||||||
|
|||||||
8689
themes/core.js
8689
themes/core.js
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user