Page 1 of 1
Ideas and fixes
Posted: 21 Aug 2017, 12:19
by hello.world
Hello. I use Phoca Cart extension and want to write couple of ideas and fixes.
Thanks the author for Phoca extensions. They are fine and flexible.
Re: Ideas and fixes
Posted: 21 Aug 2017, 12:45
by hello.world
Search module:
File: administrator\components\com_phocacart\libraries\phocacart\search\search.php
Bug: search doesn't work by couple of words because the same variable $wheres uses inside and outside foreach. Also if variable $in contains spaces then the search ignores search query and shows all producs:
Fixed code:
Code: Select all
$words = explode(' ', $in);
$wheres = array();
foreach ($words as $word) {
if (!$word = trim($word)) {
continue;
}
$word = $db->quote('%'.$db->escape($word, true).'%', false);
$_wheres = array();
$_wheres[] = 'a.title LIKE '.$word;
$_wheres[] = 'a.alias LIKE '.$word;
$_wheres[] = 'a.metakey LIKE '.$word;
$_wheres[] = 'a.metadesc LIKE '.$word;
$_wheres[] = 'a.description LIKE '.$word;
$wheres[] = implode(' OR ', $_wheres);
}
Re: Ideas and fixes
Posted: 21 Aug 2017, 13:13
by hello.world
Currently I want to have right column only on category page and items page. And don't want to show it on categories listing, product page, checkout page. But all those pages Joomla see as one Phoca Cart component. I propose to make section with text fields in the component configurations: Categories List, Category View, Items Page, Product Page, etc. In those fields can set the position names that need to disable for page type.
Now I did it separately for product page in view-file: components\com_phocacart\views\item\tmpl\default.php
Code: Select all
foreach (array('position-3', 'position-6', 'position-8') as $position) {
$modules = JModuleHelper::getModules($position);
foreach ($modules as $module) {
$module->position = 'empty';
}
}
Also I set to registry that it is product page:
Code: Select all
$registry = \Joomla\Registry\Registry::getInstance('pc');
$registry->def('is_product_page', true);
So, I can check it in other places and hide or show specific elements on product page.
Re: Ideas and fixes
Posted: 21 Aug 2017, 13:24
by hello.world
Phoca Filter and Search have own page with products (items page). But if open product page and click to the category "Back" button, we get category page instead previous page with chosen filters. My current fix for it:
In file: components\com_phocacart\views\item\tmpl\default.php
After lines:
Code: Select all
$linkUp = JRoute::_(PhocacartRoute::getCategoryRoute($this->category[0]->id, $this->category[0]->alias));
$linkUpText = $this->category[0]->title;
I added additional check of the previous page:
Code: Select all
$current = JUri::getInstance();
$referer = JUri::getInstance();
$referer->parse(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
if ($referer->getHost() === $current->getHost()
&& false !== mb_strpos($referer->getPath(), '/items')
&& ($referer->getVar('s') || $referer->getVar('search'))
) {
$linkUp = JRoute::_($referer);
$linkUpText .= ' - back to search results';
}
Re: Ideas and fixes
Posted: 21 Aug 2017, 13:54
by hello.world
The extension allows to sort groups of specifications on product page. But it doesn't sort the specifications inside group. The order of them can changing on different product pages. Will better to add additional options for every specification:
1) Rows Ordering (by title, by alias, by value, etc.)
2) Show in Filter (Yes or No)
3) Use for Search (Yes or No)
4) Default options that will show during creating new product with specifications. Because currently hard to configure values and aliases of specifications for Product Filter.
The temporary solutions for me are:
1) Specifications are sorted on product page:
In file: components\com_phocacart\views\item\tmpl\default.php
After lines:
Code: Select all
foreach($this->t['specifications'] as $k => $v) {
if(isset($v[0]) && $v[0] != '') {
$tabO .= '<h4 class="ph-spec-group-title">'.$v[0].'</h4>';
unset($v[0]);
}
if (!empty($v)) {
I added:
Code: Select all
uasort($v, function($a, $b) use ($k) {
if (2 === $k) {
// Specification with ID 2 uses value for sort.
return $a['value'] > $b['value'];
} else {
// Other specifications use title for sort.
return $a['title'] > $b['title'];
}
});
Re: Ideas and fixes
Posted: 22 Aug 2017, 19:35
by hello.world
On the product listing. If enable icons (add to cart, wishlist, compare) that show on hover and disable standard "Add to cart" button, the icon stops working. I use ajax method with popup.
Re: Ideas and fixes
Posted: 23 Aug 2017, 16:21
by Jan
Hi, thank you very much for your ideas.
1) Search module: I will take a look at it
2) Module position: Maybe it is better to modify the module so it will be not displayed on some views, example:
$app = JFactory::getApplication();
$option = $app->input->get( 'option', '', 'string' );
$view = $app->input->get( 'view', '', 'string' );
if ($option == 'com_phocacart' && ($view == 'items' || $view == 'category')) {
return;
}
3) Back button - in fact it is not a "back button" (history) but "up button" which means going back from product to its category - not going back to your previously displayed page. The problem is, you can get the product view without any history (e.g. from search engine) so you always have the right link to go up: from product to category (product list) to categories (category list)
4) Specifications - not sure if I understand correctly what you exactly mean with "hard to configure values and aliases of specifications for Product Filter"
5) product listing, ajax: which version do you use, do you use 9.1 RC? This should work without having standard button. Do you get any javascript error in console?
Jan
Re: Ideas and fixes
Posted: 06 Sep 2017, 16:37
by Jan
Hi,
- Search module - changed in 3.0.0 RC9.2
- Modules - filtering on which page they will be displayed - I think the best way will be to set option in module to display in specific view only (see previous post)
- Disable standard "Add to cart" button - should be fixed in 3.0.0 RC9.2
See:
https://www.phoca.cz/download/category/ ... -component