Jump to content

[MODULE] Change Order reference using Order ID and/or Cart ID


Recommended Posts

The error means the override that's incorporated in the module isn't installed.

Please do the following using FTP to your webserver:

Check if you already have an existing OrderPayment.php in PS Root/override/classes/order/ with content.

If you already have an OrderPayment.php override in this folder, you have to merge it's content with the PS Root/modules/modrefchange/override/classes/order/OrderPayment.php file.

If not, go to PS Root/modules/modrefchange/override/classes/order/ and move OrderPayment.php to your local drive.

Go back to PS Root/override/classes/order/ and move the OrderPayment.php from your local drive to your webserver.

Now go back into your Backoffice->Modules and try to install the module again.

 

Hi,

Tried everything you pointed but i still have the same problem listed above with error:

  • modrefchange :

Impossible d'installer la surcharge : Class OrderPaymentOverrideOriginal does not exist

Error while installing module class

 

Debug:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_FUNCTION in /public_html/classes/module/Module.php(1933) : eval()'d code on line 8

 

Prestashop v 1.5.4.1

 

Any help would be appreciated.

Thanks

Link to comment
Share on other sites

Hi, Tried everything you pointed but i still have the same problem listed above with error:
  • modrefchange :

Impossible d'installer la surcharge : Class OrderPaymentOverrideOriginal does not exist Error while installing module class Debug: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_FUNCTION in /public_html/classes/module/Module.php(1933) : eval()'d code on line 8 Prestashop v 1.5.4.1 Any help would be appreciated. Thanks

Have you moved PS Root/modules/modrefchange/override/classes/order/OrderPayment.php to PS Root/override/classes/order/ or copied the file to local and then uploaded to PS Root/override/classes/order/? If copied, delete the override folder and its content from /modules/modrefchange/ before trying to install the module
  • Like 1
Link to comment
Share on other sites

http://forge.prestas...ls:all-tabpanel

 

Hello,

This problem is coming from module called "Order reference change module"

Please contact this module developer for support

 

answer i get on errors in prestashop

The problem is the placement of the hook execution in the PaymentModule class. The email to the customer confirming his/her order is sent before the execution of the hook 'actionvalidateorder' wich executes the order reference change code.

If the customer replies to that email a thread is created using the 'old' order reference wich can not be found in the database causing an object cannot be created/found error.

The only way to prevent this problem is to create an override of the PaymentModule's class function validateOrder, placing the hook execution higher up the function, before email is send to customer.

I will update the module accordingly.

 

What causes the doubled order amount is something I will have to investigate.

Link to comment
Share on other sites

Have you moved PS Root/modules/modrefchange/override/classes/order/OrderPayment.php to PS Root/override/classes/order/ or copied the file to local and then uploaded to PS Root/override/classes/order/? If copied, delete the override folder and its content from /modules/modrefchange/ before trying to install the module

 

Deletion of override folder did the thing! Thank you very much!

Link to comment
Share on other sites

You, kind sir, are a hero.

No idea what Presta-dev-team thought by adding those random order numbers.

 

Module works like a charm.

Thanks a lot!

 

EDIT:

Just donated you some bucks. It's people like you that keep Prestashop on track!

Have a drink on me :D

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

You, kind sir, are a hero.

No idea what Presta-dev-team thought by adding those random order numbers.

 

Module works like a charm.

Thanks a lot!

 

EDIT:

Just donated you some bucks. It's people like you that keep Prestashop on track!

Have a drink on me :D

I do have an idea what Prestashop dev team was thinking. The random characters reference is meant for tracking orders with split suborders (multishipping).

 

But hey, thanks for the drink pal :D

Link to comment
Share on other sites

I do have an idea what Prestashop dev team was thinking. The random characters reference is meant for tracking orders with split suborders (multishipping).

 

Ah ok...that actually makes sense...never used/needed this feature though....

Link to comment
Share on other sites

First, all my thanks, Scorpionsworld. Your module is almost perfect.

 

But I have found a small bug. When a customer spends a part of a discount voucher, then a new discount voucher is created with the rest of the money, and an email is sent to the customer, with the new voucher code.

 

In that email, and only in it, still appears the order number in the old format.

 

It should be easy to correct that bug, I suppose, but I have no idea on how to do it  :huh:

 

Anyway, thank you very much.

Link to comment
Share on other sites

First, all my thanks, Scorpionsworld. Your module is almost perfect.

 

But I have found a small bug. When a customer spends a part of a discount voucher, then a new discount voucher is created with the rest of the money, and an email is sent to the customer, with the new voucher code.

 

In that email, and only in it, still appears the order number in the old format.

 

It should be easy to correct that bug, I suppose, but I have no idea on how to do it  :huh:

 

Anyway, thank you very much.

The bug is actually not a bug but has to do with the placement of the line that calls the hook execution in PaymentModule controller.

The solution would be to create an override on this controller replacing the complete function, which would be lot harder to maintain in terms of Prestashop upgrades.

Link to comment
Share on other sites

[NL]
Update v1.4 van deze module.
Order referentie wijzigings module is nu ook geschikt voor PS1.5.5.

U kunt de Order Referentie Wijzigings module v1.4 vinden op https://www.dropbox.com/s/7kkhtgkrpq4h755/modrefchange.zip?dl=0

Indien eerdere versies reeds geïnstalleerd volstaat het handmatig uitpakken en overschrijven van de huidige module middels FTP.

[EN]
I have come around updating this module according to the new PS version 1.5.5.
Change Order reference module is now PS1.5.5 compatible.

Please find the module change order reference v1.4 at https://www.dropbox.com/s/7kkhtgkrpq4h755/modrefchange.zip?dl=0

If you have previously installed this module, manually unzipping and uploading the module using FTP should be enought. 

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

The bug is actually not a bug but has to do with the placement of the line that calls the hook execution in PaymentModule controller.

The solution would be to create an override on this controller replacing the complete function, which would be lot harder to maintain in terms of Prestashop upgrades.

I think I have read the whole thread, and have found nothing about that (I can be wrong, because of my poor English).

 

If I understand, it is possible to avoid this issue adding any code to PaymentModule controller. Can you post a bit more detailed explanation? I have only some knowledge of php, but I would fix it, if only temporarily.

 

Thanks

Link to comment
Share on other sites

I think I have read the whole thread, and have found nothing about that (I can be wrong, because of my poor English).

 

If I understand, it is possible to avoid this issue adding any code to PaymentModule controller. Can you post a bit more detailed explanation? I have only some knowledge of php, but I would fix it, if only temporarily.

 

Thanks

Sure i can give you some more detailed explanation. The module is triggered by a hook called 'actionvalidateorder'.

This hook is executed in the class called PaymentModule almost at the bottom of the function validateOrder.

For the module to change the order reference before an email is send to the customer (in case the customer only spend part of his/her voucher) the line that starts the hook execution

Hook::exec('actionValidateOrder', array(
'cart' => $this->context->cart,
'order' => $order,
'customer' => $this->context->customer,
currency' => $this->context->currency,
'orderStatus' => $order_status
));

(lines 520 to 527) needs to be placed higher up the function's execution order. To enable this an override needs to be created at /override/classes/ called PaymentModule.php containing only the function validateOrder. The override would then look like this (function code taken from PS1.5.5):

<?php 
class PaymentModule extends PaymentModuleCore 
{ 
    /** 
    * Validate an order in database 
    * Function called from a payment module 
    * 
    * @param integer $id_cart Value 
    * @param integer $id_order_state Value 
    * @param float $amount_paid Amount really paid by customer (in the default currency) 
    * @param string $payment_method Payment method (eg. 'Credit card') 
    * @param string $message Message to attach to order 
    */
    public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', 
        $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, 
        $secure_key = false, Shop $shop = null) 
    { 
        $this->context->cart = new Cart($id_cart); 
        $this->context->customer = new Customer($this->context->cart->id_customer); 
        $this->context->language = new Language($this->context->cart->id_lang); 
        $this->context->shop = ($shop ? $shop : new Shop($this->context->cart->id_shop)); 
        ShopUrl::resetMainDomainCache(); 
  
        $id_currency = $currency_special ? (int)$currency_special : (int)$this->context->cart->id_currency; 
        $this->context->currency = new Currency($id_currency, null, $this->context->shop->id); 
        if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') 
            $context_country = $this->context->country; 
  
        $order_status = new OrderState((int)$id_order_state, (int)$this->context->language->id); 
        if (!Validate::isLoadedObject($order_status)) 
            throw new PrestaShopException('Can\'t load Order state status'); 
  
        if (!$this->active) 
            die(Tools::displayError()); 
        // Does order already exists ? 
        if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) 
        { 
            if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) 
                die(Tools::displayError()); 
  
            // For each package, generate an order 
            $delivery_option_list = $this->context->cart->getDeliveryOptionList(); 
            $package_list = $this->context->cart->getPackageList(); 
            $cart_delivery_option = $this->context->cart->getDeliveryOption(); 
  
            // If some delivery options are not defined, or not valid, use the first valid option 
            foreach ($delivery_option_list as $id_address => $package) 
                if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) 
                    foreach ($package as $key => $val) 
                    { 
                        $cart_delivery_option[$id_address] = $key; 
                        break; 
                    } 
  
            $order_list = array(); 
            $order_detail_list = array(); 
            $reference = Order::generateReference(); 
            $this->currentOrderReference = $reference; 
  
            $order_creation_failed = false; 
            $cart_total_paid = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH), 2); 
  
            foreach ($cart_delivery_option as $id_address => $key_carriers) 
                foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) 
                    foreach ($data['package_list'] as $id_package) 
                    { 
                        // Rewrite the id_warehouse 
                        $package_list[$id_address][$id_package]['id_warehouse'] = (int)$this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int)$id_carrier); 
                        $package_list[$id_address][$id_package]['id_carrier'] = $id_carrier; 
                    } 
            // Make sure CarRule caches are empty 
            CartRule::cleanCache(); 
              
            foreach ($package_list as $id_address => $packageByAddress) 
                foreach ($packageByAddress as $id_package => $package) 
                { 
                    $order = new Order(); 
                    $order->product_list = $package['product_list']; 
                      
                    if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') 
                    { 
                        $address = new Address($id_address); 
                        $this->context->country = new Country($address->id_country, $this->context->cart->id_lang); 
                    } 
                      
                    $carrier = null; 
                    if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) 
                    { 
                        $carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang); 
                        $order->id_carrier = (int)$carrier->id; 
                        $id_carrier = (int)$carrier->id; 
                    } 
                    else
                    { 
                        $order->id_carrier = 0; 
                        $id_carrier = 0; 
                    } 
                      
                    $order->id_customer = (int)$this->context->cart->id_customer; 
                    $order->id_address_invoice = (int)$this->context->cart->id_address_invoice; 
                    $order->id_address_delivery = (int)$id_address; 
                    $order->id_currency = $this->context->currency->id; 
                    $order->id_lang = (int)$this->context->cart->id_lang; 
                    $order->id_cart = (int)$this->context->cart->id; 
                    $order->reference = $reference; 
                    $order->id_shop = (int)$this->context->shop->id; 
                    $order->id_shop_group = (int)$this->context->shop->id_shop_group; 
  
                    $order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($this->context->customer->secure_key)); 
                    $order->payment = $payment_method; 
                    if (isset($this->name)) 
                        $order->module = $this->name; 
                    $order->recyclable = $this->context->cart->recyclable; 
                    $order->gift = (int)$this->context->cart->gift; 
                    $order->gift_message = $this->context->cart->gift_message; 
                    $order->mobile_theme = $this->context->cart->mobile_theme; 
                    $order->conversion_rate = $this->context->currency->conversion_rate; 
                    $amount_paid = !$dont_touch_amount ? Tools::ps_round((float)$amount_paid, 2) : $amount_paid; 
                    $order->total_paid_real = 0; 
                      
                    $order->total_products = (float)$this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier); 
                    $order->total_products_wt = (float)$this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier); 
  
                    $order->total_discounts_tax_excl = (float)abs($this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier)); 
                    $order->total_discounts_tax_incl = (float)abs($this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier)); 
                    $order->total_discounts = $order->total_discounts_tax_incl; 
  
                    $order->total_shipping_tax_excl = (float)$this->context->cart->getPackageShippingCost((int)$id_carrier, false, null, $order->product_list); 
                    $order->total_shipping_tax_incl = (float)$this->context->cart->getPackageShippingCost((int)$id_carrier, true, null, $order->product_list); 
                    $order->total_shipping = $order->total_shipping_tax_incl; 
                      
                    if (!is_null($carrier) && Validate::isLoadedObject($carrier)) 
                        $order->carrier_tax_rate = $carrier->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')})); 
  
                    $order->total_wrapping_tax_excl = (float)abs($this->context->cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier)); 
                    $order->total_wrapping_tax_incl = (float)abs($this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier)); 
                    $order->total_wrapping = $order->total_wrapping_tax_incl; 
  
                    $order->total_paid_tax_excl = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier), 2); 
                    $order->total_paid_tax_incl = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), 2); 
                    $order->total_paid = $order->total_paid_tax_incl; 
  
                    $order->invoice_date = '0000-00-00 00:00:00'; 
                    $order->delivery_date = '0000-00-00 00:00:00'; 
  
                    // Creating order 
                    $result = $order->add(); 
  
                    if (!$result) 
                        throw new PrestaShopException('Can\'t save Order'); 
  
                    // Amount paid by customer is not the right one -> Status = payment error 
                    // We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php 
                    // if ($order->total_paid != $order->total_paid_real) 
                    // We use number_format in order to compare two string 
                    if ($order_status->logable && number_format($cart_total_paid, 2) != number_format($amount_paid, 2)) 
                        $id_order_state = Configuration::get('PS_OS_ERROR'); 
  
                    $order_list[] = $order; 
  
                    // Insert new Order detail list using cart for the current order 
                    $order_detail = new OrderDetail(null, null, $this->context); 
                    $order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']); 
                    $order_detail_list[] = $order_detail; 
  
                    // Adding an entry in order_carrier table 
                    if (!is_null($carrier)) 
                    { 
                        $order_carrier = new OrderCarrier(); 
                        $order_carrier->id_order = (int)$order->id; 
                        $order_carrier->id_carrier = (int)$id_carrier; 
                        $order_carrier->weight = (float)$order->getTotalWeight(); 
                        $order_carrier->shipping_cost_tax_excl = (float)$order->total_shipping_tax_excl; 
                        $order_carrier->shipping_cost_tax_incl = (float)$order->total_shipping_tax_incl; 
                        $order_carrier->add(); 
                    } 
                } 
              
            // The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated 
            if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') 
                $this->context->country = $context_country; 
  
            // Register Payment only if the order status validate the order 
            if ($order_status->logable) 
            { 
                // $order is the last order loop in the foreach 
                // The method addOrderPayment of the class Order make a create a paymentOrder 
                //     linked to the order reference and not to the order id 
                if (isset($extra_vars['transaction_id'])) 
                    $transaction_id = $extra_vars['transaction_id']; 
                else
                    $transaction_id = null; 
                  
                if (!$order->addOrderPayment($amount_paid, null, $transaction_id)) 
                    throw new PrestaShopException('Can\'t save Order Payment'); 
            } 
  
            // Next ! 
            $only_one_gift = false; 
            $cart_rule_used = array(); 
            $products = $this->context->cart->getProducts(); 
            $cart_rules = $this->context->cart->getCartRules(); 
              
            // Make sure CarRule caches are empty 
            CartRule::cleanCache(); 
              
            foreach ($order_detail_list as $key => $order_detail) 
            { 
                $order = $order_list[$key]; 
                  
                // Hook validate order 
                Hook::exec('actionValidateOrder', array( 
                    'cart' => $this->context->cart, 
                    'order' => $order, 
                    'customer' => $this->context->customer, 
                    'currency' => $this->context->currency, 
                    'orderStatus' => $order_status
                )); 
                  
                if (!$order_creation_failed && isset($order->id)) 
                { 
                    if (!$secure_key) 
                        $message .= '<br />'.Tools::displayError('Warning: the secure key is empty, check your payment account before validation'); 
                    // Optional message to attach to this order 
                    if (isset($message) & !empty($message)) 
                    { 
                        $msg = new Message(); 
                        $message = strip_tags($message, '<br>'); 
                        if (Validate::isCleanHtml($message)) 
                        { 
                            $msg->message = $message; 
                            $msg->id_order = intval($order->id); 
                            $msg->private = 1; 
                            $msg->add(); 
                        } 
                    } 
  
                    // Insert new Order detail list using cart for the current order 
                    //$orderDetail = new OrderDetail(null, null, $this->context); 
                    //$orderDetail->createList($order, $this->context->cart, $id_order_state); 
  
                    // Construct order detail table for the email 
                    $products_list = ''; 
                    $virtual_product = true; 
  
                    foreach ($order->product_list as $key => $product) 
                    { 
                        $price = Product::getPriceStatic((int)$product['id_product'], false, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); 
                        $price_wt = Product::getPriceStatic((int)$product['id_product'], true, ($product['id_product_attribute'] ? (int)$product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); 
  
                        $customization_quantity = 0; 
                        $customized_datas = Product::getAllCustomizedDatas((int)$order->id_cart); 
                        if (isset($customized_datas[$product['id_product']][$product['id_product_attribute']])) 
                        { 
                            $customization_text = ''; 
                            foreach ($customized_datas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) 
                            { 
                                if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) 
                                    foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) 
                                        $customization_text .= $text['name'].': '.$text['value'].'<br />'; 
  
                                if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) 
                                    $customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])).'<br />'; 
                                $customization_text .= '---<br />'; 
                            } 
                            $customization_text = rtrim($customization_text, '---<br />'); 
  
                            $customization_quantity = (int)$product['customization_quantity']; 
                            $products_list .= 
                            '<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';"> 
                                <td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td> 
                                <td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').' - '.Tools::displayError('Customized').(!empty($customization_text) ? ' - '.$customization_text : '').'</strong></td> 
                                <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ?  Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td> 
                                <td style="padding: 0.6em 0.4em; width: 15%;">'.$customization_quantity.'</td> 
                                <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice($customization_quantity * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td> 
                            </tr>'; 
                        } 
  
                        if (!$customization_quantity || (int)$product['cart_quantity'] > $customization_quantity) 
                            $products_list .= 
                            '<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';"> 
                                <td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td> 
                                <td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</strong></td> 
                                <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod((int)$this->context->customer->id) == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td> 
                                <td style="padding: 0.6em 0.4em; width: 15%;">'.((int)$product['cart_quantity'] - $customization_quantity).'</td> 
                                <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(((int)$product['cart_quantity'] - $customization_quantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td> 
                            </tr>'; 
  
                        // Check if is not a virutal product for the displaying of shipping 
                        if (!$product['is_virtual']) 
                            $virtual_product &= false; 
  
                    } // end foreach ($products) 
  
                    $cart_rules_list = ''; 
                    foreach ($cart_rules as $cart_rule) 
                    { 
                        $package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list); 
                        $values = array( 
                            'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package), 
                            'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package) 
                        ); 
  
                        // If the reduction is not applicable to this order, then continue with the next one 
                        if (!$values['tax_excl']) 
                            continue; 
  
                        /* IF 
                        ** - This is not multi-shipping 
                        ** - The value of the voucher is greater than the total of the order 
                        ** - Partial use is allowed 
                        ** - This is an "amount" reduction, not a reduction in % or a gift 
                        ** THEN 
                        ** The voucher is cloned with a new value corresponding to the remainder 
                        */
                        if (count($order_list) == 1 && $values['tax_incl'] > $order->total_products_wt && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) 
                        { 
                            // Create a new voucher from the original 
                            $voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it 
                            unset($voucher->id); 
  
                            // Set a new voucher code 
                            $voucher->code = empty($voucher->code) ? substr(md5($order->id.'-'.$order->id_customer.'-'.$cart_rule['obj']->id), 0, 16) : $voucher->code.'-2'; 
                            if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) 
                                $voucher->code = preg_replace('/'.$matches[0].'$/', '-'.(intval($matches[1]) + 1), $voucher->code); 
  
                            // Set the new voucher value 
                            if ($voucher->reduction_tax) 
                                $voucher->reduction_amount = $values['tax_incl'] - $order->total_products_wt - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_incl : 0); 
                            else
                                $voucher->reduction_amount = $values['tax_excl'] - $order->total_products - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_excl : 0); 
  
                            $voucher->id_customer = $order->id_customer; 
                            $voucher->quantity = 1; 
                            $voucher->quantity_per_user = 1; 
                            $voucher->free_shipping = 0; 
                            if ($voucher->add()) 
                            { 
                                // If the voucher has conditions, they are now copied to the new voucher 
                                CartRule::copyConditions($cart_rule['obj']->id, $voucher->id); 
  
                                $params = array( 
                                    '{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false), 
                                    '{voucher_num}' => $voucher->code, 
                                    '{firstname}' => $this->context->customer->firstname, 
                                    '{lastname}' => $this->context->customer->lastname, 
                                    '{id_order}' => $order->reference, 
                                    '{order_name}' => $order->getUniqReference() 
                                ); 
                                Mail::Send( 
                                    (int)$order->id_lang, 
                                    'voucher', 
                                    sprintf(Mail::l('New voucher regarding your order %s', (int)$order->id_lang), $order->reference), 
                                    $params, 
                                    $this->context->customer->email, 
                                    $this->context->customer->firstname.' '.$this->context->customer->lastname, 
                                    null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop 
                                ); 
                            } 
  
                            $values['tax_incl'] -= $values['tax_incl'] - $order->total_products_wt; 
                            $values['tax_excl'] -= $values['tax_excl'] - $order->total_products; 
                        } 
  
                        $order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping); 
  
                        if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) 
                        { 
                            $cart_rule_used[] = $cart_rule['obj']->id; 
  
                            // Create a new instance of Cart Rule without id_lang, in order to update its quantity 
                            $cart_rule_to_update = new CartRule($cart_rule['obj']->id); 
                            $cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1); 
                            $cart_rule_to_update->update(); 
                        } 
  
                        $cart_rules_list .= ' 
                        <tr> 
                            <td colspan="4" style="padding:0.6em 0.4em;text-align:right">'.Tools::displayError('Voucher name:').' '.$cart_rule['obj']->name.'</td> 
                            <td style="padding:0.6em 0.4em;text-align:right">'.($values['tax_incl'] != 0.00 ? '-' : '').Tools::displayPrice($values['tax_incl'], $this->context->currency, false).'</td> 
                        </tr>'; 
                    } 
  
                    // Specify order id for message 
                    $old_message = Message::getMessageByCartId((int)$this->context->cart->id); 
                    if ($old_message) 
                    { 
                        $update_message = new Message((int)$old_message['id_message']); 
                        $update_message->id_order = (int)$order->id; 
                        $update_message->update(); 
  
                        // Add this message in the customer thread 
                        $customer_thread = new CustomerThread(); 
                        $customer_thread->id_contact = 0; 
                        $customer_thread->id_customer = (int)$order->id_customer; 
                        $customer_thread->id_shop = (int)$this->context->shop->id; 
                        $customer_thread->id_order = (int)$order->id; 
                        $customer_thread->id_lang = (int)$this->context->language->id; 
                        $customer_thread->email = $this->context->customer->email; 
                        $customer_thread->status = 'open'; 
                        $customer_thread->token = Tools::passwdGen(12); 
                        $customer_thread->add(); 
  
                        $customer_message = new CustomerMessage(); 
                        $customer_message->id_customer_thread = $customer_thread->id; 
                        $customer_message->id_employee = 0; 
                        $customer_message->message = $update_message->message; 
                        $customer_message->private = 0; 
  
                        if (!$customer_message->add()) 
                            $this->errors[] = Tools::displayError('An error occurred while saving message'); 
                    } 
  
                    foreach ($this->context->cart->getProducts() as $product) 
                        if ($order_status->logable) 
                            ProductSale::addProductSale((int)$product['id_product'], (int)$product['cart_quantity']); 
  
                    if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) 
                    { 
                        $history = new OrderHistory(); 
                        $history->id_order = (int)$order->id; 
                        $history->changeIdOrderState(Configuration::get('PS_OS_OUTOFSTOCK'), $order, true); 
                        $history->addWithemail(); 
                    } 
  
                    // Set order state in order history ONLY even if the "out of stock" status has not been yet reached 
                    // So you migth have two order states 
                    $new_history = new OrderHistory(); 
                    $new_history->id_order = (int)$order->id; 
                    $new_history->changeIdOrderState((int)$id_order_state, $order, true); 
                    $new_history->addWithemail(true, $extra_vars); 
  
                    unset($order_detail); 
  
                    // Order is reloaded because the status just changed 
                    $order = new Order($order->id); 
  
                    // Send an e-mail to customer (one order = one email) 
                    if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) 
                    { 
                        $invoice = new Address($order->id_address_invoice); 
                        $delivery = new Address($order->id_address_delivery); 
                        $delivery_state = $delivery->id_state ? new State($delivery->id_state) : false; 
                        $invoice_state = $invoice->id_state ? new State($invoice->id_state) : false; 
  
                        $data = array( 
                        '{firstname}' => $this->context->customer->firstname, 
                        '{lastname}' => $this->context->customer->lastname, 
                        '{email}' => $this->context->customer->email, 
                        '{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"), 
                        '{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"), 
                        '{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array( 
                            'firstname' => '<span style="font-weight:bold;">%s</span>', 
                            'lastname'  => '<span style="font-weight:bold;">%s</span>'
                        )), 
                        '{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array( 
                                'firstname' => '<span style="font-weight:bold;">%s</span>', 
                                'lastname'  => '<span style="font-weight:bold;">%s</span>'
                        )), 
                        '{delivery_company}' => $delivery->company, 
                        '{delivery_firstname}' => $delivery->firstname, 
                        '{delivery_lastname}' => $delivery->lastname, 
                        '{delivery_address1}' => $delivery->address1, 
                        '{delivery_address2}' => $delivery->address2, 
                        '{delivery_city}' => $delivery->city, 
                        '{delivery_postal_code}' => $delivery->postcode, 
                        '{delivery_country}' => $delivery->country, 
                        '{delivery_state}' => $delivery->id_state ? $delivery_state->name : '', 
                        '{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile, 
                        '{delivery_other}' => $delivery->other, 
                        '{invoice_company}' => $invoice->company, 
                        '{invoice_vat_number}' => $invoice->vat_number, 
                        '{invoice_firstname}' => $invoice->firstname, 
                        '{invoice_lastname}' => $invoice->lastname, 
                        '{invoice_address2}' => $invoice->address2, 
                        '{invoice_address1}' => $invoice->address1, 
                        '{invoice_city}' => $invoice->city, 
                        '{invoice_postal_code}' => $invoice->postcode, 
                        '{invoice_country}' => $invoice->country, 
                        '{invoice_state}' => $invoice->id_state ? $invoice_state->name : '', 
                        '{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile, 
                        '{invoice_other}' => $invoice->other, 
                        '{order_name}' => $order->getUniqReference(), 
                        '{date}' => Tools::displayDate(date('Y-m-d H:i:s'),null , 1), 
                        '{carrier}' => $virtual_product ? Tools::displayError('No carrier') : $carrier->name, 
                        '{payment}' => Tools::substr($order->payment, 0, 32), 
                        '{products}' => $this->formatProductAndVoucherForEmail($products_list), 
                        '{discounts}' => $this->formatProductAndVoucherForEmail($cart_rules_list), 
                        '{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false), 
                        '{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping + $order->total_discounts, $this->context->currency, false), 
                        '{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false), 
                        '{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false), 
                        '{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false), 
                        '{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false)); 
  
                        if (is_array($extra_vars)) 
                            $data = array_merge($data, $extra_vars); 
  
                        // Join PDF invoice 
                        if ((int)Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) 
                        { 
                            $pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $this->context->smarty); 
                            $file_attachement['content'] = $pdf->render(false); 
                            $file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf'; 
                            $file_attachement['mime'] = 'application/pdf'; 
                        } 
                        else
                            $file_attachement = null; 
  
                        if (Validate::isEmail($this->context->customer->email)) 
                            Mail::Send( 
                                (int)$order->id_lang, 
                                'order_conf', 
                                Mail::l('Order confirmation', (int)$order->id_lang), 
                                $data, 
                                $this->context->customer->email, 
                                $this->context->customer->firstname.' '.$this->context->customer->lastname, 
                                null, 
                                null, 
                                $file_attachement, 
                                null, _PS_MAIL_DIR_, false, (int)$order->id_shop 
                            ); 
                    } 
  
                    // updates stock in shops 
                    if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) 
                    { 
                        $product_list = $order->getProducts(); 
                        foreach ($product_list as $product) 
                        { 
                            // if the available quantities depends on the physical stock 
                            if (StockAvailable::dependsOnStock($product['product_id'])) 
                            { 
                                // synchronizes 
                                StockAvailable::synchronize($product['product_id'], $order->id_shop); 
                            } 
                        } 
                    } 
                } 
                else
                { 
                    $error = Tools::displayError('Order creation failed'); 
                    Logger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart)); 
                    die($error); 
                } 
            } // End foreach $order_detail_list 
            // Use the last order as currentOrder 
            $this->currentOrder = (int)$order->id; 
            return true; 
        } 
        else
        { 
            $error = Tools::displayError('Cart cannot be loaded or an order has already been placed using this cart'); 
            Logger::addLog($error, 4, '0000001', 'Cart', intval($this->context->cart->id)); 
            die($error); 
        } 
    } 
} 

PaymentModule.php

  • Like 1
Link to comment
Share on other sites

Wow! Scorpionsworld, you're my hero.

 

A superb explanation.

 

In my first attemp it didn't go, because my Prestashop is 1.5.4.1, and the override you posted is for 1.5.5.

 

But with your explanation, and using your override as a guide, I created my own one, starting from original PaymentModule.php of 1.5.4.1 version, and now everything works perfect.

 

Many many thanks.

Link to comment
Share on other sites

Wow! Scorpionsworld, you're my hero.

 

A superb explanation.

 

In my first attemp it didn't go, because my Prestashop is 1.5.4.1, and the override you posted is for 1.5.5.

 

But with your explanation, and using your override as a guide, I created my own one, starting from original PaymentModule.php of 1.5.4.1 version, and now everything works perfect.

 

Many many thanks.

Glad I could be of assistance.

Link to comment
Share on other sites

Have you moved PS Root/modules/modrefchange/override/classes/order/OrderPayment.php to PS Root/override/classes/order/ or copied the file to local and then uploaded to PS Root/override/classes/order/? If copied, delete the override folder and its content from /modules/modrefchange/ before trying to install the module

 

I did what you have explained right from the first suggestion, including copy OrderPayment.php and delete Override folder, but the system still shows error like this:

 

The following module(s) were not installed properly:

  • - modrefchange : 

    Error while adding module to hook actionValidateOrder

 

The module is installed successfully after this warning however, but when I run a test at the end and check back to BO in order section, the reference shows all letters.

 

Any clue?

Link to comment
Share on other sites

I did what you have explained right from the first suggestion, including copy OrderPayment.php and delete Override folder, but the system still shows error like this:

 

The following module(s) were not installed properly:

  • - modrefchange : 

    Error while adding module to hook actionValidateOrder

 

The module is installed successfully after this warning however, but when I run a test at the end and check back to BO in order section, the reference shows all letters.

 

Any clue?

Your error message has nothing to do with the override. Seems like the module isn't hooking into the system.

What you could do after this unsuccesfull installation is 'Transplanting' the module to the hook in your Backoffice->Modules->Positions->Transplant a module.

Choose the module and choose 'New Orders' as the 'Hook into'

Link to comment
Share on other sites

Just a question from a beginner: how to change the starting order number?

 

I am going to launch the new version of my e-shop and don't want to start order number 19 ( from 2 to 18 were used for tests).

How can I change the starting number or find a module for that?

 

Thanks

Navid

Link to comment
Share on other sites

Your error message has nothing to do with the override. Seems like the module isn't hooking into the system.

What you could do after this unsuccesfull installation is 'Transplanting' the module to the hook in your Backoffice->Modules->Positions->Transplant a module.

Choose the module and choose 'New Orders' as the 'Hook into'

 

Thank you for your support. However, I followed your advise and the module seems to be still unhooked. (As in screenshot)

 

Do you have any other suggestions?

post-388760-0-49025400-1379298323_thumb.png

post-388760-0-23639400-1379298324_thumb.png

Link to comment
Share on other sites

Just a question from a beginner: how to change the starting order number?

 

I am going to launch the new version of my e-shop and don't want to start order number 19 ( from 2 to 18 were used for tests).

How can I change the starting number or find a module for that?

 

Thanks

Navid

You could use phpmyadmin to change the starting number of id_order in the [prefix]_orders table after the table/db has been created.

Link to comment
Share on other sites

Have the same problem as slollo!

 

I updated your module version from 1.2 to the latest 1.4 on Prestashop 1.5.5.0 and after that I could no longer change Order status (would just get white screen / timeout).

 

It was hooked to New Order, so then tried to reset the module, but this failed, and then I only had the option to delete the module (could not install, reset, activate, deactivate etc).

 

Now I can no longer access any orders (will just get a Internal Server 500 error), so pretty bad experience :-(

Link to comment
Share on other sites

After manually deleting your module in FTP and also deleting the OrderPayment.php in root/override/order I can finally again access the orders, but still cannot change any order status! 


 


I even tried to reinstall your module, but whether activated or deactivated, I can no longer change order status :-(

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

Hello,

 

Thank you very much for this awesome module, a must have in my opinion.

 

I would like to ask, could it be possible to have order ID used for order reference AND invoice number AND delivery slip number ?

 

That would be perfect ! Actually all this numbers became differents, a real mess to organize that :wacko:

 

Thanks in advance.

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

Hello,

 

Thank you very much for this awesome module, a must have in my opinion.

 

I would like to ask, could it be possible to have order ID used for order reference AND invoice number AND delivery slip number ?

 

That would be perfect ! Actually all this numbers became differents, a real mess to organize that :wacko:

 

Thanks in advance.

Should be possible, but i'll have to look in to that

Link to comment
Share on other sites

hi, does it mean when i give 1 in "Number of zeros to prefix Order ID" when now it's for example 010 orders, and it will come to 100 it will be number 100 or 0100? and it will stop counting on 999? or goes 01000..010000 etc? i don't get meaning of this number of zeros if this is not it.

Link to comment
Share on other sites

hi, does it mean when i give 1 in "Number of zeros to prefix Order ID" when now it's for example 010 orders, and it will come to 100 it will be number 100 or 0100? and it will stop counting on 999? or goes 01000..010000 etc? i don't get meaning of this number of zeros if this is not it.

if you fill in 1 as the number of zeros to prefix the Order ID, the Order ID is padded with a zero only when the Order ID is below 10.

So an Order ID of 9 will give a reference of 09.

From 10 and above the reference won't have a need anymore to use zeros as padding and keep the Order ID as is.

So Order ID 10 becomes Reference number 10.

Order ID 100 becomes Reference number 100.

And so on....

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

I'm not 100% sure if this is caused by your module, but:
when i install module, weard thing i got is that, i can't open any of products on my test page with any old customer account which got even one product buyed. I made test and make new account after module installed and cofigured, and this new customer account works just fine, i can open product, buy smth and after that it also work well. On administrators accounts it's also everything ok and i can open any product with no problem,buy etc and it works great. I check error on that customer account and it's:

[PrestaShopException]

Invalid address
at line 346 in file classes/Address.php

340. 		if ($id_address)
341. 		{
342. 			$address = new Address((int)$id_address);
343. 
344. 			if (!Validate::isLoadedObject($address))
345. 				throw new PrestaShopException('Invalid address');
346. 		}
347. 		else
348. 		{
349. 			// set the default address
350. 			$address = new Address();

    AddressCore::initialize - [line 198 - classes/tax/Tax.php] - [1 Arguments]

    192. 	* @param id_address
    193. 	* @return float $tax_rate
    194. 	*/
    195. 	public static function getProductEcotaxRate($id_address = null)
    196. 	{
    197. 		$address = Address::initialize($id_address);
    198. 
    199. 		$tax_manager = TaxManagerFactory::getManager($address, (int)Configuration::get('PS_ECOTAX_TAX_RULES_GROUP_ID'));
    200. 		$tax_calculator = $tax_manager->getTaxCalculator();
    201. 
    202. 		return $tax_calculator->getTotalRate();

    TaxCore::getProductEcotaxRate - [line 301 - controllers/front/ProductController.php] - [1 Arguments]

    295. 		$product_price_with_tax = Product::getPriceStatic($this->product->id, true, null, 6);
    296. 		if (Product::$_taxCalculationMethod == PS_TAX_INC)
    297. 			$product_price_with_tax = Tools::ps_round($product_price_with_tax, 2);
    298. 		$product_price_without_eco_tax = (float)$product_price_with_tax - $this->product->ecotax;
    299. 
    300. 		$ecotax_rate = (float)Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
    301. 		$ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);
    302. 		if (Product::$_taxCalculationMethod == PS_TAX_INC && (int)Configuration::get('PS_TAX'))
    303. 			$ecotax_tax_amount = Tools::ps_round($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
    304. 
    305. 		$id_currency = (int)$this->context->cookie->id_currency;

    ProductControllerCore->assignPriceAndTax - [line 225 - controllers/front/ProductController.php] - [0 Argument]

    219. 				'textFields' => $text_fields));
    220. 
    221. 			// Assign template vars related to the category + execute hooks related to the category
    222. 			$this->assignCategory();
    223. 			// Assign template vars related to the price and tax
    224. 			$this->assignPriceAndTax();
    225. 
    226. 			// Assign template vars related to the images
    227. 			$this->assignImages();
    228. 			// Assign attribute groups to the template
    229. 			$this->assignAttributesGroups();

    ProductControllerCore->initContent - [line 167 - classes/controller/Controller.php] - [0 Argument]

    161. 
    162. 			if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))
    163. 				$this->initHeader();
    164. 
    165. 			if ($this->viewAccess())
    166. 				$this->initContent();
    167. 			else
    168. 				$this->errors[] = Tools::displayError('Access denied.');
    169. 
    170. 			if (!$this->content_only && ($this->display_footer || (isset($this->className) && $this->className)))
    171. 				$this->initFooter();

    ControllerCore->run - [line 349 - classes/Dispatcher.php] - [0 Argument]

    343. 			// Execute hook dispatcher
    344. 			if (isset($params_hook_action_dispatcher))
    345. 				Hook::exec('actionDispatcher', $params_hook_action_dispatcher);
    346. 
    347. 			// Running controller
    348. 			$controller->run();
    349. 		}
    350. 		catch (PrestaShopException $e)
    351. 		{
    352. 			$e->displayMessage();
    353. 		}

    DispatcherCore->dispatch - [line 28 - index.php] - [0 Argument]

    22. *  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
    23. *  International Registered Trademark & Property of PrestaShop SA
    24. */
    25. 
    26. require(dirname(__FILE__).'/config/config.inc.php');
    27. Dispatcher::getInstance()->dispatch();
    28. 

Like i said, i'm not 100% percent sure this is cause by module cause i made some changes on presta files(but now in Address.php), but this occur just after i got module installed so maybe something is about it and maybe i can help somehow to show this bug? When someone is testing like me there is no problem cause no customer is real now, but when someone got this error on online shop it could be problem cause deleting module don't seems to resolve problem.

Link to comment
Share on other sites

Installed and works fine thanks!

 

I still have problems with order confirm emails where apper :

 

order : {id_order}

 

instead :

 

order : 0000xx

 

same problem in my email order confirm and customer email order confirm.

 

I've tried to manage email translations but without results.

 

Any suggest to fix this?

 

thanks!

Link to comment
Share on other sites

  • - modrefchange :

    The Override can not be installed: The property definition in the OrderPayment class is already defined.

    Error while installing module class

I have V1.5.4.1 of prestashop version. May do you have any idea or suggestion what's going wrong here?

 

Thanks for all

Alexander

 

 

Hi guys

 

It's my first post on this forum, if this particual issue was already solved, and i missed it, please redirect me.

 

I have the same exact problem. It occured after restoring the shop manually, following  my attempt to delete all test order info including invoice data and invoice id - didn't work btw.  Everthing else works fine.

 

Already tried removing and reinstalling the module, copying OrderPayment.php fixes only "Class OrderPaymentOverrideOriginal does not exist".

 

My presta- 1.5.x - current stable, the module worked just fine.

 

OK Problem solved, other backup copy worked.

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

i have a problem relate with this module, i wish somebody can help me.

 

I enabled the mail alert module, please see http://www.prestashop.com/forums/topic/280410-prestashop-156-problem-mail-alerts/?view=findpost&p=1435855

 

this below is the post :

 


 

But now i have problem with the {order_name},

 

fyi, i'm using Order reference change module, http://www.prestasho...-cart-id/page-1

 

i set the the order id with format NM000X, and it works.

if as a buyer, i received the notif with the right order id that i set before, e.g NM0006

but the email sent to admin/seller i got the wrong format with the right queue. # 000006

 

 

in BO, the order id and format is right, as same as the customer received, NM0006.

i see the email template to admin is different, it use the template from mail alert module.

and the email template to buyer is from prestashop core.

 

pls help me,

Link to comment
Share on other sites

i have a problem relate with this module, i wish somebody can help me.

 

I enabled the mail alert module, please see http://www.prestashop.com/forums/topic/280410-prestashop-156-problem-mail-alerts/?view=findpost&p=1435855

 

this below is the post :

I will have a look at the new mailalert module in combination with the change order ref. module to see if there's a suitable solution.

  • Like 1
Link to comment
Share on other sites

i have a problem relate with this module, i wish somebody can help me.

 

I enabled the mail alert module, please see http://www.prestashop.com/forums/topic/280410-prestashop-156-problem-mail-alerts/?view=findpost&p=1435855

 

this below is the post :

The solution would be to change the mail alert module to match the new order reference number instead of using it's own order_name variable (order id prefixed with max. 6 zeros).

Change line 386 of mailalerts.php from

'{order_name}' => sprintf('%06d', $order->id),

to

'{order_name}' => $order->reference,

Please be shure the order reference change module is executed before the mailalerts module on BO->Modules->Positions hook actionValidateOrder

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

The solution would be to change the mail alert module to match the new order reference number instead of using it's own order_name variable (order id prefixed with max. 6 zeros).

Change line 386 of mailalerts.php from

 

wow! thank you so much.

you are a hero.

 

i knew that line to replace, but i dont know the right one. :)

 

once more, thank you scorpionsworld

Link to comment
Share on other sites

  • 2 weeks later...

navid68, on 15 Sept 2013 - 08:33 AM, said:snapback.png

Just a question from a beginner: how to change the starting order number?

 

I am going to launch the new version of my e-shop and don't want to start order number 19 ( from 2 to 18 were used for tests).

How can I change the starting number or find a module for that?

 

Thanks

Navid

 

You could use phpmyadmin to change the starting number of id_order in the [prefix]_orders table after the table/db has been created.

 

Hi, really great module. I tried this but no luck. I deleted all orders except 1 then changed the id_order in ps_orders but the next order just follwed the previous numbers that were being used. So the system must take this instruction from another place I think. Any ideas?

Link to comment
Share on other sites

 

navid68, on 15 Sept 2013 - 08:33 AM, said:snapback.png

 

 

Hi, really great module. I tried this but no luck. I deleted all orders except 1 then changed the id_order in ps_orders but the next order just follwed the previous numbers that were being used. So the system must take this instruction from another place I think. Any ideas?

 

No, the only place where the new order id number is being generated is through mysql auto_increment. Check the table operations tab if the auto_increment value has been changed.

Link to comment
Share on other sites

I try to install and i reciev this message

 

  • - modrefchange : 

    Incapaz de instalar con control manual : Class OrderPaymentOverrideOriginal528e49da5ce34 does not exist

    Error while installing module class

 

what can i do?

Manually upload/merge OrderPayment.php from the module's zip file /override/classes/ to [yourprestashoproot]/override/classes/ and then try to install again.

Link to comment
Share on other sites

Manually upload/merge OrderPayment.php from the module's zip file /override/classes/ to [yourprestashoproot]/override/classes/ and then try to install again.

I do that and i get this.

 

El siguiente módulo(s) no se ha instalado correctamente:

  • - modrefchange : 

    Incapaz de instalar con control manual : La propiedad definition en el grupo OrderPayment ya esta definida.

    Error while installing module class

Link to comment
Share on other sites

 

I do that and i get this.

 

El siguiente módulo(s) no se ha instalado correctamente:

  • - modrefchange : 

    Incapaz de instalar con control manual : La propiedad definition en el grupo OrderPayment ya esta definida.

    Error while installing module class

 

Do the following using FTP:

  • Delete [your ps root]/modules/modrefchange folder and ANY random-like (temporary) folder and its contents.
  • On your own pc/laptop, unzip the module's file.
  • Upload the modrefchange/override/classes/OrderPayment.php file to [your ps root]/override/classes/
  • Upload the modrefchange folder to [your ps root]/modules/
  • Delete the [your ps root]/modules/modrefchange/override-folder
  • Now go to your shop's backoffice->Modules and try again to install the module.

That should do the trick.

  • Like 1
Link to comment
Share on other sites

Halo scorpionsworld,

 

how are you? i hope you always fine.

i heva one question, and i tried this but cant find the string.

 

how to change subject of order confirmation email to admin, because it still 'the order id' (always #0000), not $order->reference .

i use mail alert.

 

thank you.

Link to comment
Share on other sites

Halo scorpionsworld,

 

how are you? i hope you always fine.

i heva one question, and i tried this but cant find the string.

 

how to change subject of order confirmation email to admin, because it still 'the order id' (always #0000), not $order->reference .

i use mail alert.

 

thank you.

The subject of the order confirmation email to admin is set in the mailalert module.

Link to comment
Share on other sites

Helemaal super
groeten van Vlissingen :)


Kevin Nash asked:
http://www.prestashop.com/forums/topic/218257-module-change-order-reference-using-order-id-andor-cart-id/?view=findpost&p=1392433

"I would like to ask, could it be possible to have order ID used for order reference AND invoice number AND delivery slip number ?"

Since I want of course a consistent use of references in  all of our official correspondence I need to know whether this is an issue or already solved.

By the way in this forum you find the lately link

http://www.prestashop.com/forums/topic/192541-order-reference-in-15-uppercase-replace-with-number/?view=findpost&p=1473190

and to Git:
https://github.com/PrestaShop/PrestaShop/pull/883/files
this relates to another solution that may come over the problems with the proper hooking :)
 

Edited by B.Köring (see edit history)
Link to comment
Share on other sites

  • 3 weeks later...

In Bo,when i change the order status.it throws exceptions.

Property OrderPayment->order_reference length (10) must be between 0 and 9

at line 837 in file classes/ObjectModel.php

 

So ,maybe it is a bug ?

 

Sorry,it is my default.i forgot override the OrderPayment file. Thanks!

Link to comment
Share on other sites

  • 1 month later...

Installato su 1.5.6.1 funziona perfettamente. Grazie!

I upgrade to version 1.5.6.2 and it will not work anymore re-install module not possible

modrefchange :

Niet mogelijk om overschrijven te installeren: Class OrderPaymentOverrideOriginal52dec090a6720 does not exist

Error while installing module class

Link to comment
Share on other sites

Similar free module Change Order. You Can create

  • Prefix (alfa + data formats)
  • surfix (random, icrement, order ID)

http://www.prestapoint.com/en/change-orders-reference-numbering-date-text-prestashop-module-9.html Prestashop 1.5

Try to install that one (order_ref.zip) and give error during upload via prestashop

[PrestaShop] Fatal error in module order_ref:

syntax error, unexpected '.1' (T_DNUMBER)

 

in prestashop 1.5.6.2

Link to comment
Share on other sites

  • 2 weeks later...

Helemaal super

groeten van Vlissingen :)

 

 

Kevin Nash asked:

http://www.prestashop.com/forums/topic/218257-module-change-order-reference-using-order-id-andor-cart-id/?view=findpost&p=1392433

 

"I would like to ask, could it be possible to have order ID used for order reference AND invoice number AND delivery slip number ?"

 

Since I want of course a consistent use of references in  all of our official correspondence I need to know whether this is an issue or already solved.

 

 

Hello, I did the modification myself on PS1.5.4.1, order ID also match invoice and delivery slip number now :

 

For invoices number and his pdf number :

 

In classes/pdf/HTMLTemplateInvoice.php :

 

Replace " number " line 45 ( number on the invoice pdf) and line 140 by " id_order " ( pdf file number ).

 

In classes/order/OrderInvoice.php

 

Remplace " number " line 665 by " id_order " ( back office invoice number ).

 

For delivery slip number and his pdf number :

 

In classes/pdf/HTMLTemplateDeliverySlip.php  :

 

Replace " delivery_number " line 42 by " id_order " ( number on the delivery slip pdf ) and line 90 " order->invoice_number " by " order_invoice->id_order " ( pdf file number )

 

In adminXXXX/themes/default/template/controllers/orders/_documents.tpl

 

Replace " delivery_number " line 71 by " id_order " ( back office delivery slip number ).

 

I also found a so great freeware to search a term in files ( term like delivery_number for example ;) ) PSPad http://www.pspad.com/en/ very very useful

 

@ scorpionsworld, can you modify your great module to add the invoice and delivery slip match too ?

 

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

Do the following using FTP:

  • Delete [your ps root]/modules/modrefchange folder and ANY random-like (temporary) folder and its contents.
  • On your own pc/laptop, unzip the module's file.
  • Upload the modrefchange/override/classes/OrderPayment.php file to [your ps root]/override/classes/
  • Upload the modrefchange folder to [your ps root]/modules/
  • Delete the [your ps root]/modules/modrefchange/override-folder
  • Now go to your shop's backoffice->Modules and try again to install the module.

That should do the trick.

Yes, that's a proper solution for all the bugs mentioned (have fought with them for 2 hours).

Thank you!

Link to comment
Share on other sites

I've been using the module for quite some time now, it was running well without glitches.

However recently order that are made manually by an admin from the backoffice didn't auto change - hence the ref number is still Alphanumeric. But orders that are being made from the front office is converted well.

 

Any idea what might have caused this and how to fix it?

Link to comment
Share on other sites

MDR... j'ai essayé de récupérer les deux modules cités ici par PrestaDev et PrestaPoint... Avant de mettre (peut-être) la pagaille sur mes boutique, j'aimerai savoir pourquoi les développeurs de ces modules ne les utilisent pas eux-même sur leurs sites ?  B)

 

LOL... I tried to download the two quoted modules here by PrestaDev and PrestaPoint... Before to use it (perhaps!) on my online shop, I will like to know why the developers of these modules don't use them they-same on their online-shop? B)

Link to comment
Share on other sites

Hello, I did the modification myself on PS1.5.4.1, order ID also match invoice and delivery slip number now :

 

For invoices number and his pdf number :

 

In classes/pdf/HTMLTemplateInvoice.php :

 

Replace " number " line 45 ( number on the invoice pdf) and line 140 by " id_order " ( pdf file number ).

 

In classes/order/OrderInvoice.php

 

Remplace " number " line 665 by " id_order " ( back office invoice number ).

 

For delivery slip number and his pdf number :

 

In classes/pdf/HTMLTemplateDeliverySlip.php  :

 

Replace " delivery_number " line 42 by " id_order " ( number on the delivery slip pdf ) and line 90 " order->invoice_number " by " order_invoice->id_order " ( pdf file number )

 

In adminXXXX/themes/default/template/controllers/orders/_documents.tpl

 

Replace " delivery_number " line 71 by " id_order " ( back office delivery slip number ).

 

I also found a so great freeware to search a term in files ( term like delivery_number for example ;) ) PSPad http://www.pspad.com/en/ very very useful

 

@ scorpionsworld, can you modify your great module to add the invoice and delivery slip match too ?

 

I'll try to incorporate invoice and delivery slip into my next update

 

@unanim. Good question. The answer: As i've not come around to installing the module onto my own shop yet  :P

Link to comment
Share on other sites

Nothing to my knowledge.

I will have to try and reproduce your problem to fix.

 

 

I have the same problem... When I use zero prefix combined with or without letters, zeros doesn't appear... I stille have for example XX274 and I wanted to have XX0000274 Can you tell me how to fix it?

Link to comment
Share on other sites

I have the same problem... When I use zero prefix combined with or without letters, zeros doesn't appear... I stille have for example XX274 and I wanted to have XX0000274 Can you tell me how to fix it?

 

It worked for my be specifying only letter set to : XXX000 and it worked like a charm! Thank you a lot for this great module! :) :) :)

Link to comment
Share on other sites

The subject of the order confirmation email to admin is set in the mailalert module.

Hello, I have the same problem: mail sent to admin are still in JHSDUIHW format... any clue?

 

line #325 in mailalerts.php is

'{order_name}' => $order->reference,

 

(my PS version is 1.5.6.1)

 

 

Thanks.

The module is very useful.

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

Hello, I have the same problem: mail sent to admin are still in JHSDUIHW format... any clue?

 

line #325 in mailalerts.php is

'{order_name}' => $order->reference,

(my PS version is 1.5.6.1)

 

 

Thanks.

The module is very useful.

 

So change it into:

'{order_name}' => $order->id,

and enjoy. ;)

Link to comment
Share on other sites

×
×
  • Create New...