first commit
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
|
||||
class stProductObserveFrontendActions extends stActions
|
||||
{
|
||||
public function executeAddToObserve()
|
||||
{
|
||||
|
||||
$product_id = $this->getRequestParameter('product_id');
|
||||
|
||||
stProductObservePluginListener::addObserveProduct($product_id);
|
||||
|
||||
//return sfView::NONE;
|
||||
return $this->renderText("true");
|
||||
|
||||
}
|
||||
|
||||
public function executeRemoveFromObserve()
|
||||
{
|
||||
|
||||
$product_id = $this->getRequestParameter('product_id');
|
||||
|
||||
stProductObservePluginListener::delObserveProduct($product_id);
|
||||
|
||||
//return sfView::NONE;
|
||||
return $this->renderText("true");
|
||||
|
||||
}
|
||||
|
||||
public function executeRemoveAll()
|
||||
{
|
||||
|
||||
stProductObservePluginListener::removeAll();
|
||||
|
||||
//return sfView::NONE;
|
||||
return $this->renderText("true");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function executeShowProductsSidebar()
|
||||
{
|
||||
$this->smarty = new stSmarty('stProductObserveFrontend');
|
||||
|
||||
$config_observe = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
|
||||
|
||||
|
||||
if($config_observe->get('enabled')!=1){
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
$i18n = $this->getContext()->getI18n();
|
||||
|
||||
|
||||
if(stProductObservePluginListener::getObserveProducts()){
|
||||
|
||||
$this->config = stConfig::getInstance(sfContext::getInstance(), 'stProduct');
|
||||
|
||||
$this->products = stProductObservePluginListener::getObserveProducts();
|
||||
|
||||
}else{
|
||||
return $this->renderText("<p>".$i18n->__('W tym miejscu pojawią się obserwowane produkty.')."</p>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function executeObserveProductsIds()
|
||||
{
|
||||
$products = stProductObservePluginListener::getObserveProductsIds();
|
||||
return $this->renderJSON($products);
|
||||
}
|
||||
|
||||
public function executeListShowProducts()
|
||||
{
|
||||
$this->smarty = new stSmarty('stProductObserveFrontend');
|
||||
|
||||
$config_observe = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
|
||||
|
||||
if(stProductObservePluginListener::getObserveProducts()){
|
||||
|
||||
$this->config = stConfig::getInstance(sfContext::getInstance(), 'stProduct');
|
||||
|
||||
$this->products = stProductObservePluginListener::getObserveProducts();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
|
||||
class stProductObserveFrontendComponents extends sfComponents
|
||||
{
|
||||
public function executeProductObserve()
|
||||
{
|
||||
|
||||
$this->smarty = new stSmarty('stProductObserveFrontend');
|
||||
|
||||
$config = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
|
||||
|
||||
if($config->get('enabled')!=1){
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function executeObserveProductsSidebar()
|
||||
{
|
||||
$this->smarty = new stSmarty('stProductObserveFrontend');
|
||||
|
||||
$config = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
|
||||
|
||||
if($config->get('enabled')!=1){
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function executeListProductObserve()
|
||||
{
|
||||
|
||||
$this->smarty = new stSmarty('stProductObserveFrontend');
|
||||
|
||||
$config = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
|
||||
|
||||
if($config->get('enabled')!=1){
|
||||
return sfView::NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
$smarty->display('list_product_observe.html');
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
$smarty->display('observe_products_sidebar.html');
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
$smarty->display('product_observe.html');
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
use_helper('stCurrency', 'stText', 'stProductImage', 'stUrl', 'stAvailability');
|
||||
sfLoader::loadHelpers('stProduct','stProduct');
|
||||
|
||||
st_theme_use_stylesheet('stProduct.css');
|
||||
|
||||
$results = array();
|
||||
|
||||
$smarty->assign("show_name", $config->get('show_name_other'));
|
||||
|
||||
$smarty->assign("show_image", $config->get('show_image_other'));
|
||||
|
||||
$smarty->assign("show_price", $config->get('show_price_other'));
|
||||
|
||||
$smarty->assign("show_old_price", $config->get('show_old_price_other'));
|
||||
|
||||
$smarty->assign("show_discount", $config->get('show_discount_other'));
|
||||
|
||||
$smarty->assign("show_basket", $config->get('show_basket_long'));
|
||||
|
||||
$smarty->assign("price_view", $config->get('price_view_other'));
|
||||
|
||||
$smarty->assign('button_type', $config->get('button_type_long'));
|
||||
|
||||
$photo_max_height = st_asset_thumbnail_setting('height', 'thumb');
|
||||
|
||||
$photo_max_width = st_asset_thumbnail_setting('width', 'small');
|
||||
|
||||
$cut_name = $config->get('cut_name_other');
|
||||
|
||||
$max_name_length = $config->get('cut_name_num_other');
|
||||
|
||||
foreach ($products as $index => $product)
|
||||
{
|
||||
$product_url = st_url_for('stProduct/show?url=' . $product->getFriendlyUrl());
|
||||
|
||||
$product_name = $product->getName();
|
||||
|
||||
$results[$index]['instance'] = $product;
|
||||
|
||||
if ($cut_name && st_check_strlen($product_name) > $max_name_length)
|
||||
{
|
||||
$results[$index]['name'] = '<span title="'.$product_name.'" class="hint">' . content_tag('a', st_truncate_text($product_name, $max_name_length, '...'), array('href' => $product_url, 'class' => 'product_name')) . "</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$results[$index]['name'] = content_tag('a', $product_name, array('href' => $product_url, 'class' => 'product_name'));
|
||||
}
|
||||
|
||||
$results[$index]['id'] = $product->getId();
|
||||
|
||||
$results[$index]['photo'] = content_tag('a', st_product_image_tag($product, 'thumb'), array('href' => $product_url));
|
||||
|
||||
$results[$index]['photo_small'] = content_tag('a', st_product_image_tag($product, 'small'), array('href' => $product_url));
|
||||
|
||||
$results[$index]['photo_max_height'] = $photo_max_height;
|
||||
|
||||
// $results[$index]['uom'] = st_product_uom($product);
|
||||
|
||||
$results[$index]['stock'] = $product->getStock();
|
||||
|
||||
if ($product->isPriceVisible())
|
||||
{
|
||||
if ($config->get('show_uom_other') && $product->getUom())
|
||||
{
|
||||
$uom = " / ".$results[$index]['uom'];
|
||||
}else{
|
||||
$uom = "";
|
||||
}
|
||||
|
||||
$results[$index]['price'] = st_currency_format($product->getPriceBrutto(true)).$uom;
|
||||
|
||||
$results[$index]['price_net'] = st_currency_format($product->getPriceNetto(true)).$uom;
|
||||
|
||||
$results[$index]['price_brutto_pure'] = $product->getPriceBrutto(true).$uom;
|
||||
|
||||
$results[$index]['price_netto_pure'] = $product->getPriceNetto(true).$uom;
|
||||
|
||||
$currency = stCurrency::getInstance(sfContext::getInstance());
|
||||
|
||||
if ($currency->getFrontSymbol())
|
||||
{
|
||||
$results[$index]['currency'] = $currency->getFrontSymbol();
|
||||
}
|
||||
else
|
||||
{
|
||||
$results[$index]['currency'] = $currency->getBackSymbol();
|
||||
}
|
||||
|
||||
$old_price_brutto = $product->getOldPriceBrutto(true);
|
||||
|
||||
$results[$index]['check_old_price'] = $old_price_brutto != 0;
|
||||
|
||||
$results[$index]['old_price'] = st_currency_format($old_price_brutto);
|
||||
|
||||
$results[$index]['old_price_net'] = st_currency_format($product->getOldPriceNetto(true));
|
||||
|
||||
$results[$index]['discount'] = $product->getDiscountInPercent();
|
||||
|
||||
$results[$index]['basket'] = st_get_component('stBasket', 'add', array('product' => $product));
|
||||
|
||||
$results[$index]['check_price'] = false;
|
||||
|
||||
if ($config->get('show_basic_price_long') && $product->hasBasicPrice() && $product->getBasicPriceBrutto()!=0)
|
||||
{
|
||||
$results[$index]['basic_price'] = array(
|
||||
'netto' => st_currency_format($product->getBasicPriceNetto(true)),
|
||||
'brutto' => st_currency_format($product->getBasicPriceBrutto(true)),
|
||||
'quantity' => st_product_basic_price_quantity($product),
|
||||
'for_quantity' => st_product_basic_price_for_quantity($product),
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$results[$index]['check_price'] = true;
|
||||
}
|
||||
|
||||
$results[$index]['is_observe'] = stProductObservePluginListener::isObserveProduct($product->getId());
|
||||
|
||||
$results[$index]['name_without_link'] = $product_name;
|
||||
|
||||
$results[$index]['link'] = st_url_for('stProduct/show?url=' . $product->getFriendlyUrl());
|
||||
|
||||
$results[$index]['availability'] = st_availability_show($product);
|
||||
}
|
||||
|
||||
$smarty->assign('show_stock', $config->get('show_depository_long'));
|
||||
$smarty->assign('show_availability', $config->get('show_availability_long'));
|
||||
|
||||
$smarty->assign('results', $results);
|
||||
|
||||
$config_observe = stConfig::getInstance(sfContext::getInstance(), 'stProductObserveBackend');
|
||||
|
||||
$smarty->assign('is_observe_enabled', $config_observe->get('enabled'));
|
||||
|
||||
|
||||
$smarty->display('list_show_products.html');
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
use_helper('stCurrency', 'stText', 'stProductImage', 'stUrl', 'stAvailability');
|
||||
sfLoader::loadHelpers('stProduct','stProduct');
|
||||
|
||||
st_theme_use_stylesheet('stProduct.css');
|
||||
|
||||
$results = array();
|
||||
|
||||
$smarty->assign("show_name", $config->get('show_name_other'));
|
||||
|
||||
$smarty->assign("show_image", $config->get('show_image_other'));
|
||||
|
||||
$smarty->assign("show_price", $config->get('show_price_other'));
|
||||
|
||||
$smarty->assign("show_old_price", $config->get('show_old_price_other'));
|
||||
|
||||
$smarty->assign("show_discount", $config->get('show_discount_other'));
|
||||
|
||||
$smarty->assign("show_basket", $config->get('show_basket_long'));
|
||||
|
||||
$smarty->assign("price_view", $config->get('price_view_other'));
|
||||
|
||||
$smarty->assign('button_type', $config->get('button_type_long'));
|
||||
|
||||
$photo_max_height = st_asset_thumbnail_setting('height', 'thumb');
|
||||
|
||||
$photo_max_width = st_asset_thumbnail_setting('width', 'small');
|
||||
|
||||
$cut_name = $config->get('cut_name_other');
|
||||
|
||||
$max_name_length = $config->get('cut_name_num_other');
|
||||
|
||||
foreach ($products as $index => $product)
|
||||
{
|
||||
$product_url = st_url_for('stProduct/show?url=' . $product->getFriendlyUrl());
|
||||
|
||||
$product_name = $product->getName();
|
||||
|
||||
$results[$index]['instance'] = $product;
|
||||
|
||||
if ($cut_name && st_check_strlen($product_name) > $max_name_length)
|
||||
{
|
||||
$results[$index]['name'] = '<span title="'.$product_name.'" class="hint">' . content_tag('a', st_truncate_text($product_name, $max_name_length, '...'), array('href' => $product_url, 'class' => 'product_name')) . "</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$results[$index]['name'] = content_tag('a', $product_name, array('href' => $product_url, 'class' => 'product_name'));
|
||||
}
|
||||
|
||||
$results[$index]['id'] = $product->getId();
|
||||
|
||||
$results[$index]['photo'] = content_tag('a', st_product_image_tag($product, 'thumb'), array('href' => $product_url));
|
||||
|
||||
$results[$index]['photo_small'] = content_tag('a', st_product_image_tag($product, 'small'), array('href' => $product_url));
|
||||
|
||||
$results[$index]['photo_max_height'] = $photo_max_height;
|
||||
|
||||
// $results[$index]['uom'] = st_product_uom($product);
|
||||
|
||||
$results[$index]['stock'] = $product->getStock();
|
||||
|
||||
if ($product->isPriceVisible())
|
||||
{
|
||||
if ($config->get('show_uom_other') && $product->getUom())
|
||||
{
|
||||
$uom = " / ".$results[$index]['uom'];
|
||||
}else{
|
||||
$uom = "";
|
||||
}
|
||||
|
||||
$results[$index]['price'] = st_currency_format($product->getPriceBrutto(true)).$uom;
|
||||
|
||||
$results[$index]['price_net'] = st_currency_format($product->getPriceNetto(true)).$uom;
|
||||
|
||||
$results[$index]['price_brutto_pure'] = $product->getPriceBrutto(true).$uom;
|
||||
|
||||
$results[$index]['price_netto_pure'] = $product->getPriceNetto(true).$uom;
|
||||
|
||||
$currency = stCurrency::getInstance(sfContext::getInstance());
|
||||
|
||||
if ($currency->getFrontSymbol())
|
||||
{
|
||||
$results[$index]['currency'] = $currency->getFrontSymbol();
|
||||
}
|
||||
else
|
||||
{
|
||||
$results[$index]['currency'] = $currency->getBackSymbol();
|
||||
}
|
||||
|
||||
$old_price_brutto = $product->getOldPriceBrutto(true);
|
||||
|
||||
$results[$index]['check_old_price'] = $old_price_brutto != 0;
|
||||
|
||||
$results[$index]['old_price'] = st_currency_format($old_price_brutto);
|
||||
|
||||
$results[$index]['old_price_net'] = st_currency_format($product->getOldPriceNetto(true));
|
||||
|
||||
$results[$index]['discount'] = $product->getDiscountInPercent();
|
||||
|
||||
$results[$index]['basket'] = st_get_component('stBasket', 'add', array('product' => $product));
|
||||
|
||||
$results[$index]['check_price'] = false;
|
||||
|
||||
if ($config->get('show_basic_price_long') && $product->hasBasicPrice() && $product->getBasicPriceBrutto()!=0)
|
||||
{
|
||||
$results[$index]['basic_price'] = array(
|
||||
'netto' => st_currency_format($product->getBasicPriceNetto(true)),
|
||||
'brutto' => st_currency_format($product->getBasicPriceBrutto(true)),
|
||||
'quantity' => st_product_basic_price_quantity($product),
|
||||
'for_quantity' => st_product_basic_price_for_quantity($product),
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$results[$index]['check_price'] = true;
|
||||
}
|
||||
|
||||
$results[$index]['name_without_link'] = $product_name;
|
||||
|
||||
$results[$index]['link'] = st_url_for('stProduct/show?url=' . $product->getFriendlyUrl());
|
||||
|
||||
$results[$index]['availability'] = st_availability_show($product);
|
||||
}
|
||||
|
||||
$smarty->assign('show_stock', $config->get('show_depository_long'));
|
||||
$smarty->assign('show_availability', $config->get('show_availability_long'));
|
||||
|
||||
$smarty->assign('results', $results);
|
||||
|
||||
|
||||
$smarty->display('show_products_sidebar.html');
|
||||
@@ -0,0 +1,30 @@
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active">
|
||||
<a rel="nofollow">{__ text="Obserwowane produkty"}</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</br>
|
||||
<div id="product-tab-observe">
|
||||
</div>
|
||||
|
||||
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery(function($){
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$.get('{/literal}{url_for internal=stProductObserveFrontend/listShowProducts}{literal}', function(html)
|
||||
{
|
||||
setTimeout(function() {
|
||||
$('#product-tab-observe').html(html);
|
||||
}, 200); // 500 milisekund = 0,5 sekundy
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
{/literal}
|
||||
@@ -0,0 +1,96 @@
|
||||
<section id="product-observe-list" class="full-list product-list" >
|
||||
<div class="row" data-equalizer>
|
||||
{foreach key=row item=product from=$results}
|
||||
<div class="product col-xs-4 col-sm-4 col-md-3 col-lg-3">
|
||||
<div class="thumbnail clearfix view-img">
|
||||
|
||||
{if $is_observe_enabled }
|
||||
|
||||
<div class="product-observe {if $product.is_observe}observe-yes{else}observe-no{/if}" data-product-observe="{$product.id}">
|
||||
<svg width="23" height="21" viewBox="0 0 23 21" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6.4592 1C3.44417 1 1 3.81598 1 7.28966C1 7.97227 1.09438 8.62947 1.26893 9.2449C1.71875 10.8309 2.96968 12.0161 4.1733 13.1426L11.5 20L18.8267 13.1426C20.0303 12.0161 21.2813 10.8309 21.7311 9.2449C21.9056 8.62947 22 7.97227 22 7.28966C22 3.81598 19.5558 1 16.5408 1C14.2698 1 12.3227 2.59762 11.5 4.87056C10.6773 2.59762 8.73018 1 6.4592 1Z" stroke-width="2" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
{/if}
|
||||
|
||||
{if $show_image==1}<div data-equalizer-watch="image"><div class="image">{$product.photo_small}</div></div>{/if}
|
||||
<div class="text-center caption clearfix" data-equalizer-watch="info">
|
||||
<p class="name">{if $show_name==1}{$product.name}{/if}</p>
|
||||
|
||||
{if $show_availability}
|
||||
<div class="product-availability text-center">
|
||||
{$product.availability}
|
||||
{if $show_stock}
|
||||
({$product.stock} {$product.uom})
|
||||
{/if}
|
||||
</div>
|
||||
{elseif $show_stock}
|
||||
<div class="product-availability text-center">
|
||||
{__ text="Dostępność" langCatalogue="stAvailabilityFrontend"}: {$product.stock} {$product.uom}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if $show_price==1 && $product.check_price!=1}
|
||||
{if $price_view=='net_gross'}
|
||||
<div class="double_price price">
|
||||
<span class="nowrap">{$product.price_net}</span>
|
||||
<div class="minor_price nowrap">({$product.price})</div>
|
||||
</div>
|
||||
{elseif $price_view=='only_gross'}
|
||||
<div class="price nowrap">{$product.price}</div>
|
||||
{elseif $price_view=='only_net'}
|
||||
<div class="price nowrap">{$product.price_net}</div>
|
||||
{elseif $price_view=='gross_net'}
|
||||
<div class="double_price price">
|
||||
<span class="nowrap">{$product.price}</span>
|
||||
<div class="minor_price nowrap">({$product.price_net})</div>
|
||||
</div>
|
||||
{/if}
|
||||
{if $product.basic_price}
|
||||
<div class="text-muted basic_price text-center"><i>{$product.basic_price.quantity} ( {$product.basic_price.brutto} {__ text="za"} {$product.basic_price.for_quantity} )</i></div>
|
||||
{/if}
|
||||
{/if}
|
||||
<div class="discount-old_price">
|
||||
{if $show_discount==1 && $product.discount!=0 && $product.check_price!=1}
|
||||
<div class="discount">{__ text="Rabat"}: <span class="nowrap">{$product.discount} %</span></div>
|
||||
{elseif ($show_old_price==1 && $product.check_price!=1)}
|
||||
{if $product.check_old_price==1}
|
||||
<div class="old_price price nowrap">
|
||||
{if ($price_view=='net_gross' || $price_view=='only_net')}
|
||||
{$product.old_price_net}
|
||||
{else}
|
||||
{$product.old_price}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="product-shopping-cart">
|
||||
{if $button_type == 'basket'}
|
||||
{if $show_price==1 && $show_basket==1}
|
||||
{basket_add_link product=$product.instance namespace="product_recommend_card"}
|
||||
{/if}
|
||||
{else}
|
||||
<a class="btn btn-shopping-cart" href="{$product.link}">{__ text="Sprawdź"}</a>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$(document).ready(function() {
|
||||
$('#product-observe-list [data-equalizer]').equalizer({ use_tallest: true });
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
@@ -0,0 +1,69 @@
|
||||
<div class="sidebar-header">
|
||||
|
||||
<div class="sidebar-header-icon">
|
||||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M15.8139 27.6322L16.5 28.2793L17.1861 27.6322L25.1499 20.1218L25.1923 20.0817C26.4535 18.8925 28.0132 17.4219 28.5833 15.3963L28.5834 15.3962C28.7978 14.634 28.913 13.8231 28.913 12.9839C28.913 8.77231 25.9434 5.09521 21.9791 5.09521C19.7063 5.09521 17.747 6.32102 16.5 8.1472C15.253 6.32102 13.2937 5.09521 11.0209 5.09521C7.05656 5.09521 4.08694 8.77232 4.08694 12.9839C4.08694 13.8231 4.2021 14.634 4.41667 15.3963C4.98685 17.422 6.5466 18.8927 7.80789 20.082L7.85009 20.1218L7.85009 20.1218L15.8139 27.6322Z" stroke="#5B5B5B" stroke-width="2"/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
{__ text="Obserwowane produkty"}
|
||||
|
||||
<div id="remove-all-observe-container" style="float:right;"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="product-tab-observe-sidebar">
|
||||
</div>
|
||||
|
||||
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery(function($){
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
showProductsSidebar();
|
||||
|
||||
$(document).on('click', '#remove-all-observe', function() {
|
||||
|
||||
$.get('{/literal}{url_for internal=stProductObserveFrontend/removeAll}{literal}', function(html)
|
||||
{
|
||||
setTimeout(function() {
|
||||
showProductsSidebar();
|
||||
setObserveToNo();
|
||||
}, 200); // 500 milisekund = 0,5 sekundy
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
function showProductsSidebar()
|
||||
{
|
||||
$.get('{/literal}{url_for internal=stProductObserveFrontend/showProductsSidebar}{literal}', function(html)
|
||||
{
|
||||
setTimeout(function() {
|
||||
$('#product-tab-observe-sidebar').html(html);
|
||||
}, 200); // 500 milisekund = 0,5 sekundy
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function setObserveToNo() {
|
||||
var elements = $('.product-observe');
|
||||
|
||||
elements.each(function() {
|
||||
var $element = $(this);
|
||||
if ($element.hasClass('observe-yes')) {
|
||||
$element.removeClass('observe-yes').addClass('observe-no');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
{/literal}
|
||||
@@ -0,0 +1,162 @@
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery(function($){
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
$(document).on('click', '.product-observe', function() {
|
||||
let productValue = $(this).data('product-observe');
|
||||
let div = $(this).closest('div');
|
||||
|
||||
|
||||
if(div.hasClass('observe-no')){
|
||||
|
||||
$.get('{/literal}{url_for internal=stProductObserveFrontend/addToObserve}{literal}', { 'product_id':productValue}, function(data)
|
||||
{
|
||||
setTimeout(function() {
|
||||
blinkInGreen();
|
||||
setObserveYesForProduct(productValue);
|
||||
showProductsSidebar();
|
||||
}, 200); // 500 milisekund = 0,5 sekundy
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if(div.hasClass('observe-yes')){
|
||||
|
||||
|
||||
$.get('{/literal}{url_for internal=stProductObserveFrontend/removeFromObserve}{literal}', { 'product_id':productValue}, function(data)
|
||||
{
|
||||
setTimeout(function() {
|
||||
|
||||
blinkInRed();
|
||||
setObserveNoForProduct(productValue);
|
||||
showProductsSidebar();
|
||||
}, 200); // 500 milisekund = 0,5 sekundy
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function setObserveNoForProduct(id) {
|
||||
var elements = $('div[data-product-observe="' + id + '"]');
|
||||
|
||||
elements.each(function() {
|
||||
var $element = $(this);
|
||||
|
||||
if ($element.hasClass('observe-yes')) {
|
||||
|
||||
$element.removeClass('observe-yes').addClass('observe-no');
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function setObserveYesForProduct(id) {
|
||||
var elements = $('div[data-product-observe="' + id + '"]');
|
||||
|
||||
elements.each(function() {
|
||||
var $element = $(this);
|
||||
|
||||
if ($element.hasClass('observe-no')) {
|
||||
|
||||
$element.removeClass('observe-no').addClass('observe-yes');
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showProductsSidebar() {
|
||||
$.get('{/literal}{url_for internal=stProductObserveFrontend/showProductsSidebar}{literal}', function(html)
|
||||
{
|
||||
setTimeout(function() {
|
||||
$('#product-tab-observe-sidebar').html(html);
|
||||
}, 200); // 500 milisekund = 0,5 sekundy
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function blinkInRed() {
|
||||
$('#sidebar-handle').animate({
|
||||
'dummy': 1
|
||||
}, {
|
||||
step: function(now, fx) {
|
||||
$(this).css('background-color', '#eee');
|
||||
$(this).find('.glyphicon-list').removeClass('glyphicon-list').addClass('glyphicon-trash');
|
||||
},
|
||||
complete: function() {
|
||||
$(this).animate({
|
||||
'dummy': 1
|
||||
}, {
|
||||
step: function(now, fx) {
|
||||
$(this).css('background-color', ''); // Przywróć pierwotny kolor tła
|
||||
$(this).find('.glyphicon-trash').removeClass('glyphicon-trash').addClass('glyphicon-list');
|
||||
}
|
||||
});
|
||||
},
|
||||
duration: 2000 // czas trwania animacji, możesz dostosować według potrzeb
|
||||
});
|
||||
}
|
||||
|
||||
function blinkInGreen() {
|
||||
$('#sidebar-handle').animate({
|
||||
'dummy': 1
|
||||
}, {
|
||||
step: function(now, fx) {
|
||||
$(this).css('background-color', '#eee');
|
||||
$(this).find('.glyphicon-list').removeClass('glyphicon-list').addClass('glyphicon-heart');
|
||||
},
|
||||
complete: function() {
|
||||
$(this).animate({
|
||||
'dummy': 1
|
||||
}, {
|
||||
step: function(now, fx) {
|
||||
$(this).css('background-color', ''); // Przywróć pierwotny kolor tła
|
||||
$(this).find('.glyphicon-heart').removeClass('glyphicon-heart').addClass('glyphicon-list');
|
||||
}
|
||||
});
|
||||
},
|
||||
duration: 2000 // czas trwania animacji, możesz dostosować według potrzeb
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(document).on('click', '.product-observe', function() {
|
||||
var $clone = $(this).clone();
|
||||
|
||||
var pos = $(this).offset();
|
||||
var targetPos = $("#sidebar-handle").offset();
|
||||
|
||||
if (!targetPos) {
|
||||
console.error("Element .sidebar-handle not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
$clone.css({
|
||||
position: "absolute",
|
||||
top: pos.top,
|
||||
left: pos.left,
|
||||
zIndex: 9999
|
||||
});
|
||||
|
||||
$("body").append($clone);
|
||||
|
||||
$clone.animate({
|
||||
top: targetPos.top,
|
||||
left: targetPos.left
|
||||
}, 1000, function() {
|
||||
$clone.remove();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
{/literal}
|
||||
@@ -0,0 +1,177 @@
|
||||
<section id="product-observe-sidebar" class="product-list">
|
||||
|
||||
{foreach key=row item=product from=$results}
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-2 item-image-col">
|
||||
<div class="image">{$product.photo_small}</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-10">
|
||||
|
||||
<a class="close-icon" data-product="{$product.id}" style="float:right;"></a>
|
||||
|
||||
<div class="observe-full" style="float:right; padding: 5px 10px;">
|
||||
<svg style="width: 18px; height: 15px;" width="23" height="21" viewBox="0 0 23 21" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6.4592 1C3.44417 1 1 3.81598 1 7.28966C1 7.97227 1.09438 8.62947 1.26893 9.2449C1.71875 10.8309 2.96968 12.0161 4.1733 13.1426L11.5 20L18.8267 13.1426C20.0303 12.0161 21.2813 10.8309 21.7311 9.2449C21.9056 8.62947 22 7.97227 22 7.28966C22 3.81598 19.5558 1 16.5408 1C14.2698 1 12.3227 2.59762 11.5 4.87056C10.6773 2.59762 8.73018 1 6.4592 1Z" stroke-width="2" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
{$product.name}
|
||||
|
||||
{if $show_price==1 && $product.check_price!=1}
|
||||
{if $price_view=='net_gross'}
|
||||
<div class="double_price price">
|
||||
<span class="nowrap">{$product.price_net}</span>
|
||||
<div class="minor_price nowrap">({$product.price})</div>
|
||||
</div>
|
||||
{elseif $price_view=='only_gross'}
|
||||
<div class="price nowrap">{$product.price}</div>
|
||||
{elseif $price_view=='only_net'}
|
||||
<div class="price nowrap">{$product.price_net}</div>
|
||||
{elseif $price_view=='gross_net'}
|
||||
<div class="double_price price">
|
||||
<span class="nowrap">{$product.price}</span>
|
||||
<div class="minor_price nowrap">({$product.price_net})</div>
|
||||
</div>
|
||||
{/if}
|
||||
{if $product.basic_price}
|
||||
<div class="text-muted basic_price text-center"><i>{$product.basic_price.quantity} ( {$product.basic_price.brutto} {__ text="za"} {$product.basic_price.for_quantity} )</i></div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<div class="discount-old_price">
|
||||
{if $show_discount==1 && $product.discount!=0 && $product.check_price!=1}
|
||||
<div class="discount">{__ text="Rabat"}: <span class="nowrap">{$product.discount} %</span></div>
|
||||
{elseif ($show_old_price==1 && $product.check_price!=1)}
|
||||
{if $product.check_old_price==1}
|
||||
<div class="old_price price nowrap">
|
||||
{if ($price_view=='net_gross' || $price_view=='only_net')}
|
||||
{$product.old_price_net}
|
||||
{else}
|
||||
{$product.old_price}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{/foreach}
|
||||
|
||||
{if $results|@count >= 2}
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div id="remove-all-observe" class="sidebar-header-trash">
|
||||
{__ text="Usuń wszystko"} <span class="glyphicon glyphicon-trash"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</section>
|
||||
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$(document).ready(function() {
|
||||
|
||||
checkObserveProduct();
|
||||
|
||||
$('#product-observe-sidebar .close-icon').on('click', function(e){
|
||||
|
||||
e.preventDefault(); // Zapobiega domyślnej akcji (nawigacji do strony linka)
|
||||
let productValue = $(this).data('product');
|
||||
let row = $(this).closest('.row');
|
||||
|
||||
$.get('{/literal}{url_for internal=stProductObserveFrontend/removeFromObserve}{literal}', { 'product_id':productValue}, function(data)
|
||||
{
|
||||
setTimeout(function() {
|
||||
|
||||
row.remove();
|
||||
setObserveNoForProduct(productValue);
|
||||
|
||||
$.get('{/literal}{url_for internal=stProductObserveFrontend/showProductsSidebar}{literal}', function(html)
|
||||
{
|
||||
setTimeout(function() {
|
||||
$('#product-tab-observe-sidebar').html(html);
|
||||
}, 200); // 500 milisekund = 0,5 sekundy
|
||||
});
|
||||
|
||||
}, 200); // 500 milisekund = 0,5 sekundy
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
function setObserveNoForProduct(id) {
|
||||
var elements = $('div[data-product-observe="' + id + '"]');
|
||||
|
||||
elements.each(function() {
|
||||
var $element = $(this);
|
||||
|
||||
if ($element.hasClass('observe-yes')) {
|
||||
|
||||
$element.removeClass('observe-yes').addClass('observe-no');
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function setObserveYesForProduct(id) {
|
||||
var elements = $('div[data-product-observe="' + id + '"]');
|
||||
|
||||
elements.each(function() {
|
||||
var $element = $(this);
|
||||
|
||||
if ($element.hasClass('observe-no')) {
|
||||
|
||||
$element.removeClass('observe-no').addClass('observe-yes');
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function checkObserveProduct()
|
||||
{
|
||||
$.get('{/literal}{url_for internal=stProductObserveFrontend/observeProductsIds}{literal}', function(html)
|
||||
{
|
||||
setTimeout(function() {
|
||||
resetObserve();
|
||||
|
||||
let products_observe = html;
|
||||
|
||||
for (var key in products_observe) {
|
||||
if (products_observe.hasOwnProperty(key)) {
|
||||
//console.log(products_observe[key]);
|
||||
setObserveYesForProduct(products_observe[key])
|
||||
}
|
||||
}
|
||||
}, 200); // 500 milisekund = 0,5 sekundy
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function resetObserve() {
|
||||
var elements = $('.product-observe');
|
||||
|
||||
elements.each(function() {
|
||||
var $element = $(this);
|
||||
if ($element.hasClass('observe-yes')) {
|
||||
$element.removeClass('observe-yes').addClass('observe-no');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
Reference in New Issue
Block a user