keat Posted February 3, 2017 Share Posted February 3, 2017 I'm finally in the process of upgrading all my V3 sites to V6. My V3 sites all had the cart_order_id prefixed with an identifier as to which site generated the order. How would I do this on V6 ? A code snippet would be ideal if possible, that way I don't have to modify any core files. Quote Link to comment Share on other sites More sharing options...
Noodleman Posted February 3, 2017 Share Posted February 3, 2017 just a caution, you may need to increase the size of the order number field on the various DB tables to accomodate a larger order number Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted February 3, 2017 Share Posted February 3, 2017 So different stores sell the same product? How do you keep Google from penalizing you for duplicate content? Could you give some examples of how the prefix identifies each site? Quote Link to comment Share on other sites More sharing options...
keat Posted February 3, 2017 Author Share Posted February 3, 2017 Point well spotted CC6 has an 18 char limitation CC3 was 30. Quote Link to comment Share on other sites More sharing options...
Noodleman Posted February 3, 2017 Share Posted February 3, 2017 Just an FYi... I wrote a CubeCart API, and then on top of that wrote a store integration/management solution. It allows you to run multiple stores across as many domains as you want, but uses a single CubeCart store as your central stock system and management system. All orders go to the one store, updates of orders get sent back to the store of purchase etc. Was a nice solution to reduce admin when you have lots of sites. It works well, although isn't available as a module as it has a lot of bespoke elements to it. I've deployed it to a few sites and also wrote a more commercial version of an API for a third party to use with their customers. Fun times Quote Link to comment Share on other sites More sharing options...
keat Posted February 3, 2017 Author Share Posted February 3, 2017 10 minutes ago, Noodleman said: Just an FYi... I wrote a CubeCart API, and then on top of that wrote a store integration/management solution. It allows you to run multiple stores across as many domains as you want, but uses a single CubeCart store as your central stock system and management system. All orders go to the one store, updates of orders get sent back to the store of purchase etc. Was a nice solution to reduce admin when you have lots of sites. It works well, although isn't available as a module as it has a lot of bespoke elements to it. I've deployed it to a few sites and also wrote a more commercial version of an API for a third party to use with their customers. Fun times I considered this with the V3's but never got anywhere. I found that I could in fact appear to run two URL's from the same database, but never progressed with it. 17 minutes ago, Dirty Butter said: So different stores sell the same product? How do you keep Google from penalizing you for duplicate content? Could you give some examples of how the prefix identifies each site? The prefix was modified in gateway.inc.php and would just prefix the order number with a few extra initials. CPO for CrimpsOnline, CTO for CableTiesOnline, went along the lines CTO-170203-105422-1234. We can then tell at a glance that CableTiesOnline sold the item. The web sites are not all 100% identical, one might specialise in CableTies and favour CableTie prices, another in CrimpTerminals favouring terminal prices. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted February 3, 2017 Share Posted February 3, 2017 Ah! I'm always learning something new. So it's one database with data stored from different stores. Sorry for poking my nose in where it didn't belong. LOL Quote Link to comment Share on other sites More sharing options...
keat Posted February 3, 2017 Author Share Posted February 3, 2017 No, each store has it's own database. A nightmare to administer. :-) Quote Link to comment Share on other sites More sharing options...
Noodleman Posted February 3, 2017 Share Posted February 3, 2017 order.class.php FIND: $this->_order_id = date('ymd-His-').rand(1000, 9999); ammend as required. There is no hook here at the moment, but might be an idea to open a request for one on GitHub so it can be done using a snippit/module in the future. Quote Link to comment Share on other sites More sharing options...
keat Posted February 3, 2017 Author Share Posted February 3, 2017 That's the same string as was in V3. Thanks for this. Quote Link to comment Share on other sites More sharing options...
keat Posted February 6, 2017 Author Share Posted February 6, 2017 For anyone else wishing to do this Change $this->_order_id = date('ymd-His-').rand(1000, 9999); to $this->_order_id = "your prefix". date('ymd-His-').rand(1000, 9999); You will need to increase the char length in the database though, as it's currently limed to 18. Quote Link to comment Share on other sites More sharing options...
bsmither Posted February 6, 2017 Share Posted February 6, 2017 Also realize that the Order class has the function validOrderId(). Currently, it is called in the Catalogue class where the customer has clicked a link to review an order, to delete, or order again any of their orders. Quote Link to comment Share on other sites More sharing options...
keat Posted February 6, 2017 Author Share Posted February 6, 2017 I forgot that V3 had an issue where the order Id no longer complied with what was coded and there was another edit in admin/orders/index.php. So whilst my edit has prefixed my test order, I am unable to do anything with it as a customer. I assume its this line of code on order.class: public static function validOrderId($order_id) { if(preg_match('#^ [0-9]{6}-[0-9]{6}-[0-9]{4}$#i', $order_id)) { return true; Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted February 6, 2017 Share Posted February 6, 2017 Would this work? if(preg_match('#^, "your prefix". [0-9]{6}-[0-9]{6}-[0-9]{4}$#i', $order_id)) { Quote Link to comment Share on other sites More sharing options...
keat Posted February 6, 2017 Author Share Posted February 6, 2017 Sorry, I think that I already fixed this. I got halfway through updating the thread and then got called away to a breakdown. It's still sitting on my desktop at work, I did something along the lines if(preg_match('#^, [prefix] {2} [0-9]{6}-[0-9]{6}-[0-9]{4}$#i', $order_id)) { Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted February 6, 2017 Share Posted February 6, 2017 Glad you have it working - when it's convenient please confirm the exact line that worked - who knows your info might save someone else a whole of troubles. Quote Link to comment Share on other sites More sharing options...
keat Posted February 6, 2017 Author Share Posted February 6, 2017 public static function validOrderId($order_id) { if(preg_match('#^[CC]{2}[0-9]{6}-[0-9]{6}-[0-9]{4}$#i', $order_id)) { return true; CC being my prefix Quote Link to comment Share on other sites More sharing options...
bsmither Posted February 7, 2017 Share Posted February 7, 2017 The brackets indicate a set of legal characters. If CC is fixed, then try: if(preg_match('#^'.$GLOBALS[config']->get('config','order_prefix').'[0-9]{6}-[0-9]{6}-[0-9]{4}$#i', $order_id)) { There would have to be a Store Settings field to indicate this store's order prefix. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.