Zen Cart Logo
Forums / All Other Contributions/Addons / StockByAttributes with my stock id MOD 1.0.0

StockByAttributes with my stock id MOD 1.0.0

Views: 10,111

Results 41 to 60 of 87
9 Feb 2012, 3:02 AM
#41
rooster_cogbern avatar

rooster_cogbern

New Zenner

Join Date:
Jan 2012
Posts:
10
Plugin Contributions:
0

StockByAttributes with my stock id MOD 1.0.0

One last.. I saw an older post that sounded similar.. http://www.zen-cart.com/forum/showthread.php?t=183860 to ours. The solution talked about an updated /includes/modules/pages/shopping_cart/header_php.php.
rhuseby - I looked at my header_php.php and compared yours.. I think you might have the older version. I edited (hacked) your inputs into this version.. the edits are around line 177 forward.

I have posted my version below. it might be the real problem.

  • rooster
<?php
/**
 * shopping_cart header_php.php
 *
 * @package page
 * @copyright Copyright 2003-2011 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 19098 2011-07-13 15:19:52Z wilt $
 */

// 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 (STOCK_CHECK == 'true') {
     $flagStockCheck = zen_check_stock($products[$i]['id'], $products[$i]['quantity']);
     if ($flagStockCheck == true) {
       $flagAnyOutOfStock = true;
      }
     $stockAvailable = zen_get_products_stock($products[$i]['id']);
   }  
  
  
  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'];
    }
    // stock by attributes
		if ( STOCK_CHECK == 'true' ) {

			// Added to allow individual stock of different attributes
			unset($attributes);
			if(is_array($products[$i]['attributes'])){
				$attributes = $products[$i]['attributes'];
			} else {
				$attributes = '';
			}

			$stock_check = zen_check_stock($products[$i]['id'], $products[$i]['quantity'],$attributes);
	
			if (zen_not_null($stock_check))
			{
				$flagAnyOutOfStock = true;
				$flagStockCheck = $stock_check;
			  $stockAvailable = zen_get_products_stock($products[$i]['id'], $attributes);		
			}
		}

    // rhuseby: (my_stock_id MOD)

      $my_stock_id = zen_get_my_stock_id($products[$i]['id'], $attributes);

    // rhuseby: end (my_stock_id MOD)
    // end stock by attributes
  } //end foreach [attributes]
/*
  if (STOCK_CHECK == 'true') {
    $flagStockCheck = zen_check_stock($products[$i]['id'], $products[$i]['quantity']);
    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"');
  $ppe = $products[$i]['final_price'];
  $ppe = zen_round(zen_add_tax($ppe, zen_get_tax_rate($products[$i]['tax_class_id'])), $currencies->get_decimal_places($_SESSION['currency']));
  $ppt = $ppe * $products[$i]['quantity'];
  $productsPriceEach = $currencies->format($ppe) . ($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->format($ppt) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
  $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']);
//  $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) : '');
//  $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'],
                            // rhuseby: (my_stock_id MOD)
                            'my_stock_id'=>$my_stock_id,
                            // rhuseby: end (my_stock_id MOD)
                            'attributes'=>$attrArray);
} // end FOR loop


// This should be last line of the script:
$zco_notifier->notify('NOTIFY_HEADER_END_SHOPPING_CART');
?>
9 Feb 2012, 9:25 PM
#42
boggled avatar

boggled

Zen Follower

Join Date:
Mar 2006
Location:
Tennessee
Posts:
286
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Rooster - Thank You!

I really appreciate all the suggestions and they helped a lot. The one that seemed to make the biggest difference was making sure EVERY possible combination had been defined.

The last and final 'fix' was in the attribute setup itself. We have 'read only' attributes of Age Group and Gender set up for our Google Product feed. At 2:00 am after beating my head against the wall a few times :censored: my partner suggested I try a process of elimination and remove all attributes except size and color. It started working. Apparently, SBA doesn't play well with read only attributes.

I changed them to radio button and it began working like it should; showing items in/out of stock correctly in the shopping cart.

At least for the time being...so far so good. :smile:

The only thing left to do now is figure out how to hide the radio button attributes. We had hidden the read only ones, but from looking at the code, the radio ones will be more difficult.

9 Feb 2012, 9:41 PM
#43
rooster_cogbern avatar

rooster_cogbern

New Zenner

Join Date:
Jan 2012
Posts:
10
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Awesome to hear! Glad I could help. Good luck with rest.

10 Feb 2012, 12:04 AM
#44
rhuseby avatar

rhuseby

New Zenner

Join Date:
Nov 2011
Location:
Atlanta, GA
Posts:
44
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Thanks Rooster, glad to see the community working together like it's supposed to.:smile: Sorry I wasn't more help Boggled. :unsure:

@Rooster, I'm trying to port the MOD for 1.5.0 (just started) I may need to ask for your assistance, the whole Admin menu change has me puzzled. I'm not sure how to get the Admin part working. What happened to "includes/Boxes" for instance. Feel free to email me if you want to give me some pointers...

10 Feb 2012, 12:19 AM
#45
rooster_cogbern avatar

rooster_cogbern

New Zenner

Join Date:
Jan 2012
Posts:
10
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

I started with v1.5.0... so I wasn't sure it was apart of the earlier versions.

I had the same problem in that I couldn't find the module in the Admin/Catalog. I found that you need to add a new field in the "admin_pages". I ended up manually to inserting it, but you could use a script as:

   ```php

INSERT INTO admin_pages (page_key ,language_key ,main_page ,page_params ,menu_key ,display_on_menu ,sort_order)
VALUES (
'productsWithAttributesStock','BOX_CATALOG_PRODUCTS_WITH_ATTRIBUTES_STOCK','FILENAME_PRODUCTS_WITH_ATTRIBUTES_STOCK','','catalog','Y','18'
);


I probably should have documented my steps.. but being a newbie to ZC, I kindof just banged my head:frusty: until I got it to work.  Let me know when you get to the next hurlde, I am sure I already stumbled into it... just not sure what the next one is until someone asks.

Rooster
10 Feb 2012, 2:37 AM
#46
boggled avatar

boggled

Zen Follower

Join Date:
Mar 2006
Location:
Tennessee
Posts:
286
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Ron, I have another question...

On the 'jump to product' part where it has a link to each item, is there a way to disable this?

By the time we're finished we'll have hundreds of individual products and I'm afraid it will become more problematic than useful at that point.

Thanks!

10 Feb 2012, 3:44 AM
#47
boggled avatar

boggled

Zen Follower

Join Date:
Mar 2006
Location:
Tennessee
Posts:
286
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

rhuseby:

Thanks Rooster, glad to see the community working together like it's supposed to.:smile: Sorry I wasn't more help Boggled. :unsure:

You were lots of help too, Ron! This mod is exactly what we need and I'm so glad to have gotten it working. :smile:

10 Feb 2012, 5:01 PM
#48
rhuseby avatar

rhuseby

New Zenner

Join Date:
Nov 2011
Location:
Atlanta, GA
Posts:
44
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Boggled:

Ron, I have another question...

On the 'jump to product' part where it has a link to each item, is there a way to disable this?

By the time we're finished we'll have hundreds of individual products and I'm afraid it will become more problematic than useful at that point.

Thanks!

Yes, I can tell you what edits to make. I actually created that part because I thought it was a pain to scroll through the list looking for the item you want once you have a lot of items. But if you want to get rid of it, it's not that many edits. I will reply with specifics.

Are you using Internet Explorer? I did notice it didn't display properly with Google Chrome (one long line of buttons) IE works fine though...

10 Feb 2012, 5:35 PM
#49
rhuseby avatar

rhuseby

New Zenner

Join Date:
Nov 2011
Location:
Atlanta, GA
Posts:
44
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Boggled:

Ron, I have another question...

On the 'jump to product' part where it has a link to each item, is there a way to disable this?

By the time we're finished we'll have hundreds of individual products and I'm afraid it will become more problematic than useful at that point.

Thanks!

admin/includes/classes/products_with_attributes_stock.php

  • Remove or comment out code lines 123-148
  • Remove or comment out code lines 180-181
  • Uncomment line 182
    I also changed the sort order:
  • Remove or comment out code line 192
  • Uncomment line 193

admin/products_with_attributes_stock.php

I added a stylesheet for the buttons, it probably could stay but if you want you could comment or delete this line:
351: <link rel="stylesheet" type="text/css" href="includes/pwas_jump_buttons.css">
and remove the file includes/pwas_jump_buttons.css

Most if not all of my edits have "rhuseby" in a comment next to the edit. You can search "rhuseby" or "my_stock_id" and find just about everything I changed...

10 Feb 2012, 5:44 PM
#50
noruga avatar

noruga

New Zenner

Join Date:
May 2009
Posts:
31
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

rooster_cogbern:

rhuseby,

After much tinkering and hacking, I think I got SBA working for 1.5.0.. well, I can modify stock attributes.. still working to show the MyStockID.. but a little more hacking I should get it. Wasn't too hard, just looked at the code adds for the 6 main files and added it to my 1.5.0 files. Also needed to add the page in admin_pages in MySQL.

That being said, curious if you would know an easy way to turn-off the stock attributes for some of the attributes. If I leave it blank, it won't accept the change.

Thanks,

Rooster

Hi Rooster,
I am struggling to get SBA working for 1.5.0.
Since you apparently made a workaround, would it be possible for you to post the modified files?

Thanks

10 Feb 2012, 6:00 PM
#51
rhuseby avatar

rhuseby

New Zenner

Join Date:
Nov 2011
Location:
Atlanta, GA
Posts:
44
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

rhuseby:

Are you using Internet Explorer? I did notice it didn't display properly with Google Chrome (one long line of buttons) IE works fine though...

Hmmmm... I see the buttons don't work properly in Firefox either. I will try to fix this. :smile:

10 Feb 2012, 6:40 PM
#52
boggled avatar

boggled

Zen Follower

Join Date:
Mar 2006
Location:
Tennessee
Posts:
286
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

rhuseby:

Yes, I can tell you what edits to make. I actually created that part because I thought it was a pain to scroll through the list looking for the item you want once you have a lot of items. But if you want to get rid of it, it's not that many edits. I will reply with specifics.

Are you using Internet Explorer? I did notice it didn't display properly with Google Chrome (one long line of buttons) IE works fine though...

That's always been my biggest complaint about SBA was the scrolling. I have to say that search box at the top has helped tremendously.

I'm going to leave it for the time being and see how the 'jump to' works, but did want to ask about the ability to remove it. One cart we have has over 2000 items and the new one I'm working on now will have in the hundreds minimum. All of the titles will be somewhat similar since they are all motorcycle helmets.

In a perfect world (my opinion), all the items wouldn't display on the page automatically or refresh back to the top every time you click submit. It would just have the search box or a dropdown list of model numbers and stay on the selected item until you click save.

BUT since I am not a coder and can't do it myself, I am extremely grateful for those of you who do create these mods and happily use them however they are set up. :smile:

I've been using it in Opera and IE8/9 and only have one product listed right now during my testing. Once I get more listed I'll let you know how it displays and if it needs tweaking.

10 Feb 2012, 6:42 PM
#53
rhuseby avatar

rhuseby

New Zenner

Join Date:
Nov 2011
Location:
Atlanta, GA
Posts:
44
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Boggled:

Ron, I have another question...

On the 'jump to product' part where it has a link to each item, is there a way to disable this?

By the time we're finished we'll have hundreds of individual products and I'm afraid it will become more problematic than useful at that point.

Thanks!

If it is a long line of buttons and that's why you don't like it, you could change one line of code and have links without the fancy buttons...

admin/includes/classes/products_with_attributes_stock.php

Change line 142 to not use the CSS buttons:

$html .= '<a href="#'.$row['products_name'].'"><span class="cssButton" onmouseover="this.className=\'cssButtonHover\'" onmouseout="this.className=\'cssButton\'">'.$row['products_name'].'</span></a>';

to:

$html .= '<b>[ </b><a href="#'.$row['products_name'].'">'.$row['products_name'].'</a><b> ] </b>';

10 Feb 2012, 9:25 PM
#54
rhuseby avatar

rhuseby

New Zenner

Join Date:
Nov 2011
Location:
Atlanta, GA
Posts:
44
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Boggled:

That's always been my biggest complaint about SBA was the scrolling. I have to say that search box at the top has helped tremendously.

I'm going to leave it for the time being and see how the 'jump to' works, but did want to ask about the ability to remove it. One cart we have has over 2000 items and the new one I'm working on now will have in the hundreds minimum. All of the titles will be somewhat similar since they are all motorcycle helmets.

In a perfect world (my opinion), all the items wouldn't display on the page automatically or refresh back to the top every time you click submit. It would just have the search box or a dropdown list of model numbers and stay on the selected item until you click save.

BUT since I am not a coder and can't do it myself, I am extremely grateful for those of you who do create these mods and happily use them however they are set up. :smile:

I've been using it in Opera and IE8/9 and only have one product listed right now during my testing. Once I get more listed I'll let you know how it displays and if it needs tweaking.

I know this isn't what you were talking about, but when you mentioned a drop down list it made me think that could be yet another version. This would make the jump menu a drop down instead of buttons or plain links...

admin/includes/classes/products_with_attributes_stock.php

Add as lines:

  • 131 $html .= '<form>';
  • 132 $html .= '<select onChange="location=this.options[this.selectedIndex].value;" style="font-family:\'Arial\';color:#000000;background-color:#d9e1e5;font-size:10pt;">';

Change line 142 to: (144 after adding previous 2 lines)

  • $html .= '<option value="#'.$row['products_name'].'">'.$row['products_name'].'</option>';

Change line 144 to: (146 after adding 2 lines)

  • $html .= '</select></form></td></tr>';
13 Feb 2012, 7:59 PM
#55
boggled avatar

boggled

Zen Follower

Join Date:
Mar 2006
Location:
Tennessee
Posts:
286
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

I'm back. Are you sick of me yet? :lookaroun

PROBLEM: I have Fast and Easy Checkout installed. Now when I try to checkout it gets to the 'confirm order' page and I get this:

1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.product_attribute_is_free, pa.attributes_discounted ' at line 11
in:
[select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.product_attribute_is_free, pa.products_attributes_weight, pa.products_attributes_weight_prefix, pa.attributes_discounted, pa.attributes_price_base_included, pa.attributes_price_onetime, pa.attributes_price_factor, pa.attributes_price_factor_offset, pa.attributes_price_factor_onetime, pa.attributes_price_factor_onetime_offset, pa.attributes_qty_prices, pa.attributes_qty_prices_onetime, pa.attributes_price_words, pa.attributes_price_words_free, pa.attributes_price_letters, pa.attributes_price_letters_free, pa.products_attributes_maxdays, pa.products_attributes_maxcount, pa.products_attributes_filename pa.product_attribute_is_free, pa.attributes_discounted from products_options popt, products_options_values poval, products_attributes pa left join products_attributes_download pad on pa.products_attributes_id=pad.products_attributes_id where pa.products_id = '150:d589ee96db65a5fd30e81707a211f4a4' and pa.options_id = '1' and pa.options_id = popt.products_options_id and pa.options_values_id = '6' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '1' and poval.language_id = '1']

I have turned off FEC and the problem still happens, so I don't think it's a conflict with that mod.

Any ideas what I did wrong or what needs to be fixed? I originally posted this in the regular SBA thread with no response(different cart I was building - SBA 1.4.14). Other people tested that cart and checkout went through fine for them, so I assumed it was just me.

Same thing just now happened on this new site with the SBA+Model numbers mod. Had others test and they are getting the same error too. :(

13 Feb 2012, 10:04 PM
#56
boggled avatar

boggled

Zen Follower

Join Date:
Mar 2006
Location:
Tennessee
Posts:
286
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Boggled:

I'm back. Are you sick of me yet? :lookaroun

PROBLEM: I have Fast and Easy Checkout installed. Now when I try to checkout it gets to the 'confirm order' page and I get this:

I have turned off FEC and the problem still happens, so I don't think it's a conflict with that mod.

Any ideas what I did wrong or what needs to be fixed? I originally posted this in the regular SBA thread with no response(different cart I was building - SBA 1.4.14). Other people tested that cart and checkout went through fine for them, so I assumed it was just me.

Same thing just now happened on this new site with the SBA+Model numbers mod. Had others test and they are getting the same error too. :(

Add more info....

The orders ARE showing up in the admin, but none of them have a size or any other attribute attached to them.

14 Feb 2012, 2:46 AM
#57
boggled avatar

boggled

Zen Follower

Join Date:
Mar 2006
Location:
Tennessee
Posts:
286
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Another update....

If I change Configuration > Check Stock level to false I can't add anything to the cart. I get a blank white page that says:

1065 Query was empty
in:
[]

If I turn it back to true, I can add to the cart, but get the same 1064 SQL syntax error I asked about above.

I'm assuming it's all part of the same issue. If someone could just point me in a direction to look, I'd greatly appreciate it.

14 Feb 2012, 4:49 PM
#58
rhuseby avatar

rhuseby

New Zenner

Join Date:
Nov 2011
Location:
Atlanta, GA
Posts:
44
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Boggled:

Another update....

If I change Configuration > Check Stock level to false I can't add anything to the cart. I get a blank white page that says:

1065 Query was empty
in:
[]

If I turn it back to true, I can add to the cart, but get the same 1064 SQL syntax error I asked about above.

I'm assuming it's all part of the same issue. If someone could just point me in a direction to look, I'd greatly appreciate it.

I'm not sure about the Fast Easy Checkout problem, but this empty query has to do with my MOD... Here is the fix.

File: /includes/modules/pages/shopping_cart/header_php.php
Insert this routine at line #132 right above // stock by attributes.

if ( STOCK_CHECK == 'false' ) {

		// Added for my_stock_id to work with stock check off

		unset($attributes);
		if(is_array($products[$i]['attributes'])){
		$attributes = $products[$i]['attributes'];
		} else {
		$attributes = '';
		}

               // rhuseby: (my_stock_id MOD)

              $my_stock_id = zen_get_my_stock_id($products[$i]['id'], $attributes);

              // rhuseby: end (my_stock_id MOD)
	}
14 Feb 2012, 5:07 PM
#59
boggled avatar

boggled

Zen Follower

Join Date:
Mar 2006
Location:
Tennessee
Posts:
286
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

rhuseby:

I'm not sure about the Fast Easy Checkout problem, but this empty query has to do with my MOD... Here is the fix.

File: /includes/modules/pages/shopping_cart/header_php.php
Insert this routine at line #132 right above // stock by attributes.

if ( STOCK_CHECK == 'false' ) {

	// Added for my_stock_id to work with stock check off

	unset($attributes);
	if(is_array($products[$i]['attributes'])){
	$attributes = $products[$i]['attributes'];
	} else {
	$attributes = '';
	}

           // rhuseby: (my_stock_id MOD)

          $my_stock_id = zen_get_my_stock_id($products[$i]['id'], $attributes);

          // rhuseby: end (my_stock_id MOD)
}


Thank you, Ron!  That did fix the empty query issue.

The SQL syntax error has something to do with the attributes but I'm not sure what.  Same issue with or without FEC.  

I added a product with NO attributes whatsoever and I can check out fine.  It only happens with products that have attributes - whether their variants have been set up in SBA or not.
14 Feb 2012, 5:15 PM
#60
rhuseby avatar

rhuseby

New Zenner

Join Date:
Nov 2011
Location:
Atlanta, GA
Posts:
44
Plugin Contributions:
0

Re: StockByAttributes with my stock id MOD 1.0.0

Boggled:

I'm back. Are you sick of me yet? :lookaroun

PROBLEM: I have Fast and Easy Checkout installed. Now when I try to checkout it gets to the 'confirm order' page and I get this:

1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.product_attribute_is_free, pa.attributes_discounted ' at line 11
:(

Looks like the problem is in /includes/classes/order.php, the file is used in both MODs. Did you merge it, or maybe overwrite one of them?

I haven't used FEC before...