Jump to content

Best way to auto generate SKU number?


n0sleeves
 Share

Recommended Posts

The eCommerce software (Foxycart) I am using is asking for unique code for each item I add. So I will need a way to auto-generate a sky/code/whatever that the client can see in Processwire and then input into Foxycart. 

This is for the sale of music tracks and complete albums. The way I have it setup in Processwire is like this:

Artist Name

 - Albums

   - Album Name

      - Track 1 name

      - Track 2 name

      - etc ....

I was thinking of using just the ID of each track / album, but the ID isn't shown to the client using Processwire so that's a no-go unless I can find a way to have this displayed. What would you do? Ideas? I don't want the client randomly putting SKU codes in in order to avoid duplicated entries, etc.. So it would have to be unique. 

Thanks!

Link to comment
Share on other sites

i always use the processwire ID for the code in foxycart;

<input type='hidden' name='code' value='{$page->id}' />

That' what I was going to do as well, however this is for digital goods and apparently the client needs a unique code(sku) for each product created in Foxycart (since digital goods needs to be created on the Foxy backend). I just noticed that the ID does show in the URL when editing in the Processwire backend so I may just tell the client to look in the URL. However, I am still open to suggestions. 

Are you using just the ID for digital goods?
Link to comment
Share on other sites

I don't know if you have any specific requirements for your SKU, but someone came up with something on SO:

http://stackoverflow.com/questions/15830222/text-abbreviation-from-a-string-in-php

You can also google creation of a GUID (globally unique ID). There is even a built-in php function:

http://www.php.net/manual/en/function.com-create-guid.php

Link to comment
Share on other sites

What i would do is have a custom management page with a table showing all the tracks and then i would output the page ID in it's own column so they could double click it and copy it into foxycart.

but short of that, yes you would need to grab the page id from the URL...

funny though - most labels i work with already have catalog #s for their albums;

a good sku setup would be the page for the album - page for the track (like 2034-9812) then you could at least see which tracks are part of the same album...

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...