Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
Quote:
Originally Posted by
tajul_ashyqin
Hi Frank,
Thanx for your posted fixes... and actually, instead of showing the stock values beside the respective attributes option, I just want to show the 'Out of Stock' remark to only for those attributes that has reach to 0 in quantity BUT no remarks to the one that still have stock. So that next time the online shoppers no need to 'choose' and 'add to cart' the attributes and then find that no stock available to order!!! Do you have any idea how to code that?! :smile: or anyone out there?!
In my situation, I have very limited stock level on each attribue. So, I wanted customers to see the quantities on each attribute, so that they would not add more than what's available. I also turned "show stock when low" in admin under Configuration/Stock, so that if my customers did add more than available quantities, they would get an warning message and show available stock in shopping cart.
In your situation, I assume that you have plenty merchandise in stock and you have a very tight stock level control in place. I would suggest another fix posted by Grayson before:
1. Switch back to original attributes.php by kuroi
2. If you want to force attribute selection, add a "display only" attribute as "default" selection
3. In attribute.php find
Quote:
[FONT=Times New Roman]$products_options_details = $products_options->fields['products_options_values_name'];[/FONT]
replace it with:
Quote:
if ($products_options->fields['quantity'] > 0) { $products_options_details = $products_options->fields['products_options_values_name']; } else { $products_options_details = $products_options->fields['products_options_values_name'] . ' [' . TEXT_ATTRIBUTES_NOT_IN_STOCK . ']'; }
next replace
Quote:
[FONT=Times New Roman]$products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : '');[/FONT]
with
Quote:
if ($products_options->fields['quantity'] > 0) { $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : ''); } else { $products_options_details_noname = ' [' . TEXT_ATTRIBUTES_NOT_IN_STOCK . ']' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '<br />' . $products_options_display_weight : ''); }
A few lines below this, find
[FONT=Times New Roman]
Quote:
[FONT=Times New Roman]$products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');[/FONT]
[/FONT]
Replace with:
Quote:
if ($products_options->fields['quantity'] > 0) { $products_options_details_noname = $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : ''); } else { $products_options_details_noname = ' [' . TEXT_ATTRIBUTES_NOT_IN_STOCK . '] ' . $products_options_display_price . ($products_options->fields['products_attributes_weight'] != 0 ? '' . $products_options_display_weight : '');}
Do NOT forget to add a define of [FONT=Verdana]TEXT_ATTRIBUTES_NOT_IN_STOCK[/FONT] in product_info.php in includes/languages/english/your_template folder!!
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
By the way, the fix suggested above works for single attribute product only and for radio, checkbox options.
For default dropdown display, you need to modify:
Quote:
$products_options_array[] = array()
statements in attributes.php and add a if{}else{} conditon, which is a little harder to achieve and I have not enough time to play with it.
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
Quote:
Originally Posted by
frank_lyy
...In your situation, I assume that you have plenty merchandise in stock and you have a very tight stock level control in place. I would suggest another fix posted by Grayson before...
Yup, you are correct as it reflects the real situation in my shops! I tried to insert the fixes posted but it didn't work as it shows the remarks to all the attributes defined even the stock has 0 quantity in it. I tried to change the logic though but when I define $products_options->fields['quantity'] = 0, no remarks shown instead!:no: BTW, thanx for your help, much appreciated!
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
Quote:
Originally Posted by
tajul_ashyqin
Yup, you are correct as it reflects the real situation in my shops! I tried to insert the fixes posted but it didn't work as it shows the remarks to all the attributes defined even the stock has 0 quantity in it. I tried to change the logic though but when I define $products_options->fields['quantity'] = 0, no remarks shown instead!:no: BTW, thanx for your help, much appreciated!
Sorry, my bad. I forgot to include the DB query change by Grayson. You need to change part of the DB query in attributes.php by kuori to ferry "quantity" from your DB first, then apply the fix I posted yesterday.
Here is the query change:
find this block of code:
Quote:
$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;
change it to:
Quote:
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;
}
This way, you got your quantities for each attribute then you can apply if {}else{}condition I suggested yesterday.
Keep in mind, these fix will only work for products have one attribute, and product attribute display style is radio buttons or check boxes.
In case of default dropdown display, you need to modify the $products_options_array[], such as:
Quote:
[FONT=Times New Roman]if ($products_options->fields['quantity']) > 0) {[FONT=Verdana]$products_options_array[] = array('id' => $products_options->fields['products_options_values_id'],[/FONT]
[FONT=Times New Roman]'text' => $products_options->fields['products_options_values_name'] .' [' . $products_options->fields['quantity'] . ' '. TEXT_ATTRIBUTES_NOT_In_Stock . ']');[/FONT]
[FONT=Times New Roman]}[/FONT][/FONT]
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
Quote:
Originally Posted by
frank_lyy
...Sorry, my bad. I forgot to include the DB query change by Grayson. You need to change part of the DB query in attributes.php by kuori to ferry "quantity" from your DB first, then apply the fix I posted yesterday...
Why I didn't think of that! :laugh: thank you very much Frank! that should fix it... :yes:
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
Hi, I'm not sure if the error I'm experiencing has to do with Stock by Attribute or not. My client had this add-on installed for Zen Cart 1.2. We then installed 1.3.6 for her in a test directory. I do not see the error on her old cart, only on the new one.
I noticed the following error happening in the Attributes Controller on her new site. When I try to copy the attributes from one product to another item or to a category, this message comes up:
1136 Column count doesn't match value count at row 1
in:
[insert into products_attributes values (0, '237', '70', '480', '1.5000', '+', '0', '1', '0', '+', '0', '0', '1', '', '1', '0.0000', '0.0000', '0.0000', '0.0000', '0.0000', '', '', '0.0000', '0', '0.0000', '0', '0')]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.
I thought that maybe installing the add-on would help, so I did, but it hasn't made any difference. There's no products_attributes_values table in my database...should there be?
Does this seem like an error that is somehow related to Stock by Attribute?
Thanks!
Shoshanna
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
Ok this is a simple question not really related to the functionality of the script so much as the location of the output on the products page --
if you look at the product page at - http://marylandcycling.com/shopping/...&products_id=1
The attributes selection box seems to be much lower and out of place as compared to the add item to cart screen. I am afraid users will not see the size selection... and I can't for the life of me find out where this attributes box is scripted into each zen cart product page.
Can someone direct me to where or how I can modify the location of the output of the attributes slection "please choose" on the product page?
Ideally I would like to get it above the "add to cart" box.
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
Quote:
Originally Posted by
lemuria
Does this seem like an error that is somehow related to Stock by Attribute?
Hi Shoshanna
It's right that you have no products_attributes_values table. What this sql is doing is inserting values into the products_attributes table.
I'm afraid that I can see no link between this problem and Stock by Attribute. I think that your assessment is most likely correct and that the problem occurs in a database inset in the attributes controller. Stock by Attributes steers well clear of there.
I have a hypothesis however, about your problem. What version of MySQL are you running?
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
Quote:
Originally Posted by
nickmd
Ok this is a simple question not really related to the functionality of the script so much as the location of the output on the products page
Actually this is even further off topic than that since this add-on does not actually output anything to the products page :D (though a lot of people wish it would :yes:).
Although I wouldn't want to see this thread wander off into a discussion about reworking the products page (a rather common request) here's a quick pointer in the right direction ... some of the formating is achieving through CSS, but to make the change you want to do would require some editing of the includes/templates/YOUR_TEMPLATE/templates/tpl_product_info.php file which determines the order in which content is served to the products page.
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
Quote:
Originally Posted by
kuroi
Actually this is even further off topic than that since this add-on does not actually output anything to the products page :D (though a lot of people wish it would :yes:).
Great thank you! After looking in the correct forum I found an answer -- (http://www.zen-cart.com/forum/showthread.php?t=51697) for some reason I thought this module created the attributes, but now I understand. Thanks!