[Skip to main content](#vessel-content)

#   Single Add to Cart button when Grouped By Category

##

- **[matrix](/forum/user/30418-matrix "View matrix's Profile")**
- [![matrix's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/30418-matrix "View matrix's Profile") Topic Author
- [ Offline](/forum/user/30418-matrix)

Less More

- Posts: 13
- Thank you received: 1
-
-

10 years 10 months ago -  10 years 10 months ago [\#224435](#224435) by [matrix](/forum/user/30418-matrix "View matrix's Profile")  *[Single Add to Cart button when Grouped By Category](/forum/26-product-category-display/881149-single-add-to-cart-button-when-grouped-by-category#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.")* was created by *[matrix](/forum/user/30418-matrix "View matrix's Profile")*

-- 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](https://hikashop.com/forum/product-category-display/869215-single-add-to-cart-button-on-products-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.
[ ![No&#95;subcategory&#95;listing.jpg](/forum/attachment/28508) ](/forum/attachment/28508 "...ry&#95;listing.jpg")

And when grouped by subcategory
[ ![Grouped&#95;by&#95;category.jpg](/forum/attachment/28509) ](/forum/attachment/28509 "...y&#95;category.jpg")

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.

- [ ![No&#95;subcategory&#95;listing.jpg](/forum/attachment/28508) ](/forum/attachment/28508 "...ry&#95;listing.jpg") [ ](/forum/attachment/28508?download=1 "...ry&#95;listing.jpg")
- [ ![Grouped&#95;by&#95;category.jpg](/forum/attachment/28509) ](/forum/attachment/28509 "...y&#95;category.jpg") [ ](/forum/attachment/28509?download=1 "...y&#95;category.jpg")

Last edit: 10 years 10 months ago by [matrix](/forum/user/30418-matrix "View matrix's Profile"). Reason: Typo in topic

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODExNDktc2luZ2xlLWFkZC10by1jYXJ0LWJ1dHRvbi13aGVuLWdyb3VwZWQtYnktY2F0ZWdvcnk/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

10 years 10 months ago [\#224464](#224464) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Single Add to Cart button when Grouped By Category](/forum/26-product-category-display/881149-single-add-to-cart-button-when-grouped-by-category#224464 "-- 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.")*

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: Code:

if ($this-&gt;config-&gt;get('show_quantity_field')&gt;=2) {

And move it in the "listing" view around the following foreach: Code:

foreach($this-&gt;categories as $category) { if(empty($category['products'])) continue; $this-&gt;rows = array(); foreach($allrows as $p) { if(in_array($p-&gt;product_id, $category['products'])) $this-&gt;rows[] = $p; } $this-&gt;params-&gt;set('main_div_name', $main_div_name.'_'.$category['category']-&gt;category_id); $this-&gt;setLayout('listing'); $html = $this-&gt;loadTemplate($layout_type); if(!empty($html)) { if(!empty($htmlFilter) &amp;&amp; @$_GET['task']=='category') echo $htmlFilter; ?&gt; &lt;h2&gt;&lt;?php echo $category['category']-&gt;category_name; ?&gt;&lt;/h2&gt; &lt;div class="hikashop_products_listing"&gt; &lt;?php if(JRequest::getVar('hikashop_front_end_main',0) &amp;&amp; JRequest::getVar('task')=='listing' &amp;&amp; $this-&gt;params-&gt;get('show_compare')) { ?&gt; &lt;div id="hikashop_compare_zone" class="hikashop_compare_zone"&gt; &lt;?php $empty=''; $params = new HikaParameter($empty); echo $this-&gt;cart-&gt;displayButton(JText::_('COMPARE_PRODUCTS'),'compare_button',$params,'#','compareProducts();return false;','style="display:none;" id="hikashop_compare_button"',0,1,' hikashop_compare_button'); ?&gt; &lt;/div&gt; &lt;?php } echo $html; ?&gt; &lt;/div&gt; &lt;?php } }

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODExNDktc2luZ2xlLWFkZC10by1jYXJ0LWJ1dHRvbi13aGVuLWdyb3VwZWQtYnktY2F0ZWdvcnk/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.098 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
