* @license GNU General Public License version 2 or later; see LICENSE */ defined('_JEXEC') or die; require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/order.php'; include_once JPATH_COMPONENT . '/helpers/helper.php'; $configobj = new Redconfiguration(); $order_functions = new order_functions(); $redhelper = new redhelper(); $url = JURI::base(); $Itemid = $redhelper->getCheckoutItemid(); $order_id = JRequest::getInt('oid'); $order = $order_functions->getOrderDetails($order_id); $orderitem = $order_functions->getOrderItemDetail($order_id); if ($order->order_total > 0 && !USE_AS_CATALOG) { $paymentmethod = $order_functions->getOrderPaymentDetail($order_id); $paymentmethod = $order_functions->getPaymentMethodInfo($paymentmethod[0]->payment_method_class); $paymentmethod = $paymentmethod[0]; $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '/' . $paymentmethod->element . '.xml'; $paymentparams = new JRegistry($paymentmethod->params); echo '<div>'; $is_creditcard = $paymentparams->get('is_creditcard', ''); $is_redirected = $paymentparams->get('is_redirected', 0); if (!$is_creditcard || $is_redirected == 1) { $adminpath = JPATH_ADMINISTRATOR . '/components/com_redshop'; $invalid_elements = $paymentparams->get('invalid_elements', ''); // Send the order_id and orderpayment_id to the payment plugin so it knows which DB record to update upon successful payment $billingaddresses = $order_functions->getBillingAddress($order->user_id); if (isset($billingaddresses)) { if (isset($billingaddresses->country_code)) { $billingaddresses->country_2_code = $configobj->getCountryCode2($billingaddresses->country_code); }
public function save($apply = 0) { $post = JRequest::get('post'); $adminproducthelper = new adminproducthelper(); $order_functions = new order_functions(); $shippinghelper = new shipping(); $option = JRequest::getVar('option', '', 'request', 'string'); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); $post['order_id'] = $cid[0]; $model = $this->getModel('addorder_detail'); $post['order_number'] = $order_number = $order_functions->generateOrderNumber(); $orderItem = $adminproducthelper->redesignProductItem($post); $post['order_item'] = $orderItem; // Check product Quantity $stocknote = ''; if (USE_STOCKROOM == 1) { $stockroomhelper = new rsstockroomhelper(); $producthelper = new producthelper(); for ($i = 0; $i < count($orderItem); $i++) { $quantity = $orderItem[$i]->quantity; $productData = $producthelper->getProductById($orderItem[$i]->product_id); if ($productData->min_order_product_quantity > 0 && $productData->min_order_product_quantity > $quantity) { $msg = $productData->product_name . " " . JText::_('WARNING_MSG_MINIMUM_QUANTITY'); $stocknote .= sprintf($msg, $productData->min_order_product_quantity) . "<br/>"; $quantity = $productData->min_order_product_quantity; } $currentStock = $stockroomhelper->getStockroomTotalAmount($orderItem[$i]->product_id); $finalquantity = $currentStock >= $quantity ? (int) $quantity : (int) $currentStock; if ($finalquantity > 0) { if ($productData->max_order_product_quantity > 0 && $productData->max_order_product_quantity < $finalquantity) { $msg = $productData->product_name . " " . JText::_('WARNING_MSG_MAXIMUM_QUANTITY') . "<br/>"; $stocknote .= sprintf($msg, $productData->max_order_product_quantity); $finalquantity = $productData->max_order_product_quantity; } $orderItem[$i]->quantity = $finalquantity; } else { $stocknote .= $productData->product_name . " " . JText::_('PRODUCT_OUT_OF_STOCK') . "<br/>"; unset($orderItem[$i]); } } $orderItem = array_merge(array(), $orderItem); if (count($orderItem) <= 0) { $msg = JText::_('PRODUCT_OUT_OF_STOCK'); $this->setRedirect('index.php?option=' . $option . '&view=addorder_detail&user_id=' . $post['user_id'] . '&shipping_users_info_id=' . $post['shipp_users_info_id'], $msg); return; } } $order_total = $post['order_total']; $order_shipping = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $post['shipping_rate_id']))); if (count($order_shipping) > 4) { $post['order_shipping'] = $order_shipping[3]; $order_total = $order_total + $order_shipping[3]; $post['order_shipping_tax'] = $order_shipping[6]; } $tmporder_total = $order_total; if (array_key_exists("issplit", $post) && $post['issplit']) { $tmporder_total = $order_total / 2; } $paymentmethod = $order_functions->getPaymentMethodInfo($post['payment_method_class']); $paymentmethod = $paymentmethod[0]; $paymentparams = new JRegistry($paymentmethod->params); $paymentinfo = new stdclass(); $post['economic_payment_terms_id'] = $paymentparams->get('economic_payment_terms_id'); $post['economic_design_layout'] = $paymentparams->get('economic_design_layout'); $paymentinfo->payment_price = $paymentparams->get('payment_price', ''); $paymentinfo->is_creditcard = $post['economic_is_creditcard'] = $paymentparams->get('is_creditcard', ''); $paymentinfo->payment_oprand = $paymentparams->get('payment_oprand', ''); $paymentinfo->accepted_credict_card = $paymentparams->get("accepted_credict_card"); $paymentinfo->payment_discount_is_percent = $paymentparams->get('payment_discount_is_percent', ''); $cartHelper = new rsCartHelper(); $subtotal = $post['order_subtotal']; $update_discount = 0; if ($post['update_discount'] > 0) { $update_discount = $post['update_discount']; if ($update_discount > $subtotal) { $update_discount = $subtotal; } if ($update_discount != 0) { $order_total = $order_total - $update_discount; } } $special_discount = $post['special_discount']; $subtotal_excl_vat = 0; for ($i = 0; $i < count($orderItem); $i++) { $subtotal_excl_vat = $subtotal_excl_vat + $orderItem[$i]->prdexclprice * $orderItem[$i]->quantity; } if (APPLY_VAT_ON_DISCOUNT) { $amt = $subtotal; } else { $amt = $subtotal_excl_vat; } $discount_price = $amt * $special_discount / 100; $post['special_discount'] = $special_discount; $post['special_discount_amount'] = $discount_price; $order_total = $order_total - $discount_price; if (PAYMENT_CALCULATION_ON == 'subtotal') { $paymentAmount = $subtotal; } else { $paymentAmount = $order_total; } $paymentMethod = $cartHelper->calculatePayment($paymentAmount, $paymentinfo, $order_total); $post['ship_method_id'] = urldecode(urldecode($post['shipping_rate_id'])); $order_total = $paymentMethod[0]; $post['user_info_id'] = $post['users_info_id']; $post['payment_discount'] = $paymentMethod[1]; $post['payment_oprand'] = $paymentinfo->payment_oprand; $post['order_discount'] = $update_discount; $post['order_total'] = $order_total; $post['order_payment_amount'] = $tmporder_total; $post['order_payment_name'] = $paymentmethod->name; if ($apply == 1) { $post['order_payment_status'] = 'Unpaid'; $post['order_status'] = 'P'; } if ($row = $model->store($post)) { $msg = JText::_('COM_REDSHOP_ORDER_DETAIL_SAVED'); } else { $msg = JText::_('COM_REDSHOP_ERROR_SAVING_ORDER_DETAIL'); } if ($apply == 1) { $objorder = new order_functions(); $objorder->getpaymentinformation($row, $post); } else { $this->setRedirect('index.php?option=' . $option . '&view=order', $msg . $stocknote); } }
public function display($tpl = null) { $app = JFactory::getApplication(); $shippinghelper = new shipping(); $order_functions = new order_functions(); $params = $app->getParams('com_redshop'); $option = JRequest::getVar('option'); $Itemid = JRequest::getInt('Itemid'); $issplit = JRequest::getBool('issplit'); $ccinfo = JRequest::getInt('ccinfo'); $task = JRequest::getCmd('task'); $model = $this->getModel('checkout'); $session = JFactory::getSession(); if ($issplit != '') { $session->set('issplit', $issplit); } $payment_method_id = JRequest::getCmd('payment_method_id'); $users_info_id = JRequest::getInt('users_info_id'); $auth = $session->get('auth'); if (empty($users_info_id)) { $users_info_id = $auth['users_info_id']; } $shipping_rate_id = JRequest::getString('shipping_rate_id'); $shippingdetail = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $shipping_rate_id))); if (count($shippingdetail) < 4) { $shipping_rate_id = ""; } $cart = $session->get('cart'); if ($cart['idx'] < 1) { $msg = JText::_('COM_REDSHOP_EMPTY_CART'); $app->Redirect('index.php?option=' . $option . '&Itemid=' . $Itemid, $msg); } if (SHIPPING_METHOD_ENABLE) { if ($users_info_id < 1) { $msg = JText::_('COM_REDSHOP_SELECT_SHIP_ADDRESS'); $link = 'index.php?option=' . $option . '&view=checkout&Itemid=' . $Itemid . '&users_info_id=' . $users_info_id . '&shipping_rate_id=' . $shipping_rate_id . '&payment_method_id=' . $payment_method_id; $app->Redirect($link, $msg); } if ($shipping_rate_id == '' && $cart['free_shipping'] != 1) { $msg = JText::_('COM_REDSHOP_SELECT_SHIP_METHOD'); $link = 'index.php?option=' . $option . '&view=checkout&Itemid=' . $Itemid . '&users_info_id=' . $users_info_id . '&shipping_rate_id=' . $shipping_rate_id . '&payment_method_id=' . $payment_method_id; $app->Redirect($link, $msg); } } if ($payment_method_id == '') { $msg = JText::_('COM_REDSHOP_SELECT_PAYMENT_METHOD'); $link = 'index.php?option=' . $option . '&view=checkout&Itemid=' . $Itemid . '&users_info_id=' . $users_info_id . '&shipping_rate_id=' . $shipping_rate_id . '&payment_method_id=' . $payment_method_id; $app->Redirect($link, $msg); } $paymentinfo = $order_functions->getPaymentMethodInfo($payment_method_id); $paymentinfo = $paymentinfo[0]; $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentinfo->element . '/' . $paymentinfo->element . '.xml'; $paymentparams = new JRegistry($paymentinfo->params); $is_creditcard = $paymentparams->get('is_creditcard', ''); $is_subscription = $paymentparams->get('is_subscription', 0); if (@$is_creditcard == 1) { $document = JFactory::getDocument(); JHTML::Script('credit_card.js', 'components/com_redshop/assets/js/', false); } if ($is_subscription) { $subscription_id = $session->set('subscription_id', $subscription_id); } $this->cart = $cart; $this->users_info_id = $users_info_id; $this->shipping_rate_id = $shipping_rate_id; $this->payment_method_id = $payment_method_id; $this->is_creditcard = $is_creditcard; if ($task != '') { $tpl = $task; } parent::display($tpl); }
public function orderplace() { $app = JFactory::getApplication(); $post = JRequest::get('post'); $option = JRequest::getVar('option'); $Itemid = JRequest::getVar('Itemid'); $task = JRequest::getVar('task'); $user = JFactory::getUser(); $order_functions = new order_functions(); $adminpath = JPATH_ADMINISTRATOR . '/components/com_redshop'; $user = JFactory::getUser(); $payment_method_id = JRequest::getVar('payment_method_id'); $ccinfo = JRequest::getVar('ccinfo'); $order_number = JRequest::getVar('order_number'); $remaningtopay = JRequest::getVar('remaningtopay'); $order_id = JRequest::getInt('order_id'); $order_total = JRequest::getInt('order_total'); $oid = JRequest::getInt('oid'); $orderdits = $this->getordersdetail($oid); $_SESSION['ccdata']['order_payment_name'] = JRequest::getVar('order_payment_name'); // VISA, AMEX, DISCOVER.... $_SESSION['ccdata']['creditcard_code'] = JRequest::getVar('creditcard_code'); $_SESSION['ccdata']['order_payment_number'] = JRequest::getVar('order_payment_number'); $_SESSION['ccdata']['order_payment_expire_month'] = JRequest::getVar('order_payment_expire_month'); $_SESSION['ccdata']['order_payment_expire_year'] = JRequest::getVar('order_payment_expire_year'); // 3-digit Security Code (CVV) $_SESSION['ccdata']['credit_card_code'] = JRequest::getVar('credit_card_code'); $d["order_payment_trans_id"] = ''; $tmporder_total = $remaningtopay; $paymentmethod = $order_functions->getPaymentMethodInfo($payment_method_id); $paymentmethod = $paymentmethod[0]; JRequest::setVar('paymentmethod', $paymentmethod); if ($paymentmethod->plugin == "bank_transfer") { $order_status = 'ABT'; $order_paymentstatus = JText::_('COM_REDSHOP_PAYMENT_STA_PAID'); $order_status_full = 'Awaiting bank transfer'; $query = "UPDATE " . $this->_table_prefix . "orders set order_payment_status = '" . $order_paymentstatus . "', split_payment=0 where order_id = " . (int) $oid; $this->_db->setQuery($query); $this->_db->query(); $return = JRoute::_('index.php?option=' . $option . '&view=order_detail&oid=' . $oid . '&Itemid=' . $Itemid); } $data['amount'] = 0; if ($paymentmethod->is_creditcard == 1) { $validpayment = $this->validatepaymentccinfo(); if (!$validpayment[0]) { $msg = $validpayment[1]; $link = 'index.php?option=' . $option . '&view=split_payment&Itemid=' . $Itemid . '&ccinfo=' . $ccinfo . '&payment_method_id=' . $payment_method_id . '&oid=' . $oid; $app->Redirect($link, $msg); } $paymentpath = $adminpath . '/helpers/payments/' . $paymentmethod->plugin . '/' . $paymentmethod->plugin . '.php'; include_once $paymentpath; $payment_class = new $paymentmethod->payment_class(); // Function process_payment($order_number, $order_total, &$d) $payment = $payment_class->process_payment($order_number, $tmporder_total, $d); if (!$payment) { $msg = "Payment Failure" . $d["order_payment_log"]; $link = 'index.php?option=' . $option . '&view=split_payment&Itemid=' . $Itemid . '&ccinfo=' . $ccinfo . '&payment_method_id=' . $payment_method_id . '&oid=' . $oid; $app->Redirect($link, $msg); JRequest::setVar('payment_status_log', '-' . $d["order_payment_log"]); } else { $order_status = 'ACCP'; $order_status_full = 'Awaiting credit card payment'; $data['amount'] = $tmporder_total; if ($d["order_payment_log"] == 'SUCCESS') { // If partial payment success, then update the payment and status $rowpayment = $this->getTable('order_payment'); if (!$rowpayment->bind($post)) { $this->setError($this->_db->getErrorMsg()); return false; } $rowpayment->order_id = $oid; $rowpayment->payment_method_id = $payment_method_id; $rowpayment->order_payment_code = $_SESSION['ccdata']['creditcard_code']; $rowpayment->order_payment_number = base64_encode($_SESSION['ccdata']['order_payment_number']); $rowpayment->order_payment_amount = $tmporder_total; $rowpayment->order_payment_expire = $_SESSION['ccdata']['order_payment_expire_month'] . ' ' . $_SESSION['ccdata']['order_payment_expire_year']; $rowpayment->order_payment_name = $paymentmethod->payment_method_name; $rowpayment->order_payment_trans_id = $d["order_payment_trans_id"]; if (!$rowpayment->store()) { $this->setError($this->_db->getErrorMsg()); return false; } $order_paymentstatus = JText::_('COM_REDSHOP_PAYMENT_STA_PAID'); $msg = JText::_('COM_REDSHOP_PARTIAL_PAYMENT_DONE'); $query = "UPDATE " . $this->_table_prefix . "orders set order_payment_status = " . $this->_db->quote($order_paymentstatus) . ", split_payment = 0 where order_id = " . (int) $oid; $this->_db->setQuery($query); $this->_db->query(); $userinfo = $this->getuseraccountinfo($user->id); // Add Economic integration $return = JRoute::_('index.php?option=' . $option . '&view=order_detail&oid=' . $oid . '&Itemid=' . $Itemid); } else { $order_paymentstatus = JText::_('COM_REDSHOP_PAYMENT_STA_PARTIAL_PAID'); $msg = JText::_('COM_REDSHOP_PARTIAL_PAYMENT_FAILURE'); $return = JRoute::_('index.php?option=' . $option . '&view=order_detail&oid=' . $oid . '&Itemid=' . $Itemid); } } } $app->Redirect($return, $msg); }
public function orderplace() { $app = JFactory::getApplication(); $redconfig = new Redconfiguration(); $quotationHelper = new quotationHelper(); $stockroomhelper = new rsstockroomhelper(); $helper = new redhelper(); $shippinghelper = new shipping(); $order_functions = new order_functions(); $post = JRequest::get('post'); $option = JRequest::getVar('option', 'com_redshop'); $Itemid = JRequest::getVar('Itemid'); $shop_id = JRequest::getVar('shop_id'); $gls_mobile = JRequest::getVar('gls_mobile'); $customer_message = JRequest::getVar('rs_customer_message_ta'); $referral_code = JRequest::getVar('txt_referral_code'); if ($gls_mobile) { $shop_id = $shop_id . '###' . $gls_mobile; } $user = JFactory::getUser(); $session = JFactory::getSession(); $auth = $session->get('auth'); if (!$user->id && $auth['users_info_id']) { $user->id = -$auth['users_info_id']; } $db = JFactory::getDbo(); $issplit = $session->get('issplit'); $url = JURI::root(); // If user subscribe for the newsletter if (isset($post['newsletter_signup']) && $post['newsletter_signup'] == 1) { $this->_userhelper->newsletterSubscribe(); } // If user unsubscribe for the newsletter if (isset($post['newsletter_signoff']) && $post['newsletter_signoff'] == 1) { $this->_userhelper->newsletterUnsubscribe(); } $order_paymentstatus = 'Unpaid'; $objshipping = new shipping(); $users_info_id = JRequest::getInt('users_info_id'); $thirdparty_email = JRequest::getVar('thirdparty_email'); $shippingaddresses = $this->shipaddress($users_info_id); $billingaddresses = $this->billingaddresses(); if (isset($shippingaddresses)) { $d["shippingaddress"] = $shippingaddresses; $d["shippingaddress"]->country_2_code = $redconfig->getCountryCode2($d["shippingaddress"]->country_code); $d["shippingaddress"]->state_2_code = $redconfig->getStateCode2($d["shippingaddress"]->state_code); $shippingaddresses->country_2_code = $d["shippingaddress"]->country_2_code; $shippingaddresses->state_2_code = $d["shippingaddress"]->state_2_code; } if (isset($billingaddresses)) { $d["billingaddress"] = $billingaddresses; if (isset($billingaddresses->country_code)) { $d["billingaddress"]->country_2_code = $redconfig->getCountryCode2($billingaddresses->country_code); $billingaddresses->country_2_code = $d["billingaddress"]->country_2_code; } if (isset($billingaddresses->state_code)) { $d["billingaddress"]->state_2_code = $redconfig->getStateCode2($billingaddresses->state_code); $billingaddresses->state_2_code = $d["billingaddress"]->state_2_code; } } $cart = $session->get('cart'); if ($cart['idx'] < 1) { $msg = JText::_('COM_REDSHOP_EMPTY_CART'); $app->Redirect('index.php?option=' . $option . '&Itemid=' . $Itemid, $msg); } $ccdata = $session->get('ccdata'); $shipping_rate_id = ''; if ($cart['free_shipping'] != 1) { $shipping_rate_id = JRequest::getVar('shipping_rate_id'); } $payment_method_id = JRequest::getVar('payment_method_id'); $ccinfo = JRequest::getVar('ccinfo'); if ($shipping_rate_id && $cart['free_shipping'] != 1) { $shipArr = $this->calculateShipping($shipping_rate_id); $cart['shipping'] = $shipArr['order_shipping_rate']; $cart['shipping_vat'] = $shipArr['shipping_vat']; } $cart = $this->_carthelper->modifyDiscount($cart); $paymentinfo = $this->_order_functions->getPaymentMethodInfo($payment_method_id); $paymentinfo = $paymentinfo[0]; $paymentparams = new JRegistry($paymentinfo->params); $paymentinfo = new stdclass(); $paymentinfo->payment_price = $paymentparams->get('payment_price', ''); $paymentinfo->payment_oprand = $paymentparams->get('payment_oprand', ''); $paymentinfo->payment_discount_is_percent = $paymentparams->get('payment_discount_is_percent', ''); if (PAYMENT_CALCULATION_ON == 'subtotal') { $paymentAmount = $cart['product_subtotal']; } else { $paymentAmount = $cart['total']; } $paymentArray = $this->_carthelper->calculatePayment($paymentAmount, $paymentinfo, $cart['total']); $cart['total'] = $paymentArray[0]; $cart = $session->set('cart', $cart); $cart = $session->get('cart'); $order_shipping = explode("|", $shippinghelper->decryptShipping(str_replace(" ", "+", $shipping_rate_id))); $order_status = 'P'; $order_status_full = $this->_order_functions->getOrderStatusTitle('P'); // Start code to track duplicate order number checking by parth $order_number = $this->getOrdernumber(); // End code to track duplicate order number checking by parth $order_subtotal = $cart['product_subtotal']; $cdiscount = $cart['coupon_discount']; $order_tax = $cart['tax']; $d['order_tax'] = $order_tax; $tax_after_discount = 0; if (isset($cart['tax_after_discount'])) { $tax_after_discount = $cart['tax_after_discount']; } $odiscount = $cart['coupon_discount'] + $cart['voucher_discount'] + $cart['cart_discount']; $odiscount_vat = $cart['discount_vat']; $d["order_payment_trans_id"] = ''; $d['discount'] = $odiscount; $order_total = $cart['total']; if ($issplit) { $order_total = $order_total / 2; } JRequest::setVar('order_ship', $order_shipping[3]); $paymentmethod = $this->_order_functions->getPaymentMethodInfo($payment_method_id); $paymentmethod = $paymentmethod[0]; $mainelement = $paymentmethod->element; if ($paymentmethod->element == "rs_payment_banktransfer" || $paymentmethod->element == "rs_payment_banktransfer2" || $paymentmethod->element == "rs_payment_banktransfer3" || $paymentmethod->element == "rs_payment_banktransfer4" || $paymentmethod->element == "rs_payment_banktransfer5" || $paymentmethod->element == "rs_payment_cashtransfer" || $paymentmethod->element == "rs_payment_cashsale" || $paymentmethod->element == "rs_payment_banktransfer_discount" || $paymentmethod->element == "rs_payment_eantransfer") { $paymentmethod = $order_functions->getPaymentMethodInfo($paymentmethod->element); $paymentmethod = $paymentmethod[0]; $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '.xml'; $paymentparams = new JRegistry($paymentmethod->params); $order_main_status = $paymentparams->get('verify_status', ''); if ($paymentmethod->element != "rs_payment_banktransfer" && $paymentmethod->element != "rs_payment_cashtransfer" && $paymentmethod->element != "rs_payment_cashsale" && $paymentmethod->element != "rs_payment_banktransfer_discount" && $paymentmethod->element != "rs_payment_eantransfer") { $paymentmethod->element = substr($paymentmethod->element, 0, -1); } } if ($paymentmethod->element == "rs_payment_banktransfer" || $paymentmethod->element == "rs_payment_cashtransfer" || $paymentmethod->element == "rs_payment_cashsale" || $paymentmethod->element == "rs_payment_banktransfer_discount" || $paymentmethod->element == "rs_payment_eantransfer") { $order_status = $order_main_status; if ($issplit) { $order_paymentstatus = trim("Partial Paid"); } else { $order_paymentstatus = trim("Unpaid"); } $order_status_full = $this->_order_functions->getOrderStatusTitle($order_main_status); } $paymentmethod->element = $mainelement; $payment_amount = 0; if (isset($cart['payment_amount'])) { $payment_amount = $cart['payment_amount']; } $payment_oprand = ""; if (isset($cart['payment_oprand'])) { $payment_oprand = $cart['payment_oprand']; } $xmlpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '.xml'; $params = new JRegistry($paymentmethod->params, $xmlpath); $economic_payment_terms_id = $params->get('economic_payment_terms_id'); $economic_design_layout = $params->get('economic_design_layout'); $is_creditcard = $params->get('is_creditcard', ''); $is_redirected = $params->get('is_redirected', 0); JRequest::setVar('payment_status', $order_paymentstatus); $d['order_shipping'] = $order_shipping[3]; $GLOBALS['billingaddresses'] = $billingaddresses; $timestamp = time(); // Get the IP Address if (!empty($_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; } else { $ip = 'unknown'; } $row = $this->getTable('order_detail'); if (!$row->bind($post)) { $this->setError($this->_db->getErrorMsg()); return false; } $shippingVatRate = 0; if (array_key_exists(6, $order_shipping)) { $shippingVatRate = $order_shipping[6]; } $random_gen_enc_key = $this->_order_functions->random_gen_enc_key(35); $users_info_id = $billingaddresses->users_info_id; $row->user_id = $user->id; $row->order_number = $order_number; $row->user_info_id = $users_info_id; $row->order_total = $order_total; $row->order_subtotal = $order_subtotal; $row->order_tax = $order_tax; $row->tax_after_discount = $tax_after_discount; $row->order_tax_details = ''; $row->analytics_status = 0; $row->order_shipping = $order_shipping[3]; $row->order_shipping_tax = $shippingVatRate; $row->coupon_discount = $cdiscount; $row->shop_id = $shop_id; $row->customer_message = $customer_message; $row->referral_code = $referral_code; $db = JFactory::getDbo(); $dispatcher = JDispatcher::getInstance(); $order_status_log = ''; // For credit card payment gateway page will redirect to order detail page from plugin if ($is_creditcard == 1 && $is_redirected == 1) { $redirect_ccdata = $session->set('redirect_ccdata', $ccdata); } if ($is_creditcard == 1 && $is_redirected == 0 && $cart['total'] > 0) { JPluginHelper::importPlugin('redshop_payment'); $values['order_shipping'] = $d['order_shipping']; $values['order_number'] = $order_number; $values['order_tax'] = $d['order_tax']; $values['shippinginfo'] = $d['shippingaddress']; $values['billinginfo'] = $d['billingaddress']; $values['order_total'] = $order_total; $values['order_subtotal'] = $order_subtotal; $values["order_id"] = $order_id; $values['payment_plugin'] = $paymentmethod->element; $values['odiscount'] = $odiscount; $paymentResponses = $dispatcher->trigger('onPrePayment_' . $values['payment_plugin'], array($values['payment_plugin'], $values)); $paymentResponse = $paymentResponses[0]; if ($paymentResponse->responsestatus == "Success") { $d["order_payment_trans_id"] = $paymentResponse->transaction_id; $order_status_log = $paymentResponse->message; $order_status = 'C'; $order_paymentstatus = 'Paid'; } else { if ($values['payment_plugin'] != 'rs_payment_localcreditcard') { $errorMsg = $paymentResponse->message; $this->setError($errorMsg); return false; } } } if ($order_total <= 0) { $paymentpath = JPATH_SITE . '/plugins/redshop_payment/' . $paymentmethod->element . '.xml'; $paymentparams = new JRegistry($paymentmethod->params); $order_main_status = $paymentparams->get('verify_status', ''); $order_status = $order_main_status; $order_paymentstatus = 'Paid'; } if (USE_AS_CATALOG) { $order_status = 'P'; $order_paymentstatus = 'Unpaid'; } // For barcode generation $barcode_code = $order_functions->barcode_randon_number(12, 0); // End $row->order_discount = $odiscount; $row->order_discount_vat = $odiscount_vat; $row->payment_discount = $payment_amount; $row->payment_oprand = $payment_oprand; $row->order_status = $order_status; $row->order_payment_status = $order_paymentstatus; $row->cdate = $timestamp; $row->mdate = $timestamp; $row->ship_method_id = $shipping_rate_id; $row->customer_note = $post['customer_note']; $row->requisition_number = $post['requisition_number']; $row->ip_address = $ip; $row->encr_key = $random_gen_enc_key; $row->split_payment = $issplit; $row->discount_type = $this->discount_type; $row->order_id = JRequest::getVar('order_id', $row->order_id); $row->barcode = $barcode_code; if (!$row->store()) { $this->setError($this->_db->getErrorMsg()); // Start code to track duplicate order number checking by parth $this->deleteOrdernumberTrack(); // End code to track duplicate order number checking by parth return false; } // Start code to track duplicate order number checking by parth $this->deleteOrdernumberTrack(); // End code to track duplicate order number checking by parth $order_id = $row->order_id; $this->coupon($cart, $order_id); $this->voucher($cart, $order_id); $query = "UPDATE `#__redshop_orders` SET discount_type = " . $db->quote($this->discount_type) . " where order_id = " . (int) $order_id; $db->setQuery($query); $db->query(); if (SHOW_TERMS_AND_CONDITIONS == 1 && isset($post['termscondition']) && $post['termscondition'] == 1) { $this->_userhelper->updateUserTermsCondition($users_info_id, 1); } // Place order id in quotation table if it Quotation if (array_key_exists("quotation_id", $cart) && $cart['quotation_id']) { $quotationHelper->updateQuotationwithOrder($cart['quotation_id'], $row->order_id); } if ($row->order_status == CLICKATELL_ORDER_STATUS) { $helper->clickatellSMS($order_id); } $session->set('order_id', $order_id); // Add order status log $rowOrderStatus = $this->getTable('order_status_log'); $rowOrderStatus->order_id = $order_id; $rowOrderStatus->order_status = $order_status; $rowOrderStatus->date_changed = time(); $rowOrderStatus->customer_note = $order_status_log; $rowOrderStatus->store(); $country_name = $this->_order_functions->getCountryName($billingaddresses->country_code); $state_name = $this->_order_functions->getStateName($billingaddresses->state_code, $billingaddresses->country_code); JRequest::setVar('order_id', $row->order_id); JRequest::setVar('order_number', $row->order_number); if (!isset($order_shipping[5])) { $order_shipping[5] = ""; } if ($order_shipping[5] == 'regular') { $regDel = $objshipping->getRegularDelivery(); JRequest::setVar('order_delivery', "Delivered in one instance � DELIVERY TIME: " . current($regDel) . " weeks</td>"); } elseif ($order_shipping[5] == 'split') { $delArray = $objshipping->getProductDeliveryArray($shipping_rate_id); $splitdel = $objshipping->getSplitDelivery(); if (count($splitdel) > 1) { $split1 = $splitdel[0]; $split2 = $splitdel[1]; $prods1 = ''; $prods2 = ''; for ($i = 0; $i < count($split1); $i++) { $value = current($split1); $deltime1 = $value; $key = key($split1); $product = $this->_producthelper->getProductById($key, "product_name"); $prods1 .= $product->product_name . ','; next($split1); } for ($i = 0; $i < count($split2); $i++) { $value = current($split2); $deltime2 = $value; $key = key($split2); $product = $this->_producthelper->getProductById($key, "product_name"); $prods2 .= $product->product_name . ','; next($split2); } $prods1 = trim($prods1, ","); $prods2 = trim($prods2, ","); } JRequest::setVar('order_delivery', "Delivered over two instances for " . SPLIT_DELIVERY_COST . "kr extra DELIVERY TIME: " . $deltime1 . " Weeks for " . $prods1 . " AND " . $deltime2 . " Weeks for " . $prods2 . " "); } else { $delArray = $objshipping->getProductDeliveryArray($shipping_rate_id); $splitdel = $objshipping->getSplitDelivery(); $split1 = $splitdel[0]; $value = current($split1); $product_delivery_time = $this->_producthelper->getProductMinDeliveryTime($cart[0]['product_id']); JRequest::setVar('order_delivery', $product_delivery_time); } $idx = $cart['idx']; $product_name = ""; $product_note = ""; $product_price = ""; $product_quantity = ""; $product_total_price = ""; for ($i = 0; $i < $idx; $i++) { // GiftCARD start $is_giftcard = 0; $giftcard_price = 0; $giftcard_name = 0; // GiftCARD end $product_id = $cart[$i]['product_id']; $product = $this->_producthelper->getProductById($product_id); $rowitem = $this->getTable('order_item_detail'); // The redCRM product purchase price if ($helper->isredCRM()) { $crmProductHelper = new crmProductHelper(); $crmproduct = $crmProductHelper->getProductById($product_id); $rowitem->product_purchase_price = $crmproduct->product_purchase_price > 0 ? $crmproduct->product_purchase_price : $crmproduct->product_price; $crmdata = array(); $crmDebitorHelper = new crmDebitorHelper(); $crmDebitorHelper_values = $crmDebitorHelper->getShippingDestination(0, 0, $shippingaddresses->users_info_id); if ($session->get('isredcrmuser')) { $crmDebitorHelper_contact_values = $crmDebitorHelper->getContactPersons(0, 0, 0, $user->id, 0); } else { $crmDebitorHelper_contact_values = $crmDebitorHelper->getContactPersons(0, 0, 0, 0, $crmDebitorHelper_values[0]->shipping_id); } $crmdata['order_id'] = JRequest::getVar('order_id', $row->order_id); $crmdata['debitor_id'] = $shippingaddresses->users_info_id; $crmdata['custom_status'] = ''; $crmdata['rma_number'] = ''; if (count($crmDebitorHelper_values) > 0) { $crmdata['shipping_id'] = $crmDebitorHelper_values[0]->shipping_id; } else { $crmdata['shipping_id'] = 0; } if (count($crmDebitorHelper_contact_values) > 0 && count($crmDebitorHelper_values) > 0) { $crmdata['person_id'] = $crmDebitorHelper_contact_values[0]->person_id; } else { $crmdata['person_id'] = 0; } $crmOrderHelper = new crmOrderHelper(); $crmOrderHelper->storeCRMOrder($crmdata); } // End if (!$rowitem->bind($post)) { $this->setError($this->_db->getErrorMsg()); return false; } if ($order_shipping[5] == 'regular') { $rowitem->delivery_time = $regDel; } elseif ($order_shipping[5] == 'split') { $rowitem->delivery_time = $delArray[$product_id]; } else { $rowitem->delivery_time = ''; } if (isset($cart[$i]['giftcard_id']) && $cart[$i]['giftcard_id']) { $is_giftcard = 1; } // Product stockroom update if (!$is_giftcard) { $updatestock = $stockroomhelper->updateStockroomQuantity($product_id, $cart[$i]['quantity']); $stockroom_id_list = $updatestock['stockroom_list']; $stockroom_quantity_list = $updatestock['stockroom_quantity_list']; $rowitem->stockroom_id = $stockroom_id_list; $rowitem->stockroom_quantity = $stockroom_quantity_list; } // End product stockroom update $vals = explode('product_attributes/', $cart[$i]['hidden_attribute_cartimage']); if (!empty($cart[$i]['attributeImage']) && file_exists(JPATH_ROOT . '/components/com_redshop/assets/images/mergeImages/' . $cart[$i]['attributeImage'])) { $rowitem->attribute_image = $order_id . $cart[$i]['attributeImage']; $old_media = JPATH_ROOT . '/components/com_redshop/assets/images/mergeImages/' . $cart[$i]['attributeImage']; $new_media = JPATH_ROOT . '/components/com_redshop/assets/images/orderMergeImages' . $rowitem->attribute_image; copy($old_media, $new_media); } elseif (!empty($vals[1])) { $rowitem->attribute_image = $vals[1]; } $wrapper_price = 0; if (@$cart[$i]['wrapper_id']) { $wrapper_price = $cart[$i]['wrapper_price']; } if ($is_giftcard == 1) { $giftcardData = $this->_producthelper->getGiftcardData($cart[$i]['giftcard_id']); $rowitem->product_id = $cart[$i]['giftcard_id']; $rowitem->order_item_name = $giftcardData->giftcard_name; $rowitem->product_item_old_price = $cart[$i]['product_price']; } else { $rowitem->product_id = $product_id; $rowitem->product_item_old_price = $cart[$i]['product_old_price']; $rowitem->supplier_id = $product->manufacturer_id; $rowitem->order_item_sku = $product->product_number; $rowitem->order_item_name = $product->product_name; } $rowitem->product_item_price = $cart[$i]['product_price']; $rowitem->product_quantity = $cart[$i]['quantity']; $rowitem->product_item_price_excl_vat = $cart[$i]['product_price_excl_vat']; $rowitem->product_final_price = $cart[$i]['product_price'] * $cart[$i]['quantity']; $rowitem->is_giftcard = $is_giftcard; $retAttArr = $this->_producthelper->makeAttributeCart($cart[$i]['cart_attribute'], $product_id, 0, 0, $cart[$i]['quantity']); $cart_attribute = $retAttArr[0]; // For discount calc data $cart_calc_data = ""; if (isset($cart[$i]['discount_calc_output'])) { $cart_calc_data = $cart[$i]['discount_calc_output']; } // End $retAccArr = $this->_producthelper->makeAccessoryCart($cart[$i]['cart_accessory'], $product_id); $cart_accessory = $retAccArr[0]; $rowitem->order_id = $order_id; $rowitem->user_info_id = $users_info_id; $rowitem->order_item_currency = REDCURRENCY_SYMBOL; $rowitem->order_status = $order_status; $rowitem->cdate = $timestamp; $rowitem->mdate = $timestamp; $rowitem->product_attribute = $cart_attribute; $rowitem->discount_calc_data = $cart_calc_data; $rowitem->product_accessory = $cart_accessory; $rowitem->container_id = $objshipping->getProductContainerId($cart[$i]['product_id']); $rowitem->wrapper_price = $wrapper_price; if (!empty($cart[$i]['wrapper_id'])) { $rowitem->wrapper_id = $cart[$i]['wrapper_id']; } if (!empty($cart[$i]['reciver_email'])) { $rowitem->giftcard_user_email = $cart[$i]['reciver_email']; } if (!empty($cart[$i]['reciver_name'])) { $rowitem->giftcard_user_name = $cart[$i]['reciver_name']; } if ($this->_producthelper->checkProductDownload($rowitem->product_id)) { $medianame = $this->_producthelper->getProductMediaName($rowitem->product_id); for ($j = 0; $j < count($medianame); $j++) { $product_serial_number = $this->_producthelper->getProdcutSerialNumber($rowitem->product_id); $this->_producthelper->insertProductDownload($rowitem->product_id, $user->id, $rowitem->order_id, $medianame[$j]->media_name, $product_serial_number->serial_number); } } // Import files for plugin JPluginHelper::importPlugin('redshop_product'); if (!$rowitem->store()) { $this->setError($this->_db->getErrorMsg()); return false; } // Add plugin support $dispatcher->trigger('afterOrderItemSave', array($cart, $rowitem, $i)); // End if (isset($cart[$i]['giftcard_id']) && $cart[$i]['giftcard_id']) { $section_id = 13; } else { $section_id = 12; } $this->_producthelper->insertProdcutUserfield($i, $cart, $rowitem->order_item_id, $section_id); // My accessory save in table start if (count($cart[$i]['cart_accessory']) > 0) { $setPropEqual = true; $setSubpropEqual = true; $attArr = $cart[$i]['cart_accessory']; for ($a = 0; $a < count($attArr); $a++) { $accessory_vat_price = 0; $accessory_attribute = ""; $accessory_id = $attArr[$a]['accessory_id']; $accessory_name = $attArr[$a]['accessory_name']; $accessory_price = $attArr[$a]['accessory_price']; $accessory_quantity = $attArr[$a]['accessory_quantity']; $accessory_org_price = $accessory_price; if ($accessory_price > 0) { $accessory_vat_price = $this->_producthelper->getProductTax($rowitem->product_id, $accessory_price); } $attchildArr = $attArr[$a]['accessory_childs']; for ($j = 0; $j < count($attchildArr); $j++) { $prooprand = array(); $proprice = array(); $attribute_id = $attchildArr[$j]['attribute_id']; $accessory_attribute .= urldecode($attchildArr[$j]['attribute_name']) . ":<br/>"; $rowattitem = $this->getTable('order_attribute_item'); $rowattitem->order_att_item_id = 0; $rowattitem->order_item_id = $rowitem->order_item_id; $rowattitem->section_id = $attribute_id; $rowattitem->section = "attribute"; $rowattitem->parent_section_id = $accessory_id; $rowattitem->section_name = $attchildArr[$j]['attribute_name']; $rowattitem->is_accessory_att = 1; if ($attribute_id > 0) { if (!$rowattitem->store()) { $this->setError($this->_db->getErrorMsg()); return false; } } $propArr = $attchildArr[$j]['attribute_childs']; for ($k = 0; $k < count($propArr); $k++) { $prooprand[$k] = $propArr[$k]['property_oprand']; $proprice[$k] = $propArr[$k]['property_price']; $section_vat = 0; if ($propArr[$k]['property_price'] > 0) { $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price']); } $property_id = $propArr[$k]['property_id']; $accessory_attribute .= urldecode($propArr[$k]['property_name']) . " (" . $propArr[$k]['property_oprand'] . $this->_producthelper->getProductFormattedPrice($propArr[$k]['property_price'] + $section_vat) . ")<br/>"; $subpropArr = $propArr[$k]['property_childs']; $rowattitem = $this->getTable('order_attribute_item'); $rowattitem->order_att_item_id = 0; $rowattitem->order_item_id = $rowitem->order_item_id; $rowattitem->section_id = $property_id; $rowattitem->section = "property"; $rowattitem->parent_section_id = $attribute_id; $rowattitem->section_name = $propArr[$k]['property_name']; $rowattitem->section_price = $propArr[$k]['property_price']; $rowattitem->section_vat = $section_vat; $rowattitem->section_oprand = $propArr[$k]['property_oprand']; $rowattitem->is_accessory_att = 1; if ($property_id > 0) { if (!$rowattitem->store()) { $this->setError($this->_db->getErrorMsg()); return false; } } for ($l = 0; $l < count($subpropArr); $l++) { $section_vat = 0; if ($subpropArr[$l]['subproperty_price'] > 0) { $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price']); } $subproperty_id = $subpropArr[$l]['subproperty_id']; $accessory_attribute .= urldecode($subpropArr[$l]['subproperty_name']) . " (" . $subpropArr[$l]['subproperty_oprand'] . $this->_producthelper->getProductFormattedPrice($subpropArr[$l]['subproperty_price'] + $section_vat) . ")<br/>"; $rowattitem = $this->getTable('order_attribute_item'); $rowattitem->order_att_item_id = 0; $rowattitem->order_item_id = $rowitem->order_item_id; $rowattitem->section_id = $subproperty_id; $rowattitem->section = "subproperty"; $rowattitem->parent_section_id = $property_id; $rowattitem->section_name = $subpropArr[$l]['subproperty_name']; $rowattitem->section_price = $subpropArr[$l]['subproperty_price']; $rowattitem->section_vat = $section_vat; $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand']; $rowattitem->is_accessory_att = 1; if ($subproperty_id > 0) { if (!$rowattitem->store()) { $this->setError($this->_db->getErrorMsg()); return false; } } } } // FOR ACCESSORY PROPERTY AND SUBPROPERTY PRICE CALCULATION if ($setPropEqual && $setSubpropEqual) { $accessory_priceArr = $this->_producthelper->makeTotalPriceByOprand($accessory_price, $prooprand, $proprice); $setPropEqual = $accessory_priceArr[0]; $accessory_price = $accessory_priceArr[1]; } for ($t = 0; $t < count($propArr); $t++) { $subprooprand = array(); $subproprice = array(); $subElementArr = $propArr[$t]['property_childs']; for ($tp = 0; $tp < count($subElementArr); $tp++) { $subprooprand[$tp] = $subElementArr[$tp]['subproperty_oprand']; $subproprice[$tp] = $subElementArr[$tp]['subproperty_price']; } if ($setPropEqual && $setSubpropEqual) { $accessory_priceArr = $this->_producthelper->makeTotalPriceByOprand($accessory_price, $subprooprand, $subproprice); $setSubpropEqual = $accessory_priceArr[0]; $accessory_price = $accessory_priceArr[1]; } } // FOR ACCESSORY PROPERTY AND SUBPROPERTY PRICE CALCULATION } $accdata = $this->getTable('accessory_detail'); if ($accessory_id > 0) { $accdata->load($accessory_id); } $accProductinfo = $this->_producthelper->getProductById($accdata->child_product_id); $rowaccitem = $this->getTable('order_acc_item'); $rowaccitem->order_item_acc_id = 0; $rowaccitem->order_item_id = $rowitem->order_item_id; $rowaccitem->product_id = $accessory_id; $rowaccitem->order_acc_item_sku = $accProductinfo->product_number; $rowaccitem->order_acc_item_name = $accessory_name; $rowaccitem->order_acc_price = $accessory_org_price; $rowaccitem->order_acc_vat = $accessory_vat_price; $rowaccitem->product_quantity = $accessory_quantity; $rowaccitem->product_acc_item_price = $accessory_price; $rowaccitem->product_acc_final_price = $accessory_price * $accessory_quantity; $rowaccitem->product_attribute = $accessory_attribute; if ($accessory_id > 0) { if (!$rowaccitem->store()) { $this->setError($this->_db->getErrorMsg()); return false; } } } } // My attribute save in table start if (count($cart[$i]['cart_attribute']) > 0) { $attchildArr = $cart[$i]['cart_attribute']; for ($j = 0; $j < count($attchildArr); $j++) { $attribute_id = $attchildArr[$j]['attribute_id']; $rowattitem = $this->getTable('order_attribute_item'); $rowattitem->order_att_item_id = 0; $rowattitem->order_item_id = $rowitem->order_item_id; $rowattitem->section_id = $attribute_id; $rowattitem->section = "attribute"; $rowattitem->parent_section_id = $rowitem->product_id; $rowattitem->section_name = $attchildArr[$j]['attribute_name']; $rowattitem->is_accessory_att = 0; if ($attribute_id > 0) { if (!$rowattitem->store()) { $this->setError($this->_db->getErrorMsg()); return false; } } $propArr = $attchildArr[$j]['attribute_childs']; if (count($propArr) > 0) { for ($k = 0; $k < count($propArr); $k++) { $section_vat = 0; if ($propArr[$k]['property_price'] > 0) { $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $propArr[$k]['property_price']); } $property_id = $propArr[$k]['property_id']; // Product property STOCKROOM update start $updatestock_att = $stockroomhelper->updateStockroomQuantity($property_id, $cart[$i]['quantity'], "property", $product_id); $stockroom_att_id_list = $updatestock_att['stockroom_list']; $stockroom_att_quantity_list = $updatestock_att['stockroom_quantity_list']; $rowattitem = $this->getTable('order_attribute_item'); $rowattitem->order_att_item_id = 0; $rowattitem->order_item_id = $rowitem->order_item_id; $rowattitem->section_id = $property_id; $rowattitem->section = "property"; $rowattitem->parent_section_id = $attribute_id; $rowattitem->section_name = $propArr[$k]['property_name']; $rowattitem->section_price = $propArr[$k]['property_price']; $rowattitem->section_vat = $section_vat; $rowattitem->section_oprand = $propArr[$k]['property_oprand']; $rowattitem->is_accessory_att = 0; $rowattitem->stockroom_id = $stockroom_att_id_list; $rowattitem->stockroom_quantity = $stockroom_att_quantity_list; if ($property_id > 0) { if (!$rowattitem->store()) { $this->setError($this->_db->getErrorMsg()); return false; } } $subpropArr = $propArr[$k]['property_childs']; for ($l = 0; $l < count($subpropArr); $l++) { $section_vat = 0; if ($subpropArr[$l]['subproperty_price'] > 0) { $section_vat = $this->_producthelper->getProducttax($rowitem->product_id, $subpropArr[$l]['subproperty_price']); } $subproperty_id = $subpropArr[$l]['subproperty_id']; // Product subproperty STOCKROOM update start $updatestock_subatt = $stockroomhelper->updateStockroomQuantity($subproperty_id, $cart[$i]['quantity'], "subproperty", $product_id); $stockroom_subatt_id_list = $updatestock_subatt['stockroom_list']; $stockroom_subatt_quantity_list = $updatestock_subatt['stockroom_quantity_list']; $rowattitem = $this->getTable('order_attribute_item'); $rowattitem->order_att_item_id = 0; $rowattitem->order_item_id = $rowitem->order_item_id; $rowattitem->section_id = $subproperty_id; $rowattitem->section = "subproperty"; $rowattitem->parent_section_id = $property_id; $rowattitem->section_name = $subpropArr[$l]['subproperty_name']; $rowattitem->section_price = $subpropArr[$l]['subproperty_price']; $rowattitem->section_vat = $section_vat; $rowattitem->section_oprand = $subpropArr[$l]['subproperty_oprand']; $rowattitem->is_accessory_att = 0; $rowattitem->stockroom_id = $stockroom_subatt_id_list; $rowattitem->stockroom_quantity = $stockroom_subatt_quantity_list; if ($subproperty_id > 0) { if (!$rowattitem->store()) { $this->setError($this->_db->getErrorMsg()); return false; } } } } } } } // Subtracting the products from the container. means decreasing stock if (USE_CONTAINER) { $this->_producthelper->updateContainerStock($product_id, $cart[$i]['quantity'], $rowitem->container_id); } // Subtracting the products from the container. means decreasing stock end // Store user product subscription detail if ($product->product_type == 'subscription') { $subscribe = $this->getTable('product_subscribe_detail'); $subscription_detail = $this->_producthelper->getProductSubscriptionDetail($product_id, $cart[$i]['subscription_id']); $add_day = $subscription_detail->period_type == 'days' ? $subscription_detail->subscription_period : 0; $add_month = $subscription_detail->period_type == 'month' ? $subscription_detail->subscription_period : 0; $add_year = $subscription_detail->period_type == 'year' ? $subscription_detail->subscription_period : 0; $subscribe->order_id = $order_id; $subscribe->order_item_id = $rowitem->order_item_id; $subscribe->product_id = $product_id; $subscribe->subscription_id = $cart[$i]['subscription_id']; $subscribe->user_id = $user->id; $subscribe->start_date = time(); $subscribe->end_date = mktime(0, 0, 0, date('m') + $add_month, date('d') + $add_day, date('Y') + $add_year); if (!$subscribe->store()) { $this->setError($this->_db->getErrorMsg()); return false; } } } $rowpayment = $this->getTable('order_payment'); if (!$rowpayment->bind($post)) { $this->setError($this->_db->getErrorMsg()); return false; } $rowpayment->order_id = $order_id; $rowpayment->payment_method_id = $payment_method_id; if (!isset($ccdata['creditcard_code'])) { $ccdata['creditcard_code'] = 0; } if (!isset($ccdata['order_payment_number'])) { $ccdata['order_payment_number'] = 0; } if (!isset($ccdata['order_payment_expire_month'])) { $ccdata['order_payment_expire_month'] = 0; } if (!isset($ccdata['order_payment_expire_year'])) { $ccdata['order_payment_expire_year'] = 0; } $rowpayment->order_payment_code = $ccdata['creditcard_code']; $rowpayment->order_payment_cardname = base64_encode($ccdata['order_payment_name']); $rowpayment->order_payment_number = base64_encode($ccdata['order_payment_number']); // This is ccv code $rowpayment->order_payment_ccv = base64_encode($ccdata['credit_card_code']); $rowpayment->order_payment_amount = $order_total; $rowpayment->order_payment_expire = $ccdata['order_payment_expire_month'] . $ccdata['order_payment_expire_year']; $rowpayment->order_payment_name = $paymentmethod->name; $rowpayment->payment_method_class = $paymentmethod->element; $rowpayment->order_payment_trans_id = $d["order_payment_trans_id"]; $rowpayment->authorize_status = ""; if (!$rowpayment->store()) { $this->setError($this->_db->getErrorMsg()); return false; } // For authorize status JPluginHelper::importPlugin('redshop_payment'); $dispatcher = JDispatcher::getInstance(); $data = $dispatcher->trigger('onAuthorizeStatus_' . $paymentmethod->element, array($paymentmethod->element, $order_id)); $GLOBALS['shippingaddresses'] = $shippingaddresses; // Add billing Info $userrow = $this->getTable('user_detail'); $userrow->load($billingaddresses->users_info_id); $userrow->thirdparty_email = $post['thirdparty_email']; $orderuserrow = $this->getTable('order_user_detail'); if (!$orderuserrow->bind($userrow)) { $this->setError($this->_db->getErrorMsg()); return false; } $orderuserrow->order_id = $order_id; $orderuserrow->address_type = 'BT'; if (!$orderuserrow->store()) { $this->setError($this->_db->getErrorMsg()); return false; } // Add shipping Info $userrow = $this->getTable('user_detail'); if (isset($shippingaddresses->users_info_id)) { $userrow->load($shippingaddresses->users_info_id); } $orderuserrow = $this->getTable('order_user_detail'); if (!$orderuserrow->bind($userrow)) { $this->setError($this->_db->getErrorMsg()); return false; } $orderuserrow->order_id = $order_id; $orderuserrow->address_type = 'ST'; if (!$orderuserrow->store()) { $this->setError($this->_db->getErrorMsg()); return false; } $checkOrderStatus = 1; if ($paymentmethod->element == "rs_payment_banktransfer" || $paymentmethod->element == "rs_payment_banktransfer_discount" || $paymentmethod->element == "rs_payment_banktransfer2" || $paymentmethod->element == "rs_payment_banktransfer3" || $paymentmethod->element == "rs_payment_banktransfer4" || $paymentmethod->element == "rs_payment_banktransfer5") { $checkOrderStatus = 0; } if (isset($cart['extrafields_values'])) { if (count($cart['extrafields_values']) > 0) { $this->_producthelper->insertPaymentShippingField($cart, $order_id, 18); $this->_producthelper->insertPaymentShippingField($cart, $order_id, 19); } } // Economic Integration start for invoice generate and book current invoice if (ECONOMIC_INTEGRATION == 1 && ECONOMIC_INVOICE_DRAFT != 2) { $economic = new economic(); $economicdata['split_payment'] = $issplit; $economicdata['economic_payment_terms_id'] = $economic_payment_terms_id; $economicdata['economic_design_layout'] = $economic_design_layout; $economicdata['economic_is_creditcard'] = $is_creditcard; $payment_name = $paymentmethod->element; $paymentArr = explode("rs_payment_", $paymentmethod->element); if (count($paymentArr) > 0) { $payment_name = $paymentArr[1]; } $economicdata['economic_payment_method'] = $payment_name; $invoiceHandle = $economic->createInvoiceInEconomic($row->order_id, $economicdata); if (ECONOMIC_INVOICE_DRAFT == 0) { $bookinvoicepdf = $economic->bookInvoiceInEconomic($row->order_id, $checkOrderStatus); if (is_file($bookinvoicepdf)) { $ret = $this->_redshopMail->sendEconomicBookInvoiceMail($row->order_id, $bookinvoicepdf); } } } // End Economic // Send the Order mail before payment if (!ORDER_MAIL_AFTER || ORDER_MAIL_AFTER && $row->order_payment_status == "Paid") { $this->_redshopMail->sendOrderMail($row->order_id); } else { // If Order mail set to send after payment then send mail to administrator only. $this->_redshopMail->sendOrderMail($row->order_id, true); } if ($row->order_status == "C") { $this->_order_functions->SendDownload($row->order_id); } // RedCRM includes if ($helper->isredCRM()) { if (ENABLE_ITEM_TRACKING_SYSTEM) { // Supplier order helper object $crmSupplierOrderHelper = new crmSupplierOrderHelper(); $getStatus = array(); $getStatus['orderstatus'] = $row->order_status; $getStatus['paymentstatus'] = $row->order_payment_status; $crmSupplierOrderHelper->redSHOPOrderUpdate($row->order_id, $getStatus); unset($getStatus); } } return $row; }
public function createInvoice() { if (ECONOMIC_INTEGRATION == 1 && ECONOMIC_INVOICE_DRAFT != 2) { $order_id = JRequest::getCmd('order_id'); $order_function = new order_functions(); $paymentInfo = $order_function->getOrderPaymentDetail($order_id); if (count($paymentInfo) > 0) { $payment_name = $paymentInfo[0]->payment_method_class; $paymentArr = explode("rs_payment_", $paymentInfo[0]->payment_method_class); if (count($paymentArr) > 0) { $payment_name = $paymentArr[1]; } $economicdata['economic_payment_method'] = $payment_name; $paymentmethod = $order_function->getPaymentMethodInfo($paymentInfo[0]->payment_method_class); if (count($paymentmethod) > 0) { $paymentparams = new JRegistry($paymentmethod[0]->params); $economicdata['economic_payment_terms_id'] = $paymentparams->get('economic_payment_terms_id'); $economicdata['economic_design_layout'] = $paymentparams->get('economic_design_layout'); $economicdata['economic_is_creditcard'] = $paymentparams->get('is_creditcard'); } } $economic = new economic(); $economicdata['split_payment'] = 0; $invoiceHandle = $economic->createInvoiceInEconomic($order_id, $economicdata); if (ECONOMIC_INVOICE_DRAFT == 0) { $bookinvoicepdf = $economic->bookInvoiceInEconomic($order_id, 1); if (is_file($bookinvoicepdf)) { $redshopMail = new redshopMail(); $ret = $redshopMail->sendEconomicBookInvoiceMail($order_id, $bookinvoicepdf); } } } $this->setRedirect('index.php?option=com_redshop&view=order'); }
<fieldset class="adminform"> <legend><?php echo JText::_('COM_REDSHOP_PAYMENT_METHOD'); ?> </legend> <div> <form action="<?php echo JRoute::_('index.php?option=com_redshop&view=split_payment'); ?> " method="post" name="adminForm" id="adminForm"> <?php $paymentmethod = $order_functions->getPaymentMethodInfo(); $adminpath = JPATH_ADMINISTRATOR . '/components/com_redshop'; for ($p = 0; $p < count($paymentmethod); $p++) { $paymentpath = $adminpath . '/helpers/payments/' . $paymentmethod[$p]->plugin . '/' . $paymentmethod[$p]->plugin . '.php'; include_once $paymentpath; ?> <input type="radio" name="payment_method_id" value="<?php echo $paymentmethod[$p]->payment_method_id; ?> " <?php if ($this->payment_method_id == $paymentmethod[$p]->payment_method_id || !$this->payment_method_id) { ?> checked="checked" <?php } ?>
public function display($tpl = null) { $app = JFactory::getApplication(); JToolBarHelper::title(JText::_('COM_REDSHOP_TEMPLATES_MANAGEMET'), 'redshop_templates48'); $uri = JFactory::getURI(); jimport('joomla.html.pane'); $pane = JPane::getInstance('sliders'); $this->pane = $pane; $model = $this->getModel('template_detail'); $user = JFactory::getUser(); $redtemplate = new Redtemplate(); // fail if checked out not by 'me' if ($model->isCheckedOut($user->get('id'))) { $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('COM_REDSHOP_THE_DETAIL'), $detail->title); $app->redirect('index.php?option=com_redshop&view=template', $msg); } $this->setLayout('default'); $lists = array(); $detail = $this->get('data'); $isNew = $detail->template_id < 1; $text = $isNew ? JText::_('COM_REDSHOP_NEW') : JText::_('COM_REDSHOP_EDIT'); JToolBarHelper::title(JText::_('COM_REDSHOP_TEMPLATES') . ': <small><small>[ ' . $text . ' ]</small></small>', 'redshop_templates48'); JToolBarHelper::apply(); JToolBarHelper::save(); if ($isNew) { JToolBarHelper::cancel(); } else { // EDIT - check out the item $model->checkout($user->get('id')); JToolBarHelper::cancel('cancel', JText::_('JTOOLBAR_CLOSE')); } // TEMPLATE MOVE DB TO FILE $post = JRequest::get('post'); if ($isNew && (isset($post['template_name']) && $post['template_name'] != "")) { $detail->template_name = $post['template_name']; $detail->template_section = $post['template_section']; $template_desc = JRequest::getVar('template_desc', '', 'post', 'string', JREQUEST_ALLOWRAW); $detail->template_desc = $template_desc; $detail->published = $post['published']; $detail->msg = JText::_('PLEASE_CHANGE_FILE_NAME_IT_IS_ALREADY_EXISTS'); } // TEMPLATE MOVE DB TO FILE END // Section can be added from here $optionsection = $redtemplate->getTemplateSections(); $lists['section'] = JHTML::_('select.genericlist', $optionsection, 'template_section', 'class="inputbox" size="1" onchange="showclicktellbox();"', 'value', 'text', $detail->template_section); $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox" ', $detail->published); $order_functions = new order_functions(); $paymentMethod = $order_functions->getPaymentMethodInfo(); $payment_methods = explode(',', $detail->payment_methods); $tmp = new stdClass(); $tmp = @array_merge($tmp, $payment_methods); $lists['payment_methods'] = JHTML::_('select.genericlist', $paymentMethod, 'payment_methods[]', 'class="inputbox" multiple="multiple" size="4" ', 'element', 'name', $payment_methods); $shippingMethod = $order_functions->getShippingMethodInfo(); $shipping_methods = explode(',', $detail->shipping_methods); $tmp = new stdClass(); $tmp = @array_merge($tmp, $shipping_methods); $lists['shipping_methods'] = JHTML::_('select.genericlist', $shippingMethod, 'shipping_methods[]', 'class="inputbox" multiple="multiple" size="4" ', 'element', 'name', $shipping_methods); $lists['order_status'] = $order_functions->getstatuslist('order_status', $detail->order_status, 'class="inputbox" multiple="multiple"'); $this->lists = $lists; $this->detail = $detail; $this->request_url = $uri->toString(); parent::display($tpl); }