user933 From Unknown Member since Dec -0001 user933 Jan 12 2015 02:19 AM Hi there i have created a custom order form which will display on the product page so form has been working properly and sending data in database but some of the options like Order item in admin panel ""Order"" is not displaying the item that were order and order total is not displaying the amount and if i try to add product in order page total cost gets reset... Please i need help and it is urgent ,reply as soon as possible how can i do that please mention it in brief...by the way i love Lite cart due to its features and simplicity .. Thanks
litecart Main Crew From Sweden Member since Feb 2013 litecart Jan 12 2015 02:56 AM We're happy to hear you love the platform. :) I'm not sure what you are trying to accomplish as the image you attached was the regular edit order page. If you want to add custom items to the cart, this has never been done before. You need to edit lib_cart.inc.php which is the object that holds the cart and gets inherited to the checkout later. To do so I suggest creating a custom method similar to add_product(). I'm thinking: public static function add_custom_item($item, $quantity=1) { $item = array( 'id' => '', 'product_id' => null, 'options' => null, 'option_stock_combination' => null, 'image' => $item['image'], 'name' => $item['name'], 'code' => $item['code'], 'sku' => $item['sku'], 'upc' => $item['upc'], 'taric' => $item['taric'], 'price' => $item['price'], 'tax_class_id' => $item['tax_class_id'], 'quantity' => (int)$quantity, 'weight' => $item['weight'], 'weight_class' => $item['weight_class'], 'dim_x' => $item['dim_x'], 'dim_y' => $item['dim_y'], 'dim_z' => $item['dim_z'], 'dim_class' => $item['dim_class'], ); $item_key = md5(serialize(array($item['code'], '...'))); if (isset(self::$data['items'][$item_key])) { self::update($item_key, self::$data['items'][$item_key]['quantity'] + $quantity); } else { self::$data['items'][$item_key] = $item; self::_calculate_total(); self::checksum(); self::save(); } } You also need a command to pass the form data in the startup method: if (!empty($_POST['add_cart_custom_item'])) { self::add_custom_item($_POST['item'], (isset($_POST['quantity']) ? $_POST['quantity'] : 1)); } Please note the code was written from straight from my head and have not been tested. Syntax errors and such may be in it.
user933 From Unknown Member since Dec -0001 user933 Jan 12 2015 12:30 PM https://drive.google.com/file/d/0Bx26DUxESTiGUXZhRVlHSmZTMlk/view?usp=sharing i hope this image will help you to understand what i am trying to do ....when i submit the form all values properly sent to the database but the earlier image which i have uploaded is it does not add the item by itself and subtotal is also not displaying but when i see the database it contains all the values properly but not the admin panel order section ....
litecart Main Crew From Sweden Member since Feb 2013 litecart Jan 14 2015 01:31 AM Did you create an order total and pass the order total to the order object? Pass an order item with $order->add_item() and order total lines with $order->add_ot_row(). If you don't wanna make use of the cart. Which you seem not to wanna do. Just create an order object and feed it: $order = new ctrl_order('session'); // New order stored in session memory $order->add_item($item); $order->add_item($item2); $order->add_ot_row($subtotal); $order->add_ot_row($additional_fee); $payment = new mod_payment(); $payment->set('myfancymodule:option'); if (isset($_POST['confirm_order'])) { if ($payment_error = $payment->pre_check($order)) { notices::add('errors', $payment_error); header('Location: '. document::ilink('checkout')); exit; } if ($gateway = $payment->transfer($order)) { if (!empty($gateway['error'])) { notices::add('errors', $gateway['error']); header('Location: '. document::ilink('checkout')); exit; } switch (strtolower($gateway['method'])) { case 'post': echo ''. language::translate('title_redirecting', 'Redirecting') .'...' . PHP_EOL . '' . PHP_EOL; if (is_array($gateway['fields'])) { foreach ($gateway['fields'] as $key => $value) echo ' ' . functions::form_draw_hidden_field($key, $value) . PHP_EOL; } else { echo $gateway['fields']; } echo '' . PHP_EOL . '' . PHP_EOL; if (!empty($gateway['delay'])) { echo ' var t=setTimeout(function(){' . PHP_EOL . ' document.forms[""gateway_form""].submit();' . PHP_EOL . ' }, '. ($gateway['delay']*1000) .');' . PHP_EOL; } else { echo ' document.forms[""gateway_form""].submit();' . PHP_EOL; } echo ''; exit; case 'html': echo $gateway['content']; require_once vmod::check(FS_DIR_HTTP_ROOT . WS_DIR_INCLUDES . 'app_footer.inc.php'); exit; case 'get': default: header('Location: '. (!empty($gateway['action']) ? $gateway['action'] : document::ilink())); exit; } } // Verify transaction $result = $payment->verify($order); // If payment error if (!empty($result['error'])) { notices::add('errors', $result['error']); header('Location: '. document::ilink('checkout')); exit; } // Set order status id if (isset($result['order_status_id'])) $order->data['order_status_id'] = $result['order_status_id']; // Set transaction id if (isset($result['transaction_id'])) $order->data['payment_transaction_id'] = $result['transaction_id']; // Save order $order->save(); [color=red]I have not tested the code.[/color]