Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Shopping Cart Sidebox Grouping

Shopping Cart Sidebox Grouping

Views: 490

Results 1 to 3 of 3
17 Nov 2011, 10:08 PM
#1
sappster avatar

sappster

New Zenner

Join Date:
Jul 2011
Posts:
13
Plugin Contributions:
0

Shopping Cart Sidebox Grouping

Does anyone know how to rearrange the Shopping Cart sidebox so that when I buy my products they will be separated into their subcategories in the sidebox? I see the php file under sideboxes, but I'm not sure how to write the code to group them by category id.

example: I sell cabinets so I want in my shopping cart sidebox for all the base cabinets to be grouped together and all the wall cabinets to be grouped together even if the customer buys a base, then wall, then 2 walls, then 3 bases. I want them to be grouped by their ID.

18 Nov 2011, 6:54 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Shopping Cart Sidebox Grouping

I'm not sure if the sidebox code has the product's cPath info available, but there is a zen_ function to look up a product id's master category id. You could add that as a new field to the output array, then sort the array contents by the value of that field.

18 Nov 2011, 3:53 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Shopping Cart Sidebox Grouping

If you can sort by categories_id, products_name for this ... you could customize the file:
/includes/templates/your_template_dir/sideboxes/tpl_shopping_cart.php

and add the code in RED to do this:

    $products = $_SESSION['cart']->get_products();

// bof: sort by master_categories_id and products_name
    function sort_products_category_name($a, $b) {
      $retval = strnatcmp($a['category'], $b['category']);
      if(!$retval) return strnatcmp($a['name'], $b['name']);
        return $retval;
      }

      usort($products, 'sort_products_category_name');
// eof: sort by master_categories_id and products_name

    for ($i=0, $n=sizeof($products); $i<$n; $i++) {

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!