Jump to content

Order reference change


Saxon

Recommended Posts

Hello Everyone,

 

I have a question about how to change the order reference in certain pattern. I know the similar question has been ask plenty of times, but trust me, I have read those post before now I post this thread

First, I want to change my order reference with this pattern: "R17A01" <- this pattern base on every year every month to update, 17 means year 2017, A means January.

 

I have follow some post that create a Order.php in the /override/classes/order/ folder, and the code like this:

 

<?php

class Order extends OrderCore
{
    public static function generateReference()
    {

        $last_id = Db::getInstance()->getValue('SELECT COUNT(date_add) FROM ps_orders WHERE YEAR(date_add) = YEAR(CURRENT_DATE()) AND MONTH(date_add) = MONTH(CURRENT_DATE())');
       
        $month=chr(64+$date("n"));

        
        $l="R".date("y").$month.str_pad($last_id + 1, 5, '0', STR_PAD_LEFT);
        return $l;
      
    }
}
 

But after I do a simulate order in RockPOS, the order is complete(it said), the order reference can not be shown, and message say "Internal Server Error", and I didn't see any order in the order panel.

If I just delete those sentences and type return 'R123456'; sometimes work, but most of the time not work. 

I have already deal this problem some days but I have no idea to fix it, can anyone help me and explain ? Thank you very much!

 

 

Link to comment
Share on other sites

Using your pattern (R17A01), doesn't that mean you are limited to 99 orders per month?  Since I assume 01 means the first order, 02, 03 up to 99?

As for errors, you should enable debug mode in Prestashop, and also check your servers PHP log which should give you the error message and hopefully give you some direction as to what you did wrong.

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