Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2014
    Location
    Southern Oregon
    Posts
    25
    Plugin Contributions
    0

    Default Attributes and Availability

    Is there a way to indicate a specific attribute is soldout without having to delete it?

    If not, where is the edit that displays when a given attribute is flagged as readonly? I will just change this edit to indicate that specific one is sold out instead of the default message "Please correct the following: On the Option for: Size You picked an Invalid Selection: 1 pound"

    To make sure there is no confusion.....

    Product A has 3 attributes. For this example, lets say Small, Med and Large. I want to indicate that only the Large is sold out, but want to be able to continue selling the Small and Med sizes.

    Thanks!

  2. #2
    Join Date
    Sep 2014
    Location
    Southern Oregon
    Posts
    25
    Plugin Contributions
    0

    Default Re: Attributes and Availability

    Since no one has any suggestions I am going to try this to hide the readonly attributes: http://www.zen-cart.com/showthread.p...nly-attributes

  3. #3
    Join Date
    Sep 2014
    Location
    Southern Oregon
    Posts
    25
    Plugin Contributions
    0

    Default Re: Attributes and Availability

    Well, that won't work with my current template.

    I even tried digging around in the code and editing the SQL statement to not pull in readonly attributes. The dang template either shows all attributes or none. And, I am not familiar enough to start editing it.

    So, back to square one. How in the world can I change the edit to state that the item is unavailable or to get it to not display at all? I don't care how, all I want is for my customer to realize the item is soldout/unavailable for that one attribute.

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

    Default Re: Attributes and Availability

    Have you tried the Stock by Attribute mod? I haven't used it, but I suspect it should display stock of a certain attribute as 0.

  5. #5
    Join Date
    Sep 2014
    Location
    Southern Oregon
    Posts
    25
    Plugin Contributions
    0

    Default Re: Attributes and Availability

    Quote Originally Posted by stevesh View Post
    Have you tried the Stock by Attribute mod? I haven't used it, but I suspect it should display stock of a certain attribute as 0.
    I am using 1.5.3 and I read that the Stock by Attribute mod is not yet ready. I am thinking of attempting to install it to see if it might work for me.....or if it produces usable error messages where I could tweak the code.

  6. #6
    Join Date
    Sep 2004
    Location
    Western Massachusetts
    Posts
    2,945
    Plugin Contributions
    5

    Default Re: Attributes and Availability

    I modified the attributes functionality to include a status flag on each attribute: with a store that has over 400 options, 3000 option values and 20,000 product attributes it was essential to be able to simply turn off some product attributes rather than delete them only to add them back later.
    To achieve this, you'll need to:
    1. add a status field to the products_attributes table:
    Code:
    ALTER TABLE `products_attributes` ADD `attributes_status` TINYINT( 1 ) NOT NULL DEFAULT '1'
    2. Make an override copy of includes/modules/attributes.php by copying it to includes/modules/YOUR_TEMPLATE/attributes.php, then edit that new file. (Note: all file edits proposed here are based on clean copies of v1.5.3 files)
    At about line 25, edit
    Code:
    and patrib.options_id = popt.products_options_id
    to be
    Code:
    and patrib.options_id = popt.products_options_id and patrib.attributes_status = '1'
    At about line 47, edit
    Code:
    and patrib.options_id = popt.products_options_id
    to be
    Code:
    and patrib.options_id = popt.products_options_id and patrib.attributes_status = '1'
    At about line 82, edit
    Code:
    and pa.options_values_id = pov.products_options_values_id
    to be
    Code:
    and pa.options_values_id = pov.products_options_values_id and pa.attributes_status = '1'
    That's it for the catalog side, now you need to change the admin side to make it work.
    3. You need to edit the file YOUR_ADMIN_FOLDER/attributes_controller.php (this is a core file and doesn't have an override capability, so be careful with upgrades in the future)
    At about line 207, immediately before
    Code:
    //// EOF OF FLAGS
    add this code:
    Code:
    		case 'set_flag_attributes_status':
    			if (isset($_POST['divertClickProto'])) {
    				$action='';
    				$new_flag= $db->Execute("select products_attributes_id, products_id, attributes_status from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
    				if ($new_flag->fields['attributes_status'] == '0') {
    					$db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_status='1' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
    				} else {
    					$db->Execute("update " . TABLE_PRODUCTS_ATTRIBUTES . " set attributes_status='0' where products_id='" . $_GET['products_filter'] . "' and products_attributes_id='" . $_GET['attributes_id'] . "'");
    				}
    				zen_redirect(zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, $_SESSION['page_info'] . '&products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $_GET['current_category_id']));
    			}
    			break;
    At about line 1106, immediately after
    Code:
    <td class="smallText" align="center"><?php echo LEGEND_ATTRIBUTES_DOWNLOAD ?></td>
    add a new line
    Code:
    <td class="smallText" align="center"><?php echo LEGEND_ATTRIBUTES_ACTIVE ?></td>
    At about line 1118, immediately after
    Code:
    <td class="smallText" align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_status_green.gif') . '&nbsp;' . zen_image(DIR_WS_IMAGES . 'icon_status_red.gif'); ?></td>
    add a new line
    {code]<td class="smallText" align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_green_off.gif') . '&nbsp;' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif'); ?></td>[/CODE]
    At about line 1634, immediately after
    Code:
    <td class="smallText" align="center"><?php echo ($options_set->fields["attributes_required"] == '0' ? '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_required' . '&attributes_id=' . $options_set->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '" onClick="divertClick(this.href);return false;">' . zen_image(DIR_WS_IMAGES . 'icon_red_off.gif', LEGEND_ATTRIBUTES_REQUIRED) . '</a>' : '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_required' . '&attributes_id=' . $options_set->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '" onClick="divertClick(this.href);return false;">' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', LEGEND_ATTRIBUTES_REQUIRED)) . '</a>'; ?></td>
    Add
    Code:
    <td class="smallText" align="center"><?php echo ($options_set->fields["attributes_status"] == '0' ? '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_status' . '&attributes_id=' . $options_set->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '" onClick="divertClick(this.href);return false;">' . zen_image(DIR_WS_IMAGES . 'icon_green_off.gif', LEGEND_ATTRIBUTES_STATUS) . '</a>' : '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'action=set_flag_attributes_status' . '&attributes_id=' . $options_set->fields["products_attributes_id"] . (isset($_GET['option_page']) ? '&option_page=' . $_GET['option_page'] . '&' : '') . (isset($_GET['value_page']) ? '&value_page=' . $_GET['value_page'] . '&' : '') . (isset($_GET['attribute_page']) ? '&attribute_page=' . $_GET['attribute_page'] : '') . '&products_filter=' . $products_filter . '&current_category_id=' . $current_category_id) . '" onClick="divertClick(this.href);return false;">' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', LEGEND_ATTRIBUTES_STATUS)) . '</a>'; ?></td>
    4. If you ever use the attributes copy functions on the attributes controller page, you'll need to make sure that the new attributes_status value is also copied. To do this, you'll need to edit the function zen_copy_products_attributes in YOUR_ADMIN_FOLDER/includes/functions/general.php (again, this is a core file with no override capability)
    At about line 2113, in the sql query, find
    Code:
    attributes_required) values (0,
    and change that to
    Code:
    attributes_required, attributes_status) values (0,
    At about line 2192, find
    Code:
    '" . $products_copy_from->fields['attributes_required'] . "')");
    and change that to
    Code:
    '" . $products_copy_from->fields['attributes_required'] . "', 
              '" . $products_copy_from->fields['attributes_status'] . "')");
    At about line 2221, find
    Code:
    attributes_required='" . $products_copy_from->fields['attributes_required'] . "'"
    and change that to
    Code:
    attributes_required='" . $products_copy_from->fields['attributes_required'] . "',
              attributes_status='" . $products_copy_from->fields['attributes_status'] . "'"
    5. You'll need to add new language definitions for the attributes controller page: make a new file YOUR_ADMIN_FOLDER/includes/languages/english/extra_definitions/attributes_status_definitions.php
    Include in that new file:
    Code:
    define('LEGEND_ATTRIBUTES_ACTIVE', 'Active');
    define('LEGEND_ATTRIBUTES_STATUS','Status');
    That should be it... but as with all custom coding, please make sure that you do this on a TEST Site first before making the changes to a live site.
    Neville
    An assumption is what you arrive at when you get tired of thinking...

  7. #7
    Join Date
    Jun 2016
    Location
    Minneapolis, MN
    Posts
    37
    Plugin Contributions
    0

    Default Re: Attributes and Availability

    Thank you, I am getting sick of deleting attributes when we are out of stock but then having to add them back later.

    I have it installed but I can't get it to actually work. Maybe it's because this is a 155d store and not 153 but there wasn't any difference around these areas when added the codes into.

    What help I still need is that when I push the green status button to presumably turn off the attribute it stays on. I have them turned off in the database for now and that isn't a hard thing to achieve either. If someone could help me figure out where I would need to make a change to get this piece of code to work, I have three sites I would loved to have this ability.

    Thanks in advance!
    M

  8. #8
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,107
    Plugin Contributions
    11

    Default Re: Attributes and Availability

    The 1.5.3 code may not be compatible with your current PHP version or it could be other causes. You're always taking chances when using mods not specifically cited as working with your version of Zen Cart.
    There are newer versions. One is finalizing on github and another is a commercial version.

  9. #9
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Attributes and Availability

    As dbltoe indicated, Stock by attributes as available from https://github.com/mc12345678/Stock_...butes_Combined and supports ZC 1.5.5. Most of the finalizing part is writing instruction to address it's full capability which is far from previous versions. It would handle your requested capability of either identifying that an attribute combination is out-of-stock or simply not display those that are out-of-stock.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. Replies: 1
    Last Post: 13 Dec 2012, 06:15 AM
  2. Product availability and shipping time
    By Bakedblue in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 27 Sep 2010, 10:18 AM
  3. Category and Products availability by Zone
    By Berserker in forum General Questions
    Replies: 0
    Last Post: 11 Feb 2010, 03:15 PM
  4. Implement a library style checkout and availability
    By zhamid in forum General Questions
    Replies: 0
    Last Post: 31 Aug 2009, 04:15 AM
  5. PayPal System Availability and/or Current Problems Report
    By DrByte in forum PayPal Express Checkout support
    Replies: 1
    Last Post: 8 Jan 2007, 10:16 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