Jump to content

Changing the auto generated order number


keat
 Share

Recommended Posts

Guys.

I have 2 cubecart sites, both paying into the same SecPay account.

To make life easier, is it possible to change the way the automated order number is generated.

If I could prefix it with something, I could tell at a glance which shop the payment came from.

I could also create an email filter and ensure the email gets directed to the correct department

Link to comment
Share on other sites

The order number is:

YYMMDD-HHMMSS-RAND and is generated in the file, at around line 64: \includes\content\gateway.inc.php

The string means nothing except as something to specify in a WHERE clause, but list results *may* be sorted by this string in a couple of places.

You might try:

$cart_order_id = "prefix-".date("ymd-His-").rand(1000,9999);

Link to comment
Share on other sites

Thanks for the answer, I actually found this earlier this afternoon, whilst trawling the forums.

So I've created a prefix, and dropped the last 4 digit random number (waste of time having that)

All my orders are now showing Prefix-date-time as the order number.

I have my email filter in place, and all orders showing the prefix are being sent to the relevent people.

This has solved my problem exactly as I wanted it, but created another. Orders cannot be deleted from the admin control panel.

Link to comment
Share on other sites

Guys

I found my own answers, however, someone else might want to do this so here goes.

To add a prefix to order numbers and or to remove the last 4 digit random numbers:

Applies to CC V3. It might come in handy if like me, you want to differentiate between multiple cubecart orders from 2 different sites, and using the same payment gateway.

Edit \includes\content\gateway.inc.php

Find the line $cart_order_id = date("ymd-His-").rand(1000,9999);

Change to $cart_order_id = "prefix-". date("ymd-His");

Prefix is your prefix and .rand(1000,9999) is the waste of time random number on the end of each order.

Your order number will now look similar to ABC-090921-123456.

To fix the delete order problem edit admin/orders/index.php

Change the line

// delete document

if(isset($_GET['delete']) && $_GET['delete']>0){

to

// delete document

if(isset($_GET['delete']) && $_GET['delete']>""){

Link to comment
Share on other sites

I believe the standard test is:

if(isset($_GET['delete']) && !empty($_GET['delete'])){ but I could be wrong.

And "ABC..." > 0?

When comparing strings to numbers, PHP first converts a string to an integer. My question is: is the result of this conversion 90921 (stripping everything not a number until a number, then dropping every thing from the first non-number after that), or simply 0 (if it doesn't start with a number, plus, or minus)?

Certainly, if(isset($_GET['delete']) && $_GET['delete']>'0'){ // note the zero within apostrophe's

should also work.

But be aware that this comparison will probably exist in many other places. I recommend modifying your approach to this solution as opposed to modifying every instance of CC code as you stumble across it.

$cart_order_id = date("ymd-His-").$uniqueSuffix;

I'm sure your email filter can switch/case on the 14th character+, or just "if it's here somewhere".

Link to comment
Share on other sites

  • 4 weeks later...

Now that I am getting sales I noticed that the email CC sends to me is using its generated number which is fine.

But I wished in there somewhere if showed my product number so I would know quickly what item sold and not have to go digging for it.

Link to comment
Share on other sites

In /includes/content/gateway.inc.php, at around line 267, $prodtext is added to the email sent to the admin. $prodtext is assembled at around line 107-122. It includes productName, productCode, and quantity of each.

Can you reply with an abridged version of the email you get from the store?

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

 Share

×
×
  • Create New...