Jump to content

Unique Order_Reference Code In Order Splitting


Devil089

Recommended Posts

Hi prestashop community  :) , 

 

I need the following scenario

 

I want to split each article from my shopping chart after payment into his own order_reference code and oder number.

Prestashop has no option for order splitting.

 

So I try the following:

 

I know that if i add to each product different shipping-service, prestashop split the order automatically after payment. Cause of different shipping-services

This works quite good. 

 

The only thing is, that these splitted orders have the same order_reference code. :wacko: .

How can i change the core that each splitted order have his own order_reference_code

 

Can anyone help me how i can archive this? :)

 

This would be nice.

 

 

Thank you Devil

 

 

 

Link to comment
Share on other sites

Look at class PaymentModule.php.

You'll see:

            do {
                $reference = Order::generateReference();
            } while (Order::getByReference($reference)->count());

            $this->currentOrderReference = $reference;

And this:

            foreach ($package_list as $id_address => $packageByAddress) {
                foreach ($packageByAddress as $id_package => $package) {
                    /** @var Order $order */
                    $order = new Order();
                    $order->product_list = $package['product_list'];

Now, move the first block into the second block. The final code looks like this:

            foreach ($package_list as $id_address => $packageByAddress) {
                foreach ($packageByAddress as $id_package => $package) {
                    do {
                        $reference = Order::generateReference();
                    } while (Order::getByReference($reference)->count());

                    $this->currentOrderReference = $reference;                    
                    /** @var Order $order */
                    $order = new Order();
                    $order->product_list = $package['product_list'];

Hope that helps!

Tung

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