Creating a SKU number from ID_NUM values

Problems installing or using the NOP Design Free Shopping Cart. **ARCHIVE** Please post new topics to one of the groups below.

Moderator: scott

Creating a SKU number from ID_NUM values

Postby winkphoto » Tue Dec 24, 2002 1:01 pm

Ok, here is a rather off the wall idea.

At the end of a "shopping session", when I go to the managecart page, I'd like to see everything that you already see, PLUS I'd like to assemble all of the ID_NUM values in order, separated by a hyphen or other character (or tab) that would create a SKU number for the product.

Right now I'm coding a shopping system where a usewill be selecting a number of pieces that go together to make one large product. All the ID_NUM strings, when placed in order, will create a SKU number that the vendor will recognize by virtue of that SKU (much like a VIN number of a car ie - the string 020450025218 could mean 02-year of manufacture 04 is 4 wheel drive 500 is 5.0 litre engine 252 is the option package and 18 is the size of the wheels)

Since it is a literal string, I expect that getting the values would not be difficult, but no obvious printf statement is coming to mind in order to do this.

Any ideas Scott?

Also, is there a way to pull the "NAME value" and print it on subsequent pages while placing an order? This way, the customer knows what the "base" product name and quantity is while choosing other options (ie 500 cotton napkins" and then ordering the 500 napkin holders, and finding the price for monogramming for 500 items etc.)

Thanks


Marc
winkphoto
Guru
 
Posts: 176
Joined: Fri Nov 15, 2002 9:21 pm
Location: Nashua, NH

Postby scott » Thu Dec 26, 2002 11:17 pm

All very doable. Check out where the code is that processes for linkpoint -- it does something very similar. It takes product id/name/description of each product in the cart, and concatenates them together to fit the single description field for that processor. All you'd need is the first part of that, and you'll about ready to go. As for the stuff to show on other pages, just use code from managecart -- trimmed down as necessary.

Your 'printf' statement would be document.write. No nead for a 'scanf' like function, since each id is stored 'seperately' -- stuffed into a cookie pipe seperated. (ie. ID|NAME|ADDTLINFO|QTY|PRICE). See the code in checkout cart for everything you need.

-Scott
scott
Site Admin
 
Posts: 558
Joined: Sun Jul 14, 2002 7:00 pm
Location: Phoenix, AZ

Ok, here is a snippet

Postby winkphoto » Fri Dec 27, 2002 5:36 pm

Scott,

All I really need is for the managecart.html page to show this "sku" number created from the product ID's. The person is going to print that page as an "order" to give to the customer. They will then input that "sku" number into their own ERP system that then delivers the "kit" created by the sku number generated.

That being said, here is the code I lifted from the linkpoint section of nopcart.js

Code: Select all
} else if ( PaymentProcessor == 'lp') {
         //Process this for LinkPoint         
         strOutput += "<input type=hidden name=\"mode\" value=\"fullpay\">";
         strOutput += "<input type=hidden name=\"chargetotal\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
         strOutput += "<input type=hidden name=\"tax\" value=\""+ MonetarySymbol + strTax + "\">";
         strOutput += "<input type=hidden name=\"subtotal\" value=\""+ MonetarySymbol + strTotal + "\">";
         strOutput += "<input type=hidden name=\"shipping\" value=\""+ MonetarySymbol + strShipping + "\">";
         strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";


I'm guessing that I want to modify this
Code: Select all
strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
to reflect the strID_NUM, but how would I know what was in the cookie and get that to appear in a specific sequence in the htnl page.

The items would have to appear in the order in which they would be chosen (the html guides them to the different options in order).

Any help would be appreciated. I'm not going to try the other code (different prices for different amounts of product since the differences are not figured by set percentages, across all the different options). I'll leave that for later :-)

thanks again

Marc
winkphoto
Guru
 
Posts: 176
Joined: Fri Nov 15, 2002 9:21 pm
Location: Nashua, NH

Tried a bunch of different things, all failed :-(

Postby winkphoto » Mon Dec 30, 2002 7:24 pm

Scott

I know this isn't exactly a piece of code that everyone will want to use, so I know if might not be on the top of your list to make a solution.

Can you point me in the right direction?

Obviously, I have to pull the ID_NUM for each of the products in the cart, but it is just not coming clear to me, no matter how many times I read your response and stare at the code.

I'm thinking:

Code: Select all
strOutput += "<input type=hidden name=\"desc\" value=\""+ strID_NUM1 +strID_NUM2 +strID_NUM3 =strID_NUM4 +strID_NUM5 + "\">";


I don't expect more than 5 ID's for a kit, but if so, I can always add the same thought to id num 6 and beyond.

Am I headed in the right direction?

If so, where would I put this "code" so it would write a line of text underneath the table on managecart.html so that is a completely separate line?

Regards,

Marc
winkphoto
Guru
 
Posts: 176
Joined: Fri Nov 15, 2002 9:21 pm
Location: Nashua, NH

Just an reminder....

Postby winkphoto » Wed Jan 01, 2003 3:23 pm

So that this message doesn't go too far down the forum.

I really need to get this figured out, as it could be a lead in to a substantial bunch of website programming, where the cart is merged in there <g>

Let me know if I'm on track or way off base.

Or if you are feeling really generous, I'll be happy to get the code direct from the master himself....

Happy New Year.


Regards,

Marc
winkphoto
Guru
 
Posts: 176
Joined: Fri Nov 15, 2002 9:21 pm
Location: Nashua, NH

I tried this and it failed...

Postby winkphoto » Wed Jan 01, 2003 4:06 pm

Scott, I tried this but it failed

Code: Select all
//---------------------------------------------------------------------||
// FUNCTION:    SKUCreate                                              ||
// PARAMETERS:  Null                                                   ||
// RETURNS:     SKU Table Written to Document                          ||
// PURPOSE:     Writes ID_NUM in sequence to create SKU on HTML page   ||
//---------------------------------------------------------------------||
function SKUCreate( ) {
   var iNumberOrdered = 0;    //Number of products ordered
   var fTotal         = 0;    //Total cost of order
   var fTax           = 0;    //Tax amount
   var fShipping      = 0;    //Shipping amount
   var strTotal       = "";   //Total cost formatted as money
   var strTax         = "";   //Total tax formatted as money
   var strShipping    = "";   //Total shipping formatted as money
   var strOutput      = "";   //String to be written to page
   var bDisplay       = true; //Whether to write string to the page (here for programmers)

   iNumberOrdered = GetCookie("NumberOrdered");
   if ( iNumberOrdered == null )
      iNumberOrdered = 0;

   if ( bDisplay )
      strOutput = "<TABLE CLASS=\"nopcart\"><TR>" +
                  "<TD CLASS=\"nopheader\"><B>"+strILabel+"</B></TD>"</TR>";

   if ( iNumberOrdered == 0 ) {
      strOutput += "<TR><TD COLSPAN=6 CLASS=\"nopentry\"><CENTER><BR><B>Your InstaKit is empty</B><BR><BR></CENTER></TD></TR>";
   }

   for ( i = 1; i <= iNumberOrdered; i++ ) {
      NewOrder = "Order." + i;
      database = "";
      database = GetCookie(NewOrder);

      Token0 = database.indexOf("|", 0);
     

      fields = new Array;
      fields[0] = database.substring( 0, Token0 );                 // Product ID
     

     

      if ( bDisplay ) {
         strOutput += "<TR><TD CLASS=\"nopentry\">"  + fields[0] + "</TD>"</TR>";
      }

      if ( AppendItemNumToOutput ) {
         strFooter = i;
      } else {
         strFooter = "";
      }
      if ( HiddenFieldsToCheckout ) {
         strOutput += "<input type=hidden name=\"" + OutputItemId        + strFooter + "\" value=\"" + fields[0] + "\">";
         
      }

   }

   
      strOutput += "</TABLE>";

     

   document.write(strOutput);
   document.close();
}


I called it by:
Code: Select all
<SCRIPT>
SKUCreate();
</SCRIPT>


Any thoughts?


Marc
winkphoto
Guru
 
Posts: 176
Joined: Fri Nov 15, 2002 9:21 pm
Location: Nashua, NH

Postby scott » Fri Jan 03, 2003 9:26 pm

Looks close if not quite correct... the only problem I see is that you call document.close() -- which if called before managecart would keep the cart from working, or vice versa if managecart was called first. I think all you need to do is remove that line, then call this within your form tag before the managecart call and it should work (barring any typos).

-Scott
scott
Site Admin
 
Posts: 558
Joined: Sun Jul 14, 2002 7:00 pm
Location: Phoenix, AZ

Postby scott » Fri Jan 03, 2003 9:26 pm

Post an URL with all the code if you still have problems and I'll look at it.

-Scott
scott
Site Admin
 
Posts: 558
Joined: Sun Jul 14, 2002 7:00 pm
Location: Phoenix, AZ

Problem solved

Postby winkphoto » Wed Jan 08, 2003 2:54 am

I created a variable
var strProducts = "";


to pull id-num data from the array
strProducts += fields[0] + "-";


and then just output it below the managecart table
strOutput += "<P> <b> Your SKU number is: " + strProducts + " </b> ";


which gave me the id_num string all nice and neat, separated by the "-" .

The other method I was chasing would only give me the one id_num value instead of all of them

This method worked better. :-)


Regards,


Marc
winkphoto
Guru
 
Posts: 176
Joined: Fri Nov 15, 2002 9:21 pm
Location: Nashua, NH


Return to Installation and Setup Problems

Who is online

Users browsing this forum: No registered users and 0 guests

cron