Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Feb 2012
    Posts
    67
    Plugin Contributions
    0

    red flag Conditional statement in shopping_cart

    Source: tpl_shopping_cart_default.php

    I added the following conditional statement to the sheet. It is meant to not show any row with a option_value of "None".
    Code:
    <?php
    
    if $value['products_options_values_name'] == "None" {
    } else {
    <li>
    
    <?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']); ?>
    
    </li>
    }
    
    ?>
    When the code is uploaded, the page doesn't load. Any thoughts?

  2. #2
    Join Date
    Feb 2010
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Conditional statement in shopping_cart

    Code:
    <?php
    
    if ($value['products_options_values_name'] == "None") {
    // show nothing
    } else {
    echo '<li>';
    echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']);
    echo '</li>';
    }
    
    ?>

  3. #3
    Join Date
    Feb 2012
    Posts
    67
    Plugin Contributions
    0

    Default Re: Conditional statement in shopping_cart

    Same outcome

  4. #4
    Join Date
    Feb 2012
    Posts
    67
    Plugin Contributions
    0

    Default Re: Conditional statement in shopping_cart

    I was thinking about this one all night... Wouldn't the change have to be made near the array? So the section as a whole changes, not just that one section seeing as the whole section is for the one array.

    I tried this but with the same outcome:

    Code:
    <?php
      foreach ($productArray as $product) {
    
    echo $value['products_options_values_name'];
    
    if ($value['products_options_values_name'] == "None") {
    echo "test";
    // show nothing
    }
    ?>
    
         <tr class="<?php echo $product['rowClass']; ?>">
           <td class="cartQuantity">
    <?php
      if ($product['flagShowFixedQuantity']) {
        echo $product['showFixedQuantityAmount'] . '<br /><span class="alert bold">' . $product['flagStockCheck'] . '</span><br /><br />' . $product['showMinUnits'];
      } else {
        echo $product['quantityField'] . '<br /><span class="alert bold">' . $product['flagStockCheck'] . '</span><br /><br />' . $product['showMinUnits'];
      }
    ?>
           </td>
           <td class="cartQuantityUpdate">
    <?php
      if ($product['buttonUpdate'] == '') {
        echo '' ;
      } else {
        echo $product['buttonUpdate'];
      }
    ?>
           </td>
           <td class="cartProductDisplay">
    <a href="<?php echo $product['linkProductsName']; ?>"><span id="cartImage" class="back"><?php echo $product['productsImage']; ?></span><span id="cartProdTitle"><?php echo $product['productsName'] 
    
    . '<span class="alert bold">' . $product['flagStockCheck'] . '</span>'; ?></span></a>
    <br class="clearBoth" />
    
    
    <?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>';
      }
    ?>
           </td>
           <td class="cartUnitDisplay"><?php echo $product['productsPriceEach']; ?></td>
           <td class="cartTotalDisplay"><?php echo $product['productsPrice']; ?></td>
           <td class="cartRemoveItemDisplay">
    <?php
      if ($product['buttonDelete']) {
    ?>
               <a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, 'action=remove_product&product_id=' . $product['id']); ?>"><?php echo zen_image($template->get_template_dir(ICON_IMAGE_TRASH, 
    
    DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . ICON_IMAGE_TRASH, ICON_TRASH_ALT); ?></a>
    <?php
      }
      if ($product['checkBoxDelete'] ) {
        echo zen_draw_checkbox_field('cart_delete[]', $product['id']);
      }
    ?>
    </td>
         </tr>
    <?php
      } // end foreach ($productArray as $product)
    ?>

  5. #5
    Join Date
    Feb 2012
    Posts
    67
    Plugin Contributions
    0

    Default Re: Conditional statement in shopping_cart

    anyone?

  6. #6
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default Re: Conditional statement in shopping_cart

    Can you show me where the option value 'none' is loading on the page you'd like to hide it from? Also why the value is being set to the cart as 'none' ?
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    Twitch Base8 - Obsidian - This, is what's new.

  7. #7
    Join Date
    Feb 2012
    Posts
    67
    Plugin Contributions
    0

    Default Re: Conditional statement in shopping_cart

    The "None" is the option value set in the attributes. It's not hard coded. The goal is that a list full of options are modified to show only what was selected in the cart / receipt. Anything set to "None" are bypassed. If the next one is set to "Tomato", it is shown.

  8. #8
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default Re: Conditional statement in shopping_cart

    I understand what you're explaining but I'll need to see it in action to give you direction on the code. Also are there any other edits to your cart?
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    Twitch Base8 - Obsidian - This, is what's new.

  9. #9
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default Re: Conditional statement in shopping_cart

    Thanks, now I can see exactly what needs to be done, check your PM there's instructions. We can update the forum once it's fixed :)
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    Twitch Base8 - Obsidian - This, is what's new.

  10. #10
    Join Date
    Feb 2012
    Posts
    67
    Plugin Contributions
    0

    Default Re: Conditional statement in shopping_cart

    I figured it out:

    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) {
    if ($value['products_options_values_name'] == "None") {
    } else { ?>
    <li>
    <?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']); ?>
    </li>
    
    
    <?php
    }
    ?>
    
    
    <?php
        }
      echo '</ul>';
      echo '</div>';
      }
    
    ?>

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Conditional statement in product info
    By twdhosting in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 13 Aug 2011, 02:44 AM
  2. Conditional Statement - Parent and Child Category Display Additional Information
    By crlannen in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 6 Feb 2011, 04:13 AM
  3. Shopping_cart
    By aerosmith in forum General Questions
    Replies: 1
    Last Post: 18 Sep 2008, 01:40 AM
  4. Stock quantity conditional statement?
    By doodlebee in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 18 Jun 2007, 03:57 PM
  5. Php Conditional Statement
    By zforrest in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 16 Jun 2006, 01:07 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