✏️ 正在编辑: Order.php
路径:
/home/bpioifn/www/pigmentse/modules/axepta/override/classes/order/Order.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php /** * 1961-2019 BNP Paribas * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) that is available * through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0 * If you are unable to obtain it through the world-wide-web, please send an email * to modules@quadra-informatique.fr so we can send you a copy immediately. * * @author Quadra Informatique <modules@quadra-informatique.fr> * @copyright 1961-2019 BNP Paribas * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ class Order extends OrderCore { /** * AXEPTA OVERRIDE * Create a reference if the cart doesn't have one, else return the reference * @return string */ public static function generateReference() { $id_cart = (int)Context::getContext()->cart->id; $reference = self::getReferenceByCartId($id_cart); if (empty($reference)) { $reference = Tools::strtoupper(Tools::passwdGen(9)); } return $reference; } /** * Retrieve the pregenerate reference * @param int $id_cart * @return boolean | string */ public static function getReferenceByCartId($id_cart) { if (empty($id_cart)) { return false; } $sql = 'SELECT `reference` FROM `'._DB_PREFIX_.'axepta_order_reference` WHERE `id_cart` ='.pSQL((int)$id_cart); return Db::getInstance()->getValue($sql); } public function getOrderPaymentCollection() { if ($this->module == 'axepta') { $order_payments = new PrestaShopCollection('OrderPayment'); $order_payments->where('order_reference', '=', $this->reference); $order_payments->orderBy('date_add'); $transactions = $this->getTransactionByOrderIdOrderByDate(); $i_payment = 0; $found = false; while (!$found && $i_payment < count($order_payments)) { foreach ($transactions as $transaction) { if ($order_payments[$i_payment]->transaction_id == $transaction['pay_id'] || $transaction['amount'] == $order_payments[$i_payment]->amount) { // pay_id is in order_payment $found = true; // Get name of method by mean_brand if ($transaction['payment_mean_brand'] != 'N/A' && ($transaction['trigram'] == 'CVM' || $transaction['trigram'] == 'VIM')) { $order_payments[$i_payment]->payment_method = $transaction['payment_mean_brand']; } else { // Get name of method by trigram $sql = 'SELECT `code` FROM `' . _DB_PREFIX_ . 'axepta_xml_method` WHERE `trigram` = "'. pSQL($transaction['trigram']).'"'; $code = Db::getInstance()->getValue($sql); // replace payment method name $order_payments[$i_payment]->payment_method = $code; } } } $i_payment++; } return $order_payments; } else { return parent::getOrderPaymentCollection(); } } /** * Return the transaction for an order id, ordered by date * @param string $id_order * @return boolean|array */ public function getTransactionByOrderIdOrderByDate() { if (empty($this->id)) { return false; } return Db::getInstance()->executeS(' SELECT * FROM `' . _DB_PREFIX_ . 'axepta_transaction` WHERE `id_order` = "' . pSQL((int) $this->id) . '" ORDER BY `transaction_date` ASC '); } }
💾 保存文件
← 返回文件管理器