Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2013
    Location
    Hong Kong
    Posts
    40
    Plugin Contributions
    0

    red flag Hide Normalprice for sold out products & in product listing page ONLY!

    I'm using the Grid Layout, and the sold out product currently display like this in the product listing page:

    - Image
    - Product Name
    (space break)
    - productSpecialPrice
    - normalprice
    (space break - Originally "...more info" link)
    - Sold Out (text link)

    I want to get it look like this:
    - Image
    - Product Name
    (space break)
    - productSpecialPrice
    - Sold Out (text link)


    So, how can I hide/remove the "normalprice" ONLY IN product listing page & ONLY FOR sold out products?


    Here is my code in includes/modules/elegancer_pink/product_listing.php
    PHP Code:
    <?php
    /**
     * product_listing module
     *
     * @package modules
     * @copyright Copyright 2012 Glenn Herbert
     * @copyright Portions Copyright 2003-2011 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.gnu.org/licenses/ GNU Public License V3.0
     * @version $Id: product_listing.php 18695 2011-05-04 05:24:19Z drbyte $
     * UPDATED TO WORK WITH COLUMNAR PRODUCT LISTING For Zen Cart v1.3.6 - 10/25/2006
     * Upgraded for v1.3.8-compatibility Dec 28, 2007 by stevefriedman71
     * Modified for Flexible Product Listing  by Glenn Herbert  (gjh42)  2010-04-08
     * Updated for v1.3.9f-compatibility by gjh42 2010-09-14
     * Updated for v1.5.0-compatibility by gjh42 2011-12-29
     * Updated to CLGv2.3.1, modified for Listing Subheadings by gjh42 2012-11-30
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die(
    'Illegal Access');
    }
    // Column Layout Support originally added for Zen Cart v 1.1.4 by Eric Stamper - 02/14/2004
    // Upgraded to be compatible with Zen-cart v 1.2.0d by Rajeev Tandon - Aug 3, 2004
    // Column Layout Support (Grid Layout) upgraded for v1.3.0 compatibility DrByte 04/04/2006

    if (!defined('PRODUCT_LISTING_LAYOUT_STYLE')) define('PRODUCT_LISTING_LAYOUT_STYLE',(isset($_GET['view']) ? $_GET['view'] : 'rows'));
    if (!
    defined('PRODUCT_LISTING_COLUMNS_PER_ROW')) define('PRODUCT_LISTING_COLUMNS_PER_ROW',3);
    if (!
    defined('PRODUCT_LISTING_GRID_SORT')) define('PRODUCT_LISTING_GRID_SORT',0);
    $product_listing_layout_style = isset($_GET['view'])? $_GET['view']: PRODUCT_LISTING_LAYOUT_STYLE;
    $row 0;
    $col 0;
    $list_box_contents = array();
    $title '';
    $flex_skips 0//flag for reducing # of columns - do not alter

    $max_results = ($product_listing_layout_style=='columns' && PRODUCT_LISTING_COLUMNS_PER_ROW>0) ? (PRODUCT_LISTING_COLUMNS_PER_ROW * (int)(MAX_DISPLAY_PRODUCTS_LISTING/PRODUCT_LISTING_COLUMNS_PER_ROW)) : MAX_DISPLAY_PRODUCTS_LISTING;


    $show_submit zen_run_normal();
    $listing_split = new splitPageResults($listing_sql$max_results'p.products_id''page');
    $zco_notifier->notify('NOTIFY_MODULE_PRODUCT_LISTING_RESULTCOUNT'$listing_split->number_of_rows);
    $how_many 0;
    $flex_skip_list flex_skip_list();
    // Begin Row Layout Header
    if ($product_listing_layout_style == 'rows' or PRODUCT_LISTING_GRID_SORT) {        // For Column Layout (Grid Layout) add on module

    $list_box_contents[0] = array('params' => 'class="productListing-rowheading"');

    //zc_col_count_description = 0;
    for ($col=0$n=sizeof($column_list); $col<$n$col++) {
      
    $lc_align '';//align settings moved to stylesheet
      
    switch ($column_list[$col]) {
        case 
    'PRODUCT_LIST_MODEL':
        
    $lc_text TABLE_HEADING_MODEL;
        
    $lc_class 'listingModelCell';// flex
        //$zc_col_count_description++;
        
    break;
        case 
    'PRODUCT_LIST_NAME':
        
    $lc_text TABLE_HEADING_PRODUCTS;
        
    $lc_class 'listingNameCell';
        
    //$zc_col_count_description++;
        
    break;
        case 
    'PRODUCT_LIST_MANUFACTURER':
        
    $lc_text TABLE_HEADING_MANUFACTURER;
        
    $lc_class 'listingManufacturerCell';
        
    //$zc_col_count_description++;
        
    break;
        case 
    'PRODUCT_LIST_PRICE':
        
    $lc_text TABLE_HEADING_PRICE;
        
    $lc_class 'listingPriceCell';
        
    $lc_align = (PRODUCTS_LIST_PRICE_WIDTH '" width="' PRODUCTS_LIST_PRICE_WIDTH '');
        
    //$zc_col_count_description++;
        
    break;
        case 
    'PRODUCT_LIST_QUANTITY':
        
    $lc_text TABLE_HEADING_QUANTITY;
        
    $lc_class 'listingQuantityCell';
        
    //$zc_col_count_description++;
        
    break;
        case 
    'PRODUCT_LIST_WEIGHT':
        
    $lc_text TABLE_HEADING_WEIGHT;
        
    $lc_class 'listingWeightCell';
        
    //$zc_col_count_description++;
        
    break;
        case 
    'PRODUCT_LIST_IMAGE':
    if (
    $product_listing_layout_style == 'rows') { //skip if grid
        
    $lc_text TABLE_HEADING_IMAGE;
        
    $lc_class 'listingImageCell';
        
    //$zc_col_count_description++;
        
    }
        break;
      }

      if ( (
    $column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
        
    $lc_text zen_create_sort_heading($_GET['sort'], $col+1$lc_text);
      }

      
    // flex skip column in output array
      
    if (($flex_skip_list[$col] == 1) and ($product_listing_layout_style == 'rows')) {
        
    $flex_skips++;//don't add a column this time
      
    } else {
      
    $list_box_contents[0][$col-$flex_skips] = array('align' => $lc_align,//align used only for admin price col width
                                          
    'params' => 'class="' $lc_class '"'// flex
                                          
    'text' => $lc_text );
      }
    // flex
    }
      if (
    $product_listing_layout_style == 'columns') { //grid sort option
        
    $grid_sort $list_box_contents[0];
        
    $list_box_contents = array();
      }
    $subhead_colspan $col $flex_skips;//listing_subheads

    // End Row Layout Header used in Column Layout (Grid Layout) add on module

    /////////////  HEADER ROW ABOVE /////////////////////////////////////////////////

    $num_products_count $listing_split->number_of_rows;

    if (
    $listing_split->number_of_rows 0) {
      
    $rows 0;
      
    // Used for Column Layout (Grid Layout) add on module
      
    $column 0;    
      if (
    $product_listing_layout_style == 'columns') {
        if (
    $num_products_count PRODUCT_LISTING_COLUMNS_PER_ROW || PRODUCT_LISTING_COLUMNS_PER_ROW == ) {
          
    $col_width floor(100/$num_products_count) - 0.5;
        } else {
          
    $col_width floor(100/PRODUCT_LISTING_COLUMNS_PER_ROW) - 0.5;
        }
      }
      
    // Used for Column Layout (Grid Layout) add on module

      
    $listing $db->Execute($listing_split->sql_query);
      
    $extra_row 0;
      while (!
    $listing->EOF) {

        if (
    $product_listing_layout_style == 'rows') { // Used in Column Layout (Grid Layout) Add on module
        
    $rows++;
        if(
    defined('PROD_SUBHEADS')) {//listing_subheads
          
    $cur_row $rows;
          
    listing_subhead('PROD', ($cPath '_' $listing->fields['products_id']), $rows$column);
          if (
    $cur_row != $rows$list_box_contents[$rows-1][0][params] .= $list_box_contents[$rows-1][0][params] . ' colspan="' .$subhead_colspan '"';
        }
    //listing_subheads
        
    if ((($rows-$extra_row)/2) == floor(($rows-$extra_row)/2)) {
          
    $list_box_contents[$rows] = array('params' => 'class="productListing-even"');
        } else {
          
    $list_box_contents[$rows] = array('params' => 'class="productListing-odd"');
        }

        
    $cur_row sizeof($list_box_contents) - 1;
        }   
    // End of Conditional execution - only for row (regular style layout)

        
    $product_contents = array(); // Used For Column Layout (Grid Layout) Add on module
        
    $flex_skips 0//reset flag for reducing # of columns
        
    $prev_cell_text '';
        for (
    $col=0$n=sizeof($column_list); $col<$n$col++) {
          
    $lc_align '';
          
    $lc_text '';
          switch (
    $column_list[$col]) {
            case 
    'PRODUCT_LIST_MODEL':
            
    $lc_text '<div class="listingModel">' $listing->fields['products_model'] . '</div>';
            
    $lc_class 'listingModelCell';
            break;
            case 
    'PRODUCT_LIST_NAME':
            
    $lc_text .= '<h3 class="itemTitle"><a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > and $_GET['filter_id'] > 0) ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' $listing->fields['products_id']) . '">' $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
            
    $lc_class 'listingNameCell';
            break;
            case 
    'PRODUCT_LIST_MANUFACTURER':
            
    $lc_text .= '<div class="listingManufacturer"><a href="' zen_href_link(FILENAME_DEFAULT'manufacturers_id=' $listing->fields['manufacturers_id']) . '">' $listing->fields['manufacturers_name'] . '</a>' '</div>';
            
    $lc_class 'listingManufacturerCell';
            break;
            case 
    'PRODUCT_LIST_PRICE':
            
    $lc_price zen_get_products_display_price($listing->fields['products_id']);
            
    $lc_text .= '<div class="listingPrice">' $lc_price '</div>';
            
    $lc_class 'listingPriceCell';

            
    // more info in place of buy now
            
    $lc_button '';
            if (
    zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
              
    $lc_button '<a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > and $_GET['filter_id']) > ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > $_GET['cPath'] : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' $listing->fields['products_id']) . '">' '</a>';
            } else {
              if (
    PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0) {
                if (
                    
    // not a hide qty box product
                    
    $listing->fields['products_qty_box_status'] != &&
                    
    // product type can be added to cart
                    
    zen_get_products_allow_add_to_cart($listing->fields['products_id']) != 'N'
                    
    &&
                    
    // product is not call for price
                    
    $listing->fields['product_is_call'] == 0
                    
    &&
                    
    // product is in stock or customers may add it to cart anyway
                    
    ($listing->fields['products_quantity'] > || SHOW_PRODUCTS_SOLD_OUT_IMAGE == 0) ) {
                  
    $how_many++;
                }
                
    // hide quantity box
                
    if ($listing->fields['products_qty_box_status'] == 0) {
                  
    $lc_button '<a href="' zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' $listing->fields['products_id']) . '">' zen_image_button(BUTTON_IMAGE_BUY_NOWBUTTON_BUY_NOW_ALT'class="listingBuyNowButton"') . '</a>';
                } else {
                  
    $lc_button TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART "<input type=\"text\" name=\"products_id[" $listing->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
                }
              } else {
                
    // qty box with add to cart button
                
    if (PRODUCT_LIST_PRICE_BUY_NOW == '2' && $listing->fields['products_qty_box_status'] != 0) {
                  
    $lc_buttonzen_draw_form('cart_quantity'zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' $listing->fields['products_id']), 'post''enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' zen_draw_hidden_field('products_id'$listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CARTBUTTON_IN_CART_ALT) . '</form>';
                } else {
                  
    $lc_button '<a href="' zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' $listing->fields['products_id']) . '">' zen_image_button(BUTTON_IMAGE_BUY_NOWBUTTON_BUY_NOW_ALT'class="listingBuyNowButton"') . '</a>';
                }
              }
            }
            
    $the_button $lc_button;
            
    $products_link '<a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . ( ($_GET['manufacturers_id'] > and $_GET['filter_id']) > zen_get_generated_category_path_rev($_GET['filter_id']) : $_GET['cPath'] > zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id'])) . '&products_id=' $listing->fields['products_id']) . '">' '</a>';
            
    $lc_text .= '<div class="listingButtonGroup">' zen_get_buy_now_button($listing->fields['products_id'], $the_button$products_link) . '<br />' zen_get_products_quantity_min_units_display($listing->fields['products_id']);
            
    $lc_text .= '<br />' . (zen_get_show_product_switch($listing->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($listing->fields['products_id']) ? '<br />' TEXT_PRODUCT_FREE_SHIPPING_ICON '') : '') . '</div>';
            break;
            case 
    'PRODUCT_LIST_QUANTITY':
            
    $lc_text .= '<div class="listingQuantity">' $listing->fields['products_quantity'] . '</div>';
            
    $lc_class 'listingQuantityCell';
            break;
            case 
    'PRODUCT_LIST_WEIGHT':
            
    $lc_text .= '<div class="listingWeight">' .  $listing->fields['products_weight'] . '</div>';
            
    $lc_class 'listingWeightCell';
            break;
            case 
    'PRODUCT_LIST_IMAGE':
            if (
    $listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
              
    $lc_text .= '';
            } else {
              
    $lc_text .= '<div class="listingImage">';
              if (isset(
    $_GET['manufacturers_id'])) {
                
    $lc_text .= '<a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > and $_GET['filter_id']) > ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' $listing->fields['products_id']) . '">' zen_image(DIR_WS_IMAGES $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTHIMAGE_PRODUCT_LISTING_HEIGHT'class="listingProductImage"') . '</a>';
              } else {
                
    $lc_text .= '<a href="' zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > and $_GET['filter_id']) > ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' $listing->fields['products_id']) . '">' zen_image(DIR_WS_IMAGES $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTHIMAGE_PRODUCT_LISTING_HEIGHT'class="listingProductImage"') . '</a>';
              }
              
    $lc_text .= '</div>';
            }
            
    $lc_class 'listingImageCell'
            break;
          }

          
    $product_contents[] = $lc_text// Used For Column Layout (Grid Layout) Option

          
    if ($product_listing_layout_style == 'rows') {
            if (
    $col == 0){
              
    $prev_lc_align $lc_align;
              
    $prev_lc_class $lc_class;
            } else {
              if (
    $flex_skip_list[$col] == '') {//load previous cell
                
    $list_box_contents[$rows][$col-$flex_skips-1] = array('align' => $prev_lc_align,
                                                  
    'params' => 'class="' $prev_lc_class '"'
                                                  
    'text'  => $prev_cell_text);
                
    $prev_cell_text '';
                
    $prev_lc_align $lc_align;
                
    $prev_lc_class $lc_class;
              } else {
    // skip column in output array
                
    $flex_skips++;
              }
            }
            
    $prev_cell_text .= $lc_text;
            if (
    $col == $n-1) {//load last cell
              
    $list_box_contents[$rows][$col-$flex_skips] = array('align' => $prev_lc_align,
                                                  
    'params' => 'class="' $prev_lc_class '"'
                                                  
    'text'  => $prev_cell_text);
            }
          }
        }

        
    // add description and match alternating colors
        //if (PRODUCT_LIST_DESCRIPTION > 0) {
        //  $rows++;
        //  if ($extra_row == 1) {
        //    $list_box_description = "productListing-data-description-even";
        //    $extra_row=0;
        //  } else {
        //    $list_box_description = "productListing-data-description-odd";
        //    $extra_row=1;
        //  }
        //  $list_box_contents[$rows][] = array('params' => 'class="' . $list_box_description . '" colspan="' . $zc_col_count_description . '"',
        //  'text' => zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION));
        //}

        // Following code will be executed only if Column Layout (Grid Layout) option is chosen
        
    if ($product_listing_layout_style == 'columns') {
          
    $lc_text implode("\n"$product_contents);
          if(
    defined('PROD_SUBHEADS')) listing_subhead('PROD', ($cPath '_' $listing->fields['products_id']), $rows$column);//listing_subheads
          
    $list_box_contents[$rows][$column] = array('params' => 'class="centerBoxContentsProducts centeredContent back"' ' ' 'style="width:' $col_width '%;"',
                                                     
    'text'  => $lc_text);
          
    $column ++;
          if (
    $column >= PRODUCT_LISTING_COLUMNS_PER_ROW) {
            
    $column 0;
            
    $rows ++;
          }
        }
        
    // End of Code fragment for Column Layout (Grid Layout) option in add on module
        
    $listing->MoveNext();
      }
      
    $error_categories false;
    } else {
      
    $list_box_contents = array();

      
    $list_box_contents[0] = array('params' => 'class="productListing-odd"');
      
    $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                                  
    'text' => TEXT_NO_PRODUCTS);

      
    $error_categories true;
    }

    if ((
    $how_many and $show_submit == true and $listing_split->number_of_rows 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == or  PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 3) ) {
      
    $show_top_submit_button true;
    } else {
      
    $show_top_submit_button false;
    }
    if ((
    $how_many and $show_submit == true and $listing_split->number_of_rows 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART >= 2) ) {
      
    $show_bottom_submit_button true;
    } else {
      
    $show_bottom_submit_button false;
    }



      if (
    $how_many && PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != and $show_submit == true and $listing_split->number_of_rows 0) {
      
    // bof: multiple products
        
    echo zen_draw_form('multiple_products_cart_quantity'zen_href_link(FILENAME_DEFAULTzen_get_all_get_params(array('action')) . 'action=multiple_products_add_product'), 'post''enctype="multipart/form-data"');
      }

    Hope someone could help me figure this out.
    Thanks!

  2. #2
    Join Date
    Jul 2012
    Posts
    16,028
    Plugin Contributions
    17

    Default Re: Hide Normalprice for sold out products & in product listing page ONLY!

    So with it sold out you do still want the special(final) price to be displayed but not the normal price, correct?

    Basically need to override the $lc_price portion of:

    Code:
    case##'PRODUCT_LIST_PRICE': 
    ################$lc_price##=##zen_get_products_display_price($listing->fields['products_id']);
    Code:
    case##'PRODUCT_LIST_PRICE': 
    ################if ($listing->fields['products_quantity'] > 0) {
    ################  $lc_price##=##zen_get_products_display_price($listing->fields['products_id']); 
    ################} else {
    ################  $lc_price = function similar to zen_uget_products_display_price but modified to not show the normal price.
    ################}
    Otherwise you could use css for the product_listing page to hide it, but the data is still in the page to be parsed by SEs and those interested in looking at the page source...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. Replies: 16
    Last Post: 2 May 2014, 10:07 PM
  2. Sold Out Notification only appears for products with Attributes
    By Youngblood in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 25 Jun 2013, 06:17 PM
  3. Hide Sold Out button on Product Listing
    By ZeroGravity in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 24 Dec 2011, 12:09 PM
  4. Hide Sold out product from Product Listing page
    By needsome in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 7 May 2011, 06:49 PM
  5. Change sold out image for upcoming products only?
    By jenzi in forum Setting Up Categories, Products, Attributes
    Replies: 19
    Last Post: 8 Oct 2010, 07:51 PM

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