Jump to content

Iletait1maille

Members
  • Posts

    3
  • Joined

  • Last visited

Profile Information

  • First Name
    Marion
  • Last Name
    Meunier

Recent Profile Visitors

101 profile views

Iletait1maille's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Works like a charm ! Thanks for the update on 1.6 @Aioras !
  2. Thanks for your answer but it doesn't suit my needs. I would have to manually change the status. And that's exactly what i don't want to have to do.
  3. Hello everyone ! I'm quite new in prestashop development and i'm trying to do something that's not quite easy to me. I'm looking for a way to have the order status to be update automatically at a certain date. Trying to be clear : - We are using an addon to manage rental of the products. - There is a "supposed date of return". - I want that 36h before that date, the system change the order status to a new one i created. I thought about overriding the OrderHistory class like below but i feel i'm way to far from doing the right thing. Any ideas to help me ? Thanks a lot ! class OrderHistory extends OrderHistoryCore { public function changeIdOrderState($new_order_state, $id_order, $use_existing_payment = false) { /*Changes made by the rental module developers */ parent::changeIdOrderState($new_order_state, $id_order, $use_existing_payment); require_once(_PS_MODULE_DIR_.'ipslocationadvanced/ipslocationadvanced.php'); if((int)$id_order->id_cart > 0 ) { IPSLocationAdvanced::changeReservationOrder(array('id_cart'=>(int)$id_order->id_cart),(int)$id_order->id); if($new_order_state == _PS_OS_PAYMENT_) { IPSLocationAdvanced::updateStatusReservation(array('id_order'=>$id_order->id),_IPS_STATUS_PAYMENT_); } else { IPSLocationAdvanced::updateStatusReservation(array('id_order'=>$id_order->id),_IPS_STATUS_RESERVE_); } } /*My updates begin here*/ $today = date(); $alert_dt = ($dpr_dt-2160); $current_order_state = $order->getCurrentOrderState(); if($today == $alert_dt) { // Create new OrderHistory $history = new OrderHistory(); $history->id_order = $order->id; $history->id_employee = (int)$this->context->employee->id; $use_existings_payment = false; if (!$order->hasInvoice()) { $use_existings_payment = true; } $history->changeIdOrderState((18)$order_state->id, $order, $use_existings_payment); $carrier = new Carrier($order->id_carrier, $order->id_lang); $templateVars = array(); if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number) { $templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url)); } // Save all changes if ($history->addWithemail(true, $templateVars)) { // synchronizes quantities if needed.. if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { foreach ($order->getProducts() as $product) { if (StockAvailable::dependsOnStock($product['product_id'])) { StockAvailable::synchronize($product['product_id'], (int)$product['id_shop']); } } } Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int)$order->id.'&vieworder&token='.$this->token); } $this->errors[] = Tools::displayError('An error occurred while changing order status, or we were unable to send an email to the customer.'); } } } id of custom status is 18 $dpr_dt is date when the product is supposed to be returned by the client. PS: First time i post in that forum, not sure if i did it correctly :/
×
×
  • Create New...