本文整理汇总了PHP中Cart::getCartByOrderId方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::getCartByOrderId方法的具体用法?PHP Cart::getCartByOrderId怎么用?PHP Cart::getCartByOrderId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::getCartByOrderId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initContent
public function initContent()
{
$this->display_column_left = false;
$this->display_column_right = false;
parent::initContent();
global $smarty;
if (isset($_GET['order_id'])) {
$cart = Cart::getCartByOrderId($_GET['order_id']);
if ($cart == null) {
die;
}
} else {
global $cart;
}
$address = new Address((int) $cart->id_address_invoice);
$customer = new Customer((int) $cart->id_customer);
$amount = $cart->getOrderTotal(true, Cart::BOTH);
$przelewy24 = new Przelewy24();
$currencies = $przelewy24->getCurrency(intval($cart->id_currency));
$currency = $currencies[0];
if (isset($currency['decimals']) && $currency['decimals'] == '0') {
if (Configuration::get('PS_PRICE_ROUND_MODE') != null) {
switch (Configuration::get('PS_PRICE_ROUND_MODE')) {
case 0:
$amount = ceil($amount);
break;
case 1:
$amount = floor($amount);
break;
case 2:
$amount = round($amount);
break;
}
}
}
$amount = number_format($amount, 2, '.', '') * 100;
$s_sid = md5(time());
Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'przelewy24_amount` ' . '(`s_sid`,`i_id_order`,`i_amount`) ' . 'VALUES("' . $s_sid . '",' . $cart->id . ',' . $amount . ')');
$s_lang = new Country((int) $address->id_country);
$order = Order::getOrderByCartId($cart->id);
if ($order == null) {
$s_descr = '';
$validationRequired = true;
} else {
$s_descr = 'Zamówienie: ' . $order;
$validationRequired = false;
}
$url = 'secure.przelewy24.pl';
if (Configuration::get('P24_TEST_MODE') == 1) {
if (Configuration::get('P24_TEST_MODE_TRANSACTION') == 1) {
$url = 'sandbox.przelewy24.pl';
} else {
$url = 'sandbox.przelewy24.pl';
$s_descr = 'TEST_ERR102';
}
}
$smarty->assign(array('productsNumber' => $cart->nbProducts(), 'ps_version' => _PS_VERSION_, 'p24_url' => $url, 'p24_session_id' => $cart->id . '|' . $s_sid, 'p24_id_sprzedawcy' => Configuration::get('P24_ID_SPRZEDAWCY'), 'p24_kwota' => $amount, 'p24_opis' => $s_descr, 'p24_klient' => $customer->firstname . ' ' . $customer->lastname, 'p24_adres' => $address->address1 . " " . $address->address2, 'p24_kod' => $address->postcode, 'p24_miasto' => $address->city, 'p24_language' => strtolower($s_lang->iso_code), 'p24_kraj' => $s_lang->iso_code, 'p24_email' => $customer->email, 'p24_metoda' => Tools::getValue('payment_method'), 'p24_return_url_ok' => $this->context->link->getModuleLink('przelewy24', 'paymentSuccessful'), 'p24_return_url_error' => $this->context->link->getModuleLink('przelewy24', 'paymentFailed'), 'p24_validationRequired' => $validationRequired));
$this->setTemplate('paymentConfirmation.tpl');
}
示例2: initContent
/**
* Display payment instruction for cash or transfer payments
*/
public function initContent()
{
$this->display_column_left = false;
parent::initContent();
$errorMessage = NULL;
if (Tools::getValue('order_id')) {
$this->context->cart = Cart::getCartByOrderId(Tools::getValue('order_id'));
$this->initPersonalData();
}
$channel = $this->context->cookie->dotpay_channel;
unset($this->context->cookie->dotpay_channel);
DotpayRegisterOrder::init($this);
$payment = DotpayRegisterOrder::create($channel);
if ($payment === NULL) {
$instruction = DotpayInstruction::getByOrderId(Tools::getValue('order_id'));
if (!empty($instruction) && $instruction->id == NULL) {
$this->context->smarty->assign(array('isOk' => false));
}
} else {
if (isset($payment['instruction']) && isset($payment['operation'])) {
if ($this->api->isChannelInGroup($payment['operation']['payment_method']['channel_id'], array(DotpayApi::cashGroup))) {
$isCash = true;
} else {
$isCash = false;
}
$instruction = new DotpayInstruction();
$instruction->amount = $payment['instruction']['amount'];
$instruction->currency = $payment['instruction']['currency'];
$instruction->number = $payment['operation']['number'];
$instruction->hash = DotpayInstruction::gethashFromPayment($payment);
$instruction->is_cash = $isCash;
$instruction->order_id = Tools::getValue('order_id');
$instruction->channel = $payment['operation']['payment_method']['channel_id'];
if (isset($payment['instruction']['recipient'])) {
$instruction->bank_account = $payment['instruction']['recipient']['bank_account_number'];
}
try {
$instruction->save();
} catch (Exception $e) {
$this->context->smarty->assign(array('errorMessage' => $this->module->l("Unable to save instructions." . $e->getMessage())));
}
}
}
if (!empty($instruction) && $instruction->id != NULL) {
if ($instruction->is_cash) {
$template = 'cash.tpl';
$address = $instruction->getPdfUrl($this->config->getDotpayTargetUrl());
$bankImage = '';
} else {
$template = 'transfer.tpl';
$address = $instruction->getBankPage($this->config->getDotpayTargetUrl());
}
$chData = $this->api->getChannelData($instruction->channel);
$channelImage = $chData['logo'];
$this->context->smarty->assign(array('meta_title' => $this->module->l('Complete payment'), 'isOk' => true, 'amount' => $instruction->amount, 'currency' => $instruction->currency, 'title' => $instruction->number, 'address' => $address, 'bankAccount' => $instruction->bank_account, 'recipient' => DotpayInstruction::DOTPAY_NAME, 'street' => DotpayInstruction::DOTPAY_STREET, 'city' => DotpayInstruction::DOTPAY_CITY, 'template' => './confirm/' . $template, 'channelImage' => $channelImage));
}
$this->setTemplate("confirm.tpl");
}
示例3: initContent
/**
* Preparing hidden form with payment data before sending it to Dotpay
*/
public function initContent()
{
parent::initContent();
$this->display_column_left = false;
$this->display_header = false;
$this->display_footer = false;
$cartId = 0;
if (Tools::getValue('order_id') == false) {
$cartId = $this->context->cart->id;
$exAmount = $this->api->getExtrachargeAmount(true);
if ($exAmount > 0 && !$this->isExVPinCart()) {
$productId = $this->config->getDotpayExchVPid();
if ($productId != 0) {
$product = new Product($productId, true);
$product->price = $exAmount;
$product->save();
$product->flushPriceCache();
$this->context->cart->updateQty(1, $product->id);
$this->context->cart->update();
$this->context->cart->getPackageList(true);
}
}
$discAmount = $this->api->getDiscountAmount();
if ($discAmount > 0) {
$discount = new CartRule($this->config->getDotpayDiscountId());
$discount->reduction_amount = $this->api->getDiscountAmount();
$discount->reduction_currency = $this->context->cart->id_currency;
$discount->reduction_tax = 1;
$discount->update();
$this->context->cart->addCartRule($discount->id);
$this->context->cart->update();
$this->context->cart->getPackageList(true);
}
$result = $this->module->validateOrder($this->context->cart->id, (int) $this->config->getDotpayNewStatusId(), $this->getDotAmount(), $this->module->displayName, NULL, array(), NULL, false, $this->customer->secure_key);
} else {
$this->context->cart = Cart::getCartByOrderId(Tools::getValue('order_id'));
$this->initPersonalData();
$cartId = $this->context->cart->id;
}
$this->api->onPrepareAction(Tools::getValue('dotpay_type'), array('order' => Order::getOrderByCartId($cartId), 'customer' => $this->context->customer->id));
$sa = new DotpaySellerApi($this->config->getDotpaySellerApiUrl());
if ($this->config->isDotpayDispInstruction() && $this->config->isApiConfigOk() && $this->api->isChannelInGroup(Tools::getValue('channel'), array(DotpayApi::cashGroup, DotpayApi::transfersGroup)) && $sa->isAccountRight($this->config->getDotpayApiUsername(), $this->config->getDotpayApiPassword(), $this->config->getDotpayApiVersion())) {
$this->context->cookie->dotpay_channel = Tools::getValue('channel');
Tools::redirect($this->context->link->getModuleLink($this->module->name, 'confirm', array('order_id' => Order::getOrderByCartId($cartId))));
die;
}
$this->context->smarty->assign(array('hiddenForm' => $this->api->getHiddenForm()));
$cookie = new Cookie('lastOrder');
$cookie->orderId = Order::getOrderByCartId($cartId);
$cookie->write();
$this->setTemplate("preparing.tpl");
}
示例4: initContent
/**
* Displays template with Dotpay payment channels
*/
public function initContent()
{
$this->display_column_left = false;
parent::initContent();
if (Tools::getValue('order_id')) {
$cart = Cart::getCartByOrderId(Tools::getValue('order_id'));
if (empty($cart)) {
$cart = new Cart();
}
$this->context->cart = $cart;
$this->context->cart->update();
}
$this->context->smarty->assign($this->getArrayForSmarty(true));
$this->setTemplate("payment.tpl");
}
示例5: changeIdOrderState
public function changeIdOrderState($new_order_state = NULL, $id_order)
{
if ($new_order_state != NULL) {
Hook::updateOrderStatus(intval($new_order_state), intval($id_order));
/* Best sellers */
$newOS = new OrderState(intval($new_order_state));
$oldOrderStatus = OrderHistory::getLastOrderState(intval($id_order));
$cart = Cart::getCartByOrderId($id_order);
$isValidated = $this->isValidated();
if (Validate::isLoadedObject($cart)) {
foreach ($cart->getProducts() as $product) {
/* If becoming logable => adding sale */
if ($newOS->logable and (!$oldOrderStatus or !$oldOrderStatus->logable)) {
ProductSale::addProductSale($product['id_product'], $product['cart_quantity']);
} elseif (!$newOS->logable and ($oldOrderStatus and $oldOrderStatus->logable)) {
ProductSale::removeProductSale($product['id_product'], $product['cart_quantity']);
}
if (!$isValidated and $newOS->logable and isset($oldOrderStatus) and $oldOrderStatus and $oldOrderStatus->id == _PS_OS_ERROR_) {
Product::updateQuantity($product);
Hook::updateQuantity($product, $order);
}
}
}
$this->id_order_state = intval($new_order_state);
/* Change invoice number of order ? */
$newOS = new OrderState(intval($new_order_state));
$order = new Order(intval($id_order));
if (!Validate::isLoadedObject($newOS) or !Validate::isLoadedObject($order)) {
die(Tools::displayError('Invalid new order state'));
}
/* The order is valid only if the invoice is available and the order is not cancelled */
$order->valid = $newOS->logable;
$order->update();
if ($newOS->invoice and !$order->invoice_number) {
$order->setInvoice();
}
if ($newOS->delivery and !$order->delivery_number) {
$order->setDelivery();
}
Hook::postUpdateOrderStatus(intval($new_order_state), intval($id_order));
}
}
示例6: ajaxProcessDuplicateOrder
public function ajaxProcessDuplicateOrder()
{
if ($this->tabAccess['edit'] === '1') {
$errors = array();
if (!($id_order = Tools::getValue('id_order'))) {
$errors[] = Tools::displayError('Invalid order');
}
$cart = Cart::getCartByOrderId($id_order);
$new_cart = $cart->duplicate();
if (!$new_cart || !Validate::isLoadedObject($new_cart['cart'])) {
$errors[] = Tools::displayError('The order cannot be renewed.');
} elseif (!$new_cart['success']) {
$errors[] = Tools::displayError('The order cannot be renewed.');
} else {
$this->context->cart = $new_cart['cart'];
echo Tools::jsonEncode($this->ajaxReturnVars());
}
}
}
示例7: getSingleMapData
private function getSingleMapData($params)
{
$cart = Cart::getCartByOrderId((int) $params['id_order']);
if (Validate::isLoadedObject($cart)) {
$products = $cart->getProducts();
if (count($products) == 0 && method_exists('Shop', 'getContextShopID') && Shop::getContextShopID() != (int) $cart->id_shop) {
Shop::initialize();
$products = $cart->getProducts(true);
}
$currency = Currency::getCurrencyInstance((int) $cart->id_currency);
if (!is_null($products) && is_array($products) && Validate::isLoadedObject($currency)) {
$data = array();
$data['order_date'] = $params['date_add'];
$data['email'] = $params['email'];
$data['customer_name'] = $params['firstname'] . ' ' . $params['lastname'];
$data['order_id'] = (int) $params['id_order'];
$data['currency_iso'] = $currency->iso_code;
$products_arr = array();
foreach ($products as $product) {
$product_data = array();
$product_data['url'] = $this->getProductLink($product['id_product'], $product['link_rewrite']);
$product_data['name'] = $product['name'];
$product_data['image'] = $this->getProductImageUrl((int) $product['id_product']);
$product_data['description'] = $this->getDescritpion($product, (int) $params['id_lang']);
$product_data['price'] = $product['price'];
$products_arr[(int) $product['id_product']] = $product_data;
}
$data['products'] = $products_arr;
return $data;
}
}
return null;
}
示例8: confirm
public function confirm()
{
// Global vars
$kccPath = Configuration::get(KCC_PATH);
$kccLogPath = Configuration::get(KCC_LOG);
// Order States
$order_state_completed = (int) Configuration::get('PS_OS_PAYMENT');
$order_state_failed = (int) Configuration::get('PS_OS_ERROR');
$order_state_waiting_payment = (int) Configuration::get(KCC_WAITING_PAYMENT_STATE);
// TBK Vars
$tbk_session_id = isset($_POST['TBK_ID_SESION']) ? trim($_POST['TBK_ID_SESION']) : null;
$tbk_order_id = isset($_POST['TBK_ORDEN_COMPRA']) ? trim($_POST['TBK_ORDEN_COMPRA']) : null;
$tbk_response = isset($_POST['TBK_RESPUESTA']) ? trim($_POST['TBK_RESPUESTA']) : null;
$tbk_total_amount = isset($_POST['TBK_MONTO']) ? trim($_POST['TBK_MONTO']) : null;
// Log helper closure
$logger = function ($message) {
$today = date('Y-m-d');
$now = date('Y-m-d H:i:s');
$name = "validation.{$today}.log";
$path = _PS_MODULE_DIR_ . 'webpaykcc/logs/';
$logPath = Configuration::get(KCC_LOG);
if ($logPath) {
$path = $logPath;
}
$logFile = $path . $name;
$log = fopen($logFile, 'a');
$text = "{$now} : {$message}\n";
fwrite($log, $text);
fclose($log);
};
// Helper closure
// for the total amount
$getOrderTotalAmount = function ($cart) {
$order_total = 0;
if ($cart) {
$order_total = Tools::ps_round(floatval($cart->getOrderTotal(true, Cart::BOTH)), 0);
}
return $order_total;
};
// Default Values
$result = KCC_REJECTED_RESULT;
$order = null;
$cart = null;
$isDone = false;
// Start Validation Process
$logger("Start Validation");
$logger("#################");
// Log Params Received
if (count($_POST) > 0) {
$logger("Params Received");
foreach ($_POST as $key => $value) {
$logger("{$key} => {$value}");
}
} else {
$logger("Params Not Found");
}
// Get cart data
if (isset($tbk_order_id)) {
try {
$order = new Order(Order::getOrderByCartId($tbk_order_id));
$cart = Cart::getCartByOrderId($order->id);
} catch (Exception $e) {
$logger($e->getMessage());
}
} else {
$logger("TBK_ORDEN_COMPRA Not Set");
}
// First we must check the tbk_response.
if (isset($tbk_response)) {
if ($tbk_response == KCC_OK_RESPONSE) {
$logger("Response is OK");
// Both order and cart must exist
if (isset($order->id) && isset($cart->id)) {
$logger("Order Exists");
// Now we check the current state of the order and cart
if ($order->current_state == $order_state_waiting_payment) {
$logger("Order is Waiting Payment");
// The amounts must be equal
$total_order_amount = $getOrderTotalAmount($cart);
// Needed 00 at the end
$total_order_amount_formatted = $total_order_amount . '00';
if ($total_order_amount_formatted == $tbk_total_amount) {
$logger("Amounts are Equal");
// Now check the session log file
if (isset($tbk_session_id)) {
// The log file was generated in front controller
$tbk_log_path = getKccLog($kccLogPath, $tbk_session_id);
if (file_exists($tbk_log_path)) {
// Open the log file
$tbk_log = fopen($tbk_log_path, 'r');
// Put everything inside in a string
$tbk_log_string = fgets($tbk_log);
fclose($tbk_log);
// $tbk_details is an array
// separated by semicolon
$tbk_details = explode(';', $tbk_log_string);
// Details should exist
if (isset($tbk_details) && isset($tbk_details[0]) && isset($tbk_details[1])) {
$logger("Session File Exists");
$tbk_session_total_amount = $tbk_details[0];
//.........这里部分代码省略.........
示例9: getRestToCapture
public function getRestToCapture($id_order)
{
$cart = Cart::getCartByOrderId($id_order);
$total = Tools::ps_round($cart->getOrderTotal(), 2) - Tools::ps_round(self::getTotalAmountCapturedByIdOrder($id_order), 2);
if ($total > Tools::ps_round(0, 2)) {
return true;
} else {
return false;
}
}
示例10: ajaxProcessDuplicateOrder
public function ajaxProcessDuplicateOrder()
{
if ($this->access('edit')) {
$errors = array();
if (!($id_order = Tools::getValue('id_order'))) {
$errors[] = $this->trans('Invalid order', array(), 'Admin.OrdersCustomers.Notification');
}
$cart = Cart::getCartByOrderId($id_order);
$new_cart = $cart->duplicate();
if (!$new_cart || !Validate::isLoadedObject($new_cart['cart'])) {
$errors[] = $this->trans('The order cannot be renewed.', array(), 'Admin.OrdersCustomers.Notification');
} elseif (!$new_cart['success']) {
$errors[] = $this->trans('The order cannot be renewed.', array(), 'Admin.OrdersCustomers.Notification');
} else {
$this->context->cart = $new_cart['cart'];
echo json_encode($this->ajaxReturnVars());
}
}
}
示例11: viewDetails
public function viewDetails()
{
global $currentIndex, $cookie, $link;
$irow = 0;
if (!($order = $this->loadObject())) {
return;
}
$customer = new Customer($order->id_customer);
$customerStats = $customer->getStats();
$addressInvoice = new Address($order->id_address_invoice, (int) $cookie->id_lang);
if (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) {
$invoiceState = new State((int) $addressInvoice->id_state);
}
$addressDelivery = new Address($order->id_address_delivery, (int) $cookie->id_lang);
if (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) {
$deliveryState = new State((int) $addressDelivery->id_state);
}
$carrier = new Carrier($order->id_carrier);
$history = $order->getHistory($cookie->id_lang);
$products = $order->getProducts();
$customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
Product::addCustomizationPrice($products, $customizedDatas);
$discounts = $order->getDiscounts();
$messages = Message::getMessagesByOrderId($order->id, true);
$states = OrderState::getOrderStates((int) $cookie->id_lang);
$currency = new Currency($order->id_currency);
$currentLanguage = new Language((int) $cookie->id_lang);
$currentState = OrderHistory::getLastOrderState($order->id);
$sources = ConnectionsSource::getOrderSources($order->id);
$cart = Cart::getCartByOrderId($order->id);
$row = array_shift($history);
if ($prevOrder = Db::getInstance()->getValue('SELECT id_order FROM ' . _DB_PREFIX_ . 'orders WHERE id_order < ' . (int) $order->id . ' ORDER BY id_order DESC')) {
$prevOrder = '<a href="' . $currentIndex . '&token=' . Tools::getValue('token') . '&vieworder&id_order=' . $prevOrder . '"><img style="width:24px;height:24px" src="../img/admin/arrow-left.png" /></a>';
}
if ($nextOrder = Db::getInstance()->getValue('SELECT id_order FROM ' . _DB_PREFIX_ . 'orders WHERE id_order > ' . (int) $order->id . ' ORDER BY id_order ASC')) {
$nextOrder = '<a href="' . $currentIndex . '&token=' . Tools::getValue('token') . '&vieworder&id_order=' . $nextOrder . '"><img style="width:24px;height:24px" src="../img/admin/arrow-right.png" /></a>';
}
if ($order->total_paid != $order->total_paid_real) {
echo '<center><span class="warning" style="font-size: 16px">' . $this->l('Warning:') . ' ' . Tools::displayPrice($order->total_paid_real, $currency, false) . ' ' . $this->l('paid instead of') . ' ' . Tools::displayPrice($order->total_paid, $currency, false) . ' !</span></center><div class="clear"><br /><br /></div>';
}
// display bar code if module enabled
$hook = Module::hookExec('invoice', array('id_order' => $order->id));
if ($hook !== false) {
echo '<div style="float: right; margin: -40px 40px 10px 0;">';
echo $hook;
echo '</div><br class="clear" />';
}
// display order header
echo '
<div style="float:left" style="width:440px">';
echo '<h2>
' . $prevOrder . '
' . (Validate::isLoadedObject($customer) ? $customer->firstname . ' ' . $customer->lastname . ' - ' : '') . $this->l('Order #') . sprintf('%06d', $order->id) . '
' . $nextOrder . '
</h2>
<div style="width:429px">
' . ((($currentState->invoice or $order->invoice_number) and count($products)) ? '<a href="pdf.php?id_order=' . $order->id . '&pdf"><img src="../img/admin/charged_ok.gif" alt="' . $this->l('View invoice') . '" /> ' . $this->l('View invoice') . '</a>' : '<img src="../img/admin/charged_ko.gif" alt="' . $this->l('No invoice') . '" /> ' . $this->l('No invoice')) . ' -
' . (($currentState->delivery or $order->delivery_number) ? '<a href="pdf.php?id_delivery=' . $order->delivery_number . '"><img src="../img/admin/delivery.gif" alt="' . $this->l('View delivery slip') . '" /> ' . $this->l('View delivery slip') . '</a>' : '<img src="../img/admin/delivery_ko.gif" alt="' . $this->l('No delivery slip') . '" /> ' . $this->l('No delivery slip')) . ' -
<a href="javascript:window.print()"><img src="../img/admin/printer.gif" alt="' . $this->l('Print order') . '" title="' . $this->l('Print order') . '" /> ' . $this->l('Print page') . '</a>
</div>
<div class="clear"> </div>';
/* Display current status */
echo '
<table cellspacing="0" cellpadding="0" class="table" style="width: 429px">
<tr>
<th>' . Tools::displayDate($row['date_add'], (int) $cookie->id_lang, true) . '</th>
<th><img src="../img/os/' . $row['id_order_state'] . '.gif" /></th>
<th>' . stripslashes($row['ostate_name']) . '</th>
<th>' . (!empty($row['employee_lastname']) ? '(' . stripslashes(Tools::substr($row['employee_firstname'], 0, 1)) . '. ' . stripslashes($row['employee_lastname']) . ')' : '') . '</th>
</tr>';
/* Display previous status */
foreach ($history as $row) {
echo '
<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
<td>' . Tools::displayDate($row['date_add'], (int) $cookie->id_lang, true) . '</td>
<td><img src="../img/os/' . $row['id_order_state'] . '.gif" /></td>
<td>' . stripslashes($row['ostate_name']) . '</td>
<td>' . (!empty($row['employee_lastname']) ? '(' . stripslashes(Tools::substr($row['employee_firstname'], 0, 1)) . '. ' . stripslashes($row['employee_lastname']) . ')' : '') . '</td>
</tr>';
}
echo '
</table>
<br />';
/* Display status form */
echo '
<form action="' . $currentIndex . '&view' . $this->table . '&token=' . $this->token . '" method="post" style="text-align:center;">
<select name="id_order_state">';
$currentStateTab = $order->getCurrentStateFull($cookie->id_lang);
foreach ($states as $state) {
echo '<option value="' . $state['id_order_state'] . '"' . ($state['id_order_state'] == $currentStateTab['id_order_state'] ? ' selected="selected"' : '') . '>' . stripslashes($state['name']) . '</option>';
}
echo '
</select>
<input type="hidden" name="id_order" value="' . $order->id . '" />
<input type="submit" name="submitState" value="' . $this->l('Change') . '" class="button" />
</form>';
/* Display customer information */
if (Validate::isLoadedObject($customer)) {
echo '<br />
<fieldset style="width: 400px">
//.........这里部分代码省略.........
示例12: handleOK
private function handleOK()
{
// Get Webpay Post Data
// Check if the Post Data exists
$session_id = isset($_POST['TBK_ID_SESION']) ? $_POST['TBK_ID_SESION'] : null;
$cart_id = isset($_POST['TBK_ORDEN_COMPRA']) ? $_POST['TBK_ORDEN_COMPRA'] : null;
$response = isset($_POST['TBK_RESPUESTA']) ? $_POST['TBK_RESPUESTA'] : null;
$tbk_total_amount = isset($_POST['TBK_MONTO']) ? $_POST['TBK_MONTO'] : null;
// log files
$tbk_log_path = null;
$tbk_cache_path = null;
// Paths from Configuration
$kccPath = Configuration::get(KCC_PATH);
$kccLogPath = Configuration::get(KCC_LOG);
$kccTocPage = Configuration::get(KCC_TOC_PAGE_URL);
$cart = null;
$order = null;
$customer = null;
$webpaykcc = new WebpayKcc();
// Error vars
$error = false;
$error_message = null;
// Set the log paths
// and cart and order vars
if (!is_null($cart_id) && !is_null($session_id)) {
// The log file was generated in front controller
$tbk_log_path = getKccLog($kccLogPath, $session_id);
// The cache file is needed for validation
// was generated in validate.php
$tbk_cache_path = $tbk_log_path . '.cache';
// Get cart data
// $cart_id is set in /controllers/front/payment.php
// as the current cart id
// this is called by transbank with those vars
try {
$order = new Order(Order::getOrderByCartId($cart_id));
$cart = Cart::getCartByOrderId($order->id);
} catch (Exception $e) {
$error = true;
$error_message = $e->getMessage();
}
} else {
$error = true;
$error_message = 'Session and Cart params not found';
}
// Start Checks for Success
if (!$error) {
// Check if log files are present
if (file_exists($tbk_log_path) && file_exists($tbk_cache_path)) {
// Check if order and cart exists
if (isset($order->id) && isset($cart->id)) {
// Check for customer
$customer = $order->getCustomer();
if (isset($customer->id)) {
// Check Log Data
$tbk_cache = fopen($tbk_cache_path, 'r');
$tbk_cache_string = fgets($tbk_cache);
fclose($tbk_cache);
$tbk_data = explode('&', $tbk_cache_string);
// there must be at least 12 params
// response is the 2nd param
if (is_array($tbk_data) && isset($tbk_data[2]) && count($tbk_data) >= 12) {
// Check Response to be OK
$tbk_response = explode('=', $tbk_data[2]);
if (isset($tbk_response[1]) && $tbk_response[1] == KCC_OK_RESPONSE) {
// Check current order state
// must be completed
$order_state_completed = (int) Configuration::get('PS_OS_PAYMENT');
if ($order->current_state == $order_state_completed) {
// Everything seems OK
// should render the Success Page
$error = false;
$error_message = null;
} else {
$error = true;
$error_message = "Order state is not completed, current state {$order->current_state}";
}
} else {
$error = true;
$error_message = 'Response is not OK';
}
} else {
$error = true;
$error_message = 'Cache data is invalid';
}
} else {
$error = true;
$error_message = 'Customer not found';
}
} else {
$error = true;
$error_message = 'Order or Cart Objects not Found';
}
} else {
$error = true;
$error_message = 'Log files not found';
}
}
// Render the template
if (!$error && is_null($error_message)) {
//.........这里部分代码省略.........
示例13: getOrderData
public function getOrderData($order)
{
$xml = new DOMDocument('1.0', 'utf-8');
$xml_root = $xml->createElement('OrderDetails');
$xml->appendChild($xml_root);
$cart = Cart::getCartByOrderId((int) $order->id);
$products = $cart->getProducts();
if (count($products)) {
foreach ($products as $product) {
$item_id = $product['id_product'];
$order_id = (int) $order->id;
//$product_id = $product['id_product'];
$product_sku = $product['name'] . '_' . $product['id_product'];
$product_name = $product['name'];
$qty = $product['cart_quantity'];
$price = $product['price'];
$subtotal = '0';
$taxtotal = '0';
$grandtotal = '0';
$xml_item = $xml->createElement('Item');
$xml_item->appendChild($xml->createTextNode($product_name));
$dom_attribute = $xml->createAttribute('MerchentOrderRecordRef');
$dom_attribute->value = $order_id;
$xml_item->appendChild($dom_attribute);
$dom_attribute = $xml->createAttribute('MerchentOrderRecordLineRef');
$dom_attribute->value = $item_id;
$xml_item->appendChild($dom_attribute);
$dom_attribute = $xml->createAttribute('Sku');
$dom_attribute->value = $product_sku;
$xml_item->appendChild($dom_attribute);
$dom_attribute = $xml->createAttribute('Qty');
$dom_attribute->value = $qty;
$xml_item->appendChild($dom_attribute);
$dom_attribute = $xml->createAttribute('Price');
$dom_attribute->value = $price;
$xml_item->appendChild($dom_attribute);
$dom_attribute = $xml->createAttribute('LineSubTotal');
$dom_attribute->value = $subtotal;
$xml_item->appendChild($dom_attribute);
$dom_attribute = $xml->createAttribute('LineTaxesTotal');
$dom_attribute->value = $taxtotal;
$xml_item->appendChild($dom_attribute);
$dom_attribute = $xml->createAttribute('LineTotal');
$dom_attribute->value = $grandtotal;
$xml_item->appendChild($dom_attribute);
$xml_root->appendChild($xml_item);
}
}
$xml_order_details = $xml->saveXML();
return $xml_order_details;
}