Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2009
    Posts
    26
    Plugin Contributions
    0

    Default Display Add to Cart.. Code?

    Hi,

    Whats the code that I have to add to DISPLAY the Add to Cart + Quantity box in the product listing page? I have turned it on to display via admin but it doesnt appear. I'm using the Columns Layout Grid for Product Listing addon.

    This is the code for how the product results appear:

    Code:
    <div id="listingcontainer">
    <div id="listingleft"><a href="'.$href.'">'.$img.'</a></div>
    <div id="listingright">
    <span class="listingtitle">'.$name.'</span>
    <p>Model Number: #02JS34 '.zen_image(DIR_WS_TEMPLATE.'images/spacer.gif', '', '60px', '1px').' Item Status: <span style="color: #66ae60;">In-Stock</span></p>
    <div class="enCase">
    <span class="price">'.$price.'</span>
    <br /><br />
    
    </div>
    
    <div align="right"><a href="'.$href.'"><img src="'.(DIR_WS_TEMPLATE.'images/details.gif').'"></a></div>
    </div>
    </div>
    I can see that the code for the add to cart / quantity to function already exists @ product_listing.php. I just need the code to make it display

    Thanks

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Display Add to Cart.. Code

    You don't add code to make the add/qty button display. If it doesn't display with the correct admin setting, you probably have attributes in your products (or else your admin settings are not correct). In that case, the customer must go to the product info page to make choices, and cannot add from the product listing page.

  3. #3
    Join Date
    Dec 2009
    Posts
    26
    Plugin Contributions
    0

    Default Re: Display Add to Cart.. Code

    Quote Originally Posted by gjh42 View Post
    You don't add code to make the add/qty button display. If it doesn't display with the correct admin setting, you probably have attributes in your products (or else your admin settings are not correct). In that case, the customer must go to the product info page to make choices, and cannot add from the product listing page.
    Im not sure if this is correct because when I switch to display in 'columns' (using the Columns Layout Grid for Product Listing), the qty/add to cart + model works but when i switch to rows, they both dissapear (does not consider the admin settings).

  4. #4
    Join Date
    Dec 2009
    Posts
    26
    Plugin Contributions
    0

    Default Re: Display Add to Cart.. Code

    I just noticed that the code i placed in my first post works with the tpl_tabular_display.php file:
    Code:
    <?php
    /**
     * Common Template - tpl_tabular_display.php
     *
     * This file is used for generating tabular output where needed, based on the supplied array of table-cell contents.
     *
     * @package templateSystem
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: tpl_tabular_display.php 3149 2006-03-10 07:29:34Z birdbrain $
     */
    
    $list_box_contents = array();
    
    $show_submit = zen_run_normal();
    $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
    
    if ($listing_split->number_of_rows > 0) {
      $rows = 0;
      $listing = $db->Execute($listing_split->sql_query);
      $extra_row = 0;
      $link2 = '';
      while (!$listing->EOF) {
        $rows++;
    
        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;
        $list_box_contents[$rows] = array();
    
        for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
          $lc_align = '';
    
          switch ($column_list[$col]) {
            case 'PRODUCT_LIST_MODEL':
             $list_box_contents[$rows]['model'] = $listing->fields['products_model'];
             break;
            case 'PRODUCT_LIST_NAME':
             if (isset($_GET['manufacturers_id'])) {
              $list_box_contents[$rows]['name'] = $listing->fields['products_name'];
    		 $list_box_contents[$rows]['but'] = zen_href_link(zen_get_info_page($listing->fields['products_id']), 'manufacturers_id=' . $_GET['manufacturers_id'] . '&products_id=' . $listing->fields['products_id']);
             } else {
              $list_box_contents[$rows]['name'] = $listing->fields['products_name'];
    		 $list_box_contents[$rows]['but'] = zen_href_link(zen_get_info_page($listing->fields['products_id']), ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing->fields['products_id']);
    		   
             }
             $list_box_contents[$rows]['description'] = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION);
             break;
            case 'PRODUCT_LIST_MANUFACTURER':
             $list_box_contents[$rows]['manufacturer'] = '<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '" style="color:#00C3FB;">' . $listing->fields['manufacturers_name'] . '</a>';
            break;
            case 'PRODUCT_LIST_PRICE':
             $list_box_contents[$rows]['price'] = zen_get_products_display_price($listing->fields['products_id']);
    
            // 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']), 'products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
            } else {
              if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0) {
                if ($listing->fields['product_is_call'] == 0) {
                  if (zen_get_products_allow_add_to_cart($listing->fields['products_id']) !='N') {
                    if ((SHOW_PRODUCTS_SOLD_OUT_IMAGE == 1 and $listing->fields['products_quantity'] > 0) or SHOW_PRODUCTS_SOLD_OUT_IMAGE == 0) {
                      $how_many++;
                    }
                  }
                }
                $lc_button = TEXT_PRODUCT_LISTING_MULTIPLE_ADD_TO_CART . "<input type=\"text\" name=\"products_id[" . $listing->fields['products_id'] . "]\" value=\"0\" size=\"4\" />";
              } 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_NOW, BUTTON_BUY_NOW_ALT) . '</a>';
              }
            }
            $the_button = $lc_button;
            $products_link = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
            $list_box_contents[$rows]['button'] .= 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']);
            $list_box_contents[$rows]['button'] = preg_replace('/title=/i', 'style="vertical-align:middle;" title=', $list_box_contents[$rows]['button']);
            $list_box_contents[$rows]['button'] .= '<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']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
    
            break;
             case 'PRODUCT_LIST_QUANTITY':
             $list_box_contents[$rows]['quantity'] = $listing->fields['products_quantity'];
             break;
            case 'PRODUCT_LIST_WEIGHT':
             $list_box_contents[$rows]['weight'] = $listing->fields['products_weight'];
             break;
            case 'PRODUCT_LIST_IMAGE':
             if (isset($_GET['manufacturers_id'])) {
              $list_box_contents[$rows]['image'] = zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT);
             } else {
              $list_box_contents[$rows]['image'] = zen_image(DIR_WS_IMAGES . $listing->fields['products_image'], $listing->fields['products_name'], IMAGE_PRODUCT_LISTING_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT);
             }
    		 case 'PRODUCT_LIST_IMAGE2':
             if (isset($_GET['manufacturers_id'])) {
              $list_box_contents[$rows]['image2'] = zen_href_link(zen_get_info_page($listing->fields['products_id']), 'manufacturers_id=' . $_GET['manufacturers_id'] . '&products_id=' . $listing->fields['products_id']);
             } else {
              $list_box_contents[$rows]['image2'] = zen_href_link(zen_get_info_page($listing->fields['products_id']), ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing->fields['products_id']);
             }
             break;
          }
        }
        $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;
    }
    
     foreach($list_box_contents as $product){
    //  print_r($product);
     /*echo '<br style="line-height:8px;"/>
          <div class="prod_table">
           <div class="prod_table_row">
    	   '.$product['image'].'
    	<div>'.$product['name'].'<br/><br style="line-height:8px;"/>'.$product['description'].'<br>
               '.(strlen($product['price']) > 200 ? '<span class="p_left"><br style="line-height:5px;"/>'.$product['price'].'' : '<span class="p_left"><br style="line-height:5px;"/>Price:  '.$product['price']).'<span style="margin-left:25px;">
    		   <a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'manufacturers_id=' . $_GET['manufacturers_id'] . '&products_id=' . $listing->fields['products_id']) . '">'.zen_image_button('det.gif','','style="vertical-align:top;"').'</a></span>
             </span></div>
           </div>
          </div>
          <div class="pink_sep"></div>';
    	  */
    if ($product[0]['text'] == 'There is no product that matches the search criteria.')
    {
    echo '<div class="rp2">'.$product[0]['text'].'</div>';
    }
    else 
    {
    
    $tm_href = $product['but'];
    $tm_img = $product['image'];
    $tm_name = $product['name'];
    $tm_desc = $product['description']; 
    $tm_price = $product['price'];
    
    
    echo tm_listing($tm_href, $tm_img, $tm_name, $tm_desc, $tm_price);
    }
     }
    
    ?>

  5. #5
    Join Date
    Dec 2009
    Posts
    26
    Plugin Contributions
    0

    Default Re: Display Add to Cart.. Code?

    bump anyone?

  6. #6
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Display Add to Cart.. Code?

    when I switch to display in 'columns' (using the Columns Layout Grid for Product Listing), the qty/add to cart + model works but when i switch to rows, they both dissapear (does not consider the admin settings).

    Rows being the standard listing display style, the settings absolutely should work without adding code. What other mods do you have? Can you post a link to see your site?

    Code:
    <span class="listingtitle">'.$name.'</span>
    <p>Model Number: #02JS34 '.zen_image(DIR_WS_TEMPLATE.'images
    There should never be any specific product information in the PHP files; something is wrong with your code.

  7. #7
    Join Date
    Dec 2009
    Posts
    26
    Plugin Contributions
    0

    Default Re: Display Add to Cart.. Code?

    I've sent you a pm

  8. #8
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Display Add to Cart.. Code?

    The code you sent shows the culprit, if not why it is messed up or how to fix it:
    Code:
    ... function tm_listing( ...
    You have a Template Monster template, and they are notorious for changing core functions in strange ways.

    This is likely to be a nightmare to fix, and I don't have enough time to examine it now.

  9. #9
    Join Date
    Dec 2009
    Posts
    26
    Plugin Contributions
    0

    Default Re: Display Add to Cart.. Code?

    Bah I'm doomed

  10. #10
    Join Date
    Dec 2009
    Posts
    26
    Plugin Contributions
    0

    Default Re: Display Add to Cart.. Code?

    Anyone able to take a look at this?

 

 

Similar Threads

  1. v150 Code to display Manufacturers Name in Shopping Cart and Checkout Conf pages
    By Twobears in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 5 Sep 2012, 09:29 PM
  2. Display Cart in Shadowbox when Add to cart is clicked.
    By lovetheecom in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 7 Mar 2012, 01:26 PM
  3. Add custom code to a sidebox (display godaddy SSL image)
    By gemohler in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 7 Mar 2009, 04:44 AM
  4. HELP! php code to add to cart
    By utah_aviator in forum General Questions
    Replies: 3
    Last Post: 7 Dec 2006, 12:33 AM

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