Category / Product listing + one add to cart butto

  • Posts: 21
  • Thank you received: 0
9 years 7 months ago #229519

-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.4.8

How to implement this?

Default views does not allow this.

This is probably a must feature for any B2B ecommerce components and order forms as add to cart buttons takes too much time for customers when listings are 100+ items.

Last edit: 9 years 7 months ago by gigi974.

Please Log in or Create an account to join the conversation.

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 7 months ago #229566

Hi,

You say that default views do not allow this, but they do. You just need to change the "Display the quantity field on the product page" setting to "Global on listings" in the HikaShop configuration.

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 7 months ago #229645

Hi,

this works, but it seems to be global on all products/category listings, not just a specific one for instance. We are trying to do B2B order form within B2C website (separated by user rights).

So, for B2C it must exist as is, only B2B specifical one needs to have one add to cart only.

Is there any possible solution? (dont want to have separated websites)

Please Log in or Create an account to join the conversation.

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 7 months ago #229665

Hi,

Well, you can force that option based on the category you're on with a small code addition.
Edit the file "listing" of the view "product" via the menu Display>Views and add such code at the top:

<?php  if(in_array($this->element->category_id,array(XXX, YYY))){ $this->params->set('show_quantity_field',2); } ?>
where XXX and YYY can be replaced by the id of the categories where you want that option changed to "global on listings".

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 7 months ago #229764

Hi,

this puts add to cart button only to each product.

The idea is:

Product Quantity
prod1 qty1
prod2 qty2
... ...
prodN qtyN

and at the end of order form

ADD TO CART (button only)

How we can do this?

THX
GG

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.6.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2016 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?>
<?php  if(in_array($this->element->category_id,array(200))){ $this->params->set('show_quantity_field',2); } echo '#1'; ?>
<?php
if(!empty($this->rows)){
	$app = JFactory::getApplication();
	$pagination = $this->config->get('pagination','bottom');
	if(in_array($pagination,array('top','both')) && $this->params->get('show_limit') && $this->pageInfo->elements->total){ $this->pagination->form = '_top'; ?>
	<form action="<?php echo hikashop_currentURL(); ?>" method="post" name="adminForm_<?php echo $this->params->get('main_div_name').$this->category_selected;?>_top">
		<div class="hikashop_products_pagination hikashop_products_pagination_top">
		<?php echo $this->pagination->getListFooter($this->params->get('limit')); ?>
		<span class="hikashop_results_counter"><?php echo $this->pagination->getResultsCounter(); ?></span>
		</div>
		<input type="hidden" name="filter_order_<?php echo $this->params->get('main_div_name').$this->category_selected;?>" value="<?php echo $this->pageInfo->filter->order->value; ?>" />
		<input type="hidden" name="filter_order_Dir_<?php echo $this->params->get('main_div_name').$this->category_selected;?>" value="<?php echo $this->pageInfo->filter->order->dir; ?>" />
		<?php echo JHTML::_( 'form.token' ); ?>
	</form>
	<?php } ?>
	<div class="hikashop_products">
	<?php
		if ($this->config->get('show_quantity_field')>=2) { ?>
			<form action="<?php echo hikashop_completeLink('product&task=updatecart'); ?>" method="post" name="hikashop_product_form_<?php echo $this->params->get('main_div_name'); ?>" enctype="multipart/form-data">
		<?php }
		$columns = 1; ?>
		<table class="hikashop_products_table adminlist table table-striped table-hover" cellpadding="1">
			<thead>
				<tr>
					<?php if($this->config->get('thumbnail')){ $columns++; ?>
						<th class="hikashop_product_image title" align="center">
							<?php echo JText::_( 'HIKA_IMAGE' );?>
						</th>
					<?php } ?>
					<th class="hikashop_product_name title" align="center">
						<?php echo JText::_( 'PRODUCT' );?>
					</th>

					<?php if ($this->config->get('show_code')) { $columns++;?>
						<th class="hikashop_product_code title" align="center">
							<?php echo JText::_( 'PRODUCT_CODE' ); ?>
						</th>
					<?php } ?>
					<?php if($this->params->get('show_vote_product')){ ?>
						<th class="hikashop_product_vote title" align="center">
							<?php echo JText::_('VOTE'); ?>
						</th>
					<?php } ?>
					<?php
						if($this->params->get('show_price','-1')=='-1'){
							$config =& hikashop_config();
							$this->params->set('show_price',$config->get('show_price'));
						}
						if($this->params->get('show_price')){ $columns++; ?>
						<th class="hikashop_product_price title" align="center">
							<?php echo JText::_('PRICE'); ?>
						</th>
					<?php } ?>
					<?php if($this->params->get('add_to_cart') || $this->params->get('add_to_wishlist')){ $columns++; ?>
						<th class="hikashop_product_add_to_cart title" align="center">
						</th>
					<?php } ?>
					<?php if(JRequest::getVar('hikashop_front_end_main',0) && JRequest::getVar('task')=='listing' && $this->params->get('show_compare')) { $columns++; ?>
						<th class="hikashop_product_compare title" align="center">
						</th>
					<?php } ?>
				</tr>
			</thead>
			<tfoot>
				<tr>
					<td colspan="<?php echo $columns; ?>">

					</td>
				</tr>
			</tfoot>
			<tbody>
			<?php foreach($this->rows as $row){
				$this->row =& $row;
				$height = $this->params->get('image_height');
				$width = $this->params->get('image_width');
				if(empty($height)) $height=$this->config->get('thumbnail_y');
				if(empty($width)) $width=$this->config->get('thumbnail_x');
				$divWidth=$width;
				$divHeight=$height;
				$this->image->checkSize($divWidth,$divHeight,$row);
				$link = hikashop_contentLink('product&task=show&cid='.$this->row->product_id.'&name='.$this->row->alias.$this->itemid.$this->category_pathway,$this->row);
				if($row->product_parent_id != 0 && isset($row->main_product_quantity_layout)){
					$row->product_quantity_layout = $row->main_product_quantity_layout;
				}
				if(!empty($row->product_quantity_layout) &&  $row->product_quantity_layout != 'inherit'){
					$qLayout = $row->product_quantity_layout;
				}else{
					$categoryQuantityLayout = '';
					if(!empty($row->categories) ) {
						foreach($row->categories as $category) {
							if(!empty($category->category_quantity_layout) && $this->quantityDisplayType->check($category->category_quantity_layout, $app->getTemplate())) {
								$categoryQuantityLayout = $category->category_quantity_layout;
								break;
							}
						}
					}
					if(!empty($categoryQuantityLayout) && $categoryQuantityLayout != 'inherit'){
						$qLayout = $categoryQuantityLayout;
					}else{
						$qLayout = $this->config->get('product_quantity_display','show_default');
					}
				}
				JRequest::setVar('quantitylayout',$qLayout);
				?>
				<tr>
					<?php if($this->config->get('thumbnail')){ ?>
						<td class="hikashop_product_image_row">
							<div style="height:<?php echo $divHeight;?>px;text-align:center;clear:both;" class="hikashop_product_image">
								<div style="position:relative;text-align:center;clear:both;width:<?php echo $divWidth;?>px;margin: auto;" class="hikashop_product_image_subdiv">
								<?php if($this->params->get('link_to_product_page',1)){ ?>
									<a href="<?php echo $link;?>" title="<?php echo $this->escape($this->row->product_name); ?>">
								<?php }
									$image_options = array('default' => true,'forcesize'=>$this->config->get('image_force_size',true),'scale'=>$this->config->get('image_scale_mode','inside'));
									$img = $this->image->getThumbnail(@$this->row->file_path, array('width' => $this->image->main_thumbnail_x, 'height' => $this->image->main_thumbnail_y), $image_options);
									if($img->success) {
										echo '<img class="hikashop_product_listing_image" title="'.$this->escape(@$this->row->file_description).'" alt="'.$this->escape(@$this->row->file_name).'" src="'.$img->url.'"/>';
									}
									$main_thumb_x = $this->image->main_thumbnail_x;
									$main_thumb_y = $this->image->main_thumbnail_y;
									if($this->params->get('display_badges',1)){
										$this->classbadge->placeBadges($this->image, $this->row->badges, -10, 0);
									}
									$this->image->main_thumbnail_x = $main_thumb_x;
									$this->image->main_thumbnail_y = $main_thumb_y;

								if($this->params->get('link_to_product_page',1)){ ?>
									</a>
								<?php } ?>
								</div>
							</div>
						</td>
					<?php } ?>
					<td class="hikashop_product_name_row">
						<span class="hikashop_product_name">
							<?php if($this->params->get('link_to_product_page',1)){ ?>
								<a href="<?php echo $link;?>">
							<?php }
								echo $this->row->product_name;
							if($this->params->get('link_to_product_page',1)){ ?>
								</a>
							<?php } ?>
						</span>
						<?php if(!empty($this->row->extraData->afterProductName)) { echo implode("\r\n",$this->row->extraData->afterProductName); } ?>
					</td>

					<?php if ($this->config->get('show_code')){ ?>
						<td class="hikashop_product_code_row">
							<?php if($this->params->get('link_to_product_page',1)){ ?>
								<a href="<?php echo $link;?>">
							<?php }
							echo $this->row->product_code;
							if($this->params->get('link_to_product_page',1)){ ?>
								</a>
							<?php } ?>
						</td>
					<?php } ?>
					<?php if($this->params->get('show_vote_product')){ ?>
						<td class="hikashop_product_vote_row">
							<?php
							$this->row =& $row;
							$this->setLayout('listing_vote');
							echo $this->loadTemplate();
							?>
						</td>
					<?php } ?>
					<?php
						if($this->params->get('show_price','-1')=='-1'){
							$config =& hikashop_config();
							$this->params->set('show_price',$config->get('show_price'));
						}
						if($this->params->get('show_price')){ ?>
						<td class="hikashop_product_price_row">
						<?php
							$this->setLayout('listing_price');
							echo $this->loadTemplate();
						?>
						</td>
					<?php } ?>

					<?php if($this->params->get('add_to_cart')){ ?>
						<td class="hikashop_product_add_to_cart_row">
							<?php
								$this->setLayout('add_to_cart_listing');
								echo $this->loadTemplate();
							?>
						</td>
					<?php } ?>

					<?php
					if(JRequest::getVar('hikashop_front_end_main',0) && JRequest::getVar('task')=='listing' && $this->params->get('show_compare')) {
						if( $this->params->get('show_compare') == 1 ) {
					?>
						<td class="hikashop_product_compare_row">
							<?php
							$js = 'setToCompareList('.$this->row->product_id.',\''.$this->escape($this->row->product_name).'\',this); return false;';
							echo $this->cart->displayButton(JText::_('ADD_TO_COMPARE_LIST'),'compare',$this->params,$link,$js,'',0,1,'hikashop_compare_button');
							?>
						</td>
					<?php } else { ?>
						<td class="hikashop_product_compare_row">
							<input type="checkbox" class="hikashop_compare_checkbox" id="hikashop_listing_chk_<?php echo $this->row->product_id;?>" onchange="setToCompareList(<?php echo $this->row->product_id;?>,'<?php echo $this->escape($this->row->product_name); ?>',this);"><label for="hikashop_listing_chk_<?php echo $this->row->product_id;?>"><?php echo JText::_('ADD_TO_COMPARE_LIST'); ?></label>
						</td>
					<?php }
					} ?>
				</tr>
			<?php } ?>
			</tbody>
		</table>
		<?php if ($this->config->get('show_quantity_field')>=2) {
				$this->ajax = 'if(hikashopCheckChangeForm(\'item\',\'hikashop_product_form_'.$this->params->get('main_div_name').'\')){ return hikashopModifyQuantity(\'\',field,1,\'hikashop_product_form_'.$this->params->get('main_div_name').'\'); } return false;';
				$this->row = new stdClass();
				$this->row->product_quantity = -1;
				$this->row->product_min_per_order = 0;
				$this->row->product_max_per_order = -1;
				$this->row->product_sale_start = 0;
				$this->row->product_sale_end = 0;
				$this->row->prices = array('filler');
				$this->setLayout('quantity');
				echo $this->loadTemplate();
				if(!empty($this->ajax) && $this->config->get('redirect_url_after_add_cart','stay_if_cart')=='ask_user'){ ?>
					<input type="hidden" name="popup" value="1"/>
				<?php } ?>
				<input type="hidden" name="hikashop_cart_type_0" id="hikashop_cart_type_0" value="cart"/>
				<input type="hidden" name="add" value="1"/>
				<input type="hidden" name="ctrl" value="product"/>
				<input type="hidden" name="task" value="updatecart"/>
				<input type="hidden" name="return_url" value="<?php echo urlencode(base64_encode(urldecode($this->redirect_url)));?>"/>
				</form>
		<?php }
		if(in_array($pagination,array('bottom','both')) && $this->params->get('show_limit') && $this->pageInfo->elements->total){ $this->pagination->form = '_bottom'; ?>
			<form action="<?php echo hikashop_currentURL(); ?>" method="post" name="adminForm_<?php echo $this->params->get('main_div_name').$this->category_selected;?>_bottom">
				<div class="hikashop_products_pagination hikashop_products_pagination_bottom">
				<?php echo $this->pagination->getListFooter($this->params->get('limit')); ?>
				<span class="hikashop_results_counter"><?php echo $this->pagination->getResultsCounter(); ?></span>
				</div>
				<input type="hidden" name="filter_order_<?php echo $this->params->get('main_div_name').$this->category_selected;?>" value="<?php echo $this->pageInfo->filter->order->value; ?>" />
				<input type="hidden" name="filter_order_Dir_<?php echo $this->params->get('main_div_name').$this->category_selected;?>" value="<?php echo $this->pageInfo->filter->order->dir; ?>" />
				<?php echo JHTML::_( 'form.token' ); ?>
			</form>
		<?php } ?>
	</div>
<?php } ?>

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 7 months ago #229766

OK, I can hide add to cart thru product listing options, but there's still no qty field and add to cart on the bottom of the list.

BTW how can I change the size of the pics only on that specific product list (table not div)? Basically I'd like to have them resized by hika to save on loading times and to leave any other size intact.

THX

Please Log in or Create an account to join the conversation.

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 7 months ago #229773

Hi,

Try like that then:

<?php  if(in_array($this->element->category_id,array(XXX, YYY))){ $this->config->set('show_quantity_field',2); } ?>

To change the size of thumbnails only for one menu item, go in the menu manager of Joomla, edit your menu item, and in the "product options" tab, fill in the size you want for the images in the corresponding fields.

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 7 months ago #229870

Hi,

yes it's working now as expected, thx! I saw that setting for DIV list regarding image is valid for TABLE too.

Maybe one thing, add to cart button has also qty field displayed (with value 1), it is actually not needed, can this be removed?

Also there is one notice (I have turned errors on)

Notice: Trying to get property of non-object in /home/.../components/com_hikashop/views/product/tmpl/quantity.php on line 62

Can this be of any problem (it is only notice).

THX

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 7 months ago #229889

Additional question,

if I have structure

Main Category
Subcategory1 -> Products 1,2,3...
Subcategory2 -> Products 1,2,3...
...
SubcategoryN -> Products 1,2,3...

and I want to have product listing on main category (to have product grouped on the listing), it will show add to cart after each subcategory.

Is there a way to have only one add to cart button on the end of the listing?

THX

Please Log in or Create an account to join the conversation.

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 7 months ago #229892

Hi,

Can you give a link to the page where there is a the quantity field that you don't want ?

The notice can be ignored.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
9 years 7 months ago #230075

Hi,

Please grant the access to give us backend access.
That way we will be able to see how you setup the menu and debug that issue.

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 7 months ago #230130

I'll send the details to support email...

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
9 years 6 months ago #230506

Hi,

As you added a specific condition in the view "product / show_tabular" it was forcing a configuration.
But this configuration is applied only on the current view, and that's why you were not having the desired layout.

So I edited the view "product / show_quantity" to apply a specific rule based on the menu id.

We will check to improve that part on our side.

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 6 months ago #230602

Hi, I saw that now there is no qty input at add to cart button, which is correct.

What is NOT correct is, as already explained above, is add to cart button after each (sub)category.

We want only 1 (one) add to cart button at the bootom of product list eg...


Category Products 1
Category Products 2
....
Category Products N
ADD TO CART

Thank you

Last edit: 9 years 6 months ago by gigi974.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
9 years 6 months ago #230614

Hi,

This is not possible by default as every products of a category are in a form, so there is as many forms as categories listed and the "add to cart" button needs to be present in each form.

It will require code editions to have what you are looking for.

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 6 months ago #230700

This would any seious B2B system need, so I wonder if you can add on to do list or where to alter override original files to get the job done?

Thank you!

Last edit: 9 years 6 months ago by gigi974.

Please Log in or Create an account to join the conversation.

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #230739

Hi,

You can edit the file "listing" of the view "product" in order to change that. If you're a developer it shouldn't be a problem.

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
9 years 6 months ago #230754

If I was developer I guess I woulndn't ask you for help,

Please Log in or Create an account to join the conversation.

  • Posts: 84307
  • Thank you received: 13701
  • MODERATOR
9 years 6 months ago #230756

We regularily have developers asking us for hints on how to change something. While this is outside of user support, we gladly answer them with these hints (like which file should be changed).
We even provide some code modifications when it's only one or two lines to modify.
However, user support is not about spending a few hours developing and testing something for someone. That's custom development. If you're not a developer yourself, you can contact our partners:
www.hikashop.com/home/our-partners.html
They will be able to implement such modification for you with the hints we gave you.
I hope you can understand our point of view.

Please Log in or Create an account to join the conversation.

Time to create page: 0.089 seconds
Powered by Kunena Forum