Forums / Setting Up Categories, Products, Attributes / Stock by Attributes and displaying next to attributes for Customers 1.3.8

Stock by Attributes and displaying next to attributes for Customers 1.3.8

Locked

Views: 1,431

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
21 May 2009, 7:25 PM
#1
tirjasdyn avatar

tirjasdyn

New Zenner

Join Date:
Sep 2005
Posts:
7
Plugin Contributions:
0

Stock by Attributes and displaying next to attributes for Customers 1.3.8

Okay I use stock by attributes...sorry I don't remember which version at this point. I dowloaded the latest in December 2008. It works great for me as we use Zen cart to sell tickets for gaming conventions.

What I need though is to show the quatity of tickets left next to the time slots shown by attributes. I found Grayson's Mod here: http://www.zen-cart.com/forum/showthread.php?t=25987&page=11 Pages 11-19. However it seems to be for an old version of Zen Cart. After reading pages of theads which state PM Grayson...I thought I'd post what I did.

So here's what I did to get it to work with Version 1.3.8:

/includes/modules/attributes.php

Find:

   $sql = "select  pov.products_options_values_id,
             pov.products_options_values_name,
             pa.*
        from   " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov
        where   pa.products_id = '" . (int)$_GET['products_id'] . "'
        and    pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "'
        and    pa.options_values_id = pov.products_options_values_id
        and    pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
        $order_by;

Replace it with:

    if ($products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_TEXT && $products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_FILE && $products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_READONLY) {
    $sql = "select  pov.products_options_values_id,
             pov.products_options_values_name,
             pwas.quantity,
             pa.*
        from   " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
        where   pa.products_id = '" . (int)$_GET['products_id'] . "'
        and    pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "'
        and    pa.options_values_id = pov.products_options_values_id
        and    pwas.stock_attributes = pa.products_attributes_id
        and    pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
        $order_by;
    } else {
    $sql = "select  pov.products_options_values_id,
             pov.products_options_values_name,
             pa.*
        from   " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov
        where   pa.products_id = '" . (int)$_GET['products_id'] . "'
        and    pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "'
        and    pa.options_values_id = pov.products_options_values_id
        and    pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
        $order_by;
    }

In the same file find:

 if ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO or $products_options->RecordCount() == 1 or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY) {
      $products_options_value_id = $products_options->fields['products_options_values_id'];
      if ($products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_TEXT and $products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_FILE) {
       $products_options_details = $products_options->fields['products_options_values_name'];
      } else {
       // don't show option value name on TEXT or filename
       $products_options_details = '';
      }
      if ($products_options_names->fields['products_options_images_style'] >= 3) {
       $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
       $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
      } else {
       $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
       $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
      }
     }

Replace it with:

 if ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_TEXT or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_CHECKBOX or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_RADIO or $products_options->RecordCount() == 1 or $products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY) {
      $products_options_value_id = $products_options->fields['products_options_values_id'];
      if ($products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_TEXT and $products_options_names->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_FILE) {
//       $products_options_details = $products_options->fields['products_options_values_name'];
// gbm - replaced original line above to display attribute stock amount beside attribute
       $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_PIECES . ']';
      } else {
       // don't show option value name on TEXT or filename
       $products_options_details = '';
      }
      if ($products_options_names->fields['products_options_images_style'] >= 3) {
       $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
//       $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
// gbm - replaced original line above to display attribute stock amount beside attribute
       $products_options_details_noname = ' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_PIECES . '] ' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');
      } else {
       $products_options_details .= $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
//       $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
// gbm - replaced original line above to display attribute stock amount beside attribute
       $products_options_details_noname = ' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_PIECES . '] ' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');
      }
     }

Then open includes/languages/english/your_template/product_info.php and add the following line:

define('TEXT_ATTRIBUTES_PIECES','Tickets Available');

While this works great this now this messed up the default display only attribute I was using to make them choose a time attribute. This is a big problem as I need to force them to choose an attribute. I think it's because it's ignoring display only attributes. Can some one help me with this. I'll post again if I find an answer.

21 May 2009, 9:11 PM
#2
tirjasdyn avatar

tirjasdyn

New Zenner

Join Date:
Sep 2005
Posts:
7
Plugin Contributions:
0

Re: Stock by Attributes and displaying next to attributes for Customers 1.3.8

So I found out that if I add a quatitiy to the display attribute it will work but I don't want a quatity there. Is there a way to get it to display without a quantity and have the others display?

Here's the example I am working on: http://denvergamers.org/index.php?main_page=product_info&cPath=11&products_id=305

If you don't choose a time it gives an error (which I want) but If I remove the quantity than it disappears.

21 May 2009, 9:31 PM
#3
tirjasdyn avatar

tirjasdyn

New Zenner

Join Date:
Sep 2005
Posts:
7
Plugin Contributions:
0

Re: Stock by Attributes and displaying next to attributes for Customers 1.3.8

Okay I've figured out that Stock by Attributes lets me put in 0 for the quantity. So Please select a time will show up showing 0 tickets available. Yeah! I'd still like no text to show next to display only attributes.