Zen Cart Logo
Forums / All Other Contributions/Addons / Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Views: 658,586

Results 1,741 to 1,760 of 3,609
20 Oct 2013, 8:01 PM
#1741
potteryhouse avatar

potteryhouse

Zen Follower

Join Date:
Jun 2012
Location:
Florida
Posts:
123
Plugin Contributions:
0

Stock by Attribute v4.0 addon for v1.3.5-1.3.9

gohealth:

This is what the error looks like. Not only does it show a product that has quantity, but also has some formatting issues in the drop downs.
Attachment 13212

Again, any thoughts greatly appreciated. Note, I have done another clean install on another test site with the exact same issues.

The file located at:
includes\languages\english\extra_definitions\products_with_attributes.php
is where the issue resides, simply update the file with a text editor and remove the <b> </b> found around the text.

As a note, I removed these from the next version we will post.

27 Oct 2013, 8:41 AM
#1742
oavs avatar

oavs

Totally Zenned

Join Date:
Jan 2006
Location:
Downunder - QLD - Gold Coast
Posts:
921
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

gohealth:

This is what the error looks like. Not only does it show a product that has quantity, but also has some formatting issues in the drop downs.
Attachment 13212

Again, any thoughts greatly appreciated. Note, I have done another clean install on another test site with the exact same issues.

Shouldn't this simply hidden when it is sold out instead of saying 'Out of Stock' ?

How can I make it so that when there are total of ;
Item size 'S' with 5 quantity
Item size 'M' with 5 quantity
Item size 'L' with 5 quantity

Then ... when the ..

  1. Item size 'S' is sold out, Size attribute 'S' is hidden (not visible) to the customers. Leaving only Size 'M' and size 'L'
  2. Item size 'M' is sold out, Size attribute 'M' is hidden not visible to the customers. Leaving only Size 'L'
  3. Item size 'L' is sold out, All size attribute are hidden not visible to the customers. Leaving only 'OUT OF STOCK' for the product showing default Zencart 'OUT-OF-STOCK' ICON..

Of course above is only an example. In reality it applies to which ever size in what ever order happens (sold).

Love to be able to do that and looking forward to some solutions.

27 Oct 2013, 1:22 PM
#1743
pablo avatar

pablo

New Zenner

Join Date:
Jun 2011
Posts:
91
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

oavs:

Shouldn't this simply hidden when it is sold out instead of saying 'Out of Stock' ?

How can I make it so that when there are total of ;
Item size 'S' with 5 quantity
Item size 'M' with 5 quantity
Item size 'L' with 5 quantity

Then ... when the ..

  1. Item size 'S' is sold out, Size attribute 'S' is hidden (not visible) to the customers. Leaving only Size 'M' and size 'L'
  2. Item size 'M' is sold out, Size attribute 'M' is hidden not visible to the customers. Leaving only Size 'L'
  3. Item size 'L' is sold out, All size attribute are hidden not visible to the customers. Leaving only 'OUT OF STOCK' for the product showing default Zencart 'OUT-OF-STOCK' ICON..

Of course above is only an example. In reality it applies to which ever size in what ever order happens (sold).

Love to be able to do that and looking forward to some solutions.

This version will show "Out of Stock" when the product level is zero. It was written to work that way. If you want to completely hide the attribute when stock is zero, you will need to find and older version and replace the file /YOUR_ADMIN/products_with_attributes_stock.php with this file

<?php
/**
 * @package admin
 * @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: products_with_attributes_stock.php 389 2008-11-14 16:02:14Z hugo13 $
 */

require('includes/application_top.php');
require(DIR_WS_CLASSES . 'currencies.php');
require(DIR_WS_CLASSES . 'products_with_attributes_stock.php');


$stock = new products_with_attributes_stock;

if(isset($_SESSION['languages_id'])){ $language_id = $_SESSION['languages_id'];} else { $language_id=1;}

if(isset($_GET['action']))
{
	$action = $_GET['action'];
}
else
{
	$action = '';
}

switch($action)
{
	case 'add':
		if(isset($_GET['products_id']) and is_numeric((int)$_GET['products_id']))
		{
			$products_id = (int)$_GET['products_id'];
		}
		if(isset($_POST['products_id']) and is_numeric((int)$_POST['products_id']))
		{
			$products_id = (int)$_POST['products_id'];
		}

		if(isset($products_id))
		{

			if(zen_products_id_valid($products_id))
			{

				$product_name = zen_get_products_name($products_id);
				$product_attributes = $stock->get_products_attributes($products_id, $language_id);

  			$hidden_form .= zen_draw_hidden_field('products_id',$products_id)."\n";
			}
			else
			{

				zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, zen_get_all_get_params(array('action')), 'NONSSL'));
			}
		}
		else
		{

			$query = 'SELECT DISTINCT
                        attrib.products_id, description.products_name
                      FROM 
                        '.TABLE_PRODUCTS_ATTRIBUTES.' attrib, '.TABLE_PRODUCTS_DESCRIPTION.' description
                      WHERE 
                        attrib.products_id = description.products_id and description.language_id='.$language_id.' order by description.products_name';

			$products = $db->execute($query);
			while(!$products->EOF)
			{
				$products_array_list[] = array(
				'id' => $products->fields['products_id'],
				'text' => $products->fields['products_name']
				);
				$products->MoveNext();
			}
		}
		break;
	case 'edit':
		$hidden_form = '';
		if(isset($_GET['products_id']) and is_numeric((int)$_GET['products_id']))
		{
			$products_id = $_GET['products_id'];
		}

		if(isset($_GET['attributes']))
		{
			$attributes = $_GET['attributes'];
		}

		if(isset($products_id) and isset($attributes))
		{
			$attributes = explode(',',$attributes);
			foreach($attributes as $attribute_id){
				$hidden_form .= zen_draw_hidden_field('attributes[]',$attribute_id)."\n";
				$attributes_list[] = $stock->get_attributes_name($attribute_id, $language_id);
			}
			$hidden_form .= zen_draw_hidden_field('products_id',$products_id)."\n";
		}
		else
		{
			zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, zen_get_all_get_params(array('action')), 'NONSSL'));
		}

		break;

	case 'confirm':
		if(isset($_POST['products_id']) and is_numeric((int)$_POST['products_id']))
		{

			if(!isset($_POST['quantity']) || !is_numeric($_POST['quantity']))
			{
				zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, zen_get_all_get_params(array('action')), 'NONSSL'));
			}
			$products_id = $_POST['products_id'];
			$product_name = zen_get_products_name($products_id);
			if(is_numeric($_POST['quantity']))
			{
				$quantity = $_POST['quantity'];
			}

			$attributes = $_POST['attributes'];
	
			foreach($attributes as $attribute_id)
			{
				$hidden_form .= zen_draw_hidden_field('attributes[]',$attribute_id)."\n";
				$attributes_list[] = $stock->get_attributes_name($attribute_id, $_SESSION['languages_id']);
			}
			$hidden_form .= zen_draw_hidden_field('products_id',$products_id)."\n";
			$hidden_form .= zen_draw_hidden_field('quantity',$quantity)."\n";
			$s_mack_noconfirm .="products_id=" . $products_id . "&"; //s_mack:noconfirm
			$s_mack_noconfirm .="quantity=" . $quantity . "&"; //s_mack:noconfirm

			if(sizeof($attributes) > 1)
			{
				sort($attributes);
				$stock_attributes = implode(',',$attributes);
			}
			else
			{
				$stock_attributes = $attributes[0];
			}
			$s_mack_noconfirm .='attributes=' . $stock_attributes . '&'; //kuroi: to pass string not array

			$query = 'select * from '.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.' where products_id = '.$products_id.' and stock_attributes="'.$stock_attributes.'"';
			$stock_check = $db->Execute($query);

			if(!$stock_check->EOF)
			{
				$hidden_form .= zen_draw_hidden_field('add_edit','edit');
				$hidden_form .= zen_draw_hidden_field('stock_id',$stock_check->fields['stock_id']);
				$s_mack_noconfirm .="stock_id=" . $stock_check->fields['stock_id'] . "&"; //s_mack:noconfirm
				$s_mack_noconfirm .="add_edit=edit&"; //s_mack:noconfirm
				$add_edit = 'edit';
			}
			else
			{
				$hidden_form .= zen_draw_hidden_field('add_edit','add')."\n";
				$s_mack_noconfirm .="add_edit=add&"; //s_mack:noconfirm
			}

		}
		else
		{
			zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, zen_get_all_get_params(array('action')), 'NONSSL'));
		}
		zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, $s_mack_noconfirm . "action=execute", 'NONSSL')); //s_mack:noconfirm
		break;
	case 'execute':
		$attributes = $_POST['attributes'];
		if ($_GET['attributes']) { $attributes = $_GET['attributes']; } //s_mack:noconfirm

		$products_id = $_POST['products_id'];
		if ($_GET['products_id']) { $products_id = $_GET['products_id']; } //s_mack:noconfirm

		$quantity = $_GET['quantity']; //s_mack:noconfirm
		if ($_GET['quantity']) { $quantity = $_GET['quantity']; } //s_mack:noconfirm
		if(!is_numeric((int)$quantity)) //s_mack:noconfirm
		{
			zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, zen_get_all_get_params(array('action')), 'NONSSL'));
		}

		/*
		michael mcinally <[email protected]>
		heavily modified version to allow inserting "ALL" attributes at once
		also should probably run this SQL command as well:
		ALTER TABLE `products_with_attributes_stock` ADD UNIQUE `products_id_stock_attributes` (`products_id`, `stock_attributes`);
		*/
		if(($_POST['add_edit'] == 'add') || ($_GET['add_edit'] == 'add')) //s_mack:noconfirm
		{
			if (preg_match("/\|/", $attributes)) {

				$arrTemp = preg_split("/\,/", $attributes);
				$arrMain = array();
				$intCount = 0;
				for ($i = 0;$i < sizeof($arrTemp);$i++) {
          $arrTemp1 = preg_split("/\|/", $arrTemp[$i]);
          $arrMain[] = $arrTemp1;
					if ($intCount) {
						$intCount = $intCount * sizeof($arrTemp1);
					} else {
						$intCount = sizeof($arrTemp1);
					}
				}
				$intVars = sizeof($arrMain);
				$arrNew = array();
				if ($intVars >= 1) {
					eval('
					for ($i = 0;$i < sizeof($arrMain[0]);$i++) {
						if ($intVars >= 2) {
							for ($j = 0;$j < sizeof($arrMain[1]);$j++) {
								if ($intVars >= 3) {
									for ($k = 0;$k < sizeof($arrMain[2]);$k++) {
										if ($intVars >= 4) {
											for ($l = 0;$l < sizeof($arrMain[3]);$l++) {
												if ($intVars >= 5) {
													for ($m = 0;$m < sizeof($arrMain[4]);$m++) {
														if ($intVars >= 6) {
															for ($n = 0;$n < sizeof($arrMain[5]);$n++) {
																$arrNew[] = array($arrMain[0][$i], $arrMain[1][$j], $arrMain[2][$k], $arrMain[3][$l], $arrMain[4][$m], $arrMain[5][$n]);
															}
														} else {
															$arrNew[] = array($arrMain[0][$i], $arrMain[1][$j], $arrMain[2][$k], $arrMain[3][$l], $arrMain[4][$m]);
														}
													}
												} else {
													$arrNew[] = array($arrMain[0][$i], $arrMain[1][$j], $arrMain[2][$k], $arrMain[3][$l]);
												}
											}
										} else {
											$arrNew[] = array($arrMain[0][$i], $arrMain[1][$j], $arrMain[2][$k]);
										}
									}
								} else {
									$arrNew[] = array($arrMain[0][$i], $arrMain[1][$j]);
								}
							}
						} else {
							$arrNew[] = array($arrMain[0][$i]);
						}
					}
					');
				}
				for ($i = 0;$i < sizeof($arrNew);$i++) {
					$strAttributes = implode(",", $arrNew[$i]);
					$query = 'insert into `'.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.'` (`products_id`,`stock_attributes`,`quantity`) values ('.$products_id.',"'.$strAttributes.'",'.$quantity.') ON DUPLICATE KEY UPDATE `stock_attributes` = "'.$strAttributes.'", `quantity` = '.$quantity;
					$db->Execute($query);
				}
			} else {
			$query = 'insert into `'.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.'` (`products_id`,`stock_attributes`,`quantity`) values ('.$products_id.',"'.$attributes.'",'.$quantity.')';
				$db->Execute($query);
			}
		}
		elseif(($_POST['add_edit'] == 'edit') || ($_GET['add_edit'] == 'edit')) //s_mack:noconfirm
		{
			$stock_id = $_POST['stock_id']; //s_mack:noconfirm
			if ($_GET['stock_id']) { $stock_id = $_GET['stock_id']; } //s_mack:noconfirm
			if(!is_numeric((int)$stock_id)) //s_mack:noconfirm
			{
				zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, zen_get_all_get_params(array('action')), 'NONSSL'));
			}

			$query = 'update `'.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.'` set quantity='.$quantity.' where stock_id='.$stock_id.' limit 1';
				$db->Execute($query);
		}
		

		$stock->update_parent_products_stock($products_id);
		$messageStack->add_session('Product successfully updated', 'success');
		zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, '', 'NONSSL'));

		break;
	case 'delete':
		if(!isset($_POST['confirm']))
		{
			// do nothing
		}
		else
		{
			// delete it
			if($_POST['confirm'] == TEXT_YES){
				$query = 'delete from '.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.' where products_id="'.$_POST['products_id'].'" and stock_attributes="'.$_POST['attributes'].'" limit 1';
				$db->Execute($query);
				$stock->update_parent_products_stock((int)$_POST['products_id']);
				$messageStack->add_session('Product Variant was deleted', 'failure');
				zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, '', 'NONSSL'));
			} else {
				zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, '', 'NONSSL'));
			}
		}
		break;

	case 'resync':
		if(is_numeric((int)$_GET['products_id'])){

			$stock->update_parent_products_stock((int)$_GET['products_id']);
			$messageStack->add_session('Parent Product Quantity Updated', 'success');
			zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, '', 'NONSSL'));

		} else {
			zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, '', 'NONSSL'));
		}
		break;
  case 'resync_all':
    $stock->update_all_parent_products_stock();
    $messageStack->add_session('Parent Product Quantities Updated', 'success');
    zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, '', 'NONSSL'));    
  break;
  case 'auto_sort':
    // get all attributes
    $sql = $db->Execute("SELECT stock_id, stock_attributes FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " ORDER BY stock_id ASC;");
    $count = 0;
    while (!$sql->EOF) {
      // get main attribute only for sort
      $attributes = explode(',', $sql->fields['stock_attributes']);
      $main_attribute_id = $attributes[0];
      // get the sort order
      $sort_query = "SELECT pa.products_attributes_id, pov.products_options_values_sort_order as sort 
                     FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                     LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on (pov.products_options_values_id = pa.options_values_id)
                     WHERE pa.products_attributes_id = " . $main_attribute_id . "
                     LIMIT 1;";
      $sort = $db->Execute($sort_query); 
      $sort = $sort->fields['sort'];
      // update sort in db
      $db->Execute("UPDATE " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " set sort = '" . $sort . "' WHERE stock_id = '" . $sql->fields['stock_id'] . "' LIMIT 1;");
      $count++;
      $sql->MoveNext();
    }
    $messageStack->add_session($count . ' stock attributes updated for sort by primary attribute sort order', 'success');
    zen_redirect(zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, '', 'NONSSL'));                   
  break;
	default:
		// Show a list of the products

		break;
}


?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<link rel="stylesheet" type="text/css" href="includes/products_with_attributes_stock_ajax.css" media="all" id="hoverJS">
<script language="javascript" type="text/javascript" src="../ajax/jquery.js"></script>
<script language="javascript" type="text/javascript" src="../ajax/jquery.form.js"></script>
<script language="javascript" type="text/javascript" src="../ajax/products_with_attributes_stock_ajax.js"></script>
<script language="javascript" type="text/javascript" src="includes/menu.js"></script>
<script language="javascript" type="text/javascript" src="includes/general.js"></script>
<script type="text/javascript">
<!--
function init()
{
	cssjsmenu('navbar');
	if (document.getElementById)
	{
		var kill = document.getElementById('hoverJS');
		kill.disabled = true;
	}
}
// -->
</script>
</head>
<body onLoad="init()">
<!-- header //-->
<?php
require(DIR_WS_INCLUDES . 'header.php');
?>
<!-- header_eof //-->
<div style="padding: 20px;">

<!-- body_text_eof //-->
<!-- body_eof //-->
<?php

switch($action)
{
	case 'add':


		if(isset($products_id))
		{

			echo zen_draw_form('final_refund_exchange', FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, 'action=confirm', 'post', '', true)."\n";
			echo $hidden_form;

			echo '<p><strong>'.$product_name.'</strong></p>'."\n";

			foreach($product_attributes as $option_name => $options)
			{
// MULTI
				$arrValues = array();
				if (is_array($options)) {
					if (sizeof($options) > 0) {
						foreach ($options as $k => $a) {
							$arrValues[] = $a['id'];
						}
					}
				}
				
				array_unshift($options, array('id' => implode("|", $arrValues), 'text' => 'All'));
				echo '<p><strong>'.$option_name.': </strong>';
				echo zen_draw_pull_down_menu('attributes[]',$options).'</p>'."\n";

			}

			echo '<p><strong>' . PWA_QUANTITY . '</strong>'.zen_draw_input_field('quantity').'</p>'."\n";

		}
		else
		{

			echo zen_draw_form('final_refund_exchange', FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, 'action=add', 'post', '', true)."\n";
			echo zen_draw_pull_down_menu('products_id',$products_array_list)."\n";
		}

?>
	<p><input type="submit" value="<?php echo PWA_SUBMIT ?>"></p>
	</form>
<?php
break;
	case 'edit':

		echo zen_draw_form('final_refund_exchange', FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, 'action=confirm', 'post', '', true)."\n";
		echo '<h3>'.zen_get_products_name($products_id).'</h3>';

		foreach($attributes_list as $attributes)
		{
			echo '<p><strong>'.$attributes['option'].': </strong>'.$attributes['value'].'</p>';
		}

		echo $hidden_form;
		echo '<p><strong>Quantity: </strong>'.zen_draw_input_field('quantity', $_GET['q']).'</p>'."\n"; //s_mack:prefill_quantity
?>
	<p><input type="submit" value="<?php echo PWA_SUBMIT ?>"></p>
	</form>
<?php
break;
	case 'delete':
		if(!isset($_POST['confirm']))
		{

			echo zen_draw_form('final_refund_exchange', FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, 'action=delete', 'post', '', true)."\n";
			echo PWA_DELETE_VARIANT_CONFIRMATION;
			foreach($_GET as $key=>$value)
			{
				echo zen_draw_hidden_field($key,$value);
			}
?>
 	<p><input type="submit" value="<?php echo TEXT_YES ?>" name="confirm"> * <input type="submit" value="<?php echo TEXT_NO ?>" name="confirm"></p>
 	</form>
<?php  
		}
		break;
	case 'confirm':

		echo '<h3>Confirm '.$product_name.'</h3>';

		foreach($attributes_list as $attributes)
		{
			echo '<p><strong>'.$attributes['option'].': </strong>'.$attributes['value'].'</p>';
		}

		echo '<p><strong>Quantity</strong>'.$quantity.'</p>';
		echo zen_draw_form('final_refund_exchange', FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, 'action=execute', 'post', '', true)."\n";
		echo $hidden_form;
?>
	<p><input type="submit" value="<?php echo PWA_SUBMIT ?>"></p>
	</form>

<?php 	
break;
	default:
    echo '<div id="hugo1" style="background-color: green; padding: 2px 10px;"></div>';    
    echo '<form method="get" action="' . zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, '', 'NONSSL') . '" id="pwas-search" name="pwas-search">Search:  <input id="pwas-filter" type="text" name="search"/><input type="submit" value="Search" id="pwas-search-button" name="pwas-search-button"/></form><span style="margin-right:10px;"> </span>';
    echo '<a href="' . zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, '', 'NONSSL') . '">Reset</a><span style="margin-right:10px;"> </span><a href="' . zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, 'action=auto_sort', 'NONSSL') . '">Sort</a>';
    echo '<span id="loading" style="display: none;"><img src="../images/ajax-loader2.gif" alt="" /> Loading...</span><hr />';
    echo '<a class="forward" style="float:right;" href="'.zen_href_link(FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK, "action=resync_all", 'NONSSL').'"><strong>Sync All Quantities</strong></a><br class="clearBoth" /><hr />';
    echo '<div id="pwa-table">';
    echo $stock->displayFilteredRows();
    echo '</div>';
break;
}
?>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br />
</div>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
27 Oct 2013, 11:03 PM
#1744
potteryhouse avatar

potteryhouse

Zen Follower

Join Date:
Jun 2012
Location:
Florida
Posts:
123
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

oavs:

Shouldn't this simply hidden when it is sold out instead of saying 'Out of Stock' ?

How can I make it so that when there are total of ;
Item size 'S' with 5 quantity
Item size 'M' with 5 quantity
Item size 'L' with 5 quantity

Then ... when the ..

  1. Item size 'S' is sold out, Size attribute 'S' is hidden (not visible) to the customers. Leaving only Size 'M' and size 'L'
  2. Item size 'M' is sold out, Size attribute 'M' is hidden not visible to the customers. Leaving only Size 'L'
  3. Item size 'L' is sold out, All size attribute are hidden not visible to the customers. Leaving only 'OUT OF STOCK' for the product showing default Zencart 'OUT-OF-STOCK' ICON..

Of course above is only an example. In reality it applies to which ever size in what ever order happens (sold).

Love to be able to do that and looking forward to some solutions.

There are several ways to do what you are asking, you will need to try each to see which one you prefer.

The first is simply to edit the language file and change ' Out of Stock: ' to ''
includes\languages\english\extra_definitions\products_with_attributes.php

Another option is as easy, change the settings in the Configuration/Stock page.
Set the "Check stock Level" to false
and
set the Allow checkout to false.

31 Oct 2013, 2:39 PM
#1745
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Nice to see this update done:

Stock by Attributes - Version: 1.5.2 This update Ports (merged) the functionality from:
http://www.zen-cart.com/downloads.php?do=file&id=1355
stock_by_attributes_1.4.13_with_my_stock_id_MOD version 1.0.2 by rhuseby.

Combining this functionality into the "main" (original) version of SBA means that there is one less variant out there to add to the confusion that is SBA.. Well done!:smile: Maybe I'll give this version of SBA another looksee.. Seems like there's been some good movement..

8 Nov 2013, 3:15 PM
#1746
lunabug avatar

lunabug

New Zenner

Join Date:
Dec 2009
Posts:
94
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Hi!

Just installed this and it seems to be working in most cases. The problem I'm having is on an item with 2 attributes. When I set one of the items to 0 (out of stock), as a customer I don't see that item as out of stock until I add it to my cart, but the problem is when I add the same item with a different attribute and it ALSO show as out of stock when it really is not.

Attachment 13326

First one has no stock, when added to cart it informs me such... ok
Second one has 11 items in stock, when added to cart, it says the same thing as the first item... not ok

Attachment 13327

I have a different product that has only one attribute and it's working as expected and showing 'out of stock' on the product page.

Thanks,
Leslie

8 Nov 2013, 3:46 PM
#1747
peter_m_dodge avatar

peter_m_dodge

New Zenner

Join Date:
Nov 2013
Posts:
24
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Good afternoon,
The search function doesn't really help me find the answer and this is a very long thread to read through start-to-finish, so I thought I'd just ask:

I have a custom template, and I have added the plugin to my install. The administration works fine and I can add attribute stock fine, but in the product area it only displays the overall quantity not the breakdown of in stock items. Do I need to change something to do so? I did upload the template files included in the plugin to the template directory.

Cheers,
Peter M Dodge

8 Nov 2013, 4:28 PM
#1748
philman1008 avatar

philman1008

New Zenner

Join Date:
Sep 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Hi,

Just installed this on zen cart 1.5.1 and it works a treat, but I have a small issue. We used to be able to into an order and add products to the order and resend the invoice for payment. This module seems to have removed this facility from the order.php page. Can this be put back in?

Also, not sure is this applies to this thread, but is there any way that the (+£2.00) can disappear from the attribute on the product page and just show the full price when you choose the attribute?

Cheers, Phil.

8 Nov 2013, 4:43 PM
#1749
philman1008 avatar

philman1008

New Zenner

Join Date:
Sep 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Hello,

Also when setting these attributes I get mysterious text appearing as below. How do I get rid of this please?

Attachment 13328

8 Nov 2013, 5:13 PM
#1750
potteryhouse avatar

potteryhouse

Zen Follower

Join Date:
Jun 2012
Location:
Florida
Posts:
123
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

lunabug:

Hi!

Just installed this and it seems to be working in most cases. The problem I'm having is on an item with 2 attributes. When I set one of the items to 0 (out of stock), as a customer I don't see that item as out of stock until I add it to my cart, but the problem is when I add the same item with a different attribute and it ALSO show as out of stock when it really is not.

Attachment 13326

The "Multiple" attribute combination (two or more attributes in the same row), is not yet functional in this version, this is noted in the instructions on the Notes page. you can have these all listed in separate rows and it will work.

I have been told there is a work-around if you must have multiple attributes in the same row, but stock checks will not be accurate, have a look at post:
http://www.zen-cart.com/showthread.php?47180-Stock-by-Attribute-v4-0-addon-for-v1-3-5-1-3-9&p=1222803#post1222803
This shows an optional way to configure the multiple attributes per row, but remember it will be buggy when using this configuration.

The best setup in this version is to configured as shown in the instructions, then the mod works as expected.

8 Nov 2013, 5:18 PM
#1751
potteryhouse avatar

potteryhouse

Zen Follower

Join Date:
Jun 2012
Location:
Florida
Posts:
123
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Philman1008:

Hello,

Also when setting these attributes I get mysterious text appearing as below. How do I get rid of this please?

Attachment 13328

This display error seems to be caused by an error in one of the files you made a change to, my guess is that you are missing an open or closing quotation mark in a file, or that there is an extra one added. Use a compare program (such as winmerg or beyond compare) and compare the original file to the one you updated, look for missing or extra quotes.

8 Nov 2013, 5:22 PM
#1752
potteryhouse avatar

potteryhouse

Zen Follower

Join Date:
Jun 2012
Location:
Florida
Posts:
123
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Peter M Dodge:

Good afternoon,
The search function doesn't really help me find the answer and this is a very long thread to read through start-to-finish, so I thought I'd just ask:

I have a custom template, and I have added the plugin to my install. The administration works fine and I can add attribute stock fine, but in the product area it only displays the overall quantity not the breakdown of in stock items. Do I need to change something to do so? I did upload the template files included in the plugin to the template directory.

Cheers,
Peter M Dodge

Did you configure the "Configuration/Stock" options for SBA? one of those settings is to display the quantity next to the attribute selection. The Instructions explain these settings.

8 Nov 2013, 5:28 PM
#1753
peter_m_dodge avatar

peter_m_dodge

New Zenner

Join Date:
Nov 2013
Posts:
24
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

potteryhouse:

Did you configure the "Configuration/Stock" options for SBA? one of those settings is to display the quantity next to the attribute selection. The Instructions explain these settings.

Yes, I did set this option, which is why I am wondering why if there are additional template steps required.

Cheers,
Peter M Dodge

9 Nov 2013, 10:17 AM
#1754
realgs avatar

realgs

New Zenner

Join Date:
Nov 2013
Location:
Wroclaw, Poland
Posts:
4
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

I've been looking for a solution but probably don't know how to name my need. I'm sure that this is a common problem, thus I want to ask you before I start coding it. I need to make a separate textfields for quantities of each color. "Add to cart" button should transfer all chosen colors to a cart.
An example is shown on this site:
Colors example
I'm using zencart 1.5 not upgraded.

11 Nov 2013, 12:06 AM
#1755
k1ra avatar

k1ra

New Zenner

Join Date:
Jul 2013
Posts:
57
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

I just downloaded the most recent version of Stock By Attributes. V1.5.2.

Because I need to require that a user select a size on the product info page, I have created the following attributes:

**Size: **
Please Choose An Option... [display only, default]
Small
Medium
Large

In a previous version of Stock By Attributes I had to select the option 'Please Choose An Options..' from the products_with_attributes_stock.php page in Admin, and give it a stock value of 1. This option shows up on products that are already on the site.

In this version, the option 'Please Choose An Option...' does not show up in the products_with_attributes_stock.php page in Admin. I get a 'N/A' value instead. Which is great as it should not require a stock value; however, the 'Please Choose An Option...' value does not show up in the front end on a product I just added Size attributes to, thus not forcing the user to select a size before adding to cart.

Any ideas on what to do? Did I miss something?

11 Nov 2013, 1:53 AM
#1756
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Please read the comments in red.

lunabug:

Hi!

Just installed this and it seems to be working in most cases. The problem I'm having is on an item with 2 attributes. When I set one of the items to 0 (out of stock), as a customer I don't see that item as out of stock until I add it to my cart,
Under admin>Configuration>Stock
set
Check stock level = true
. They will get the Out of stock warning on the product_info page

but the problem is when I add the same item with a different attribute and it ALSO show as out of stock when it really is not.

and one of them is out of stock, you will get the red

Attachment 13326

First one has no stock, when added to cart it informs me such... ok
Second one has 11 items in stock, when added to cart, it says the same thing as the first item... not ok

Attachment 13327

I have a different product that has only one attribute and it's working as expected and showing 'out of stock' on the product page.

Thanks,
Leslie

I hoe it helps.

11 Nov 2013, 2:31 AM
#1757
potteryhouse avatar

potteryhouse

Zen Follower

Join Date:
Jun 2012
Location:
Florida
Posts:
123
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

k1ra:

I just downloaded the most recent version of Stock By Attributes. V1.5.2.

Because I need to require that a user select a size on the product info page, I have created the following attributes:

**Size: **
Please Choose An Option... [display only, default]
Small
Medium
Large

In a previous version of Stock By Attributes I had to select the option 'Please Choose An Options..' from the products_with_attributes_stock.php page in Admin, and give it a stock value of 1. This option shows up on products that are already on the site.

In this version, the option 'Please Choose An Option...' does not show up in the products_with_attributes_stock.php page in Admin. I get a 'N/A' value instead. Which is great as it should not require a stock value; however, the 'Please Choose An Option...' value does not show up in the front end on a product I just added Size attributes to, thus not forcing the user to select a size before adding to cart.

Any ideas on what to do? Did I miss something?

I believe you can do this, Add a read only selection as the first size (use whatever text makes sense, I just used Please Choose as a same here) see the attached images.

I added this attribute and set to sort order 0.
Attachment 13332

This is how it will display on the product page, forcing the customer to make a selection.
Attachment 13333

This is also explained in the following thread.
http://www.zen-cart.com/showthread.php?122165-How-can-I-require-a-customer-to-select-from-a-list-of-attribute-options&p=921215#post921215

11 Nov 2013, 10:04 AM
#1758
philman1008 avatar

philman1008

New Zenner

Join Date:
Sep 2013
Location:
United Kingdom
Posts:
11
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Hello,

Thank you for this response:

This display error seems to be caused by an error in one of the files you made a change to, my guess is that you are missing an open or closing quotation mark in a file, or that there is an extra one added

I have not amended any files beyond installing the basic SBA mod. Do you know which file this would relate to so I can try and find the issue?

Regards, Phil.

12 Nov 2013, 4:34 AM
#1759
potteryhouse avatar

potteryhouse

Zen Follower

Join Date:
Jun 2012
Location:
Florida
Posts:
123
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Philman1008:

Hello,

Thank you for this response:

I have not amended any files beyond installing the basic SBA mod. Do you know which file this would relate to so I can try and find the issue?

Regards, Phil.

In the file attributes.php make these changes. This should resolve your display error.

On line 199 change this:

$products_options_display_price = ATTRIBUTES_PRICE_DELIMITER_PREFIX . '<span class="productSpecialPrice">' . $products_options->fields['price_prefix'] . $currencies->display_price($new_attributes_price, zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . '</span>' . ATTRIBUTES_PRICE_DELIMITER_SUFFIX;

To this:

$products_options_display_price = ATTRIBUTES_PRICE_DELIMITER_PREFIX . $products_options->fields['price_prefix'] . $currencies->display_price($new_attributes_price, zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ATTRIBUTES_PRICE_DELIMITER_SUFFIX;

On line 224 change this:

$originalpricedisplaytext = ATTRIBUTES_PRICE_DELIMITER_PREFIX . '<span class="normalprice">' . $products_options->fields['price_prefix'] . $currencies->display_price( zen_get_attributes_price_final($products_options->fields["products_attributes_id"], 1, '', 'false'), zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . '</span>' . ATTRIBUTES_PRICE_DELIMITER_SUFFIX;

To this:

$originalpricedisplaytext = ATTRIBUTES_PRICE_DELIMITER_PREFIX . $products_options->fields['price_prefix'] . $currencies->display_price( zen_get_attributes_price_final($products_options->fields["products_attributes_id"], 1, '', 'false'), zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ATTRIBUTES_PRICE_DELIMITER_SUFFIX;
15 Nov 2013, 2:53 AM
#1760
potteryhouse avatar

potteryhouse

Zen Follower

Join Date:
Jun 2012
Location:
Florida
Posts:
123
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

This version (1.5.2.x_TEST) is provided to get feedback for the next version to be posted to the plug-ins.
This is a test version only.

The attributes.php file has been moved to an overrides folder.
There was no change to the database.

The following files have been updated. The update is based on Version 1.5.2:

admin\includes\classes\products_with_attributes_stock.php
admin\products_with_attributes_stock.php
admin\stock_by_attr_install.php
includes\functions\extra_functions\products_with_attributes.php

This file has been moved to an override folder, rename 'YOUR_TEMPLATE' to your template name:
includes\modules\YOUR_TEMPLATE\attributes.php

This version should resolve several display problems and a few other things that have been posted in the forum.

  1. Dynamic Filter not working correctly with SBA.
  2. <span> tag in the drop-down selection list.
  3. QTY: showing up on read-only attributes.
  4. <b> tag showing up in drop-down selection list.

Please use only on a TEST installation and provide thoughts, suggestions, feedback.

[Attachment no longer available]