public function updateAttributeItem($order_item_id, $quantity = 0, $stockroom_id = 0) { $stockroomhelper = new rsstockroomhelper(); $order_functions = new order_functions(); $attArr = $order_functions->getOrderItemAttributeDetail($order_item_id, 0, "attribute"); /** my attribute save in table start */ for ($j = 0; $j < count($attArr); $j++) { $propArr = $order_functions->getOrderItemAttributeDetail($order_item_id, 0, "property", $attArr[$j]->section_id); for ($k = 0; $k < count($propArr); $k++) { $propitemdata = $this->getTable('order_attribute_item'); $propitemdata->load($propArr[$k]->order_att_item_id); /** product property STOCKROOM update start */ if ($quantity > 0) { $stockroomhelper->manageStockAmount($propitemdata->section_id, $quantity, $propArr[$k]->stockroom_id, "property"); } elseif ($quantity < 0) { $updatestock = $stockroomhelper->updateStockroomQuantity($propitemdata->section_id, -$quantity, "property"); } $subpropArr = $order_functions->getOrderItemAttributeDetail($order_item_id, 0, "subproperty", $propitemdata->section_id); for ($l = 0; $l < count($subpropArr); $l++) { $subpropitemdata = $this->getTable('order_attribute_item'); $subpropitemdata->load($subpropArr[$l]->order_att_item_id); if ($quantity > 0) { $stockroomhelper->manageStockAmount($subpropitemdata->section_id, $quantity, $subpropArr[$l]->stockroom_id, "subproperty"); } elseif ($quantity < 0) { $updatestock = $stockroomhelper->updateStockroomQuantity($subpropitemdata->section_id, -$quantity, "subproperty"); } } } } return true; }
public function makeAttributeOrder($order_item_id = 0, $is_accessory = 0, $parent_section_id = 0, $stock = 0, $export = 0, $data = '') { $stockroomhelper = new rsstockroomhelper(); $order_functions = new order_functions(); $displayattribute = ""; $chktag = $this->getApplyattributeVatOrNot($data); $product_attribute = ""; $quantity = 0; $stockroom_id = "0"; $orderItemdata = $order_functions->getOrderItemDetail(0, 0, $order_item_id); $products = $this->getProductById($orderItemdata[0]->product_id); if (count($orderItemdata) > 0 && $is_accessory != 1) { $product_attribute = $orderItemdata[0]->product_attribute; $quantity = $orderItemdata[0]->product_quantity; $stockroom_id = $orderItemdata[0]->stockroom_id; } $orderItemAttdata = $order_functions->getOrderItemAttributeDetail($order_item_id, $is_accessory, "attribute", $parent_section_id); // Get Attribute middle template $attribute_middle_template = $this->getAttributeTemplateLoop($data); $attribute_final_template = ''; if (count($orderItemAttdata) > 0) { for ($i = 0; $i < count($orderItemAttdata); $i++) { $attribute = $this->getProductAttribute(0, 0, $orderItemAttdata[$i]->section_id); $hide_attribute_price = 0; if (count($attribute) > 0) { $hide_attribute_price = $attribute[0]->hide_attribute_price; } if (!strstr($data, '{remove_product_attribute_title}')) { $displayattribute .= "<div class='checkout_attribute_title'>" . urldecode($orderItemAttdata[$i]->section_name) . "</div>"; } // Assign Attribute middle template in tmp variable $tmp_attribute_middle_template = $attribute_middle_template; $tmp_attribute_middle_template = str_replace("{product_attribute_name}", urldecode($orderItemAttdata[$i]->section_name), $tmp_attribute_middle_template); $orderPropdata = $order_functions->getOrderItemAttributeDetail($order_item_id, $is_accessory, "property", $orderItemAttdata[$i]->section_id); for ($p = 0; $p < count($orderPropdata); $p++) { $property_price = $orderPropdata[$p]->section_price; if ($stock == 1) { $stockroomhelper->manageStockAmount($orderPropdata[$p]->section_id, $quantity, $orderPropdata[$p]->stockroom_id, "property"); } $property = $this->getAttibuteProperty($orderPropdata[$p]->section_id); $virtualNumber = ""; if (count($property) > 0 && $property[0]->property_number) { $virtualNumber = "<div class='checkout_attribute_number'>" . $property[0]->property_number . "</div>"; } if (!empty($chktag)) { $property_price = $orderPropdata[$p]->section_price + $orderPropdata[$p]->section_vat; } if ($export == 1) { $disPrice = " (" . $orderPropdata[$p]->section_oprand . REDCURRENCY_SYMBOL . $property_price . ")"; } else { $disPrice = ""; if (!$hide_attribute_price) { $disPrice = " (" . $orderPropdata[$p]->section_oprand . $this->getProductFormattedPrice($property_price) . ")"; } if (!strstr($data, '{product_attribute_price}')) { $disPrice = ''; } if (!strstr($data, '{product_attribute_number}')) { $virtualNumber = ''; } } $displayattribute .= "<div class='checkout_attribute_wrapper'><div class='checkout_attribute_price'>" . urldecode($orderPropdata[$p]->section_name) . $disPrice . "</div>" . $virtualNumber . "</div>"; // Replace attribute property price and value $tmp_attribute_middle_template = str_replace("{product_attribute_value}", urldecode($orderPropdata[$p]->section_name), $tmp_attribute_middle_template); $tmp_attribute_middle_template = str_replace("{product_attribute_value_price}", $disPrice, $tmp_attribute_middle_template); // Assign tmp variable to looping variable to get copy of all texts $attribute_final_template .= $tmp_attribute_middle_template; $orderSubpropdata = $order_functions->getOrderItemAttributeDetail($order_item_id, $is_accessory, "subproperty", $orderPropdata[$p]->section_id); for ($sp = 0; $sp < count($orderSubpropdata); $sp++) { $subproperty_price = $orderSubpropdata[$sp]->section_price; if ($stock == 1) { $stockroomhelper->manageStockAmount($orderSubpropdata[$sp]->section_id, $quantity, $orderSubpropdata[$sp]->stockroom_id, "subproperty"); } $subproperty = $this->getAttibuteSubProperty($orderSubpropdata[$sp]->section_id); $virtualNumber = ""; if (count($subproperty) > 0 && $subproperty[0]->subattribute_color_number) { $virtualNumber = "<div class='checkout_subattribute_number'>[" . $subproperty[0]->subattribute_color_number . "]</div>"; } if (!empty($chktag)) { $subproperty_price = $orderSubpropdata[$sp]->section_price + $orderSubpropdata[$sp]->section_vat; } if ($export == 1) { $disPrice = " (" . $orderSubpropdata[$sp]->section_oprand . REDCURRENCY_SYMBOL . $subproperty_price . ")"; } else { $disPrice = ""; if (!$hide_attribute_price) { $disPrice = " (" . $orderSubpropdata[$sp]->section_oprand . $this->getProductFormattedPrice($subproperty_price) . ")"; } if (!strstr($data, '{product_attribute_price}')) { $disPrice = ''; } if (!strstr($data, '{product_attribute_number}')) { $virtualNumber = ''; } } if (!strstr($data, '{remove_product_subattribute_title}')) { $displayattribute .= "<div class='checkout_subattribute_title'>" . urldecode($subproperty[0]->subattribute_color_title) . " : </div>"; } $displayattribute .= "<div class='checkout_subattribute_wrapper'><div class='checkout_subattribute_price'>" . urldecode($orderSubpropdata[$sp]->section_name) . $disPrice . "</div>" . $virtualNumber . "</div>"; } } } } else { $displayattribute = $product_attribute; } if ($products->use_discount_calc == 1) { $displayattribute = $displayattribute . $orderItemdata[0]->discount_calc_data; } $data = new stdClass(); $data->product_attribute = $displayattribute; $data->attribute_middle_template = $attribute_final_template; $data->attribute_middle_template_core = $attribute_middle_template; return $data; }
public function orderStatusUpdate($order_id, $post = array()) { $helper = new redhelper(); $stockroomhelper = new rsstockroomhelper(); $producthelper = new producthelper(); $newstatus = $post['order_status_all']; $customer_note = $post['customer_note' . $order_id]; $isproduct = isset($post['isproduct']) ? $post['isproduct'] : 0; $product_id = isset($post['product_id']) ? $post['product_id'] : 0; $paymentstatus = $post['order_paymentstatus' . $order_id]; JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_redshop/tables'); // Add status log... $order_log = JTable::getInstance('order_status_log', 'Table'); $order_log->order_id = $customer_note; $order_log->customer_note = $customer_note; $order_log->order_status = $newstatus; $order_log->date_changed = time(); if (!$order_log->store()) { return JError::raiseWarning('', $order_log->getError()); } // Changing the status of the order $this->updateOrderStatus($order_id, $newstatus); // Changing the status of the order if (isset($paymentstatus)) { $this->updateOrderPaymentStatus($order_id, $paymentstatus); } // For Consignor Label generation JPluginHelper::importPlugin('redshop_shippinglabel'); $dispatcher = JDispatcher::getInstance(); $results = $dispatcher->trigger('onChangeStatusToShipped', array($order_id, $newstatus, $paymentstatus)); // For Webpack Postdk Label Generation $this->createWebPacklabel($order_id, "", $newstatus, $paymentstatus); if (CLICKATELL_ENABLE) { // Changing the status of the order end $helper->clickatellSMS($order_id); } // If changing the status of the order then there item status need to change if ($isproduct != 1) { $this->updateOrderItemStatus($order_id, 0, $newstatus); } // If order is cancelled then, putting stock in the container from where it was dedcuted if ($newstatus == 'X') { $orderproducts = $this->getOrderItemDetail($order_id); for ($j = 0; $j < count($orderproducts); $j++) { $conid = $orderproducts[$j]->container_id; $prodid = $orderproducts[$j]->product_id; $prodqty = $orderproducts[$j]->stockroom_quantity; // When the order is set to "cancelled",product will return to stock $stockroomhelper->manageStockAmount($prodid, $prodqty, $orderproducts[$j]->stockroom_id); $producthelper->makeAttributeOrder($orderproducts[$j]->order_item_id, 0, $prodid, 1); if (USE_CONTAINER) { $this->manageContainerStock($prodid, $prodqty, $conid); } } } elseif ($newstatus == 'RT') { // If any of the item from the order is returuned back then, // change the status of whole order and also put back to stock. if ($isproduct) { $orderproductdetail = $this->getOrderItemDetail($order_id, $product_id); $conid = $orderproductdetail[0]->container_id; $prodid = $orderproductdetail[0]->product_id; $prodqty = $orderproductdetail[0]->product_quantity; if (USE_CONTAINER) { $this->manageContainerStock($prodid, $prodqty, $conid); } // Changing the status of the order item to Returned $this->updateOrderItemStatus($order_id, $prodid, "RT"); // Changing the status of the order to Partially Returned $this->updateOrderStatus($order_id, "PRT"); } else { $orderproducts = $this->getOrderItemDetail($order_id); for ($k = 0; $k < count($orderproducts); $k++) { $conid = $orderproducts[$k]->container_id; $prodid = $orderproducts[$k]->product_id; $prodqty = $orderproducts[$k]->product_quantity; if (USE_CONTAINER) { $this->manageContainerStock($prodid, $prodqty, $conid); } } } } elseif ($newstatus == 'RC') { // If any of the item from the order is reclamation back then, // change the status of whole order and also put back to stock. if ($isproduct) { // Changing the status of the order item to Reclamation $this->updateOrderItemStatus($order_id, $product_id, "RC"); // Changing the status of the order to Partially Reclamation $this->updateOrderStatus($order_id, "PRC"); } else { $orderproducts = $this->getOrderItemDetail($order_id); for ($l = 0; $l < count($orderproducts); $l++) { $conid = $orderproducts[$l]->container_id; $prodid = $orderproducts[$l]->product_id; $prodqty = $orderproducts[$l]->product_quantity; if (USE_CONTAINER) { $this->manageContainerStock($prodid, $prodqty, $conid); } } } } elseif ($newstatus == 'S') { if ($isproduct) { // Changing the status of the order item to Reclamation $this->updateOrderItemStatus($order_id, $product_id, "S"); // Changing the status of the order to Partially Reclamation $this->updateOrderStatus($order_id, "PS"); } } // Mail to customer of order status change $this->changeOrderStatusMail($order_id, $newstatus, $customer_note); $this->createBookInvoice($order_id, $newstatus); // GENERATE PDF CODE WRITE return true; }