Jump to content

Customise order numbers


huggettm

Recommended Posts

thank you,

so to add a prefix "OFD" the function

$this->_order_id = date('ymd-His-').rand(1000, 9999);

becomes

$this->_order_id = OFD.date('ymd-His-').rand(1000, 9999);

 

?

is there a function to change the order_id in the db,

 

I have just seen it is also in cubecart_transactions also

Link to comment
Share on other sites

$this->_order_id = 'OFD'.date('ymd-His-').rand(1000, 9999); 

changes need to be applied manually in the DB, easy to do using PHPMyAdmin, change the max length to whatever is required. ensure you make sure the change is the same for all fields otherwise it can impact index performance

Link to comment
Share on other sites

ok thank you

 

is there a way to search for the instances of cart_order_id  - or is it a manual check of all tables?

 

so far i can see

order_history

order_inventory

order_notes

order_summary

order_tax

cubecart_transactions

which would be

 

ALTER TABLE `CubeCart_transactions` CHANGE `order_id` `order_id` VARCHAR(24) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;
ALTER TABLE `CubeCart_order_history` CHANGE `cart_order_id` `cart_order_id` VARCHAR(24) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;
ALTER TABLE `CubeCart_order_inventory` CHANGE `cart_order_id` `cart_order_id` VARCHAR(24) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;
ALTER TABLE `CubeCart_order_notes` CHANGE `cart_order_id` `cart_order_id` VARCHAR(24) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;
ALTER TABLE `CubeCart_order_tax` CHANGE `cart_order_id` `cart_order_id` VARCHAR(24) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;
ALTER TABLE `CubeCart_order_summary` CHANGE `cart_order_id` `cart_order_id` VARCHAR(24) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;

Edited by huggettm
Link to comment
Share on other sites

that doesnt seem to work, have I over simplified it?

 

ah got it, I didnt change the character number after the prefix to 3 in my case:

public static function validOrderId($order_id) {
        if(preg_match('#^[OFD]{3}[0-9]{6}-[0-9]{6}-[0-9]{4}$#i', $order_id)) {
            return true;

Edited by huggettm
Link to comment
Share on other sites

  • 1 month later...

Yech -  I have a Cc4 store that I want to upgrade.  I currently have a sequential order number add-on installed and it is a dealbreaker for me to go back to the standard user-hostile (and admin-hostile) order numbers.  I don’t understand why is is such a big problem to have sequential numbers.  Can someone explain why it can’t be done?

I gather from this posting that there is no supported alternative?  

Link to comment
Share on other sites

@Ploughguy

 

If you upgrade from V4 with extended order numbers, the upgrade will ignore those order number extensions, and revert back to however many are default (16 or 18 digits i think).

It's possible to upgrade and keep these, but there will be work involved.

When I did mine, I opened the new database tables, along side the old tables then copy and pasted the extended order numbers. (The upgrade will delete anything larger than the aforemention 16 or 18 digits)

If I recall, I did this by exporting as a CSV and using MS Excel.

Not overly difficult, but an added step in your upgrade process.

 

Personally, the way I would handle this, would be to create a new domain, and build an exact mirror of my live site on a password protected second domain.

get this working as an exact copy of your V4 site.

You can then play until your hearts content that you've cracked the process.

If you mess up, start over.

 

I upgraded from V3 to V6, i spent weeks fine tuning the process and documenting fixes/pitfalls as I went.

 

Edited by keat
Link to comment
Share on other sites

  • 2 weeks later...

Thanks for the help.

I am planning to follow the process you have described.  I need to build a bunch of new plug-ins to get the functionality I have added to the 4.3.4 store.  Then I will, as you suggest, develop a migration process and test until acceptable, install a fresh installation with a new database then migrate the data from my old store to the new store, and then switch them over.  This also means that if the migration process fails for some reason, the old store is still there, up to date and ready to resume its faithful service.

I will create a plugin to mirror the sequential order number functionality that I already have.  Who knows, I might even publish it.

Thanks for the advice!

Russ

Link to comment
Share on other sites

If you have cpanel, or plesk,

 

Using PHPMyadmin highlight the database, and choose the options tab.

In the operations tab, copy your existing database to a new database, I usually append '_copy' to the end.

Next using cpanel or plesk file manager, copy your entire public_html folder, again append '_copy' to the end.

Both these processes will take no more than5 minutes, and you now have everything you require to roll back.

 

In the event that you need to roll back, it's a 5 minute process.

 

 

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.

×
×
  • Create New...