Jump to content

Change to same number, idorder and reference


Recommended Posts

First:
In PrestaShop 1.6 (tested and confirmed working in v1.6.0.14) you can accomplish this by the following method.

    Copy the file /classes/PaymentModule.php to /override/classes/PaymentModule.php.

    Edit the file /override/classes/PaymentModule.php as follows.

At lines 337-341 is a code block that should read like this:

if (!result)
{
  PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created',
    3, null, 'Cart', (int)$id_cart, true);
  throw new PrestaShopException('Can\'t save Order');
}

Immediately after that code block, insert the following two lines of code:

$order->reference = str_pad($order->id, 9, '0', STR_PAD_LEFT);
$order->update();

    Delete the file /cache/class_index.php so that Prestashop automatically re-creates this file taking into account the new override file.

note: if you want to start from 3456 (put 5 not 9 )here-> id, 9, '0', STR_PAD_LEFT);
so, is gona be id order 03456 ( not 000003456)

Second:

Ive made a plugin for the backend for this. To use it:
1. Copy the attached file into your admin/tabs folder
2. Go to Administration/ Menus /Add New
3. Enter "Order Options" as the name
4. Enter "AdminOrderOptions" as the class
5. Select "Orders" as the parent
6. Click Save
7. Go to Orders/Order Options
8. Enter the new number you want to start with
9. Click "Change Start number"


It is not my merit, I only joined two pieces of information found on this forum!

 

AdminOrderOptions.php

  • Like 2
Link to comment
Share on other sites

 
 
I had trouble with that module, see picture, marked by red.
the method above, marked by blue.
I went to prestashop after ZenCart, and had orders 18k
not  consecutive numbers because I just made this change and we wiped the test orders

post-1011659-0-68076400-1434052578_thumb.jpg

post-1011659-0-87634000-1434053109_thumb.jpg

Edited by benyben (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 4 months later...

This did not work for me. I have 1.6.0.14 but I need to update because of certain error messages on admin due to hosting server settings. Anyway I made a copy of my shop to test upgrading to 1.6.1.1. The problem is that the module does not seem to work with 1.6.1.1 and thus I uninstalled the module and tried this approach. But even with this modification the reference is still letters.

 

I did the oerride file and modified it as per instructions and then deleted the class cache file.

 

Sill letters as a reference???

 

Changing of the order id works though :D

 

Any pointers?

Edited by KarZan (see edit history)
Link to comment
Share on other sites

This did not work for me. I have 1.6.0.14 but I need to update because of certain error messages on admin due to hosting server settings. Anyway I made a copy of my shop to test upgrading to 1.6.1.1. The problem is that the module does not seem to work with 1.6.1.1 and thus I uninstalled the module and tried this approach. But even with this modification the reference is still letters.

 

I did the oerride file and modified it as per instructions and then deleted the class cache file.

 

Sill letters as a reference???

 

Changing of the order id works though :D

 

Any pointers?

 

Actually as soon as I had posted this I I found this

https://www.prestashop.com/forums/topic/433999-free-module-order-reference-change-module/page-3?hl=%2Bchange+%2Border+%2Breference&do=findComment&comment=2169299

 

So I ones more made sure the module was removed AND I also made sure the PaymentModule.php in the overrides/classes was "empty"

<?php
abstract class PaymentModule extends PaymentModuleCore
{

Then I reinstalled the module and went through it's setup. After that all was working again as in the previus version :)

Link to comment
Share on other sites

  • 1 month later...

I tryed the module "change order reference" version 1.5.5.1 but it was not working for payments through PayPal. So I followed an easier override method, in the Order.php class, for me it is working in PS 1.6.1.2.

Instructions by NemoPS: http://nemops.com/prestashop-replace-order-references-with-ids/#.VmPx-HshlXn

Just pay attention to the generation of class_index.php, and check if all your overrides are running, and how.
In my case i had to delete manually the 3 overrides the module ChangeRef created, because uninstalling it, they were not deleted:

  • override/classes/order/Order.php
  • override/classes/order/OrderInvoice.php
  • override/classes/order/OrderPayment.php

After that, i put my Order.php by NemoPS, generated my class_index.php and at first it had NO overrides (not sure why), so it seemed not working. No worry, i generated it again, overrides were all up and running, and now it is working.

Edited by zod (see edit history)
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
×
×
  • Create New...