コード例 #1
0
ファイル: OrderSlip.php プロジェクト: jpodracky/dogs
 /**
  * @param int $orderSlipId
  * @param Order $order
  * @return array
  */
 public static function getOrdersSlipProducts($orderSlipId, $order)
 {
     $cart_rules = $order->getCartRules(true);
     $productsRet = OrderSlip::getOrdersSlipDetail($orderSlipId);
     $order_details = $order->getProductsDetail();
     $slip_quantity = array();
     foreach ($productsRet as $slip_detail) {
         $slip_quantity[$slip_detail['id_order_detail']] = $slip_detail;
     }
     $products = array();
     foreach ($order_details as $key => $product) {
         if (isset($slip_quantity[$product['id_order_detail']]) && $slip_quantity[$product['id_order_detail']]['product_quantity']) {
             $products[$key] = $product;
             $products[$key] = array_merge($products[$key], $slip_quantity[$product['id_order_detail']]);
         }
     }
     return $order->getProducts($products);
 }
コード例 #2
0
    /**
     * Creating order details of order
     * @param $neteven_order
     * @param $id_order
     * @return mixed
     */
    private function createOrderDetails($neteven_order, $id_order)
    {
        global $cookie;
        $date_now = date('Y-m-d H:i:s');
        if (in_array($neteven_order->Status, $this->getValue('t_list_order_status'))) {
            return;
        }
        // If order detail doesn't exist
        if (!($res = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'orders_gateway` WHERE `id_order_neteven` = ' . (int) $neteven_order->OrderID . ' AND `id_order_detail_neteven` = ' . (int) $neteven_order->OrderLineID))) {
            // If product exist
            $ref_temp = $neteven_order->SKU;
            $type_temp = substr($ref_temp, 0, 1);
            $id_p_temp = str_replace($type_temp, '', $ref_temp);
            $where_req = '';
            if ($type_temp == 'D') {
                $where_req = 'pa.`id_product_attribute` = ' . (int) $id_p_temp;
            }
            if ($type_temp == 'P') {
                $where_req = 'p.`id_product` = ' . (int) $id_p_temp;
            }
            if (self::$type_sku == 'reference') {
                $where_req = ' (p.`reference` = "' . pSQL($ref_temp) . '" OR pa.`reference` = "' . pSQL($ref_temp) . '") ';
            }
            if (empty($where_req)) {
                return;
            }
            $res_product = Db::getInstance()->getRow('
					SELECT pl.`name` as name_product, p.`id_product`, pa.`id_product_attribute`, p.`reference` as product_reference, pa.`reference` as product_attribute_reference, p.`weight` as weight, GROUP_CONCAT(CONCAT(agl.`name`," : ",al.`name`) SEPARATOR ", ") as attribute_name
					FROM `' . _DB_PREFIX_ . 'product` p
					INNER JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON(p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) $this->getValue('id_lang') . ')
					LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (pa.`id_product` = p.`id_product`)
					LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac ON (pac.`id_product_attribute`=pa.`id_product_attribute`)
					LEFT JOIN `' . _DB_PREFIX_ . 'attribute` a ON (a.`id_attribute`=pac.`id_attribute`)
					LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON (al.`id_attribute`=a.`id_attribute` AND al.`id_lang`=' . (int) $this->getValue('id_lang') . ')
					LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group_lang` agl ON (agl.`id_attribute_group`=a.`id_attribute_group` AND agl.`id_lang`=' . (int) $this->getValue('id_lang') . ')
					WHERE p.`active` = 1 AND ' . $where_req . '
					GROUP BY pa.`id_product_attribute`, p.`id_product`
				');
            if ($res_product) {
                // Get order detail informations
                $product_reference = $res_product['product_reference'];
                $id_product_attribute = 0;
                $name = $res_product['name_product'];
                $control_attribute_product = false;
                if (!empty($res_product['id_product_attribute'])) {
                    $product_reference = $res_product['product_attribute_reference'];
                    $id_product_attribute = $res_product['id_product_attribute'];
                    if (!empty($res_product['attribute_name'])) {
                        $name .= ' - ' . $res_product['attribute_name'];
                    }
                    $control_attribute_product = true;
                }
                // Add product in cart
                $order = new Order($id_order);
                if (!Db::getInstance()->getRow('SELECT `id_cart` FROM `' . _DB_PREFIX_ . 'cart_product` WHERE `id_cart` = ' . (int) $order->id_cart . ' AND `id_product` = ' . (int) $res_product['id_product'] . ' AND `id_product_attribute` = ' . (int) $id_product_attribute)) {
                    Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_product` (`id_cart`, `id_product`, `id_product_attribute`, `quantity`, `date_add`) VALUES (' . (int) $order->id_cart . ', ' . (int) $res_product['id_product'] . ', ' . (int) $id_product_attribute . ', ' . (int) $neteven_order->Quantity . ', "' . pSQL($date_now) . '")');
                }
                if ($this->time_analyse) {
                    $this->current_time_0 = time();
                    Toolbox::displayDebugMessage(self::getL('Order information') . ' : ' . ((int) $this->current_time_0 - (int) $this->current_time_2) . 's');
                }
                // Add order detail
                $tax = new Tax(Configuration::get('PS_TAX'), $cookie->id_lang);
                $price_product = ($neteven_order->Price->_ - floatval($neteven_order->VAT->_)) / $neteven_order->Quantity;
                $order_detail = new OrderDetail();
                $order_detail->id_order = $id_order;
                $order_detail->product_id = $res_product['id_product'];
                $order_detail->product_attribute_id = $id_product_attribute;
                $order_detail->product_name = $name;
                $order_detail->product_quantity = $neteven_order->Quantity;
                $order_detail->product_quantity_in_stock = $neteven_order->Quantity;
                $order_detail->product_quantity_refunded = 0;
                $order_detail->product_quantity_return = 0;
                $order_detail->product_quantity_reinjected = 0;
                $order_detail->product_price = number_format((double) $price_product, 4, '.', '');
                $order_detail->total_price_tax_excl = number_format((double) $price_product, 4, '.', '');
                $order_detail->unit_price_tax_incl = number_format((double) $price_product, 4, '.', '');
                $order_detail->unit_price_tax_excl = $tax->rate ? number_format((double) $price_product / ((double) $tax->rate / 100), 4, '.', '') : $price_product;
                $order_detail->reduction_percent = 0;
                $order_detail->reduction_amount = 0;
                $order_detail->group_reduction = 0;
                $order_detail->product_quantity_discount = 0;
                $order_detail->product_ean13 = NULL;
                $order_detail->product_upc = NULL;
                $order_detail->product_reference = $product_reference;
                $order_detail->product_supplier_reference = NULL;
                $order_detail->product_weight = !empty($res_product['weight']) ? (double) $res_product['weight'] : 0;
                $order_detail->tax_name = $tax->name;
                $order_detail->tax_rate = (double) $tax->rate;
                $order_detail->ecotax = 0;
                $order_detail->ecotax_tax_rate = 0;
                $order_detail->discount_quantity_applied = 0;
                $order_detail->download_hash = '';
                $order_detail->download_nb = 0;
                $order_detail->download_deadline = '0000-00-00 00:00:00';
                $order_detail->id_warehouse = 0;
                if (Configuration::get('PS_SHOP_ENABLE')) {
                    $order_detail->id_shop = (int) Configuration::get('PS_SHOP_DEFAULT');
                }
                if (!$order_detail->add()) {
                    Toolbox::addLogLine(self::getL('Failed for creation of order detail / NetEven Order Id') . ' ' . (int) $neteven_order->OrderID . ' ' . self::getL('NetEven order detail id') . ' ' . $neteven_order->OrderLineID);
                } else {
                    if ($this->time_analyse) {
                        $this->current_time_2 = time();
                        Toolbox::displayDebugMessage(self::getL('Order detail') . ' : ' . ((int) $this->current_time_2 - (int) $this->current_time_0) . 's');
                    }
                    $id_order_detail_temp = $order_detail->id;
                    Toolbox::addLogLine(self::getL('Creation of order detail for NetEven order Id') . ' ' . (int) $neteven_order->OrderID . ' ' . self::getL('NetEven order detail id') . ' ' . (int) $neteven_order->OrderLineID);
                    // Update quantity of product
                    if (class_exists('StockAvailable')) {
                        // Update quantity of product
                        if ($control_attribute_product) {
                            StockAvailable::setQuantity($res_product['id_product'], $id_product_attribute, StockAvailable::getQuantityAvailableByProduct($res_product['id_product'], $id_product_attribute) - $neteven_order->Quantity);
                        } else {
                            StockAvailable::setQuantity($res_product['id_product'], 0, StockAvailable::getQuantityAvailableByProduct($res_product['id_product']) - $neteven_order->Quantity);
                        }
                    } else {
                        $t_info_product = array();
                        $t_info_product['id_product'] = $res_product["id_product"];
                        $t_info_product['cart_quantity'] = $neteven_order->Quantity;
                        $t_info_product['id_product_attribute'] = NULL;
                        if ($control_attribute_product) {
                            $t_info_product['id_product_attribute'] = $id_product_attribute;
                        }
                        Product::updateQuantity($t_info_product);
                    }
                    if ($this->time_analyse) {
                        $this->current_time_0 = time();
                        Toolbox::displayDebugMessage(self::getL('Cart product') . ' : ' . ((int) $this->current_time_0 - (int) $this->current_time_2) . 's');
                    }
                    // Insert order in orders_gateway table
                    if (!Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'orders_gateway` (`id_order_neteven`, `id_order`, `id_order_detail_neteven`, `date_add`, `date_upd`) VALUES (' . (int) $neteven_order->OrderID . ', ' . (int) $id_order . ', ' . (int) $neteven_order->OrderLineID . ', "' . pSQL($date_now) . '", "' . pSQL($date_now) . '")')) {
                        Toolbox::addLogLine(self::getL('Failed for save export NetEven order Id') . ' ' . (int) $neteven_order->OrderID . ' ' . self::getL('NetEven order detail id') . ' ' . (int) $neteven_order->OrderLineID);
                    } else {
                        Toolbox::addLogLine(self::getL('Save export NetEven order Id') . ' ' . (int) $neteven_order->OrderID . ' ' . self::getL('NetEven order detail id') . ' ' . (int) $neteven_order->OrderLineID);
                    }
                }
            }
        } else {
            Toolbox::addLogLine(self::getL('Failed for creation of order detail of NetEven order Id') . $neteven_order->OrderID . ' ' . self::getL('NetEven order detail id') . ' ' . $neteven_order->OrderLineID . ' ' . self::getL('Product not found SKU') . ' ' . $neteven_order->SKU);
        }
        $order = new Order($id_order);
        $products = $order->getProductsDetail();
        if (count($products) == 0 && $this->getValue('mail_active')) {
            $this->sendDebugMail($this->getValue('mail_list_alert'), self::getL('Order imported is empty'), self::getL('Order Id') . ' ' . (int) $order->id);
        }
    }
コード例 #3
0
ファイル: dpdgroup.php プロジェクト: remixaz/dpdgroup
 public function hookAdminOrder($params)
 {
     $shipment = new DpdGroupShipment((int) $params['id_order']);
     if (Tools::isSubmit('printLabels')) {
         $pdf_file_contents = $shipment->getLabelsPdf();
         if ($pdf_file_contents) {
             ob_end_clean();
             header('Content-type: application/pdf');
             header('Content-Disposition: attachment; filename="shipment_labels_' . (int) Tools::getValue('id_order') . '.pdf"');
             echo $pdf_file_contents;
         } else {
             $this->addFlashError(reset(DpdGroupShipment::$errors));
             Tools::redirectAdmin(self::getAdminOrderLink() . '&id_order=' . (int) $params['id_order']);
         }
     }
     $this->displayFlashMessagesIfIsset();
     $order = new Order((int) $params['id_order']);
     $customer = new Customer($order->id_customer);
     $products = $shipment->getParcelsSetUp($order->getProductsDetail());
     if ($shipment->parcels) {
         DpdGroupParcel::addParcelDataToProducts($products, $order->id);
     }
     $id_method = self::getMethodIdByCarrierId($order->id_carrier);
     DpdGroupWS::$parcel_weight_warning_message = false;
     $price = $shipment->calculatePriceForOrder((int) $id_method, $order->id_address_delivery, $products);
     $carrier = new Carrier((int) $order->id_carrier, $order->id_lang);
     $ws_shipping_price = $price !== false ? $price : '---';
     $total_shipping = version_compare(_PS_VERSION_, '1.5', '>=') ? $order->total_shipping_tax_incl : $order->total_shipping;
     $this->context->smarty->assign(array('order' => $order, 'module_link' => $this->getModuleLink('AdminModules'), 'settings' => new DpdGroupConfiguration(), 'total_weight' => DpdGroupShipment::convertWeight($order->getTotalWeight()), 'shipment' => $shipment, 'selected_shipping_method_id' => $id_method, 'ws_shippingPrice' => $price !== false ? $price : '---', 'products' => $products, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'carrier_url' => $carrier->url, 'order_link' => self::getAdminOrderLink() . '&id_order=' . (int) Tools::getValue('id_order'), 'errors' => $this->getErrorMessagesForOrderPage(), 'warnings' => $this->getWarningMessagesForOrderPage($shipment->id_shipment, $id_method, $ws_shipping_price, $total_shipping), 'force_enable_button' => DpdGroupWS::$parcel_weight_warning_message, 'display_product_weight_warning' => $this->orderProductsWithoutWeight($products)));
     if (!$this->ps_14) {
         $this->context->controller->addJS(_DPDGROUP_JS_URI_ . 'jquery.bpopup.min.js');
         $this->context->controller->addJS(_DPDGROUP_JS_URI_ . 'adminOrder.js');
         $css_filename = $this->bootstrap ? 'adminOrder_16' : 'adminOrder';
         $this->context->controller->addCSS(_DPDGROUP_CSS_URI_ . $css_filename . '.css');
     }
     $this->setGlobalVariablesForAjax();
     $template_filename = $this->bootstrap ? 'adminOrder_16' : 'adminOrder';
     return $this->context->smarty->fetch(_DPDGROUP_TPL_DIR_ . 'hook/' . $template_filename . '.tpl');
 }
コード例 #4
0
ファイル: seur.php プロジェクト: tomideru/PrestaShop-modules
    public function hookDisplayOrderConfirmation($params)
    {
        $carrier_pos = SeurLib::getSeurCarrier('SEP');
        if ($carrier_pos['id'] != (int) $params['objOrder']->id_carrier) {
            //check if COD carrier with pickup points
            return '';
        }
        if (Db::getInstance()->getValue('
			SELECT `id_address_delivery`
			FROM `' . _DB_PREFIX_ . 'seur_order`
			WHERE `id_order` = "' . (int) $params['objOrder']->id . '"
		')) {
            return;
        }
        $customer_address = new Address((int) $params['objOrder']->id_address_delivery);
        $pickup_point_info = SeurLib::getOrderPos((int) $params['objOrder']->id_cart);
        $pickup_point_address = new Address();
        $pickup_point_address->id_country = $customer_address->id_country;
        $pickup_point_address->id_state = $customer_address->id_state;
        $pickup_point_address->alias = $customer_address->alias;
        $pickup_point_address->company = urldecode($pickup_point_info['company']);
        $pickup_point_address->lastname = $customer_address->lastname;
        $pickup_point_address->firstname = $customer_address->firstname;
        $pickup_point_address->address1 = urldecode($pickup_point_info['address']);
        $pickup_point_address->postcode = urldecode($pickup_point_info['postal_code']);
        $pickup_point_address->city = urldecode($pickup_point_info['city']);
        $pickup_point_address->phone = $customer_address->phone_mobile ? $customer_address->phone_mobile : self::DEFAULT_PUDO_MOBILE;
        $order = new Order((int) $params['objOrder']->id);
        $products = $order->getProductsDetail();
        $order_weigth = 0;
        foreach ($products as $product) {
            $order_weigth += (double) $product['product_weight'] * (double) $product['product_quantity'];
        }
        $order_weigth = $order_weigth > 1 ? $order_weigth : 1;
        if ($pickup_point_address->save()) {
            $order->id_address_delivery = (int) $pickup_point_address->id;
            if ($order->save()) {
                Db::getInstance()->Execute('
					INSERT INTO `' . _DB_PREFIX_ . 'seur_order`
					VALUES ("' . (int) $order->id . '", "1", "' . (double) $order_weigth . '", null, "0", "0", "' . (int) $pickup_point_address->id . '");');
            } else {
                Db::getInstance()->Execute('
					INSERT INTO `' . _DB_PREFIX_ . 'seur_order`
					VALUES ("' . (int) $order->id . '", "1", "' . (double) $order_weigth . '", null, "0", "0", "");');
            }
        } else {
            Db::getInstance()->Execute('
				INSERT INTO `' . _DB_PREFIX_ . 'seur_order`
				VALUES ("' . (int) $order->id . '", "1", "' . (double) $order_weigth . '", null, "0", "0", "");');
        }
    }
コード例 #5
0
                    if ($current_state != Configuration::get('PS_OS_PAYMENT')) {
                        $history = new OrderHistory();
                        $history->id_order = (int) $order->id;
                        $history->changeIdOrderState((int) Configuration::get($state), $order->id);
                        $history->addWithemail(true);
                    }
                } else {
                    $current_state = $order->current_state;
                    if ($current_state != Configuration::get('PS_OS_PAYMENT')) {
                        $history = new OrderHistory();
                        $history->id_order = (int) $order->id;
                        $history->changeIdOrderState((int) Configuration::get($state), $order, true);
                        $history->addWithemail(true);
                    }
                }
            } else {
                $customer = new Customer((int) $cart->id_customer);
                Context::getContext()->customer = $customer;
                Context::getContext()->currency = $currency_cart;
                $payulatam->validateOrder((int) $cart->id, (int) Configuration::get($state), (double) $cart->getordertotal(true), 'PayU Latam', null, array(), (int) $currency_cart->id, false, $customer->secure_key);
                Configuration::updateValue('PAYULATAM_CONFIGURATION_OK', true);
                $order = new Order((int) Order::getOrderByCartId($cart->id));
            }
            if ($state != 'PS_OS_PAYMENT') {
                foreach ($order->getProductsDetail() as $product) {
                    StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], +(int) $product['product_quantity'], $order->id_shop);
                }
            }
        }
    }
}
コード例 #6
0
 private function getOrderDetails($id_order)
 {
     global $cookie;
     $confs = Configuration::getMultiple(array('EMC_LOGIN', 'PS_SHOP_NAME', 'EMC_GENDER', 'EMC_FIRST_NAME', 'EMC_LAST_NAME', 'EMC_ADDRESS', 'EMC_ZIP_CODE', 'EMC_CITY', 'EMC_COUNTRY', 'EMC_PHONE', 'EMC_EMAIL', 'EMC_EMAILS'));
     $orderDetails = array();
     $order = new Order((int) $id_order);
     $customer = new Customer((int) $order->id_customer);
     $adresseDelivery = new Address((int) $order->id_address_delivery);
     $genderTab = array(1 => 'M.', 2 => 'Mme', 9 => '');
     $orderDetails['url_suivi'] = Tools::getProtocol() . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/envoimoinscher/tracking.php?token=' . $customer->secure_key;
     $orderDetails['infoexterne'] = str_replace('.', '_', str_replace('www.', '', $_SERVER['HTTP_HOST'])) . '_' . (int) $id_order;
     $orderDetails['packaging'] = Tools::getValue('packaging_' . (int) $id_order);
     $orderDetails['type_objet'] = Tools::getValue('type_objet_' . (int) $id_order);
     $orderDetails['envoi_emailsconf'] = (int) $confs['EMC_EMAILS'];
     //products infos
     $productsDetails = $order->getProductsDetail();
     $tabDetails = array();
     foreach ($productsDetails as $details) {
         $features = self::getFeatures((int) $details['product_id']);
         $tabDetailsProduct = array();
         $tabDetailsProduct['id'] = (int) $details['product_id'];
         $tabDetailsProduct['nb'] = (int) $details['product_quantity'];
         $tabDetailsProduct['poids'] = (double) $details['product_weight'];
         $tabDetailsProduct['description'] = htmlspecialchars($details['product_name'], ENT_COMPAT, 'UTF-8');
         foreach ($features as $key => $value) {
             $tabDetailsProduct[$key] = $value;
         }
         $tabDetails[] = $tabDetailsProduct;
     }
     $orderDetails['products'] = $tabDetails;
     //sending infos
     $orderExpediteur['civilite'] = htmlspecialchars($genderTab[$confs['EMC_GENDER']], ENT_COMPAT, 'UTF-8');
     $orderExpediteur['collecte_type'] = 'entreprise';
     $orderExpediteur['societe'] = htmlspecialchars($confs['PS_SHOP_NAME'], ENT_COMPAT, 'UTF-8');
     $orderExpediteur['nom'] = htmlspecialchars($confs['EMC_LAST_NAME'], ENT_COMPAT, 'UTF-8');
     $orderExpediteur['prenom'] = htmlspecialchars($confs['EMC_FIRST_NAME'], ENT_COMPAT, 'UTF-8');
     $orderExpediteur['adresse'] = htmlspecialchars($confs['EMC_ADDRESS'], ENT_COMPAT, 'UTF-8');
     $orderExpediteur['codepostal'] = htmlspecialchars($confs['EMC_ZIP_CODE'], ENT_COMPAT, 'UTF-8');
     $orderExpediteur['ville'] = htmlspecialchars($confs['EMC_CITY'], ENT_COMPAT, 'UTF-8');
     $orderExpediteur['pz_id'] = htmlspecialchars($confs['EMC_COUNTRY'], ENT_COMPAT, 'UTF-8');
     $orderExpediteur['tel'] = htmlspecialchars($confs['EMC_PHONE'], ENT_COMPAT, 'UTF-8');
     $orderExpediteur['email'] = htmlspecialchars($confs['EMC_EMAIL'], ENT_COMPAT, 'UTF-8');
     $orderDetails['expediteur'] = $orderExpediteur;
     //delivery infos
     $orderDelivery['civilite'] = $genderTab[(int) $customer->id_gender];
     if (isset($adresseDelivery->company)) {
         $orderDelivery['collecte_type'] = 'particulier';
     }
     $orderDelivery['societe'] = htmlspecialchars($adresseDelivery->company, ENT_COMPAT, 'UTF-8');
     $orderDelivery['prenom'] = htmlspecialchars($adresseDelivery->firstname, ENT_COMPAT, 'UTF-8');
     $orderDelivery['nom'] = htmlspecialchars($adresseDelivery->lastname, ENT_COMPAT, 'UTF-8');
     $orderDelivery['adresse'] = htmlspecialchars($adresseDelivery->address1, ENT_COMPAT, 'UTF-8');
     $orderDelivery['codepostal'] = htmlspecialchars($adresseDelivery->postcode, ENT_COMPAT, 'UTF-8');
     $orderDelivery['ville'] = htmlspecialchars($adresseDelivery->city, ENT_COMPAT, 'UTF-8');
     $orderDelivery['pz_id'] = Country::getIsoById(Country::getIdByName((int) $cookie->id_lang, $adresseDelivery->country));
     if (isset($adresseDelivery->phone)) {
         $orderDelivery['tel'] = htmlspecialchars($adresseDelivery->phone, ENT_COMPAT, 'UTF-8');
     } else {
         $orderDelivery['tel'] = htmlspecialchars($adresseDelivery->phone_mobile, ENT_COMPAT, 'UTF-8');
     }
     $orderDelivery['email'] = htmlspecialchars($customer->email, ENT_COMPAT, 'UTF-8');
     $orderDetails['destinataire'] = $orderDelivery;
     //d($orderDetails);
     return $orderDetails;
 }
コード例 #7
0
 private function cancelOrder($id_order)
 {
     $order = new Order($id_order);
     $orderDetails = $order->getProductsDetail();
     //$orderDetails = $order->get
     foreach ($orderDetails as $order_product) {
         $orderDetail = new OrderDetail((int) $order_product['id_order_detail']);
         // Reinject product
         if (!$order->hasBeenDelivered()) {
             $reinjectableQuantity = (int) $orderDetail->product_quantity - (int) $orderDetail->product_quantity_reinjected;
             $quantityToReinject = $reinjectableQuantity;
             if (!Product::reinjectQuantities($orderDetail, $quantityToReinject)) {
                 $this->_errors[] = Tools::displayError('Cannot re-stock product') . ' <span class="bold">' . $orderDetail->product_name . '</span>';
             }
         }
         Module::hookExec('cancelProduct', array('order' => $order, 'id_order_detail' => $order_product['id_order_detail']));
     }
 }
コード例 #8
0
ファイル: itembase.php プロジェクト: Evil1991/PrestaShop-1.4
    /**
     * Execute hook
     * 
     * @param mixed $params
     */
    public function hookOrderConfirmation($params)
    {
        global $smarty, $cookie, $link;
        if (!$this->active) {
            return;
        }
        // seting error handler
        eval('function itembaseErrorHandler($errno, $errstr, $errfile, $errline) {
' . ((bool) Configuration::get('PS_ITEMBASE_DEBUG') ? 'echo "
<!--ITEMBASE
".print_r(array($errno, $errstr, $errfile, $errline), true)."ITEMBASE-->
";' : '') . '
	return true;
}');
        set_error_handler('itembaseErrorHandler', E_ALL);
        try {
            include_once rtrim(_PS_MODULE_DIR_, '/') . '/itembase/plugindata.php';
            include_once rtrim(_PS_MODULE_DIR_, '/') . '/itembase/oauth.php';
            // geting access token
            $responseArray = $this->jsonDecode(authenticateClient(Configuration::get('PS_ITEMBASE_APIKEY'), Configuration::get('PS_ITEMBASE_SECRET')));
            if (!isset($responseArray['access_token'])) {
                itembaseErrorHandler(0, 'no access_token for ' . Tools::safeOutput(Configuration::get('PS_ITEMBASE_APIKEY')) . ' ' . substr(Tools::safeOutput(Configuration::get('PS_ITEMBASE_SECRET')), 0, 4) . '... ' . PS_ITEMBASE_SERVER_OAUTH . ' ' . print_r($responseArray, true), __FILE__, __LINE__ - 1);
            }
            // order data gathering
            $order = new Order($params['objOrder']->id, NULL);
            $currency = Currency::getCurrency((int) $order->id_currency);
            $carrier = new Carrier((int) $order->id_carrier);
            $language = Language::getLanguage((int) $cookie->id_lang);
            $customer = new Customer((int) $order->id_customer);
            $address = $customer->getAddresses($cookie->id_lang);
            if (is_object($address)) {
                $address = (array) $address;
            }
            if (isset($address['0'])) {
                $address = $address['0'];
            }
            // products data gathering
            $allProducts = array();
            foreach ($order->getProductsDetail() as $order_detail) {
                $product_id = $order_detail['product_id'];
                $product = new Product($product_id, true, null);
                $cover = Product::getCover($product_id);
                $product_img = $link->getImageLink($product->link_rewrite, $product_id . '-' . $cover['id_image']);
                if (strpos($product_img, 'http') !== 0) {
                    $product_img = Tools::getHttpHost(true) . $product_img;
                }
                $category = new Category($product->id_category_default);
                $allProducts[] = array('id' => $order_detail['product_id'], 'category' => $category->name, 'name' => $product->name, 'quantity' => $order_detail['product_quantity'], 'price' => $product->getPrice(true, NULL, 2), 'ean' => $product->ean13, 'isbn' => '', 'asin' => '', 'description' => $product->description_short, 'pic_thumb' => $product_img, 'pic_medium' => $product_img, 'pic_large' => $product_img, 'url' => $product->getLink(), 'presta_lang_id' => $language['id_lang']);
            }
            $dataForItembase = array('access_token' => $responseArray['access_token'], 'email' => $customer->email, 'firstname' => $customer->firstname, 'lastname' => $customer->lastname, 'street' => $address['address1'] . ($address['address2'] ? ' ' . $address['address2'] : ''), 'zip' => $address['postcode'], 'city' => $address['city'], 'country' => $address['country'], 'phone' => $address['phone'], 'lang' => $language['iso_code'], 'purchase_date' => $order->date_add, 'currency' => $currency['iso_code'], 'total' => $order->total_products_wt, 'order_number' => $order->id, 'customer_id' => $order->id_customer, 'invoice_number' => $order->invoice_number, 'shipping_cost' => $order->total_shipping, 'carrier' => $carrier->name, 'payment_option' => $order->payment, 'is_opt_in' => $customer->newsletter, 'shop_name' => class_exists('Context', false) ? Context::getContext()->shop->name : Configuration::get('PS_SHOP_NAME'), 'products' => $allProducts);
            // encoding data
            utf8EncodeRecursive($dataForItembase);
            $smarty->assign('ibdata', $dataForItembase);
            $smarty->assign('ibdatajson', $this->jsonEncode($dataForItembase));
            $smarty->assign('ibembedserver', PS_ITEMBASE_SERVER_EMBED);
            $smarty->assign('ibhostserver', PS_ITEMBASE_SERVER_HOST);
            $smarty->assign('ibpluginversion', PS_ITEMBASE_PLUGIN_VERSION);
            $smarty->assign('ibtop', Configuration::get('PS_ITEMBASE_TOP'));
        } catch (Exception $e) {
            itembaseErrorHandler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine());
        }
        // restoring error handler
        restore_error_handler();
        return $this->display(__FILE__, 'views/templates/front/checkout_plugin.tpl');
    }