Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Attribute Product Codes [Contribution]


Guest

Recommended Posts

Is it possible to adapt this contribution, to have completely unique product codes per attribute for a particular product option instead of appending to the product's main code? Further options would append as per the original. Using the Apples example, this would become something like:

 

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

Link to comment
Share on other sites

  • 1 year later...
  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

has anyone managed to get this excellent contribution working with Ajax Attribute Manager?

 

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

Link to comment
Share on other sites

  • 1 month later...

I have two sizes for one product, then there are multiple flavours for each...

 

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.

Link to comment
Share on other sites

  • 2 months later...

Does anyone have this working ok with QT-PRO installed??????????????

 

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....

Link to comment
Share on other sites

  • 2 weeks later...

Ok, managed to fix this. smile.gif

 

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. smile.gif 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!

Link to comment
Share on other sites

  • 8 months later...

This add on worked great for my needs. However, there are a couple things that are not working properly. When I add something to the cart, it is added to the cart but the next page that is displayed is blank as well as the checkout process.

 

Also, the next and previous buttons are showing IMAGE_BUTTON_PREVIOUS_PRODUCT.

 

Any thoughts on which page may be incorrect?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...