Forums / Setting Up Categories, Products, Attributes / Can I hide certain attributes in the shopping cart?

Can I hide certain attributes in the shopping cart?

Views: 766

Results 1 to 10 of 10
5 Feb 2013, 12:41 AM
#1
jelly8ean avatar

jelly8ean

New Zenner

Join Date:
Nov 2012
Posts:
12
Plugin Contributions:
0

Can I hide certain attributes in the shopping cart?

Hi,

I'm not altogether sure if this is the correct forum for this, so excuse me if it's not!

I have a product currently called "Design your own starter pack" that is priced by attribute. There are many options, and each contains a "None" attribute amongst other things.

When a user adds the product to the cart, I'd like those options left at "None" to be excluded from the list in the cart. Is this possible?

The product is at: http://www.catastart.co.uk/shopping/index.php?main_page=product_info&cPath=5&products_id=4

Thanks in advance :)

5 Feb 2013, 7:17 AM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Can I hide certain attributes in the shopping cart?

jelly8ean:

When a user adds the product to the cart, I'd like those options left at "None" to be excluded from the list in the cart. Is this possible?

It's certainly possible, but you'll need to do a little bit of custom coding to make it work.

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

5 Feb 2013, 12:05 PM
#3
jelly8ean avatar

jelly8ean

New Zenner

Join Date:
Nov 2012
Posts:
12
Plugin Contributions:
0

Re: Can I hide certain attributes in the shopping cart?

RodG:

It's certainly possible, but you'll need to do a little bit of custom coding to make it work.

Thanks Rod. Could you guide me on what to do..., or are there any alternatives like leaving blanks rather than using "None"...? Any help would be greatly appreciated.

5 Feb 2013, 1:53 PM
#4
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Can I hide certain attributes in the shopping cart?

jelly8ean:

Thanks Rod. Could you guide me on what to do...

Sorry, but this isn't one of those things that I'd 'know' how to do without having to dig around the code and basically do it for you (and I simply don't have time to do that).

jelly8ean:

or are there any alternatives like leaving blanks rather than using "None"...? Any help would be greatly appreciated.

I can't answer this either. There may be other ways to achieve what you desire, but nothing springs to mind at the moment.

All I can really tell you is that somewhere in the shipping cart page there will be a code loop that outputs the attributes data. The theory is that you'll just need to add a line of code within this loop to detect the 'None' value, and if/when found then simply don't output the data.

Probably the hardest part is to identify the page/code that contains the relevant code.

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

5 Feb 2013, 2:57 PM
#5
jelly8ean avatar

jelly8ean

New Zenner

Join Date:
Nov 2012
Posts:
12
Plugin Contributions:
0

Re: Can I hide certain attributes in the shopping cart?

jelly8ean:

Could you guide me on what to do...,

I'd seen the code in includes/templates/template_default/templates/tpl_shopping_cart_default.php, but have no idea what to do with it. I think it's this bit:

<?php echo $product['attributeHiddenField']; if (isset($product['attributes']) && is_array($product['attributes'])) { echo '<div class="cartAttribsList">'; echo '<ul>'; reset($product['attributes']); foreach ($product['attributes'] as $option => $value) { ?> <li><?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']); ?></li> <?php } echo '</ul>'; echo '</div>'; } ?>

Can anyone help?

5 Feb 2013, 3:34 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Can I hide certain attributes in the shopping cart?

This is a start on blocking the option_value_id for the various pages/email etc.

There will be a lot of places that you need to code for this and each set of code will use a different variable to test for ...

Let's say you want to block options_values_id 45 and 46 ...

Example, tpl_shopping_cart_default:

<?php
  echo $product['attributeHiddenField'];
  if (isset($product['attributes']) && is_array($product['attributes'])) {
  echo '<div class="cartAttribsList">';
  echo '<ul>';
    reset($product['attributes']);
    foreach ($product['attributes'] as $option => $value) {
?>
<?php // echo '<pre>'; echo var_dump($value); echo '</pre>'; ?>

<?php
if ($value['options_values_id'] == 45 || $value['options_values_id'] == 46) {
  // skip
} else {
?>
<li><?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']); ?></li>
<?php } ?>
<?php
    }
  echo '</ul>';
  echo '</div>';
  }
?>

Example, tpl_checkout_confirmation_default.php

<?php // now loop thru all products to display quantity and price ?>
<?php for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { ?>
        <tr class="<?php echo $order->products[$i]['rowClass']; ?>">
          <td  class="cartQuantity"><?php echo $order->products[$i]['qty']; ?> x</td>
          <td class="cartProductDisplay"><?php echo $order->products[$i]['name']; ?>
          <?php  echo $stock_check[$i]; ?>

<?php // if there are attributes, loop thru them and display one per line
    if (isset($order->products[$i]['attributes']) && sizeof($order->products[$i]['attributes']) > 0 ) {
    echo '<ul class="cartAttribsList">';
      for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
?>
<?php // echo '<pre>'; echo var_dump($order->products[$i]['attributes']); echo '</pre>'; ?>

<?php
if ($order->products[$i]['attributes'][$j]['value_id'] == 45 || $order->products[$i]['attributes'][$j]['value_id'] == 46) {
  // skip
} else {
?>
      <li><?php echo $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value'])); ?></li>
<?php } ?>
<?php
      } // end loop
      echo '</ul>';
    } // endif attribute-info
?>

Now you have emails, My History page(s), etc.

I would suggest leave them in there for the Admin so there is no question on what was ordered or not ordered by the customer ...

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!

5 Feb 2013, 3:51 PM
#7
jelly8ean avatar

jelly8ean

New Zenner

Join Date:
Nov 2012
Posts:
12
Plugin Contributions:
0

Re: Can I hide certain attributes in the shopping cart?

I would suggest leave them in there for the Admin so there is no question on what was ordered or not ordered by the customer ...

Haha, You've frightened me sufficiently with that code, as to agree with you! But it's really useful to see how it's put together.

Thanks for your time Ajeh

:o)

5 Feb 2013, 3:55 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Can I hide certain attributes in the shopping cart?

You are most welcome ... :smile:

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!

6 Feb 2013, 6:44 AM
#9
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Can I hide certain attributes in the shopping cart?

jelly8ean:

Haha, You've frightened me sufficiently with that code, as to agree with you! But it's really useful to see how it's put together.

Thanks for your time Ajeh

:o)

Don't let the Ajeh's code scare you. It is pretty much exactly the same as I'd have given you, but Ajeh has gone one step further and supplied you with the modifications needed for both the shopping cart page AND the confirmation emails. These don't necessarily have to be performed together.

What's more, if you take a close look at what Ajeh has provided you, you'll note that the code in black text is the existing code. All you need to do is locate that same code in your own files (Ajeh has even provided the filenames for you), then load the code into a text editor and just copy/paste the text that she has highlighted in red for you.

The only changes you'll need to make to Ajeh's example will be to the _values_id' numbers, and these can be easily found to suit your specific needs by viewing the option value manager (from your admin->catalog settings).

It has probably taken me longer to type this reply than it would take you to do the update.

Cheers
Rod.

ps. Please make a backup of the files before making changes... just in case something goes amiss.
pss. @Ajeh. Thanks for following this up... it has saved me having to take to time to provide a less useful reply. :)

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

7 Feb 2013, 2:22 AM
#10
ajeh avatar

ajeh

Oba-san

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

Re: Can I hide certain attributes in the shopping cart?

Not a problem ... I just figured a few examples of what all needs to be done might be easier than here is one example and have at it ... as the little nuances can be confusing at first without a few comparisons to peek at ... :cool:

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!