Single Add to Cart button when Grouped By Category

  • Posts: 13
  • Thank you received: 1
9 years 5 months ago #224435

-- HikaShop version -- : 2.6.0
-- Joomla version -- : 3.4.0
-- PHP version -- : 5.4

Hi,

My question is similar to the thread hikashop.com/forum/product-category-disp...roducts-listing.html , however that one is locked apparently so i am creating a new one here.

In my product display menu, I want a list of products, grouped by subcategory, with a single add to cart button at the end. I have done the required configuration, but I am getting a add to cart button at the end of each category group, not the page. Kindly refer to the two attachements.

This is when I have no subcategory listing.



And when grouped by subcategory


What i want is to have the products grouped, but only one add to cart button at the very end of the page.

Any pointers, including code modifications would be very helpful.

Thank you.

Attachments:
Last edit: 9 years 5 months ago by matrix. Reason: Typo in topic

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

  • Posts: 13201
  • Thank you received: 2322
9 years 5 months ago #224464

Hi,

This will not be possible only via settings, it will require some views editions.

The views to edit will be "product / listing_table" and "product / listing".
Globally what need to be done is to have only one HTML form for all the products instead of one per category as it is currently the case. And so display only one add to cart product.
So in the view "listing_table" you will have to remove the code adding the HTML form and the code displaying the add to cart button, so the code between the if condition:

if ($this->config->get('show_quantity_field')>=2) {
And move it in the "listing" view around the following foreach:
	foreach($this->categories as $category) {
		if(empty($category['products']))
			continue;

		$this->rows = array();
		foreach($allrows as $p) {
			if(in_array($p->product_id, $category['products']))
				$this->rows[] = $p;
		}

		$this->params->set('main_div_name', $main_div_name.'_'.$category['category']->category_id);

		$this->setLayout('listing');
		$html = $this->loadTemplate($layout_type);
		if(!empty($html)) {
			if(!empty($htmlFilter) && @$_GET['task']=='category')
				echo $htmlFilter;
?>
	<h2><?php echo $category['category']->category_name; ?></h2>
	<div class="hikashop_products_listing">
<?php
		if(JRequest::getVar('hikashop_front_end_main',0) && JRequest::getVar('task')=='listing' && $this->params->get('show_compare')) {
?>
			<div id="hikashop_compare_zone" class="hikashop_compare_zone">
<?php
			$empty='';
			$params = new HikaParameter($empty);
			echo $this->cart->displayButton(JText::_('COMPARE_PRODUCTS'),'compare_button',$params,'#','compareProducts();return false;','style="display:none;" id="hikashop_compare_button"',0,1,' hikashop_compare_button');
?>
			</div>
<?php
		}
		echo $html;
?>
	</div>
<?php
		}
	}

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

Time to create page: 0.079 seconds
Powered by Kunena Forum