Attribute Product Codes [Contribution]
#41
Posted 18 December 2007 - 07:48 PM
Base # ID1
1 oz - Suffix = 6
2 oz - Suffix = 7
Apple - Suffix = 00
Pear - Suffix = 01
- Suffix = 02
etc
On the orders page the product model numbers are backwards! It is showing as "ID1-00-6", I need it to be "ID1-6-00". I have changed the suffix order but that doesnt seem to have an effect.
Thoughts?
Thanks in advance!
~Roq
#42
Posted 09 January 2008 - 09:51 AM
Im having an issue where the "products_code" isint being inserted into the database. From looking at the code I think this should be done in checkout_process.php around line 160 right? When is checkout_process.php called, and is it possible that if im using a different payment method that this isint the file which is doing the inserting?
Thanks,
Allan
#43
Posted 25 February 2008 - 12:54 AM
abrown1982, on Jan 9 2008, 09:51 AM, said:
Im having an issue where the "products_code" isint being inserted into the database. From looking at the code I think this should be done in checkout_process.php around line 160 right? When is checkout_process.php called, and is it possible that if im using a different payment method that this isint the file which is doing the inserting?
Thanks,
Allan
Do note that in file catalog/includes/classes/shopping_cart.php the change has to be in function get_products().
#44
Posted 25 February 2008 - 01:08 AM
In catalog/includes/classes/shopping_cart.php and in function get_products() the following:
$attribute_code_array = array();
if (is_array($this->contents[$products_id]['attributes'])) {
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_code_query = tep_db_query("select code_suffix, suffix_sort_order from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_code = tep_db_fetch_array($attribute_code_query);
if (tep_not_null($attribute_code['code_suffix'])) {
$attribute_code_array[(int)$attribute_code['suffix_sort_order']] = $attribute_code['code_suffix'];
}
}
$separator = '';
if (count($attribute_code_array) > 1) {
$separator = '-';
} elseif (count($attribute_code_array) == 1) {
$separator = '/';
}
$products_code = $products['products_model'] . $separator . implode("/", $attribute_code_array);
}
The function won't go in to while loop: while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
and thus won't get the suffix from database and by that it returns wrong code, which is the product_model only. I can't figure out why the while clausule would be false in this case. Could someone smarter help? I've tested that $this->contents[$products_id]['attributes'] does have correct values. For some reason that while is just being ignored!
Edited by jemmasta, 25 February 2008 - 01:13 AM.
#45
Posted 25 February 2008 - 01:58 AM
Also tried with while (each($this->contents[$products_id]['attributes'])){
And even then while was not entered. So
each($this->contents[$products_id]['attributes'])for some reason returns false even if it has correct array values right before, I'm stumbled.
#46
Posted 25 February 2008 - 03:10 AM
Quote
and
Quote
Wouldn't this mean, that since each() has been used in while (list($products_id, ) = each($this->contents)) {
It would point to left on the NEXT product in while when it reaches each($this->contents[$products_id]['attributes']) and so would return FALSE, because pointer is actually at the end of the array contents.
Is there any workaround available for this problem?
#47
Posted 25 February 2008 - 03:48 AM
I changed this part:
if (is_array($this->contents[$products_id]['attributes'])) {
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_code_query = tep_db_query("select code_suffix, suffix_sort_order from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_code = tep_db_fetch_array($attribute_code_query);
if (tep_not_null($attribute_code['code_suffix'])) {
$attribute_code_array[(int)$attribute_code['suffix_sort_order']] = $attribute_code['code_suffix'];
}
}
to this:
if (is_array($this->contents[$products_id]['attributes'])) {
$i = 0;
foreach ($this->contents[$products_id]['attributes'] as $attributes){
$option = array_keys($this->contents[$products_id]['attributes']);
$value = $this->contents[$products_id]['attributes'];
$attribute_code_query = tep_db_query("select code_suffix, suffix_sort_order from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option[$i] . "' and options_values_id = '" . (int)$value[$option[$i]] . "'");
$attribute_code = tep_db_fetch_array($attribute_code_query);
if (tep_not_null($attribute_code['code_suffix'])) {
$attribute_code_array[(int)$attribute_code['suffix_sort_order']] = $attribute_code['code_suffix'];
}
$i++;
}
So changed while logic to foreach and removed the each() by fetching key values by array_keys and using those values to point to correct option values. Perhaps a bit crude, but now it works as it should've in the first place.
Edited by jemmasta, 25 February 2008 - 03:50 AM.
#48
Posted 25 February 2008 - 12:35 PM
It seems that this module isn't working with latest osCommerce version (2.2rc2a)?
Am I right?
#49
Posted 25 February 2008 - 03:38 PM
celtic78, on Feb 25 2008, 12:35 PM, said:
It seems that this module isn't working with latest osCommerce version (2.2rc2a)?
Am I right?
The above modification allows it to work with 2.2rc2a. Don't know if the problem mentioned is on other revisions, but I have it working on 2.2rc2a after installation just make the modification I've mentioned above your post.
#50
Posted 26 February 2008 - 09:11 AM
Got it working just like it should.
#51
Posted 17 March 2010 - 12:56 PM
Red Apple - RED-AP
Large Red Apple - RED-AP-LG
Green Apple - GRE-AP
Large Green Apple - GRE-AP-LG
Rotten Apple - MUSHY
Large Rotten Apple - MUSHY-LG
Also, would all attributes require a product code to be entered? (so rotten apples and large rotten apples could be sold under the product code 'MUSHY')
Thanks in advance.
Ian
#52
Posted 23 January 2012 - 01:01 PM
I have mangaed to get the code copied over to the attribute manager by parrot fashion but cannot get my head around the .js part.
I have got the fields into attribute manager but it will not save to the db, guess this is where the java script comes in.
Not being a programmer I have just about got my head around the php part but .js baffles me.
If anyone can point me in the right direction on integrating code suffix into the java script of attribute manager I will upload the rest that I have done once it is working.
Regards Andy
#53
Posted 20 March 2012 - 06:51 AM
roquetsynce, on 18 December 2007 - 07:48 PM, said:
Base # ID1
1 oz - Suffix = 6
2 oz - Suffix = 7
Apple - Suffix = 00
Pear - Suffix = 01
Orange - Suffix = 02
etc
On the orders page the product model numbers are backwards! It is showing as "ID1-00-6", I need it to be "ID1-6-00". I have changed the suffix order but that doesnt seem to have an effect.
Thoughts?
Thanks in advance!
~Roq
I have the same problem as @roquetsynce: It doesn't matter what you set the Suffix Order to, they always report back in the same order.
For example:
Base # ID1 1 oz - Suffix = 6, Order = 1 2 oz - Suffix = 7, Order = 1 Apple - Suffix = 00, Order = 2 Pear - Suffix = 01, Order = 2 Orange - Suffix = 02, Order = 2
Ordering a 1oz Apple could result in the code "AP1-00-6" instead of the desired "AP1-6-00". I found out what is happening is that the php function "implode" the converts the array to a string does not sort by the key, instead sorting by the order it was typed in. What we need to do is use the php function "KSORT" just before the code is generated.
In catalog\admin\classes\shopping_cart.php
Find (about line 358):
$products_code = $products['products_model'] . $separator . implode("/", $attribute_code_array);
Add BEFORE:
ksort($attribute_code_array);
I've added this to the contribution update V1.2 along with some other corrections.
#54
Posted 13 June 2012 - 02:50 PM
admin side working ok, storing suffix, showing OK on shopping_cart.php,
but not on roder, inovices packing slips, checkout_confirmation.php
was working before QT-PRO....
INSTALLED:Document Manager / Monthly Sales and Tax Returns / Batch Print Invoices / Ultimate HTML EMAILs / AJAX Attribute Manager / OSC PDF Catalog / Move Bookmarks / Sort Order / Easy Populate / Sales Reports / Low Stock Report / Admin: Model # on Category / Product Administration Screen / Mini images in admin / SLiCK reCaptcha / Google + / Beautiful Breadcrumbs / 2.3.1 - Banner Language Mod / ADD New Page / EASY MAP (google) v.3.0 / Who's Online Enhancement for 2.3.1 / Admin Notes / scrambled order number / remove_unused_images / Quantity Select / Unit Weight / Product Specifions (filter results) / AJAX Product Attributes/ Attribute Codes/ Date & Order No. to Invoice/ O.P.I. 2.0 / Attribute Images / Manual Order Editor / Attributes Clone / Order Editor / Create Order / Company VAT No. / Add customer/ CKEditor 2.3.1 / Page Manager / Default images via admin / Percentage Shipping Price / QTPro / Scroll to Top / PDF Invoice / Featured Products / Product Listing Enhancements / AutoBackups / Ultimate SEO URLS 5 Pro / Kiss Tags/ ..Custom Admin Mods /
#55
Posted 25 June 2012 - 10:42 AM
jemmasta, on 25 February 2008 - 03:48 AM, said:
I changed this part:
if (is_array($this->contents[$products_id]['attributes'])) {
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_code_query = tep_db_query("select code_suffix, suffix_sort_order from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_code = tep_db_fetch_array($attribute_code_query);
if (tep_not_null($attribute_code['code_suffix'])) {
$attribute_code_array[(int)$attribute_code['suffix_sort_order']] = $attribute_code['code_suffix'];
}
}
to this:
if (is_array($this->contents[$products_id]['attributes'])) {
$i = 0;
foreach ($this->contents[$products_id]['attributes'] as $attributes){
$option = array_keys($this->contents[$products_id]['attributes']);
$value = $this->contents[$products_id]['attributes'];
$attribute_code_query = tep_db_query("select code_suffix, suffix_sort_order from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option[$i] . "' and options_values_id = '" . (int)$value[$option[$i]] . "'");
$attribute_code = tep_db_fetch_array($attribute_code_query);
if (tep_not_null($attribute_code['code_suffix'])) {
$attribute_code_array[(int)$attribute_code['suffix_sort_order']] = $attribute_code['code_suffix'];
}
$i++;
}
So changed while logic to foreach and removed the each() by fetching key values by array_keys and using those values to point to correct option values. Perhaps a bit crude, but now it works as it should've in the first place. [img]http://forums.oscommerce.com/public/style_emoticons/default/smile.gif[/img] It really seems that reusing each() within a loop that has already used each() caused this problem, at least in PHP5. This solves the problem.
BINGO!!!!!! Boom we are back in the game! NIce one!
INSTALLED:Document Manager / Monthly Sales and Tax Returns / Batch Print Invoices / Ultimate HTML EMAILs / AJAX Attribute Manager / OSC PDF Catalog / Move Bookmarks / Sort Order / Easy Populate / Sales Reports / Low Stock Report / Admin: Model # on Category / Product Administration Screen / Mini images in admin / SLiCK reCaptcha / Google + / Beautiful Breadcrumbs / 2.3.1 - Banner Language Mod / ADD New Page / EASY MAP (google) v.3.0 / Who's Online Enhancement for 2.3.1 / Admin Notes / scrambled order number / remove_unused_images / Quantity Select / Unit Weight / Product Specifions (filter results) / AJAX Product Attributes/ Attribute Codes/ Date & Order No. to Invoice/ O.P.I. 2.0 / Attribute Images / Manual Order Editor / Attributes Clone / Order Editor / Create Order / Company VAT No. / Add customer/ CKEditor 2.3.1 / Page Manager / Default images via admin / Percentage Shipping Price / QTPro / Scroll to Top / PDF Invoice / Featured Products / Product Listing Enhancements / AutoBackups / Ultimate SEO URLS 5 Pro / Kiss Tags/ ..Custom Admin Mods /
#56
Posted 03 March 2013 - 08:05 PM
Also, the next and previous buttons are showing IMAGE_BUTTON_PREVIOUS_PRODUCT.
Any thoughts on which page may be incorrect?









