Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2012
    Posts
    12
    Plugin Contributions
    0

    Default 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/...&products_id=4

    Thanks in advance :)

  2. #2
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

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

    Quote Originally Posted by jelly8ean View Post
    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

  3. #3
    Join Date
    Nov 2012
    Posts
    12
    Plugin Contributions
    0

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

    Quote Originally Posted by RodG View Post
    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.

  4. #4
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

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

    Quote Originally Posted by jelly8ean View Post
    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).

    Quote Originally Posted by jelly8ean View Post
    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

  5. #5
    Join Date
    Nov 2012
    Posts
    12
    Plugin Contributions
    0

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

    Quote Originally Posted by jelly8ean View Post
    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?

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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:
    Code:
    <?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
    Code:
    <?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']; ?>&nbsp;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: v1.5.5]
    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!

  7. #7
    Join Date
    Nov 2012
    Posts
    12
    Plugin Contributions
    0

    Default 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)

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

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

    You are most welcome ...
    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: v1.5.5]
    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!

  9. #9
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

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

    Quote Originally Posted by jelly8ean View Post
    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. :)
    Last edited by RodG; 6 Feb 2013 at 07:46 AM.

  10. #10
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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 ...
    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: v1.5.5]
    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!

 

 

Similar Threads

  1. shopping cart - hide the Cart Quantity Update button when not needed
    By dause in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 1 Oct 2009, 04:28 AM
  2. How can I hide the "back to shopping" button?
    By heheno1 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 1 May 2009, 10:56 PM
  3. Can I hide categories to certain users?
    By Erume in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 18 Jul 2008, 11:52 AM
  4. hide prices in the shopping cart?
    By venera15 in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 9 Apr 2008, 07:37 AM
  5. How can I hide inventory warnings on shopping cart page?
    By John Vieth in forum General Questions
    Replies: 1
    Last Post: 26 Nov 2007, 02:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR