473,883 Members | 1,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strange shopping cart number

I don't know, maybe this isn't strange but someone else set up the
shopping card coding I'm working with, the way it works is to get the
time() in seconds like 1172693735 and that's the shopper_ID number and
the shopping_cart_l ast_modified number is generated the same way once
they check out... then an invoice number is generated by subtracting the
two numbers (shopper_ID is older from when they registered). Is this
strange or bad or clever and efficient? Or maybe I'm misreading the
code. While unlikey, it seems possible to get the same number twice.

And the numbers end up being almost completely random, with no sequence
for sorting or clue of the actual date. In fact the invoice number is
only generated on the fly when composing a confirmation email and on the
admin interface to the shopping carts.

Maybe it would make sense to concatenate the numbers... at least that
would be sequential but would be a huge number... I'm setting up credit
card payment and we'll need to use the invoice number to find
transactions for issuing credits and such.

1172693735 + 1172693735 = 117269373511726 93735 = too long!

Surely we'd never have more than 9999 invoices a year so the invoice
number could just be 070001, 070002, etc.

Or start counting time on 1-1-07 so the number is 37 years worth of
seconds smaller like: 5,088,686 I'm not too concerned about two people
checking out at the same second. That way I don't need to add a new
field to the database or change much. That would grow by 10,800 seconds
a year and 432,000 in 40 years: as long as I'll be alive :-)

Is that a sensible way to approach this?

//seconds since the Unix Epoch (January 1 1970)
print time();

//seconds since 1-1-07 (-37 years))
print " ".(time()- (31556926*37));
Feb 28 '07 #1
2 1832
Paul Furman kirjoitti:
I don't know, maybe this isn't strange but someone else set up the
shopping card coding I'm working with, the way it works is to get the
time() in seconds like 1172693735 and that's the shopper_ID number and
the shopping_cart_l ast_modified number is generated the same way once
they check out... then an invoice number is generated by subtracting the
two numbers (shopper_ID is older from when they registered). Is this
strange or bad or clever and efficient? Or maybe I'm misreading the
code. While unlikey, it seems possible to get the same number twice.
If two customers spend the exact same time shopping then yes, highly
unlike but possible. The bigger problem is that there is no sequence.
Sequent invoice numbers can be 1234, 43, 345345345, 5434 which in my
mind makes absolutely no sense, I'd call them 1, 2, 3 and 4...

If only the first or second timestamp would be used as the id, then at
least they'd be unique and in sequence. I guess the original designer
was maybe worried about saving some drive space and optimizing it like
that, but it actually creates the two problems of possible collision and
non-sequantial order. Using a few bytes more for storing the whole
timestamp is totally worth it when you get unique and sequential id's.
And the numbers end up being almost completely random, with no sequence
for sorting or clue of the actual date. In fact the invoice number is
only generated on the fly when composing a confirmation email and on the
admin interface to the shopping carts.

Maybe it would make sense to concatenate the numbers... at least that
would be sequential but would be a huge number... I'm setting up credit
card payment and we'll need to use the invoice number to find
transactions for issuing credits and such.

1172693735 + 1172693735 = 117269373511726 93735 = too long!
It depends, for a human it is too long, for a computer it's just a drop
in the ocean. I mean if a human needs to type that number somewhere then
it definately is too long, but just for computer to computer it's no
different from 123 and 456.
Surely we'd never have more than 9999 invoices a year so the invoice
number could just be 070001, 070002, etc.
That's not a bad idea at all.
Or start counting time on 1-1-07 so the number is 37 years worth of
seconds smaller like: 5,088,686 I'm not too concerned about two people
checking out at the same second. That way I don't need to add a new
field to the database or change much. That would grow by 10,800 seconds
a year and 432,000 in 40 years: as long as I'll be alive :-)

Is that a sensible way to approach this?
I'd just use the databases built-in automaticly incrementing field type,
in fact in our own invoicing system both user id's and invoice numbers
come from an autoincremented databasefields. I've never ever encountered
any problems with that. Just let the database worry about uniquity
//seconds since the Unix Epoch (January 1 1970)
print time();

//seconds since 1-1-07 (-37 years))
print " ".(time()- (31556926*37));
or something like date('ymdHis'); maybe? But really, I'd just trust
whatever the db uses for autoincrementin g column if that's possible for you.

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
sp**@outolempi. net | Gedoon-S @ IRCnet | rot13(xv***@bhg byrzcv.arg)
Feb 28 '07 #2
Kimmo Laine wrote:
Paul Furman kirjoitti:
>I don't know, maybe this isn't strange but someone else set up the
shopping card coding I'm working with, the way it works is to get the
time() in seconds like 1172693735 and that's the shopper_ID number and
the shopping_cart_l ast_modified number is generated the same way once
they check out... then an invoice number is generated by subtracting
the two numbers (shopper_ID is older from when they registered). Is
this strange or bad or clever and efficient? Or maybe I'm misreading
the code. While unlikey, it seems possible to get the same number twice.

If two customers spend the exact same time shopping then yes, highly
unlike but possible. The bigger problem is that there is no sequence.
Sequent invoice numbers can be 1234, 43, 345345345, 5434 which in my
mind makes absolutely no sense, I'd call them 1, 2, 3 and 4...
Thanks for your thoughts.
It looks like I was misreading and it wasn't subtacting the two
timestamps but concatenating them with a hypen!
1172693735-1172693736
customer_ID."-".shopping_cart _ID
(both are timestamps)

So that was a safe tactic to create unique numbers but the numbers are
too long for a human to read. I've decided to go with 7 digits of
seconds since 1-1-2007:

//seconds since 1-1-07 (-37 years))
print " ".(time()- (31556926*37));

looks like:
Invoice Number: 5091491

The real purpose here is looking up the invoice number on the credit
card site to make adjustments and credits & such, and we'll also be able
to check the name, etc. it's just a quick way to find an order. And I
don't want to have to re-write more than necessary. This project is
killing me, I'm not that skillful :-)

Old invoices end up being negative and 10 digits:
-1167606262
but those are already paid & delivered so it doesn't really matter.
If only the first or second timestamp would be used as the id, then at
least they'd be unique and in sequence. I guess the original designer
was maybe worried about saving some drive space and optimizing it like
that, but it actually creates the two problems of possible collision and
non-sequantial order. Using a few bytes more for storing the whole
timestamp is totally worth it when you get unique and sequential id's.
>And the numbers end up being almost completely random, with no
sequence for sorting or clue of the actual date. In fact the invoice
number is only generated on the fly when composing a confirmation
email and on the admin interface to the shopping carts.

Maybe it would make sense to concatenate the numbers... at least that
would be sequential but would be a huge number... I'm setting up
credit card payment and we'll need to use the invoice number to find
transactions for issuing credits and such.

1172693735 + 1172693735 = 117269373511726 93735 = too long!

It depends, for a human it is too long, for a computer it's just a drop
in the ocean. I mean if a human needs to type that number somewhere then
it definately is too long, but just for computer to computer it's no
different from 123 and 456.
>Surely we'd never have more than 9999 invoices a year so the invoice
number could just be 070001, 070002, etc.

That's not a bad idea at all.
>Or start counting time on 1-1-07 so the number is 37 years worth of
seconds smaller like: 5,088,686 I'm not too concerned about two people
checking out at the same second. That way I don't need to add a new
field to the database or change much. That would grow by 10,800
seconds a year and 432,000 in 40 years: as long as I'll be alive :-)

Is that a sensible way to approach this?

I'd just use the databases built-in automaticly incrementing field type,
in fact in our own invoicing system both user id's and invoice numbers
come from an autoincremented databasefields. I've never ever encountered
any problems with that. Just let the database worry about uniquity
>//seconds since the Unix Epoch (January 1 1970)
print time();

//seconds since 1-1-07 (-37 years))
print " ".(time()- (31556926*37));


or something like date('ymdHis'); maybe? But really, I'd just trust
whatever the db uses for autoincrementin g column if that's possible for
you.
Feb 28 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2877
by: Don Grover | last post by:
I am retrieving costs and product id's from a sql db. and need to build a shopping cart around it. How do I store the selected items and qty req so I can move into another catalog and total up as im going. Just a couple of hints will do, Im familiar with vb script but not java based code , and im wondering how to store what they select so I can move around different product ranges. Don
2
3321
by: Paul Bruneau | last post by:
Hi, I hope someone can help me make a working shopping cart, as a learning tool. If I have a "Product Demo" html page with a "Buy Me" button, there must be a simple javascript method of storing the necessary product information. There could be several fields involved... Then there ought to be another javascript method that can create a new document based on the list a user has built selecting product from several
1
3590
by: madison | last post by:
Hi, I am trying to start a website using paypals shopping cart function. If i have 10 items and they sell out, how do I make it so the item is then listed as sold out. The next person would not be able to come along and add it to their shopping cart. thanks joy
0
1115
by: unknown | last post by:
Hi, I am developing an online book store with shopping cart. My shopping cart is represented as a Xml server control and I am using an XSLT to render it at the client side. I am using an XmlDocument object as session variable to represent my shopping cart. Initially when the session starts, I am using the XmlDocument with root and no elements to show that no items have been added to the
4
2417
by: Winshent | last post by:
I am having problems with adding items to my shopping cart. The problem occures when adding items that already exists in the cart. When a user adds to cart, they are automatically redirected to the cart, where they can update quantities. If the item already exists in the cart, i want to update the quantity by adding 1 to the quantity of that item. The code all works fine when i step thru the code, however when running it without...
2
2306
by: G.E.M.P | last post by:
High Level Session Handling Design for a Shopping cart 0) What am I missing? 1) How does OSCommerce do it? I'm thinking about building a shopping cart from scratch, using a library of dynamic screen generation routines (already written) that take an XML stream as input from various "search for products" forms. That way I can run queries in one window and display the dynamic results in another. The searching functions will probably
7
2644
by: isaac2004 | last post by:
hi i have a basic asp page that acts as an online bookstore. on my cart page i am having trouble generating 3 numbers; a subtotal, a shipping total, and a final price. here is my code i would like it to work properly so that a record count counts through all the books and genertates these numbers. watch out for line breaks <%@ Language=VBScript %> <% Option Explicit %> <!--#include file="DatabaseConnect.asp"-->
1
7307
by: jecha | last post by:
I'm implementing a shopping cart but am having a problem in checking out a person who has added item in his/her shopping busket.The code for the checkout.php script is given below <? require_once('functions.inc.php'); session_start(); do_html_header("Checkout"); $cart = $_SESSION; if($cart&&array_count_values($cart)) { display_cart($cart,false,0); display_checkout_form($HTTP_POST_VARS);
3
2903
by: Paulo | last post by:
Hi, beginner on asp.net 2.0 C# VS 2005, how can I use the shopping cart concept on my application? When the user clicks add item, it will be stored on some storage format, I dont know what is the term: temp/global DataSet, etc... and it should be read on other web-form to checkout the items... Can you point me to the right direction? Thank you very much!
0
9942
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9792
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10745
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10848
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9575
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7130
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5992
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3234
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.