Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Product Quantity dropdown

    instead of typing in a number then adding to cart I wan't it to be a dropdown box and select the number.

    Anyone know how to do this?

  2. #2
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Re: Product Quantity dropdown

    This would be a really cool addon, I did research and Saw tons of people wanting the same thing but only one that seemed to figure it out, however It isn't very detailed on what exactly to change and not sure if it even works

    http://www.zen-cart.com/showthread.p...ducts-listings


    My product_listing.php

    Code:
    <?php
    /**
     * product_listing module
     *
     * @package modules
     * @copyright Copyright 2003-2011 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: product_listing.php 18695 2011-05-04 05:24:19Z drbyte $
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die('Illegal Access');
    }
    $show_submit = zen_run_normal();
    $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
    $zco_notifier->notify('NOTIFY_MODULE_PRODUCT_LISTING_RESULTCOUNT', $listing_split->number_of_rows);
    $how_many = 0;
    
    $list_box_contents[0] = array('params' => 'class="productListing-rowheading"');
    
    $zc_col_count_description = 0;
    $lc_align = '';
    for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
      switch ($column_list[$col]) {
        case 'PRODUCT_LIST_MODEL':
        $lc_text = TABLE_HEADING_MODEL;
        $lc_align = '';
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_NAME':
        $lc_text = TABLE_HEADING_PRODUCTS;
        $lc_align = '';
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_MANUFACTURER':
        $lc_text = TABLE_HEADING_MANUFACTURER;
        $lc_align = '';
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_PRICE':
        $lc_text = TABLE_HEADING_PRICE;
        $lc_align = 'right' . (PRODUCTS_LIST_PRICE_WIDTH > 0 ? '" width="' . PRODUCTS_LIST_PRICE_WIDTH : '');
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_QUANTITY':
        $lc_text = TABLE_HEADING_QUANTITY;
        $lc_align = 'right';
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_WEIGHT':
        $lc_text = TABLE_HEADING_WEIGHT;
        $lc_align = 'right';
        $zc_col_count_description++;
        break;
        case 'PRODUCT_LIST_IMAGE':
        $lc_text = TABLE_HEADING_IMAGE;
        $lc_align = 'center';
        $zc_col_count_description++;
        break;
      }
    
      if ( ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
        $lc_text = zen_create_sort_heading($_GET['sort'], $col+1, $lc_text);
      }
    
    
    
      $list_box_contents[0][$col] = array('align' => $lc_align,
                                          'params' => 'class="productListing-heading"',
                                          'text' => $lc_text );
    }
    
    if ($listing_split->number_of_rows > 0) {
      $rows = 0;
      $listing = $db->Execute($listing_split->sql_query);
      $extra_row = 0;
      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;
    
        for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
          $lc_align = '';
          switch ($column_list[$col]) {
            case 'PRODUCT_LIST_MODEL':
            $lc_align = '';
            $lc_text = $listing->fields['products_model'];
            break;
            case 'PRODUCT_LIST_NAME':
            $lc_align = '';
            $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? 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>';
            break;
            case 'PRODUCT_LIST_MANUFACTURER':
            $lc_align = '';
            $lc_text = '<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a>';
            break;
            case 'PRODUCT_LIST_PRICE':
            $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
            $lc_align = 'right';
            $lc_text =  $lc_price;
    
            // 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'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? $_GET['cPath'] : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
            } else {
              if (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0) {
                if (
                    // not a hide qty box product
                    $listing->fields['products_qty_box_status'] != 0 &&
                    // 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'] > 0 || 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_NOW, BUTTON_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_button= zen_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_CART, BUTTON_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_NOW, BUTTON_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'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : $_GET['cPath'] > 0 ? 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']) . '">' . MORE_INFO_TEXT . '</a>';
            $lc_text .= '<br />' . 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']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON . '<br />' : '') : '');
    
            break;
            case 'PRODUCT_LIST_QUANTITY':
            $lc_align = 'right';
            $lc_text = $listing->fields['products_quantity'];
            break;
            case 'PRODUCT_LIST_WEIGHT':
            $lc_align = 'right';
            $lc_text = $listing->fields['products_weight'];
            break;
            case 'PRODUCT_LIST_IMAGE':
            $lc_align = 'center';
            if ($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
              $lc_text = '';
            } else {
              if (isset($_GET['manufacturers_id'])) {
                $lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? 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_WIDTH, IMAGE_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'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? 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_WIDTH, IMAGE_PRODUCT_LISTING_HEIGHT, 'class="listingProductImage"') . '</a>';
              }
            }
            break;
          }
    
          $list_box_contents[$rows][$col] = array('align' => $lc_align,
                                                  'params' => 'class="productListing-data"',
                                                  'text'  => $lc_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));
        //}
        $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 > 0 and $show_submit == true and $listing_split->number_of_rows > 0) and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 1 or  PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 3) ) {
      $show_top_submit_button = true;
    } else {
      $show_top_submit_button = false;
    }
    if (($how_many > 0 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 > 0 && PRODUCT_LISTING_MULTIPLE_ADD_TO_CART != 0 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_DEFAULT, zen_get_all_get_params(array('action')) . 'action=multiple_products_add_product', $request_type), 'post', 'enctype="multipart/form-data"');
      }
    Last edited by StoreOwner; 10 Jun 2014 at 02:55 AM.

  3. #3
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Re: Product Quantity dropdown

    I have the add to cart already, it was in the admin panel but I wan't this dropdown quantity select I can't seem to figure out..

    Example image here:
    http://i.imgur.com/ioyDIuu.jpg

  4. #4
    Join Date
    Feb 2005
    Location
    Lansing, Michigan USA
    Posts
    20,024
    Plugin Contributions
    3

    Default Re: Product Quantity dropdown

    I'd guess that someone here could come up with the code to do that, assuming:

    You want it to be a dropdown for all products, and you want the dropdown values to be the same for every product.

    Otherwise, you're looking at quite a bit of work, since there will need to be admin and SQL aspects included.

  5. #5
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Re: Product Quantity dropdown

    Quote Originally Posted by stevesh View Post
    I'd guess that someone here could come up with the code to do that, assuming:

    You want it to be a dropdown for all products, and you want the dropdown values to be the same for every product.

    Otherwise, you're looking at quite a bit of work, since there will need to be admin and SQL aspects included.
    I was hoping I could do for the quantity I put when creating the product and worked like normal :/ didn't think it would be this difficult

  6. #6
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Product Quantity dropdown

    For your product-info page, rewrite this line to replace the <input type="text"> with a <select> field containing appropriate <option> elements inside it:
    Code:
        $the_button = PRODUCTS_ORDER_QTY_TEXT . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '<br />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
    And for product listings, rewrite this line similarly:
    Code:
                  $lc_button= zen_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_CART, BUTTON_IN_CART_ALT) . '</form>';
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Re: Product Quantity dropdown

    Quote Originally Posted by DrByte View Post
    For your product-info page, rewrite this line to replace the <input type="text"> with a <select> field containing appropriate <option> elements inside it:
    Code:
        $the_button = PRODUCTS_ORDER_QTY_TEXT . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '<br />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT);
    And for product listings, rewrite this line similarly:
    Code:
                  $lc_button= zen_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_CART, BUTTON_IN_CART_ALT) . '</form>';
    this?

    $lc_button= zen_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"') . '<select> 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_CART, BUTTON_IN_CART_ALT) . '</form>';


    I did it but it doesn't display quantity # inside it


    also were is my product info page, i tried product_info.php but all i see is the php file with defines in it.
    Last edited by StoreOwner; 11 Jun 2014 at 10:09 AM.

  8. #8
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Product Quantity dropdown

    Quote Originally Posted by StoreOwner View Post
    this?

    $lc_button= zen_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"') . '<select> 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_CART, BUTTON_IN_CART_ALT) . '</form>';


    I did it but it doesn't display quantity # inside it


    also were is my product info page, i tried product_info.php but all i see is the php file with defines in it.
    I haven't dug into the code you proposed above; however, two things appear to stand out different from Dr. Byte suggested. One is that the modifications attempted appear to be related to the customer's choosing of the quantity instead of at the development/creation of the product. Two is that well, easiest to state that Dr. Byte provided guidance on what was needed, not specific code to accomplish the modification. As such I don't see the assignment/creation of items to populate the drop down, if one even is displayed.

    While such a drop down was not yet incorporated, take a look at the plugin Checkbox TextBox Icon Product Checkout (http://www.zen-cart.com/downloads.php?do=file&id=1811) for some of how this type of modification might be possible on the store front side. It does not currently offer a dropdown list.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Re: Product Quantity dropdown

    Quote Originally Posted by mc12345678 View Post
    I haven't dug into the code you proposed above; however, two things appear to stand out different from Dr. Byte suggested. One is that the modifications attempted appear to be related to the customer's choosing of the quantity instead of at the development/creation of the product. Two is that well, easiest to state that Dr. Byte provided guidance on what was needed, not specific code to accomplish the modification. As such I don't see the assignment/creation of items to populate the drop down, if one even is displayed.

    While such a drop down was not yet incorporated, take a look at the plugin Checkbox TextBox Icon Product Checkout (http://www.zen-cart.com/downloads.php?do=file&id=1811) for some of how this type of modification might be possible on the store front side. It does not currently offer a dropdown list.
    Ah cool thx :)

    I will try to mess with it i suppose but don't think I know enough yet.

  10. #10
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Re: Product Quantity dropdown

    bumpity

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v139h Altering Quantity field from text input to dropdown on a per-product basis?
    By jgold723 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 31 Aug 2012, 08:06 AM
  2. quantity dropdown to blank box - add to cart
    By CheapStairParts in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 25 Jul 2012, 02:39 PM
  3. Checking quantity of dropdown menu
    By threers in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 28 May 2011, 09:17 PM
  4. Dropdown quantity
    By scottb in forum General Questions
    Replies: 14
    Last Post: 31 Mar 2011, 07:56 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