Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Dr byte. Sorry as I didn't mean to offend you. He'll I didn't even know you read ever one of my post. LOL I feel honored. ;) maybei am using the wrong word when I say flaw. Which I have seen many others use similar words to explain the issue.
The issue I am referring to is that people are able to check out even when not selecting an attribute. IE size color etc., just hit the add to cart button and proceed to checkout. I installed a fresh cart with no mods at all and can do this. Now there clever work arounds using an attrribute and required selector to prevent checking out without making a selection as I point out those post without having to retype something someone already has.
Now in my opinion I think at default you shouldn't be allowed to checkout without an attribute selected. I am sure zen cart has it's reason for it.
I tried to come up with a mod to prevent this but couldn't quite figure out all the attribute code make it work. Using the solution kurio been helping everyone out with works for me and hopefully others.
Now to come up with a diffrent word to use... It's a zen thing... ;)
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Aszu. I am hoping to have a 1.3.9G version out this week. Scratch that have a version 1.3.9H out this week. LOL
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Quote:
Originally Posted by
creinold
Dr byte. Sorry as I didn't mean to offend you. He'll I didn't even know you read ever one of my post. LOL I feel honored. ;)
Not offended. Just puzzled. And concerned that you're pointing people to a thread that has too many different topics in it to actually be giving an answer to their specific question.
Quote:
Originally Posted by
creinold
The issue I am referring to is that people are able to check out even when not selecting an attribute. IE size color etc., just hit the add to cart button and proceed to checkout. I installed a fresh cart with no mods at all and can do this.
That's specifically by design. There are many legitimate cases for having all attributes be entirely optional. In that case it would be wrong to force attribute selection.
Quote:
Originally Posted by
creinold
Now there clever work arounds using an attrribute and required selector to prevent checking out without making a selection
Exactly. It's very easy to configure exactly what you need if you require certain attributes to be chosen: simply create an option value such as "Please select" and make it "default" and "display-only". This will force them to choose any of the other non-display-only options in order to complete checkout.
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Quote:
Originally Posted by
creinold
Nah, I was talking about the ability to check out when there isn't any stock to buy. My memory is that the attribute dropped from the list when the attribute stock amounts dropped to 0. This was several years back.
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
I have just posetd in the ugrade forum regarding an upgrade to 1.39h and the effect i found it had on SBA.
Here's my post from that thread:
Quote:
So i have just upgraded one of my sites.
It seems to have gone smoothly bar a couple of files.
Files for me which were affected were general.php (i had overwritten on 1.39g but not sure which add on had over written it - Winmerge didn't help either as the two files are so different) but everything seems to be working ok.
Main issue is stock by attributes and in particular the following two files:
- /includes/modules/pages/checkout_shipping/header_php.php
- /includes/modules/pages/shopping_cart/header_php.php
I have winmerged the header_php.php file in checkout_shipping succesfully it's the header file in the shopping_cart folder that i am struggling to merge succesfully.
With the merged file i have used no out of stock notification is showing next to an unavailable product in the cart on the customer side.
Any one else using SBA and had the same issue and resolved it?
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Try go to Admin - Configuration - Stock and change:
Allow Checkout to False
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Quote:
Originally Posted by
DVDTitan
I have just posetd in the ugrade forum regarding an upgrade to 1.39h and the effect i found it had on SBA.
Here's my post from that thread:
WHat and whos version are you using. I think my last version fixed this but it was for 1.3.9E
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Quote:
Originally Posted by
creinold
WHat and whos version are you using. I think my last version fixed this but it was for 1.3.9E
I am using your version. The latest version of zencart released today (1.39h) requires an update of the two files mentioned, which are files your SBA also modifies to prevent checkout on out of stock items.
There has been changes to these files in 1.39h from 1.39g and before.
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
I'm working on the update. Just downloaded the new zen version and will merge them together. I should hopeful have it done in a few days. Busy week, I haven't touch the files since version E due to some personal life issues.
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5+
Try this for the shopping cart header.php file
Code:
<?php
/**
* shopping_cart header_php.php
*
* @package page
* @copyright Copyright 2003-2010 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: header_php.php 17948 2010-10-13 20:33:18Z drbyte $
*/
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_HEADER_START_SHOPPING_CART');
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
$breadcrumb->add(NAVBAR_TITLE);
// Validate Cart for checkout
$_SESSION['valid_to_checkout'] = true;
$_SESSION['cart_errors'] = '';
$_SESSION['cart']->get_products(true);
if (!$_SESSION['valid_to_checkout']) {
$messageStack->add('shopping_cart', ERROR_CART_UPDATE . $_SESSION['cart_errors'] , 'caution');
}
// build shipping with Tare included
$shipping_weight = $_SESSION['cart']->show_weight();
/*
$shipping_weight = 0;
require(DIR_WS_CLASSES . 'order.php');
$order = new order;
require_once('includes/classes/http_client.php'); // shipping in basket
$total_weight = $_SESSION['cart']->show_weight();
$total_count = $_SESSION['cart']->count_contents();
require(DIR_WS_CLASSES . 'shipping.php');
$shipping_modules = new shipping;
$quotes = $shipping_modules->quote();
*/
$totalsDisplay = '';
switch (true) {
case (SHOW_TOTALS_IN_CART == '1'):
$totalsDisplay = TEXT_TOTAL_ITEMS . $_SESSION['cart']->count_contents() . TEXT_TOTAL_WEIGHT . $shipping_weight . TEXT_PRODUCT_WEIGHT_UNIT . TEXT_TOTAL_AMOUNT . $currencies->format($_SESSION['cart']->show_total());
break;
case (SHOW_TOTALS_IN_CART == '2'):
$totalsDisplay = TEXT_TOTAL_ITEMS . $_SESSION['cart']->count_contents() . ($shipping_weight > 0 ? TEXT_TOTAL_WEIGHT . $shipping_weight . TEXT_PRODUCT_WEIGHT_UNIT : '') . TEXT_TOTAL_AMOUNT . $currencies->format($_SESSION['cart']->show_total());
break;
case (SHOW_TOTALS_IN_CART == '3'):
$totalsDisplay = TEXT_TOTAL_ITEMS . $_SESSION['cart']->count_contents() . TEXT_TOTAL_AMOUNT . $currencies->format($_SESSION['cart']->show_total());
break;
}
// testing/debugging
// require(DIR_WS_MODULES . 'debug_blocks/shopping_cart_contents.php');
$flagHasCartContents = ($_SESSION['cart']->count_contents() > 0);
$cartShowTotal = $currencies->format($_SESSION['cart']->show_total());
$flagAnyOutOfStock = false;
$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if (($i/2) == floor($i/2)) {
$rowClass="rowEven";
} else {
$rowClass="rowOdd";
}
switch (true) {
case (SHOW_SHOPPING_CART_DELETE == 1):
$buttonDelete = true;
$checkBoxDelete = false;
break;
case (SHOW_SHOPPING_CART_DELETE == 2):
$buttonDelete = false;
$checkBoxDelete = true;
break;
default:
$buttonDelete = true;
$checkBoxDelete = true;
break;
$cur_row++;
} // end switch
$attributeHiddenField = "";
$attrArray = false;
$productsName = $products[$i]['name'];
// Push all attributes information in an array
if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
if (PRODUCTS_OPTIONS_SORT_ORDER=='0') {
$options_order_by= ' ORDER BY LPAD(popt.products_options_sort_order,11,"0")';
} else {
$options_order_by= ' ORDER BY popt.products_options_name';
}
foreach ($products[$i]['attributes'] as $option => $value) {
$attributes = "SELECT popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
FROM " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
WHERE pa.products_id = :productsID
AND pa.options_id = :optionsID
AND pa.options_id = popt.products_options_id
AND pa.options_values_id = :optionsValuesID
AND pa.options_values_id = poval.products_options_values_id
AND popt.language_id = :languageID
AND poval.language_id = :languageID " . $options_order_by;
$attributes = $db->bindVars($attributes, ':productsID', $products[$i]['id'], 'integer');
$attributes = $db->bindVars($attributes, ':optionsID', $option, 'integer');
$attributes = $db->bindVars($attributes, ':optionsValuesID', $value, 'integer');
$attributes = $db->bindVars($attributes, ':languageID', $_SESSION['languages_id'], 'integer');
$attributes_values = $db->Execute($attributes);
//clr 030714 determine if attribute is a text attribute and assign to $attr_value temporarily
if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID) {
$attributeHiddenField .= zen_draw_hidden_field('id[' . $products[$i]['id'] . '][' . TEXT_PREFIX . $option . ']', $products[$i]['attributes_values'][$option]);
$attr_value = htmlspecialchars($products[$i]['attributes_values'][$option], ENT_COMPAT, CHARSET, TRUE);
} else {
$attributeHiddenField .= zen_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
$attr_value = $attributes_values->fields['products_options_values_name'];
}
$attrArray[$option]['products_options_name'] = $attributes_values->fields['products_options_name'];
$attrArray[$option]['options_values_id'] = $value;
$attrArray[$option]['products_options_values_name'] = $attr_value;
$attrArray[$option]['options_values_price'] = $attributes_values->fields['options_values_price'];
$attrArray[$option]['price_prefix'] = $attributes_values->fields['price_prefix'];
}
} //end foreach [attributes]
if (STOCK_CHECK == 'true') {
$flagStockCheck = zen_check_stock($products[$i]['id'], $products[$i]['quantity'],$attributes);
if ($flagStockCheck == true) {
$flagAnyOutOfStock = true;
}
}
$linkProductsImage = zen_href_link(zen_get_info_page($products[$i]['id']), 'products_id=' . $products[$i]['id']);
$linkProductsName = zen_href_link(zen_get_info_page($products[$i]['id']), 'products_id=' . $products[$i]['id']);
$productsImage = (IMAGE_SHOPPING_CART_STATUS == 1 ? zen_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT) : '');
$show_products_quantity_max = zen_get_products_quantity_order_max($products[$i]['id']);
$showFixedQuantity = (($show_products_quantity_max == 1 or zen_get_products_qty_box_status($products[$i]['id']) == 0) ? true : false);
// $showFixedQuantityAmount = $products[$i]['quantity'] . zen_draw_hidden_field('products_id[]', $products[$i]['id']) . zen_draw_hidden_field('cart_quantity[]', 1);
// $showFixedQuantityAmount = $products[$i]['quantity'] . zen_draw_hidden_field('cart_quantity[]', 1);
$showFixedQuantityAmount = $products[$i]['quantity'] . zen_draw_hidden_field('cart_quantity[]', $products[$i]['quantity']);
$showMinUnits = zen_get_products_quantity_min_units_display($products[$i]['id']);
$quantityField = zen_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"');
$buttonUpdate = ((SHOW_SHOPPING_CART_UPDATE == 1 or SHOW_SHOPPING_CART_UPDATE == 3) ? zen_image_submit(ICON_IMAGE_UPDATE, ICON_UPDATE_ALT) : '') . zen_draw_hidden_field('products_id[]', $products[$i]['id']);
$tmp = zen_add_tax($products[$i]['final_price'],zen_get_tax_rate($products[$i]['tax_class_id']));
// $productsPriceEach = $currencies->rateAdjusted($tmp);
// $productsPriceTotal = $productsPriceEach * $products[$i]['quantity'];
$productsPriceTotal = $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
$productsPriceEach = $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
// $productsPriceTotal = $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
// echo $currencies->rateAdjusted($tmp);
$productArray[$i] = array('attributeHiddenField'=>$attributeHiddenField,
'flagStockCheck'=>$flagStockCheck,
'flagShowFixedQuantity'=>$showFixedQuantity,
'linkProductsImage'=>$linkProductsImage,
'linkProductsName'=>$linkProductsName,
'stockAvailable'=>$stockAvailable,
'productsImage'=>$productsImage,
'productsName'=>$productsName,
'showFixedQuantity'=>$showFixedQuantity,
'showFixedQuantityAmount'=>$showFixedQuantityAmount,
'showMinUnits'=>$showMinUnits,
'quantityField'=>$quantityField,
'buttonUpdate'=>$buttonUpdate,
'productsPrice'=>$productsPriceTotal,
'productsPriceEach'=>$productsPriceEach,
'rowClass'=>$rowClass,
'buttonDelete'=>$buttonDelete,
'checkBoxDelete'=>$checkBoxDelete,
'id'=>$products[$i]['id'],
'attributes'=>$attrArray);
} // end FOR loop
// This should be last line of the script:
$zco_notifier->notify('NOTIFY_HEADER_END_SHOPPING_CART');
?>