function generatePrintableInvoicePageTitle($orderIds) { $title = GetConfig('StoreName').' - '; // allow access to deleted orders if printing from within control panel $isAdmin = (defined('ISC_ADMIN_CP') && ISC_ADMIN_CP); if(count($orderIds) == 1 && ($order = GetOrder($orderIds[0], null, null, $isAdmin))) { return $title .= sprintf(GetLang('PrintInvoiceForOrderNumber'), $orderIds[0]); } return $title .= GetLang('PrintInvoices'); }
function takeOrder($conn) { $products = json_decode($_GET['products']); $order_id = $_GET['order_id']; foreach ($products as $product) { // sprawdzenie czy produkty są na stanie $product_amount = $conn->query("SELECT amount FROM product WHERE product_id =" . $product->product_id . ";"); $product_amount = $product_amount->fetch(); if ($product_amount['amount'] < $product->amount) { return array('code' => JSON::$resultCodes['not_enough_items'], 'data' => null); } } foreach ($products as $product) { $conn->query("UPDATE product SET amount=amount-" . $product->amount . " WHERE product_id=" . $product->product_id . ";"); $conn->query("UPDATE orders SET status_id = status_id+1 WHERE order_id =" . $order_id . ";"); $conn->query("INSERT INTO order_details VALUES(" . $order_id . " , " . $product->product_id . " , " . $product->amount . ");"); if ($conn->error) { return array('code' => JSON::$resultCodes['mysql_exception'], 'data' => null); } } $order = GetOrder($conn, $order_id); return array('code' => JSON::$resultCodes['ok'], 'data' => $order); }
private function ViewCustomFields() { if (!isset($_REQUEST['orderId']) || !isId($_REQUEST['orderId'])) { exit; } // Load the order $order = GetOrder($_REQUEST['orderId']); if (!$order || $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $order['ordvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { exit; } $fields = null; if ($order['ordcustomfields'] !== '') { $fields = unserialize($order['ordcustomfields']); } $GLOBALS['OrderID'] = $order['orderid']; $GLOBALS['OrderCustomFieldsPopupHeading'] = sprintf(GetLang('OrderCustomFieldsPopupHeading'), $order['orderid']); $GLOBALS['OrderCustomFields'] = ''; if (!is_array($fields) || empty($fields)) { $GLOBALS['HideCustomFields'] = 'none'; } else { $GLOBALS['HideMissingCustomFields'] = 'none'; foreach ($fields as $widgetId => $data) { if ($data['type'] == 'singlecheckbox') { $data['data'] = GetLang('Yes'); } $GLOBALS['CustomFieldLabel'] = isc_html_escape($data['label']); $GLOBALS['CustomFieldData'] = isc_html_escape($data['data']); $GLOBALS['OrderCustomFields'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderCustomFields'); } } $GLOBALS["ISC_CLASS_TEMPLATE"]->SetTemplate("orders.customfields.popup"); $GLOBALS["ISC_CLASS_TEMPLATE"]->ParseTemplate(); }
public function UpdateReturnStatus(&$return, $status, $crediting = false) { // Start a transaction $GLOBALS['ISC_CLASS_DB']->Query("START TRANSACTION"); // Changing the status of this return to "Refunded", so we need to perform some additional things if($status == 5 && $return['retstatus'] != 5) { $refundAmount = $return['retprodcost'] * $return['retprodqty']; $updatedProduct = array( "ordprodrefundamount" => $return['retprodcost'], "ordprodrefunded" => $return['retprodqty'], "ordprodreturnid" => $return['returnid'] ); $order = getOrder($return['retorderid']); if (!$order) { return false; } $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_products", $updatedProduct, "orderprodid='".$GLOBALS['ISC_CLASS_DB']->Quote($return['retordprodid'])."'"); $query = " UPDATE [|PREFIX|]orders SET ordrefundedamount = ordrefundedamount + ".$refundAmount." WHERE orderid='".$return['retorderid']."' "; $this->db->query($query); // Have all items in this order been refunded? Mark the order as refunded. $query = sprintf("SELECT SUM(ordprodqty-ordprodrefunded) FROM [|PREFIX|]order_products WHERE orderorderid=%d", $return['retorderid']); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $remainingItems = $GLOBALS['ISC_CLASS_DB']->FetchOne($result); if($remainingItems == 0) { $updatedOrder = array( 'ordstatus' => 4 ); $GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updatedOrder, "orderid='".$GLOBALS['ISC_CLASS_DB']->Quote($return['retorderid'])."'"); } // Update the status of this return $updatedReturn = array( "retstatus" => 5, "retuserid" => $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetUserId() ); $GLOBALS['ISC_CLASS_DB']->UpdateQuery("returns", $updatedReturn, "returnid='".$GLOBALS['ISC_CLASS_DB']->Quote($return['returnid'])."'"); // Update the product inventory for this returned item $query = sprintf("SELECT * FROM [|PREFIX|]order_products WHERE ordprodid='%d'", $return['retordprodid']); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result); UpdateInventoryOnReturn($return['retordprodid']); // dont send a refund through the checkout module if a store credit was issued if (!$crediting) { // If the checkout module that was used for an order is still enabled and has a function // to handle a status change, then call that function $valid_checkout_modules = GetAvailableModules('checkout', true, true); $valid_checkout_module_ids = array(); foreach ($valid_checkout_modules as $valid_module) { $valid_checkout_module_ids[] = $valid_module['id']; } $newStatus = $order['ordstatus']; if (isset($updatedOrder['ordstatus'])) { $newStatus = $updatedOrder['ordstatus']; } // attempt to refund this amount with the checkout provider $order = GetOrder($return['retorderid'], false); if (in_array($order['orderpaymentmodule'], $valid_checkout_module_ids)) { GetModuleById('checkout', $checkout_module, $order['orderpaymentmodule']); if (method_exists($checkout_module, 'HandleStatusChange')) { call_user_func(array($checkout_module, 'HandleStatusChange'), $return['retorderid'], $order['ordstatus'], $newStatus, $refundAmount); } } } } else { // Update the status of this return $updatedReturn = array( "retstatus" => $status ); $GLOBALS['ISC_CLASS_DB']->UpdateQuery("returns", $updatedReturn, "returnid='".$GLOBALS['ISC_CLASS_DB']->Quote($return['returnid'])."'"); } $return['retstatus'] = $status; if(GetConfig('NotifyOnReturnStatusChange') == 1) { $this->EmailReturnStatusChange($return); } if($GLOBALS['ISC_CLASS_DB']->GetErrorMsg() == "") { $GLOBALS['ISC_CLASS_DB']->Query("COMMIT"); return true; } else { return false; } }
/** * Given an order ID, load the order and convert it in to a quote based off * the ISC_QUOTE class. * * @param int $orderId The order ID to load in to a quote. * @return ISC_QUOTE Quote object for the order. */ public function convertOrderToQuote($orderId, $enableDiscounts = true) { $order = GetOrder($orderId, null, null, true); if(!$order) { return false; } $quote = new ISC_QUOTE; $quote ->setDiscountsEnabled($enableDiscounts) ->setOrderId($orderId) ->setCustomerId($order['ordcustid']) ->setAppliedStoreCredit($order['ordstorecreditamount']) ->setCustomerMessage($order['ordcustmessage']) ->setStaffNotes($order['ordnotes']) ->setOrderStatus($order['ordstatus']); $billingCustomFields = array(); if($order['ordformsessionid']) { $billingCustomFields = $GLOBALS['ISC_CLASS_FORM']->getSavedSessionData( $order['ordformsessionid'], array(), FORMFIELDS_FORM_BILLING, true ); } $quote->getBillingAddress() ->setFirstName($order['ordbillfirstname']) ->setLastName($order['ordbilllastname']) ->setCompany($order['ordbillcompany']) ->setEmail($order['ordbillemail']) ->setPhone($order['ordbillphone']) ->setAddress1($order['ordbillstreet1']) ->setAddress2($order['ordbillstreet2']) ->setCity($order['ordbillsuburb']) ->setZip($order['ordbillzip']) ->setCountryByName($order['ordbillcountry']) ->setStateByName($order['ordbillstate']) ->setCustomFields($billingCustomFields); if($order['shipping_address_count'] > 1) { $quote->setIsSplitShipping(true); } // Set the shipping addresses on the quote $query = " SELECT * FROM [|PREFIX|]order_addresses a LEFT JOIN [|PREFIX|]order_shipping s ON (s.order_address_id = a.id) WHERE a.order_id='".$order['orderid']."' "; $result = $GLOBALS['ISC_CLASS_DB']->query($query); while($address = $GLOBALS['ISC_CLASS_DB']->fetch($result)) { $shippingCustomFields = array(); if($address['form_session_id']) { $shippingCustomFields = $GLOBALS['ISC_CLASS_FORM']->getSavedSessionData( $address['form_session_id'], array(), FORMFIELDS_FORM_SHIPPING, true ); } $quoteAddress = new ISC_QUOTE_ADDRESS_SHIPPING; $quoteAddress ->setQuote($quote) ->setId($address['order_address_id']) ->setFirstName($address['first_name']) ->setLastName($address['last_name']) ->setCompany($address['company']) ->setEmail($address['email']) ->setPhone($address['phone']) ->setAddress1($address['address_1']) ->setAddress2($address['address_2']) ->setCity($address['city']) ->setZip($address['zip']) ->setCountryByName($address['country']) ->setStateByName($address['state']) ->setCustomFields($shippingCustomFields) ->setShippingMethod($address['base_cost'], $address['method'], $address['module'], true) ->setHandlingCost($address['base_handling_cost'], true); $quote->addShippingAddress($quoteAddress); } // Load any configurable fields for items on this order $configurableFields = array(); $query = " SELECT * FROM [|PREFIX|]order_configurable_fields WHERE orderid='".$order['orderid']."' "; $result = $GLOBALS['ISC_CLASS_DB']->query($query); while($configurableField = $GLOBALS['ISC_CLASS_DB']->fetch($result)) { $quoteField = array( 'name' => $configurableField['fieldname'], 'type' => $configurableField['fieldtype'], 'fileType' => $configurableField['filetype'], 'fileOriginalName' => $configurableField['originalfilename'], 'value' => $configurableField['textcontents'] ); if($quoteField['type'] == 'file') { $quoteField['value'] = $configurableField['filename']; $quoteField['isExistingFile'] = true; } $configurableFields[$configurableField['ordprodid']][$configurableField['fieldid']] = $quoteField; } // Loop through all of the items and add them to the quote $query = " SELECT * FROM [|PREFIX|]order_products WHERE orderorderid='".$order['orderid']."' "; $result = $GLOBALS['ISC_CLASS_DB']->query($query); while($product = $GLOBALS['ISC_CLASS_DB']->fetch($result)) { $variationOptions = array(); if($product['ordprodoptions']) { $variationOptions = unserialize($product['ordprodoptions']); } $configuration = array(); if(isset($configurableFields[$product['orderprodid']])) { $configuration = $configurableFields[$product['orderprodid']]; } $itemClass = 'ISC_QUOTE_ITEM'; $type = PT_PHYSICAL; if($product['ordprodtype'] == 'digital') { $type = PT_DIGITAL; } else if($product['ordprodtype'] == 'giftcertificate') { $type = PT_GIFTCERTIFICATE; $itemClass = 'ISC_QUOTE_ITEM_GIFTCERTIFICATE'; } else if (!$product['ordprodid']) { $type = PT_VIRTUAL; } $quoteItem = new $itemClass; $quoteItem ->setQuote($quote) ->setName($product['ordprodname']) ->setSku($product['ordprodsku']) ->setId($product['orderprodid']) ->setProductId($product['ordprodid']) ->setQuantity($product['ordprodqty'], false) ->setOriginalOrderQuantity($product['ordprodqty']) ->setConfiguration($configuration) ->setVariationId($product['ordprodvariationid']) ->setVariationOptions($variationOptions) ->setType($type) ->setEventName($product['ordprodeventname']) ->setAddressId($product['order_address_id']) ->setBasePrice($product['base_price'], true) ->setFixedShippingCost($product['ordprodfixedshippingcost']) ->setWeight($product['ordprodweight']) ->setInventoryCheckingEnabled(false); if ($product['applied_discounts']) { $appliedDiscounts = unserialize($product['applied_discounts']); if (!empty($appliedDiscounts)) { foreach ($appliedDiscounts as $discountId => $discountValue) { $quoteItem->addDiscount($discountId, $discountValue); } } } if($product['ordprodwrapid']) { $quoteItem->setGiftWrapping( $product['ordprodwrapid'], $product['base_wrapping_cost'], $product['ordprodwrapname'], $product['ordprodwrapmessage'] ); } if($product['ordprodeventdate']) { list($day, $month, $year) = explode('-', isc_date('d-m-Y', $product['ordprodeventdate'])); $quoteItem->setEventDate($month, $day, $year); } $quote->addItem($quoteItem, false); $quoteItem->setInventoryCheckingEnabled(true); } // Add any applied coupon codes $query = " SELECT * FROM [|PREFIX|]order_coupons WHERE ordcouporderid='".$order['orderid']."' "; $result = $GLOBALS['ISC_CLASS_DB']->query($query); while($coupon = $GLOBALS['ISC_CLASS_DB']->fetch($result)) { $quoteCoupon = array( 'id' => 0, 'code' => $coupon['ordcouponcode'], 'discountType' => $coupon['ordcoupontype'], 'discountAmount' => $coupon['ordcouponamount'], 'totalDiscount' => $coupon['applied_discount'], ); $quote->addCoupon($quoteCoupon); } // Add any applied gift certificates $query = " SELECT h.*, g.giftcertcode FROM [|PREFIX|]gift_certificate_history h LEFT JOIN [|PREFIX|]gift_certificates g ON (g.giftcertid = h.histgiftcertid) WHERE historderid='".$order['orderid']."' "; $result = $GLOBALS['ISC_CLASS_DB']->query($query); while($giftCertificate = $GLOBALS['ISC_CLASS_DB']->fetch($result)) { $quoteGiftCertificate = array( 'code' => $giftCertificate['giftcertcode'], 'id' => 0, 'amount' => $giftCertificate['histbalanceused'] ); $quote->addGiftCertificate($quoteGiftCertificate); } if($order['orddiscountamount'] > 0) { $quote->addDiscount('existing-discount', $order['orddiscountamount']); } return $quote; }
/** * Add all the products * * Method will add all the products within the $input['products'] array * * @access private * @param array &$input The referenced input data * @return bool TRUE if all the products were added, FALSE otherwise */ private function addProducts(&$input, $editingExisting = false) { if (!array_key_exists('products', $input) || !is_array($input['products'])) { return false; } $existingOrder = array(); if ($editingExisting) { $existingOrder = GetOrder($input['orderid'], true); } $couponsUsed = array(); $giftCertificates = array(); foreach ($input['products'] as $product) { $existingProduct = false; if (isset($product['existing_order_product']) && isset($existingOrder['products'][$product['existing_order_product']])) { $existingProduct = $existingOrder['products'][$product['existing_order_product']]; unset($existingOrder['products'][$product['existing_order_product']]); } if (!isset($product['product_code'])) { $product['product_code'] = ''; } if (!isset($product['variation_id'])) { $product['variation_id'] = 0; } if (isset($product['discount_price'])) { $price = $product['discount_price']; } else { $price = $product['product_price']; } // Set up some default values for the product $newProduct = array('ordprodsku' => $product['product_code'], "ordprodname" => $product['product_name'], "ordprodtype" => '', "ordprodcost" => $price, "ordprodoriginalcost" => $product['product_price'], "ordprodweight" => 0, "ordprodqty" => $product['quantity'], "orderorderid" => $input['orderid'], "ordprodid" => $product['product_id'], "ordprodvariationid" => $product['variation_id'], "ordprodoptions" => '', "ordprodcostprice" => 0, "ordprodfixedshippingcost" => 0, "ordprodistaxable" => 1); //YMM info added by Simha $newProduct['ordyear'] = $product['year']; $newProduct['ordmake'] = $product['make']; $newProduct['ordmodel'] = $product['model']; //blessen if (isset($input['offerid'])) { $newProduct['offerid'] = $input['offerid']; } /* $mmyvals = array( "omake" => $product['make'], "model" => $product['model'], "year" => $product['year'], ); $MMYInfo = serialize($mmyvals); $newProduct['mmyinfo'] = $MMYInfo; */ //YMM info added by Simha Ends // This product is a gift certificate so set the appropriate values if (isset($product['type']) && $product['type'] == "giftcertificate") { // Gift certificates can't be edited if (isset($product['existing_order_product'])) { continue; } $newProduct['ordprodtype'] = 'giftcertificate'; $giftCertificates[] = $product; } else { if (isset($product['data'])) { $newProduct['ordprodtype'] = $product['data']['prodtype']; } else { $newProduct['ordprodtype'] = 'physical'; } } if (isset($product['data']['prodcostprice'])) { $newProduct['ordprodcostprice'] = (double) $product['data']['prodcostprice']; } if (isset($product['options'])) { $newProduct['ordprodoptions'] = serialize($product['options']); } if (isset($product['data']['prodweight'])) { $newProduct['ordprodweight'] = $product['data']['prodweight']; } if (isset($product['data']['prodfixedshippingcost'])) { $newProduct['ordprodfixedshippingcost'] = $product['data']['prodfixedshippingcost']; } if (isset($product['data']['prodistaxable'])) { $newProduct['ordprodistaxable'] = $product['data']['prodistaxable']; } if (isset($product['event_date']) && isset($product['event_name'])) { $newProduct['ordprodeventdate'] = $product['event_date']; $newProduct['ordprodeventname'] = $product['event_name']; } // If wrapping has been applied to this product, add it in if (isset($product['wrapping'])) { $newProduct['ordprodwrapid'] = $product['wrapping']['wrapid']; $newProduct['ordprodwrapname'] = $product['wrapping']['wrapname']; $newProduct['ordprodwrapcost'] = $product['wrapping']['wrapprice']; if (isset($product['wrapping']['wrapmessage'])) { $newProduct['ordprodwrapmessage'] = $product['wrapping']['wrapmessage']; } } if (isset($product['original_price'])) { $newProduct['ordoriginalprice'] = $product['original_price']; } if (is_array($existingProduct)) { $ordProdID = $existingProduct['orderprodid']; $GLOBALS['ISC_CLASS_DB']->UpdateQuery('order_products', $newProduct, "orderprodid='" . (int) $ordProdID . "'"); // Delete any existing product fields we don't have $query = "\n\t\t\t\t\tSELECT orderfieldid, filename\n\t\t\t\t\tFROM [|PREFIX|]order_configurable_fields\n\t\t\t\t\tWHERE ordprodid='" . $ordProdID . "' AND fieldtype='file'\n\t\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($field = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { @unlink(ISC_BASE_PATH . '/' . GetConfig('ImageDirectory') . '/configured_products/' . $field['filename']); } $GLOBALS['ISC_CLASS_DB']->DeleteQuery('order_configurable_fields', "WHERE ordprodid='" . $ordProdID . "'"); } else { $ordProdID = $GLOBALS['ISC_CLASS_DB']->InsertQuery("order_products", $newProduct); /* To insert the complementary items to order_products table -- Baskaran */ if ($product['compitem'] == 1) { for ($y = 0; $y < count($product['complementary']); $y++) { $compprice = $product['complementary'][$y]['comp_original_price']; $CompProduct = array('ordprodsku' => $product['complementary'][$y]['comp_product_code'], "ordprodname" => $product['complementary'][$y]['comp_product_name'], "ordprodtype" => '', "ordprodcost" => $product['complementary'][$y]['comp_original_price'], "ordprodoriginalcost" => $product['complementary'][$y]['comp_original_price'], "ordprodweight" => 0, "ordprodqty" => $product['complementary'][$y]['quantity'], "orderorderid" => $input['orderid'], "ordprodid" => $product['complementary'][$y]['comp_productid'], "ordprodvariationid" => '', "ordprodoptions" => '', "ordprodcostprice" => 0, "ordprodfixedshippingcost" => 0, "ordprodistaxable" => 1, "ordoriginalprice" => $product['complementary'][$y]['comp_original_price'], "ordcompmainproductid" => $product['complementary'][$y]['comp_mainproductid']); /* $path = ISC_BASE_PATH."/simha.txt"; $fp = fopen($path, "w+"); if ($fp) { fwrite($fp, implode("\r\n", $CompProduct)."\r\n----------------------\r\n"); fclose($fp); } */ $ordProdID1 = $GLOBALS['ISC_CLASS_DB']->InsertQuery("order_products", $CompProduct); } } /* Code Ends */ } // Add configurable product fields come with the order to database if (isset($product['product_fields'])) { foreach ($product['product_fields'] as $fieldId => $field) { //move the uploaded file to configured_products folder from the temp folder. if ($field['fieldType'] == 'file' && trim($field['fileName']) != '') { $filePath = ISC_BASE_PATH . '/' . GetConfig('ImageDirectory') . '/configured_products/' . $field['fileName']; $fileTmpPath = ISC_BASE_PATH . '/' . GetConfig('ImageDirectory') . '/configured_products_tmp/' . $field['fileName']; //do not remove the temp file here, because the payment may not successful //the file should still be viewable in in the cart, @copy($fileTmpPath, $filePath); } $fieldArray = array('ordprodid' => (int) $ordProdID, 'fieldid' => (int) $fieldId, 'orderid' => (int) $input['orderid'], 'fieldname' => $field['fieldName'], 'fieldtype' => $field['fieldType'], 'textcontents' => '', 'filename' => '', 'filetype' => '', 'originalfilename' => '', 'productid' => $product['product_id']); if ($field['fieldType'] == 'file' && trim($field['fileName']) != '') { $fieldArray['filename'] = trim($field['fileName']); $fieldArray['filetype'] = trim($field['fileType']); $fieldArray['originalfilename'] = trim($field['fileOriginName']); } else { $fieldArray['textcontents'] = trim($field['fieldValue']); } $GLOBALS['ISC_CLASS_DB']->InsertQuery("order_configurable_fields", $fieldArray); } } // Ensure that coupons aren't being saved with gift certificates if (isset($product['couponcode'])) { $newOrderCoupon = array("ordcouporderid" => $input['orderid'], "ordcoupprodid" => $ordProdID, "ordcouponid" => $product['coupon'], "ordcouponcode" => $product['couponcode'], "ordcouponamount" => $product['discount'], "ordcoupontype" => $product['coupontype']); $update_coup = false; if (is_array($existingProduct)) { $query = "SELECT ordcoupid FROM [|PREFIX|]order_coupons WHERE ordcoupprodid = '" . $ordProdID . "'"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_coupons", $newOrderCoupon, "ordcoupid = " . $row["ordcoupid"]); $update_coup = true; } } if (!$update_coup) { $GLOBALS['ISC_CLASS_DB']->InsertQuery("order_coupons", $newOrderCoupon); } } else { if (is_array($existingProduct)) { $GLOBALS['ISC_CLASS_DB']->DeleteQuery('order_coupons', "WHERE ordcoupprodid='" . $ordProdID . "'"); } } if (isset($existingOrder['ordinventoryupdated']) && $existingOrder['ordinventoryupdated'] == 1) { // If we're editing an existing order and the quantities or variation have changed, do we need to // update the inventory quantities? if (is_array($existingProduct) && $existingProduct['ordprodvariationid'] != $newProduct['ordprodvariationid'] || $existingProduct['ordprodqty'] != $newProduct['ordprodqty']) { AdjustProductInventory($existingProduct['ordprodid'], $existingProduct['ordprodvariationid'], @$product['data']['prodinvtrack'], '+' . $existingProduct['ordprodqty']); AdjustProductInventory($newProduct['ordprodid'], $newProduct['ordprodvariationid'], @$product['data']['prodinvtrack'], '-' . $newProduct['ordprodqty']); } else { if (!is_array($existingProduct)) { AdjustProductInventory($newProduct['ordprodid'], $newProduct['ordprodvariationid'], @$product['data']['prodinvtrack'], '+' . $newProduct['ordprodqty']); } } } } // If we have one or more gift certificates to create, we need to create them now. if (count($giftCertificates) > 0) { $GLOBALS['ISC_CLASS_GIFT_CERTIFICATES'] = GetClass('ISC_GIFTCERTIFICATES'); $GLOBALS['ISC_CLASS_GIFT_CERTIFICATES']->CreateGiftCertificatesFromOrder($input['orderid'], $giftCertificates, 1); } // Now remove any deleted items from the order if ($editingExisting) { $removeItemIds = implode(',', array_keys($existingOrder['products'])); if ($removeItemIds != '') { $query = "\n\t\t\t\t\t\t\tSELECT op.orderprodid, p.productid, p.prodinvtrack\n\t\t\t\t\t\t\tFROM [|PREFIX|]order_products as op\n\t\t\t\t\t\t\tINNER JOIN [|PREFIX|]products as p\n\t\t\t\t\t\t\tON op.ordprodid = p.productid\n\t\t\t\t\t\t\tWHERE op.orderprodid IN (" . $removeItemIds . ") AND ordprodid > 0\n\t\t\t\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($prod = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $existingOrder['products'][$prod['orderprodid']]['prodinvtrack'] = $prod['prodinvtrack']; } //update product inventory level foreach ($existingOrder['products'] as $rmProd) { if (!$rmProd['ordprodid']) { continue; } AdjustProductInventory($rmProd['ordprodid'], $rmProd['ordprodvariationid'], $rmProd['prodinvtrack'], '+' . $rmProd['ordprodqty']); } // Delete any existing product fields we don't have $query = "\n\t\t\t\t\tSELECT orderfieldid, filename\n\t\t\t\t\tFROM [|PREFIX|]order_configurable_fields\n\t\t\t\t\tWHERE ordprodid IN (" . $removeItemIds . ") AND fieldtype='file'\n\t\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($field = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { @unlink(ISC_BASE_PATH . '/' . GetConfig('ImageDirectory') . '/configured_products/' . $field['filename']); } $GLOBALS['ISC_CLASS_DB']->DeleteQuery('order_configurable_fields', "WHERE ordprodid IN (" . $removeItemIds . ")"); $GLOBALS['ISC_CLASS_DB']->DeleteQuery('order_products', "WHERE orderprodid IN (" . $removeItemIds . ")"); $GLOBALS['ISC_CLASS_DB']->DeleteQuery('order_coupons', "WHERE ordcoupprodid IN (" . $removeItemIds . ")"); } } return true; }
/** * Ebay: Sent to a seller when a buyer completes the checkout process for an item. Not sent when an auction ends without bids. * * My notes: Seems to be triggered when the buyer's payment process for an AUCTION item has completed, is not fired for fixed price items which fire 'FixedPrice...' notifications instead * * @param array $body */ protected function _handleAuctionCheckoutComplete($body) { // The data fields in the notification are the same as those returned by the GetItemTransactions call with the default detail level. if (!empty ($body['Item']['ItemID']) && ISC_ADMIN_EBAY::validEbayItemId($body['Item']['ItemID'])) { // variables init $order = array(); $orderId = 1; $order['ShippingInsuranceCost'] = 0; $completedPaymentHoldStatus = array('None', 'Released'); $orderStatus = ORDER_STATUS_AWAITING_PAYMENT; $existingOrderId = 0; // Determine if the buyer purchase multiple items from the same seller if (!empty($body['TransactionArray']['Transaction']['ContainingOrder'])) { // Call the operation to get the order transaction. $orderId = $body['TransactionArray']['Transaction']['ContainingOrder']['OrderID']; // if the record already exist, check if we need to update existing orders, that the payment hasn't been cleared previously. $existingOrder = GetOrderByEbayOrderId($orderId); $orderTransaction = ISC_ADMIN_EBAY_OPERATIONS::getOrderTransactions($orderId); $transactions = $orderTransaction->OrderArray->Order->TransactionArray->Transaction; $order['SubTotal'] = (string) $orderTransaction->OrderArray->Order->Subtotal; $order['ShippingCost'] = (string) $orderTransaction->OrderArray->Order->ShippingServiceSelected->ShippingServiceCost; $order['ShippingInsuranceCost'] = 0; $order['GrandTotal'] = (string) $orderTransaction->OrderArray->Order->Total; $order['TotalQuantityPurchased'] = 0; foreach ($transactions as $transaction) { $convertedTransaction = (array) $transaction; $variationOptionsString = ''; if (isset($convertedTransaction['Variation']->VariationSpecifics)) { $variationNameValueList = (array) $convertedTransaction['Variation']->VariationSpecifics->NameValueList; $variationOptions = array(); $variationSpecifics = (array) $convertedTransaction['Variation']->VariationSpecifics; if (is_array($variationSpecifics['NameValueList'])) { foreach ($variationSpecifics['NameValueList'] as $option) { $variationOptions[(string) $option->Name] = (string) $option->Value; } } else { $variationOptions[(string) $variationSpecifics['NameValueList']->Name] = (string) $variationSpecifics['NameValueList']->Value; } $variationOptionsString = serialize($variationOptions); } $quantityPurchased = $convertedTransaction['QuantityPurchased']; $transactionPrice = $convertedTransaction['TransactionPrice']; $itemId = (string) $convertedTransaction['Item']->ItemID; $transactionId = (string) $convertedTransaction['TransactionID']; $totalTransactionPrice = $transactionPrice * $quantityPurchased; $order['Transaction'][] = array( 'QuantityPurchased' => $quantityPurchased, 'TransactionPrice' => $transactionPrice, 'ItemId' => $itemId, 'TotalTransactionPrice' => $totalTransactionPrice, 'VariationOptionsString' => $variationOptionsString, 'TransactionId' => $transactionId, ); $order['TotalQuantityPurchased'] += $quantityPurchased; $order['Currency'] = GetCurrencyByCode($body['TransactionArray']['Transaction']['AmountPaid']['!currencyID']); $buyerInfoShippingAddress = $body['TransactionArray']['Transaction']['Buyer']['BuyerInfo']['ShippingAddress']; $buyerEmailAddress = $body['TransactionArray']['Transaction']['Buyer']['Email']; } if ($existingOrder) { $existingOrderId = $existingOrder['orderid']; } } else { $transactions = $body['TransactionArray']; foreach ($transactions as $transaction) { $itemId = $body['Item']['ItemID']; $transactionId = $transaction['TransactionID']; $query = " SELECT * FROM [|PREFIX|]order_products WHERE ebay_item_id = '".$GLOBALS["ISC_CLASS_DB"]->Quote($itemId)."' AND ebay_transaction_id = '".$GLOBALS["ISC_CLASS_DB"]->Quote($transactionId)."' LIMIT 1 "; $res = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($res); $eachItemPriceExTax = $transaction['TransactionPrice']['!']; $quantityPurchased = $transaction['QuantityPurchased']; $totalTransactionPrice = $quantityPurchased * $eachItemPriceExTax; $variationOptionsString = ''; // do we have a variation for this product? if (isset($transaction['Variation']['VariationSpecifics'])) { $variationNameValueList = $transaction['Variation']['VariationSpecifics']['NameValueList']; $variationOptions = array(); foreach ($variationNameValueList as $option) { $variationOptions[$option['Name']] = $option['Value']; } $variationOptionsString = serialize($variationOptions); } $order['TotalQuantityPurchased'] = $quantityPurchased; $order['SubTotal'] = $eachItemPriceExTax * $order['TotalQuantityPurchased']; $order['ShippingCost'] = $transaction['ShippingServiceSelected']['ShippingServiceCost']['!']; if (isset ($transaction['ShippingServiceSelected']['ShippingInsuranceCost']['!'])) { $order['ShippingInsuranceCost'] = $transaction['ShippingServiceSelected']['ShippingInsuranceCost']['!']; } $order['GrandTotal'] = $transaction['AmountPaid']['!']; $order['Transaction'][] = array( 'QuantityPurchased' => $quantityPurchased, 'TransactionPrice' => $eachItemPriceExTax, 'ItemId' => $itemId, 'TotalTransactionPrice' => $totalTransactionPrice, 'VariationOptionsString' => $variationOptionsString, 'TransactionId' => $transactionId, ); $order['Currency'] = GetCurrencyByCode($transaction['AmountPaid']['!currencyID']); $buyerInfoShippingAddress = $transaction['Buyer']['BuyerInfo']['ShippingAddress']; $buyerEmailAddress = $transaction['Buyer']['Email']; if (!$row) { // only process the new transaction break; } else { $existingOrderId = $row['orderorderid']; } } } $paymentHoldStatus = $body['TransactionArray']['Transaction']['Status']['PaymentHoldStatus']; if (in_array(trim($paymentHoldStatus), $completedPaymentHoldStatus)) { $orderStatus = ORDER_STATUS_AWAITING_FULFILLMENT; } if ($existingOrderId != 0) { if (!isset ($existingOrder)) { $existingOrder = GetOrder($existingOrderId, false, true, true); } // check if there're any existing order need to be updated. // in the case, paypal release the hold payment of buyer if ($existingOrder['ordstatus'] == ORDER_STATUS_AWAITING_PAYMENT && $orderStatus == ORDER_STATUS_AWAITING_FULFILLMENT) { // update the quantity for each transaction $GLOBALS["ISC_CLASS_DB"]->StartTransaction(); foreach ($order['Transaction'] as $eachTransaction) { // Get product Id try { $itemObj = new ISC_ADMIN_EBAY_ITEMS($eachTransaction['ItemId']); $productId = $itemObj->getProductId(); } catch (Exception $e) { $this->log->LogSystemDebug('ebay', $e->getMessage()); return false; } // update the item quantity in store $updatedData['quantity_remaining'] = $itemObj->getQuantityRemaining() - $eachTransaction['QuantityPurchased']; if (!$GLOBALS['ISC_CLASS_DB']->UpdateQuery('ebay_items', $updatedData, "ebay_item_id='" . $eachTransaction['ItemId'] . "'")) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } if (!UpdateOrderStatus($existingOrderId, $orderStatus, true, true)) { $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } } $GLOBALS["ISC_CLASS_DB"]->CommitTransaction(); // update the store inventory if necessary if (GetConfig('UpdateInventoryLevels') == 1) { DecreaseInventoryFromOrder($existingOrderId); } $this->log->LogSystemDebug('ebay', 'The status of the store order ('. $existingOrderId .') has been updated to: Awaiting Fulfillment'); } return true; } $order['ShippingTotalCost'] = $order['ShippingInsuranceCost'] + $order['ShippingCost']; // Buyer's address information $addressMap = array( 'Name', 'CompanyName', 'Street1', 'Street2', 'CityName', 'PostalCode', 'Country', 'CountryName', 'Phone', 'StateOrProvince', ); // Initialize the value, make sure it's not empty foreach ($addressMap as $key) { if (!isset($buyerInfoShippingAddress[$key])) { $buyerInfoShippingAddress[$key] = ''; } } $buyerCountryId = GetCountryIdByISO2($buyerInfoShippingAddress['Country']); $buyerStateId = GetStateByName($buyerInfoShippingAddress['StateOrProvince'], $buyerCountryId); $buyerStateName = $buyerInfoShippingAddress['StateOrProvince']; if (!$buyerStateId) { $buyerStateId = GetStateByAbbrev($buyerInfoShippingAddress['StateOrProvince'], $buyerCountryId); $stateInfo = GetStateInfoById($buyerStateId); $buyerStateName = $stateInfo['statename']; } // Tokenize buyer's first and last name $nameTokens = explode(' ', $buyerInfoShippingAddress['Name']); $buyerFirstName = $nameTokens[0]; $buyerLastName = ''; if (!empty($nameTokens[1])) { $buyerLastName = $nameTokens[1]; } $orderToken = generateOrderToken(); // Preparing data to be inserted to orders table $newOrder = array( 'ordtoken' => $orderToken, 'orderpaymentmodule' => '', 'orderpaymentmethod' => '', 'orderpaymentmodule' => '', 'extraInfo' => serialize(array()), 'orddefaultcurrencyid' => $order['Currency']['currencyid'], 'orddate' => time(), 'ordlastmodified' => time(), 'ordcurrencyid' => $order['Currency']['currencyid'], 'ordcurrencyexchangerate' => 1, 'ordipaddress' => GetIP(), 'ordcustmessage' => '', 'ordstatus' => $orderStatus, 'base_shipping_cost' => $order['ShippingTotalCost'], 'base_handling_cost' => 0, 'ordbillemail' => $buyerEmailAddress, 'ordbillfirstname' => $buyerFirstName, 'ordbilllastname' => $buyerLastName, 'ordbillcompany' => $buyerInfoShippingAddress['CompanyName'], 'ordbillstreet1' => $buyerInfoShippingAddress['Street1'], 'ordbillstreet2' => $buyerInfoShippingAddress['Street2'], 'ordbillsuburb' => $buyerInfoShippingAddress['CityName'], 'ordbillzip' => $buyerInfoShippingAddress['PostalCode'], 'ordbillcountrycode' => $buyerInfoShippingAddress['Country'], 'ordbillphone' => $buyerInfoShippingAddress['Phone'], 'ordbillstateid' => (int) $buyerStateId, 'ordbillstate' => $buyerStateName, 'ordbillcountry' => $buyerInfoShippingAddress['CountryName'], 'ordbillcountryid' => (int) $buyerCountryId, 'total_ex_tax' => $order['GrandTotal'], 'total_inc_tax' => $order['GrandTotal'], 'shipping_cost_ex_tax' => $order['ShippingTotalCost'], 'shipping_cost_inc_tax' => $order['ShippingTotalCost'], 'subtotal_inc_tax' => $order['SubTotal'], 'subtotal_ex_tax' => $order['SubTotal'], 'ebay_order_id' => $orderId, ); ResetStartingOrderNumber(); // Start the transaction $GLOBALS["ISC_CLASS_DB"]->StartTransaction(); // Inserting order data $newOrderId = $GLOBALS["ISC_CLASS_DB"]->InsertQuery('orders', $newOrder); if (!$newOrderId) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } $orderAddress = array( 'first_name' => $buyerFirstName, 'last_name' => $buyerLastName, 'company' => $buyerInfoShippingAddress['CompanyName'], 'address_1' => $buyerInfoShippingAddress['Street1'], 'address_2' => $buyerInfoShippingAddress['Street2'], 'city' => $buyerInfoShippingAddress['CityName'], 'zip' => $buyerInfoShippingAddress['PostalCode'], 'country_iso2' => $buyerInfoShippingAddress['Country'], 'phone' => $buyerInfoShippingAddress['Phone'], 'total_items' => $order['TotalQuantityPurchased'], 'email' => $buyerEmailAddress, 'country_id' => (int) $buyerCountryId, 'country' => $buyerInfoShippingAddress['CountryName'], 'state_id' => (int) $buyerStateId, 'state' => $buyerStateName, 'order_id' => $newOrderId, ); $addressId = $GLOBALS['ISC_CLASS_DB']->insertQuery('order_addresses', $orderAddress); if (!$addressId) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } // Inserting order shipping $orderShipping = array( 'order_address_id' => $addressId, 'order_id' => $newOrderId, 'base_cost' => $order['ShippingTotalCost'], 'cost_inc_tax' => $order['ShippingTotalCost'], 'cost_ex_tax' => $order['ShippingTotalCost'], 'method' => 'Available on eBay', ); if (!$GLOBALS['ISC_CLASS_DB']->insertQuery('order_shipping', $orderShipping)) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } // Go thru each sold item in the order foreach ($order['Transaction'] as $eachTransaction) { // Get product Id try { $itemObj = new ISC_ADMIN_EBAY_ITEMS($eachTransaction['ItemId']); $productId = $itemObj->getProductId(); } catch (Exception $e) { $this->log->LogSystemDebug('ebay', $e->getMessage()); return false; } // Inserting order product $productObj = new ISC_PRODUCT($productId); $newProduct = array( 'orderorderid' => $newOrderId, 'ordprodid' => $productId, 'ordprodsku' => $productObj->GetSKU(), 'ordprodname' => $productObj->GetProductName(), 'ordprodtype' => $productObj->GetProductType(), 'ordprodqty' => $eachTransaction['QuantityPurchased'], 'base_price' => $eachTransaction['TransactionPrice'], 'price_ex_tax' => $eachTransaction['TransactionPrice'], 'price_inc_tax' => $eachTransaction['TransactionPrice'], 'price_tax' => 0, 'base_total' => $eachTransaction['TotalTransactionPrice'], 'total_ex_tax' => $eachTransaction['TotalTransactionPrice'], 'total_inc_tax' => $eachTransaction['TotalTransactionPrice'], 'total_tax' => 0, 'base_cost_price' => 0, 'cost_price_inc_tax' => 0, 'cost_price_inc_tax' => 0, 'cost_price_tax' => 0, 'ordprodweight' => $productObj->GetWeight(false), 'ordprodoptions' => $eachTransaction['VariationOptionsString'], 'ordprodvariationid' => $productObj->_prodvariationid, 'ordprodwrapid' => 0, 'ordprodwrapname' => '', 'base_wrapping_cost' => 0, 'wrapping_cost_ex_tax' => 0, 'wrapping_cost_inc_tax' => 0, 'wrapping_cost_tax' => 0, 'ordprodwrapmessage' => '', 'ordprodeventname' => '', 'ordprodeventdate' => 0, 'ordprodfixedshippingcost' => $productObj->GetFixedShippingCost(), 'order_address_id' => $addressId, 'ebay_item_id' => $eachTransaction['ItemId'], 'ebay_transaction_id' => $eachTransaction['TransactionId'], ); $orderProductId = $GLOBALS['ISC_CLASS_DB']->insertQuery('order_products', $newProduct); if (!$orderProductId) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } if ($orderStatus == ORDER_STATUS_AWAITING_FULFILLMENT) { // update the item quantity in store $updatedData['quantity_remaining'] = $itemObj->getQuantityRemaining() - $eachTransaction['QuantityPurchased']; if (!$GLOBALS['ISC_CLASS_DB']->UpdateQuery('ebay_items', $updatedData, "ebay_item_id='" . $eachTransaction['ItemId'] . "'")) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } } } $GLOBALS["ISC_CLASS_DB"]->CommitTransaction(); // update the store inventory if necessary if (GetConfig('UpdateInventoryLevels') == 1) { DecreaseInventoryFromOrder($newOrderId); } // Trigger new order notifications SendOrderNotifications($orderToken); $this->log->LogSystemDebug('ebay', 'An Item ('. $body['Item']['ItemID'] .') has been paid by the buyer and added to the store order (' . $newOrderId. ').'); return true; } return false; }
/** * Redirect the customer to eSelectPlus's site to enter their payment details */ public function TransferToProvider() { $total = number_format($this->GetGatewayAmount(), 2,'.', ''); $this->_hostedpaypageid = $this->GetValue("hostedpaypageid"); $this->_hostedpaypagetoken = $this->GetValue("hostedpaypagetoken"); $testmode_on = $this->GetValue("testmode"); if ($testmode_on == "YES") { $eselectplus_url = "https://esplusqa.moneris.com/DPHPP/index.php"; } else { $eselectplus_url = "https://esplus.moneris.com/DPHPP/index.php"; } $billingDetails = $this->GetBillingDetails(); $shippingAddress = $this->getShippingAddress(); $formFields = array( 'hpp_id' => $this->_hostedpaypageid, 'hpp_key' => $this->_hostedpaypagetoken, 'amount' => $total, 'cust_id' => GetLang('eSelectPlusOrder', array('id' => $this->GetCombinedOrderId())), 'client_email' => $billingDetails['ordbillemail'], 'od_bill_company' => $billingDetails['ordbillcompany'], 'od_bill_firstname' => $billingDetails['ordbillfirstname'], 'od_bill_lastname' => $billingDetails['ordbilllastname'], 'od_bill_address' => $billingDetails['ordbillstreet1'] . ", " . $billingDetails['ordbillstreet2'], 'od_bill_city' => $billingDetails['ordbillsuburb'], 'od_bill_state' => $billingDetails['ordbillstate'], 'od_bill_zipcode' => $billingDetails['ordbillzip'], 'od_bill_country' => $billingDetails['ordbillcountry'], 'od_bill_phone' => $billingDetails['ordbillphone'], 'od_ship_company' => $shippingAddress['company'], 'od_ship_firstname' => $shippingAddress['first_name'], 'od_ship_lastname' => $shippingAddress['last_name'], 'od_ship_address' => $shippingAddress['address_1'] . ", " . $shippingAddress['address_2'], 'od_ship_city' => $shippingAddress['city'], 'od_ship_state' => $shippingAddress['state'], 'od_ship_zipcode' => $shippingAddress['zip'], 'od_ship_country' => $shippingAddress['country'], 'od_ship_phone' => $shippingAddress['phone'] ); // add the items $orders = $this->GetOrders(); $products = array(); foreach ($orders as $order) { $order = GetOrder($order['orderid']); foreach ($order['products'] as $product) { $products[] = $product; } } $i = 1; foreach ($products as $product) { $productFields = array( 'li_id'.$i => $product['ordprodsku'], 'li_description'.$i => $product['ordprodname'], 'li_quantity'.$i => $product['ordprodqty'], 'li_price'.$i => number_format($product['total_inc_tax'], 2,'.','') ); $formFields += $productFields; $i++; } // add the shipping $shipping_cost = $this->GetShippingCost() + $this->GetHandlingCost(); if ($shipping_cost > 0) { $formFields['li_shipping'] = number_format($shipping_cost, 2, '.', ''); } // add tax if ($this->GetTaxCost() > 0) { $formFields['li_taxes'] = number_format($this->GetTaxCost(), 2, '.', ''); } $this->RedirectToProvider($eselectplus_url, $formFields); }
/** * Show the form to create a new shipment from one or more items in an order. */ public function CreateShipment() { if(!isset($_REQUEST['orderId'])) { exit; } $order = GetOrder($_REQUEST['orderId']); if(!$order || !isset($order['orderid'])) { exit; } if ($order['ordisdigital'] == 1) { $this->template->display('modal.basic.tpl', array( 'title' => GetLang('CreateShipmentFromOrder'), 'message' => GetLang('DigitalOrderNoShipping'), )); exit; } if ($order['ordtotalqty'] - $order['ordtotalshipped'] <= 0) { $this->template->display('modal.basic.tpl', array( 'title' => GetLang('CreateShipmentFromOrder'), 'message' => GetLang('AllItemsShipped'), )); exit; } if(empty($_REQUEST['addressId'])) { $addressWhere = 'order_id='.$order['orderid']; } else { $addressWhere = 'order_id='.$order['orderid'].' AND id='.(int)$_REQUEST['addressId']; } // Fetch the address associated with this order $query = " SELECT * FROM [|PREFIX|]order_addresses WHERE ".$addressWhere." LIMIT 1 "; $result = $this->db->query($query); $address = $this->db->fetch($result); if(!$address) { exit; } $query = " SELECT * FROM [|PREFIX|]order_shipping WHERE order_address_id='".$address['id']."' "; $result = $this->db->query($query); $shipping = $this->db->fetch($result); $this->template->assign('address', $address); $this->template->assign('shipping', $shipping); $shipmentModules = array(); $shippingModules = getAvailableModules('shipping'); foreach($shippingModules as $module) { $shipmentModules[$module['id']] = $module['object']->getName(); } $this->template->assign('shippingModules', $shipmentModules); $GLOBALS['OrderId'] = $order['orderid']; $GLOBALS['OrderDate'] = CDate($order['orddate']); $GLOBALS['ShippingMethod'] = isc_html_escape($shipping['method']); $GLOBALS['OrderComments'] = isc_html_escape($order['ordcustmessage']); // Fetch out any items that have already been shipped for this order $shippedItems = array(); $query = " SELECT itemid, itemqty, itemordprodid FROM [|PREFIX|]shipment_items i INNER JOIN [|PREFIX|]shipments s ON ( s.shiporderid='".(int)$order['orderid']."' AND i.shipid=s.shipmentid ) INNER JOIN [|PREFIX|]order_products op ON (op.orderprodid = i.itemordprodid) WHERE op.order_address_id='".$address['id']."' "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while($shippedItem = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if(!isset($shippedItems[$shippedItem['itemordprodid']])) { $shippedItems[$shippedItem['itemordprodid']] = 0; } $shippedItems[$shippedItem['itemordprodid']] += $shippedItem['itemqty']; } // OK, now loop through all of the items going to this address and see what we can ship $query = " SELECT * FROM [|PREFIX|]order_products WHERE order_address_id='".$address['id']."' "; $result = $this->db->query($query); $GLOBALS['ProductList'] = ''; while($product = $this->db->fetch($result)) { $shippableQuantity = $product['ordprodqty']; if(isset($shippedItems[$product['orderprodid']])) { $shippableQuantity = $product['ordprodqty'] - $shippedItems[$product['orderprodid']]; } // Completely skip over this item if there's nothing to ship if($shippableQuantity <= 0 || $product['ordprodtype'] != 'physical') { continue; } $doneProducts = true; $GLOBALS['ProductName'] = isc_html_escape($product['ordprodname']); $GLOBALS['ProductId'] = $product['ordprodid']; $GLOBALS['HideGiftWrapping'] = 'display: none'; $GLOBALS['WrappingName'] = ''; $GLOBALS['WrappingMessage'] = ''; if($product['ordprodwrapid'] > 0) { $GLOBALS['HideGiftWrapping'] = ''; $GLOBALS['WrappingName'] = isc_html_escape($product['ordprodwrapname']); if($product['ordprodwrapmessage']) { $GLOBALS['WrappingMessage'] = nl2br(isc_html_escape($product['ordprodwrapmessage'])); } else { $GLOBALS['HideGiftWrappingMessage'] = 'display: none'; } } // Show the quantity as a dropdown if(GetConfig('TagCartQuantityBoxes') == 'dropdown') { $GLOBALS['QuantityInput'] = '<select class="QtyEntry" name="quantity['.$product['orderprodid'].']">'; for($i = $shippableQuantity; $i >= 0; --$i) { $sel = ''; if($i == $shippableQuantity) { $sel = 'selected="selected"'; } $GLOBALS['QuantityInput'] .= '<option value="'.$i.'" '.$sel.'>'.$i.'</option>'; } $GLOBALS['QuantityInput'] .= '</select>'; } // As a textbox else { $GLOBALS['QuantityInput'] = '<input class="QtyEntry Field50 MaxValue'.$shippableQuantity.'" type="text" value="'.$shippableQuantity.'" name="quantity['.$product['orderprodid'].']" style="text-align: center;" />'; } $GLOBALS['ProductList'] .= $this->template->render('Snippets/CreateShipmentItem.html'); } if(!isset($doneProducts)) { exit; } $this->template->display('shipments.create.tpl'); exit; }
/** * Send an email notification to a customer when the status of their order changes. * * @param int The ID of the order to email the invoice for. * @return boolean True if successful. */ function EmailOnStatusChange($orderId, $status) { // Load the order $order = GetOrder($orderId); if (!$order) { return false; } // Load the customer we'll be contacting if ($order['ordcustid'] > 0) { $customer = GetCustomer($order['ordcustid']); $GLOBALS['ViewOrderStatusLink'] = '<a href="'.$GLOBALS['ShopPathSSL'].'/orderstatus.php">'.GetLang('ViewOrderStatus').'</a>'; } else { $customer['custconemail'] = $order['ordbillemail']; $customer['custconfirstname'] = $order['ordbillfirstname']; $GLOBALS['ViewOrderStatusLink'] = ''; } if (empty($customer['custconemail'])) { return; } // All prices in the emailed invoices will be shown in the default currency of the store $defaultCurrency = GetDefaultCurrency(); $statusName = GetOrderStatusById($status); $GLOBALS['OrderStatusChangedHi'] = sprintf(GetLang('OrderStatusChangedHi'), isc_html_escape($customer['custconfirstname'])); $GLOBALS['OrderNumberStatusChangedTo'] = sprintf(GetLang('OrderNumberStatusChangedTo'), $order['orderid'], $statusName); $GLOBALS['OrderTotal'] = FormatPrice($order['total_inc_tax'], false, true, false, $defaultCurrency, true); $GLOBALS['DatePlaced'] = CDate($order['orddate']); if ($order['orderpaymentmethod'] === 'giftcertificate') { $GLOBALS['PaymentMethod'] = GetLang('PaymentGiftCertificate'); } else if ($order['orderpaymentmethod'] === 'storecredit') { $GLOBALS['PaymentMethod'] = GetLang('PaymentStoreCredit'); } else { $GLOBALS['PaymentMethod'] = $order['orderpaymentmethod']; } $query = " SELECT COUNT(*) FROM [|PREFIX|]order_products WHERE ordprodtype='digital' AND orderorderid='".$GLOBALS['ISC_CLASS_DB']->Quote($orderId)."' "; $numDigitalProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query); $emailTemplate = FetchEmailTemplateParser(); $GLOBALS['SNIPPETS']['CartItems'] = ""; if (OrderIsComplete($status) && $numDigitalProducts > 0) { $query = " SELECT * FROM [|PREFIX|]order_products op INNER JOIN [|PREFIX|]products p ON (op.ordprodid = p.productid) WHERE ordprodtype='digital' AND orderorderid='".$GLOBALS['ISC_CLASS_DB']->Quote($orderId)."' "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($product_row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $GLOBALS['ProductOptions'] = ''; $GLOBALS['ProductQuantity'] = $product_row['ordprodqty']; $GLOBALS['ProductName'] = isc_html_escape($product_row['ordprodname']); $GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT'); $DownloadItemEncrypted = $GLOBALS['ISC_CLASS_ACCOUNT']->EncryptDownloadKey($product_row['orderprodid'], $product_row['ordprodid'], $orderId, $order['ordtoken']); $GLOBALS['DownloadsLink'] = $GLOBALS['ShopPathSSL'].'/account.php?action=download_item&data='.$DownloadItemEncrypted; $GLOBALS['SNIPPETS']['CartItems'] .= $emailTemplate->GetSnippet("StatusCompleteDownloadItem"); } } $GLOBALS['SNIPPETS']['OrderTrackingLink'] = ""; $shipments = $GLOBALS['ISC_CLASS_DB']->Query(" SELECT shipmentid, shipdate, shiptrackno, shipping_module, shipmethod, shipcomments FROM [|PREFIX|]shipments WHERE shiporderid = " . (int)$orderId . " ORDER BY shipdate, shipmentid "); $GLOBALS['TrackingLinkList'] = ''; while($shipment = $GLOBALS['ISC_CLASS_DB']->Fetch($shipments)) { if (!$shipment['shiptrackno']) { continue; } GetModuleById('shipping', /** @var ISC_SHIPPING */$module, $shipment['shipping_module']); if ($module) { $link = $module->GetTrackingLink($shipment['shiptrackno']); if ($link) { $link = '<a href="' . isc_html_escape($link) . '" target="_blank">' . $shipment['shiptrackno'] . '</a>'; } else { $link = $shipment['shiptrackno']; } } else { $link = $shipment['shiptrackno']; } if($shipment['shipmethod']) { $link .= ' (' . $shipment['shipmethod'] . ')'; } if ($link) { $GLOBALS['TrackingLinkList'] .= '<li>' . $link . '</li>'; } } if (empty($GLOBALS['TrackingLinkList'])) { $GLOBALS['TrackingLinkList'] = GetLang('NoTrackingNumbersYet'); } else { $GLOBALS['TrackingLinkList'] = '<ul>' . $GLOBALS['TrackingLinkList'] . '</ul>'; } // Set up tracking numbers for orders. Whilst we don't have tracking numbers // on orders any longer, this code is being kept for legacy reasons where // orders may already have a tracking number saved. To be removed in a future // version. if (!empty($order['ordtrackingno'])) { $GLOBALS['HideTrackingText'] = ""; $GLOBALS['OrderTrackingNo'] = isc_html_escape($order['ordtrackingno']); // Let's instantiate an object for the shipper $shipper_object = false; if ($order['ordershipmodule'] != "" && GetModuleById('shipping', $shipper_object, $order['ordershipmodule'])) { // Does it have a link to track the order? if ($shipper_object->GetTrackingLink() != "") { // Show the tracking link $GLOBALS['TrackURL'] = $shipper_object->GetTrackingLink($order['ordtrackingno']); $GLOBALS['SNIPPETS']['OrderTrackingLink'] = $emailTemplate->GetSnippet("OrderTrackingLink"); } } } if (empty($GLOBALS['SNIPPETS']['CartItems'])) { $emailTemplate->SetTemplate("order_status_email"); } else { $emailTemplate->SetTemplate("order_status_downloads_email"); } $message = $emailTemplate->ParseTemplate(true); // Create a new email API object to send the email $store_name = GetConfig('StoreName'); $subject = GetLang('OrderStatusChangedSubject'); require_once(ISC_BASE_PATH . "/lib/email.php"); $obj_email = GetEmailClass(); $obj_email->Set('CharSet', GetConfig('CharacterSet')); $obj_email->From(GetConfig('OrderEmail'), $store_name); $obj_email->Set('Subject', $subject); $obj_email->AddBody("html", $message); $obj_email->AddRecipient($customer['custconemail'], '', "h"); $email_result = $obj_email->Send(); if ($email_result['success']) { return true; } else { return false; } }
/** * Voids an authorized transaction * * @param mixed $orderId * @param mixed $transactionId * @param string $message */ public function DoVoid($orderId, $transactionId, &$message = '') { $order = GetOrder($orderId); $extraInfo = @unserialize($order['extrainfo']); if (!is_array($extraInfo) || empty($extraInfo['CyberSourceRequestToken']) || empty($extraInfo['CyberSourceRequestID'])) { $message = GetLang('CyberSourceTransactionDetailsMissing'); return false; } $request = array( 'merchantID' => $this->GetValue('merchantid'), 'merchantReferenceCode' => $orderId, 'ccAuthReversalService' => array( 'authRequestID' => $extraInfo['CyberSourceRequestID'], 'run' => 'true', ), 'orderRequestToken' => $extraInfo['CyberSourceRequestToken'], 'purchaseTotals' => array( 'currency' => GetCurrencyCodeByID($order['ordcurrencyid']), 'grandTotalAmount' => number_format($order['total_inc_tax'], 2, '.', ''), ), ); $response = $this->runTransaction($request); if (!isset($response['decision'])) { $message = GetLang('CyberSourceInvalidRequest'); return false; } $decision = $response['decision']; $reasonCode = $response['reasonCode']; $requestID = $response['requestID']; $requestToken = $response['requestToken']; $transactionType = GetLang('CyberSourceTransactionTypeVoid'); if ($decision == 'ACCEPT') { $message = GetLang('CyberSourcePaymentVoided'); unset($extraInfo['CyberSourceRequestID']); unset($extraInfo['CyberSourceRequestToken']); // Mark the order as captured $updatedOrder = array( 'ordpaymentstatus' => 'void', 'extrainfo' => serialize($extraInfo), ); // Update the orders table with new transaction details $GLOBALS['ISC_CLASS_DB']->UpdateQuery('orders', $updatedOrder, "orderid='".(int)$orderId."'"); $authorizationCode = ''; if (isset($response['ccAuthReversalReply']['authorizationCode'])) { $authorizationCode = $response['ccAuthReversalReply']['authorizationCode']; } // Log the transaction in store logs $logMessage = GetLang('CyberSourcePaymentVoidedLogMsg', array('orderId' => $orderId)); $logDetails = GetLang('CyberSourcePaymentVoidedLogDetails', array( 'decision' => $decision, 'reasonCode' => $reasonCode, 'requestID' => $requestID, 'authorizationCode' => $authorizationCode, 'transactionType' => $transactionType, )); $GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess(array('payment', $this->GetName()), $logMessage, $logDetails); return true; } else { $message = GetLang('CyberSourceVoidFailed'); // any missing fields? $missingFieldsString = ''; if (isset($response['missingField'])) { $missingFields = $response['missingField']; if (!is_array($missingFields)) { $missingFields = array($missingFields); } $missingFieldsString = implode(', ', $missingFields); } //any invalid fields? $invalidFieldsString = ''; if (isset($response['invalidField'])) { $invalidFields = $response['invalidField']; if (!is_array($invalidFields)) { $invalidFields = array($invalidFields); } $invalidFieldsString = implode(', ', $invalidFields); } $logMessage = GetLang('CyberSourceVoidFailedLogMsg', array('orderId' => $orderId)); $logDetails = GetLang('CyberSourceFailureDetails', array( 'decision' => $decision, 'reasonCode' => $reasonCode, 'requestID' => $requestID, 'transactionType' => $transactionType, 'missingFields' => $missingFieldsString, 'invalidFields' => $invalidFieldsString, )); $GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment', $this->GetName()), $logMessage, $logDetails); return false; } }
/** * Update the order status of a specific order from the manage orders page * * @return void **/ private function UpdateOrderStatus() { $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->LoadLangFile('orders'); if(isset($_REQUEST['o']) && isset($_REQUEST['s'])) { $order_id = (int)$_REQUEST['o']; $status = (int)$_REQUEST['s']; $order = GetOrder($order_id); if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $order['ordvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { echo 0; exit; } if (UpdateOrderStatus($order_id, $status)) { echo 1; } else { echo 0; } } else { echo 0; } exit; }
function PrintCheckedOrderList($servername, $username, $password, $dbname, $orderlist) { require_once 'EAN13.php'; $pdf = new PDF_EAN13('P', 'mm', array(105, 148)); // echo "PrintCheckedOrderList for: " . $orderlist . "<br><br>"; $orders = explode(";", $orderlist); foreach ($orders as $order) { if ($order != "") { $order_db = GetOrder($order); $orderlines = GetOrderLine($order_db->entity_id, $order); CreatePDFFile($servername, $username, $password, $dbname, $order_db, $orderlines, false, $pdf); } } $nomFacture = getcwd() . "/upload/Reservierungen_checked_orders.pdf"; $pdf->Output($nomFacture); echo "Reservierungszettel für <a href=\"" . "upload/Reservierungen_checked_orders.pdf" . "\">" . "alle angekreuzten Bestellunen</a> drucken.<br><br>"; foreach ($orders as $order) { if ($order != "") { $order_db = GetOrder($order); $orderlines = GetOrderLine($order_db->entity_id, $order); CreatePDFFile($servername, $username, $password, $dbname, $order_db, $orderlines, true, null); } } echo "<b>zum beenden bitte Tab schliessen</b>"; exit; }
private function ViewOrderNotes() { if (!isset($_REQUEST['orderId']) || !isId($_REQUEST['orderId'])) { exit; } // Load the order $order = GetOrder($_REQUEST['orderId']); if (!$order || $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $order['ordvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { exit; } $GLOBALS['OrderID'] = $order['orderid']; $GLOBALS['OrderNotes'] = isc_html_escape($order['ordnotes']); $GLOBALS['ThankYouID'] = 'CustomerStatus'; $GLOBALS["ISC_CLASS_TEMPLATE"]->SetTemplate("orders.notes.popup"); $GLOBALS["ISC_CLASS_TEMPLATE"]->ParseTemplate(); }
public function UpdateReturnStatus(&$return, $status, $crediting = false) { // Start a transaction $GLOBALS['ISC_CLASS_DB']->Query("START TRANSACTION"); if ($status == 5 && $return['retstatus'] != 5) { // Changing the status of this return to "Refunded", so we need to perform some additional things $refundAmount = $return['retprodcost'] * $return['retprodqty']; // Grab the order if it still exists to provide a refund on the tax as well $order = GetOrder($return['retorderid']); if ($order['ordtotalincludestax'] == 0 && $order['ordtaxrate'] > 0) { $taxCharged = number_format($refundAmount / 100 * $order['ordtaxrate'], GetConfig('DecimalPlaces'), '.', ''); $refundAmount += $taxCharged; } $updatedProduct = array("ordprodrefundamount" => $return['retprodcost'], "ordprodrefunded" => $return['retprodqty'], "ordprodreturnid" => $return['returnid']); $GLOBALS['ISC_CLASS_DB']->UpdateQuery("order_products", $updatedProduct, "orderprodid='" . $GLOBALS['ISC_CLASS_DB']->Quote($return['retordprodid']) . "'"); // Fetch the total for this order $query = sprintf("SELECT ordsubtotal, ordtotalamount FROM [|PREFIX|]orders WHERE orderid='%s'", $return['retorderid']); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $orderTotal = $GLOBALS['ISC_CLASS_DB']->Fetch($result); // Reduce the order total by retprodcost x retprodqty (the price we paid x the quantity being returned) $orderSubTotal = $orderTotal['ordsubtotal'] - $refundAmount; if ($orderSubTotal <= 0) { $orderSubTotal = 0; } $orderTotalAmount = $orderTotal['ordtotalamount'] - $orderTotal['ordsubtotal'] + $orderSubTotal; if ($orderTotalAmount <= 0) { $orderTotalAmount = 0; } $updatedOrder = array("ordsubtotal" => $orderSubTotal, "ordtotalamount" => $orderTotalAmount); // If the amount of tax has changed, need to update that total too if (isset($taxCharged)) { $updatedOrder['ordtaxtotal'] = $order['ordtaxtotal'] - $taxCharged; } else { if ($order['ordtotalincludestax']) { $taxCharged = $refundAmount / (100 + $order['ordtaxrate']) * $order['ordtaxrate']; $taxCharged = number_format($taxCharged, GetConfig('DecimalPlaces'), '.', ''); $updatedOrder['ordtaxtotal'] = $order['ordtaxtotal'] - $taxCharged; } } if ($orderTotalAmount == 0) { $updatedOrder['ordtaxtotal'] = 0; } // Have all items in this order been refunded? Mark the order as refunded. $query = sprintf("SELECT SUM(ordprodqty-ordprodrefunded) FROM [|PREFIX|]order_products WHERE orderorderid=%d", $return['retorderid']); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $remainingItems = $GLOBALS['ISC_CLASS_DB']->FetchOne($result); if ($remainingItems == 0) { $updatedOrder['ordstatus'] = 4; } $GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updatedOrder, "orderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($return['retorderid']) . "'"); // Update the status of this return $updatedReturn = array("retstatus" => 5, "retuserid" => $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetUserId()); $GLOBALS['ISC_CLASS_DB']->UpdateQuery("returns", $updatedReturn, "returnid='" . $GLOBALS['ISC_CLASS_DB']->Quote($return['returnid']) . "'"); // Update the product inventory for this returned item $query = sprintf("SELECT * FROM [|PREFIX|]order_products WHERE ordprodid='%d'", $return['retordprodid']); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result); UpdateInventoryOnReturn($return['retordprodid']); // dont send a refund through the checkout module if a store credit was issued if (!$crediting) { // If the checkout module that was used for an order is still enabled and has a function // to handle a status change, then call that function $valid_checkout_modules = GetAvailableModules('checkout', true, true); $valid_checkout_module_ids = array(); foreach ($valid_checkout_modules as $valid_module) { $valid_checkout_module_ids[] = $valid_module['id']; } $newStatus = $order['ordstatus']; if (isset($updatedOrder['ordstatus'])) { $newStatus = $updatedOrder['ordstatus']; } // attempt to refund this amount with the checkout provider $order = GetOrder($return['retorderid'], false); if (in_array($order['orderpaymentmodule'], $valid_checkout_module_ids)) { GetModuleById('checkout', $checkout_module, $order['orderpaymentmodule']); if (method_exists($checkout_module, 'HandleStatusChange')) { call_user_func(array($checkout_module, 'HandleStatusChange'), $return['retorderid'], $order['ordstatus'], $newStatus, $refundAmount); } } } } else { // Update the status of this return $updatedReturn = array("retstatus" => $status); $GLOBALS['ISC_CLASS_DB']->UpdateQuery("returns", $updatedReturn, "returnid='" . $GLOBALS['ISC_CLASS_DB']->Quote($return['returnid']) . "'"); } $return['retstatus'] = $status; if (GetConfig('NotifyOnReturnStatusChange') == 1) { $this->EmailReturnStatusChange($return); } if ($GLOBALS['ISC_CLASS_DB']->GetErrorMsg() == "") { $GLOBALS['ISC_CLASS_DB']->Query("COMMIT"); return true; } else { return false; } }
$orders[$i]['color'] = '#f7f7f7'; } else { $orders[$i]['color'] = '#ffffff'; } $i++; } $j++; } } function ShowOrder() { global $tpl, $orders, $expire_in; $tpl->assign('pf', $_REQUEST['pf']); $tpl->assign('expire_in', $expire_in); $tpl->assign('orders', $orders); $tpl->assign('error', $error_list); $tpl->display('index.html'); } /*============================================================================================= Main Program =============================================================================================*/ switch ($_REQUEST['pf']) { case 'renewal': RenewOrder(); break; case '': default: GetOrder(); ShowOrder(); break; }
private function restoreOrderActionHandler ($orderId) { if (!$this->auth->HasPermission(AUTH_Undelete_Orders)) { return array( 'success' => false, ); } $orderId = (int)$orderId; if (!$orderId) { return array( 'success' => false, ); } $order = GetOrder($orderId, false, false, true); if (!$order) { return array( 'success' => false, ); } $entity = new ISC_ENTITY_ORDER; if (!$entity->undelete($orderId)) { return array( 'success' => false, ); } FlashMessage(GetLang('iphoneRestoreOrderSuccess', array( 'orderId' => $orderId, )), MSG_SUCCESS); return array( 'success' => true, ); }
/** * Load all of the products from an order in to the cart session. * * @param int The ID of the order to pull the items from. */ public function LoadInOrderItems($orderId) { require_once ISC_BASE_PATH . '/lib/discountcalcs.php'; $this->cartSession['NUM_ITEMS'] = 0; // Load any products in the order and set them up in the session $query = "\n\t\t\tSELECT a.*,b.*,c.prodsaleprice\n\t\t\tFROM [|PREFIX|]order_products a LEFT JOIN [|PREFIX|]user_ymm b ON a.orderymmid=b.id\n\t\t\tLEFT JOIN [|PREFIX|]products c ON a.ordprodid=c.productid \n\t\t\tWHERE orderorderid='" . (int) $orderId . "'\n\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $cartItem = array('product_id' => $product['ordprodid'], 'variation_id' => $product['ordprodvariationid'], 'options' => @unserialize($product['ordprodoptions']), 'quantity' => $product['ordprodqty'], 'original_quantity' => $product['ordprodqty'], 'product_name' => $product['ordprodname'], 'product_price' => $product['ordprodcost'] < $product['ordprodoriginalcost'] && $product['ordprodcost'] > 0 ? $product['ordprodcost'] : $product['ordprodoriginalcost'], 'original_price' => $product['ordoriginalprice'], 'bulkdiscount_type' => '', 'bulkdiscount' => '', 'product_code' => $product['ordprodsku'], 'type' => $product['ordprodtype'], 'refunded_qty' => $product['ordprodrefunded'], 'product_fields' => array(), 'event_name' => $product['ordprodeventname'], 'event_date' => $product['ordprodeventdate'], 'existing_order_product' => $product['orderprodid'], 'year' => $product['year'], 'make' => $product['make'], 'model' => $product['model']); switch ($product['ordprodtype']) { case "physical": $prodtype = PT_PHYSICAL; break; case "digital": $prodtype = PT_DIGITAL; break; case "giftcertificate": $prodtype = PT_GIFTCERTIFICATE; break; } $cartItem['data'] = array('prodname' => $product['ordprodname'], 'prodtype' => $prodtype, 'prodcostprice' => $product['ordprodcostprice'], 'prodvariationid' => $product['ordprodvariationid'], 'prodistaxable' => $product['ordprodistaxable'], 'prodfixedshippingcost' => $product['ordprodfixedshippingcost'], 'prodwrapoptions' => 0, 'prodinvtrack' => 0, 'prodwidth' => 0, 'prodheight' => 0, 'proddepth' => 0, 'prodweight' => 0); if ($product['ordprodwrapname'] != '') { $cartItem['wrapping'] = array('wrapid' => $product['ordprodwrapid'], 'wrapname' => $product['ordprodwrapname'], 'wrapprice' => $product['ordprodwrapcost'], 'wrapmessage' => $product['ordprodwrapmessage']); $cartItem['data']['prodwrapoptions'] = $product['ordprodwrapid']; } // check if this product exists and apply other data $query = "SELECT * FROM [|PREFIX|]products WHERE productid = " . $cartItem['product_id']; $rescheck = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($checkProduct = $GLOBALS['ISC_CLASS_DB']->Fetch($rescheck)) { $loadFields = array('prodinvtrack', 'prodcurrentinv', 'prodfreeshipping', 'prodwidth', 'prodheight', 'proddepth', 'prodweight'); foreach ($loadFields as $field) { $cartItem['data'][$field] = $checkProduct[$field]; } } $this->cartSession['ITEMS'][$product['orderprodid']] = $cartItem; $this->cartSession['NUM_ITEMS'] += $product['ordprodqty']; } // Load any configurable fields and apply them too $query = "\n\t\t\tSELECT *\n\t\t\tFROM [|PREFIX|]order_configurable_fields\n\t\t\tWHERE orderid='" . (int) $orderId . "'\n\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($configurableField = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if (!isset($this->cartSession['ITEMS'][$configurableField['ordprodid']])) { continue; } if ($configurableField['fieldtype'] == 'file') { $field = array('fieldType' => $configurableField['fieldtype'], 'fieldName' => $configurableField['fieldname'], 'fileType' => $configurableField['filetype'], 'fileOriginName' => $configurableField['originalfilename'], 'fileName' => $configurableField['filename'], 'fieldExisting' => true); } else { $field = array('fieldType' => $configurableField['fieldtype'], 'fieldName' => $configurableField['fieldname'], 'fieldValue' => $configurableField['textcontents']); } $this->cartSession['ITEMS'][$configurableField['ordprodid']]['product_fields'][$configurableField['fieldid']] = $field; } // load coupons $query = "\n\t\t\tSELECT *\n\t\t\tFROM [|PREFIX|]order_coupons\n\t\t\tWHERE ordcouporderid='" . (int) $orderId . "'\n\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($coupon = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $this->cartSession['ITEMS'][$coupon['ordcoupprodid']]['discount'] = $coupon['ordcouponamount']; $this->cartSession['ITEMS'][$coupon['ordcoupprodid']]['couponcode'] = $coupon['ordcouponcode']; $this->cartSession['ITEMS'][$coupon['ordcoupprodid']]['coupon'] = $coupon['ordcouponid']; $this->cartSession['ITEMS'][$coupon['ordcoupprodid']]['coupontype'] = $coupon['ordcoupontype']; $this->cartSession['ITEMS'][$coupon['ordcoupprodid']]['exists_order_coupon'] = true; } // dada.wang 20120409 load cgc $orderClass = GetClass('ISC_ADMIN_ORDERS'); $orderData = GetOrder($orderId); $this->cartSession['COMPANYGIFTCERTIFICATES'] = $orderClass->GetOrderCompanyGiftCertificatesUsed($orderData); $this->cartSession['GIFTCERTIFICATES'] = $orderClass->GetOrderGiftCertificatesUsed($orderData); }
/** * Handle a change of financial state of an order * * @param array $data The google request array * * @return void **/ private function HandleFinancialStateChange($data) { $googleid = $data['google-order-number']['VALUE']; $orderid = $this->GetOrderIdByGoogleId($googleid); if ($orderid === false) { return; } $new_financial_state = $data['new-financial-order-state']['VALUE']; switch ($new_financial_state) { case 'REVIEWING': UpdateOrderStatus($orderid, ORDER_STATUS_PENDING, false, true); $GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess($this->logtype, sprintf(GetLang('GoogleCheckoutOrderStatusUpdated'), $orderid, GetOrderStatusById(ORDER_STATUS_PENDING))); break; case 'CHARGEABLE': UpdateOrderStatus($orderid, ORDER_STATUS_AWAITING_PAYMENT, false, true); $GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess($this->logtype, sprintf(GetLang('GoogleCheckoutOrderStatusUpdated'), $orderid, GetOrderStatusById(ORDER_STATUS_AWAITING_PAYMENT))); break; case 'CHARGING': // We don't need to do anything on our end when Google is midway through charging an order break; case 'CHARGED': $order = GetOrder($orderid, false); if (!OrderIsComplete($order['ordstatus'])) { $this->module->debuglog($order); if ($order['ordisdigital'] == 1) { UpdateOrderStatus($orderid, ORDER_STATUS_COMPLETED, true, true); $GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess($this->logtype, sprintf(GetLang('GoogleCheckoutOrderStatusUpdated'), $orderid, GetOrderStatusById(ORDER_STATUS_COMPLETED))); } else { $status = $this->module->GetValue('orderchargestatus'); if (!$status) { $status = ORDER_STATUS_AWAITING_FULFILLMENT; } UpdateOrderStatus($orderid, $status, false, true); $GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess($this->logtype, sprintf(GetLang('GoogleCheckoutOrderStatusUpdated'), $orderid, GetOrderStatusById($status))); } } break; case 'PAYMENT_DECLINED': UpdateOrderStatus($orderid, ORDER_STATUS_DECLINED, false, true); $GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess($this->logtype, sprintf(GetLang('GoogleCheckoutOrderStatusUpdated'), $orderid, GetOrderStatusById(ORDER_STATUS_DECLINED))); break; case 'CANCELLED': UpdateOrderStatus($orderid, ORDER_STATUS_CANCELLED, false, true); $GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess($this->logtype, sprintf(GetLang('GoogleCheckoutOrderStatusUpdated'), $orderid, GetOrderStatusById(ORDER_STATUS_CANCELLED))); break; case 'CANCELLED_BY_GOOGLE': UpdateOrderStatus($orderid, ORDER_STATUS_CANCELLED, false, true); $GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess($this->logtype, sprintf(GetLang('GoogleCheckoutOrderStatusUpdated'), $orderid, GetOrderStatusById(ORDER_STATUS_CANCELLED))); break; default: break; } }
echo "<div class=\"ac_results\" style=\"display: none; position: absolute;\"></div>"; echo "<div class=\"ac_results\" style=\"position: absolute; width: 169px; top: 530px; left: 179px; display: none;\">"; echo "<ul><li></li></ul></div>"; echo "</table>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "<p><input type=\"button\" onclick=\"searchartikle()\" style=\"font-family: Arial; font-size: 12pt; height: 24px\" value=\"Artikelstamm aktualisieren\"/></p>"; echo "<p id='result'></p>"; } else { $order = substr($eanorder, 0, strlen($eanorder) - 1); $order = ltrim($order, '0'); if ($order != "") { $order_db = GetOrder($order); $orderlines = GetOrderLine($order_db->entity_id, $order); if ($order_db->entity_id != "") { echo CreateOrderHead($order_db, $MKZ, $UGP); echo CreateOrderArticle($orderlines, $MKZ, $UGP, true); $orderfound = true; } else { $orderfound = false; $link = OpenDatabase(); $sql = "SELECT * FROM `Artikel` where `ean` = " . $eanorder; $res = mysql_query($sql, $link); $art = new Article(); $articlefound = false; if ($art = mysql_fetch_object($res)) { $articlefound = true; echo GetUserInfo();
public function UpdateReviewRequestStatus($orderIds, $status) { if (!is_array($orderIds)) { $orderIds = array($orderIds); } foreach ($orderIds as $orderId) { $order = GetOrder($orderId, false); if (!$order['orderid']) { return false; } // Start transaction $GLOBALS['ISC_CLASS_DB']->Query("START TRANSACTION"); $updatedStatus = array('requestdate' => date('Y-m-d H:i:s', time()), "requeststatus" => (int) $status); // Update the status for this order review request if ($GLOBALS['ISC_CLASS_DB']->UpdateQuery("requests", $updatedStatus, "orderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($orderId) . "'")) { // Log this action if we are in the control panel if (defined('ISC_ADMIN_CP')) { //$GLOBALS['ISC_CLASS_LOG']->LogAdminAction($orderId, $statusName); } } // Was there an error? If not, commit if ($GLOBALS['ISC_CLASS_DB']->Error() == "") { $GLOBALS['ISC_CLASS_DB']->Query("COMMIT"); return true; } else { return false; } } return false; }
/** * Update the tracking number of an order from the manage orders page * * @return void **/ private function UpdateTrackingNo() { if (isset($_REQUEST['o']) && isset($_REQUEST['tn'])) { $order_id = (int) $_REQUEST['o']; $order = GetOrder($order_id); if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $order['ordvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { echo 0; exit; } $trackingno = $GLOBALS['ISC_CLASS_DB']->Quote($_REQUEST['tn']); $updatedOrder = array("ordtrackingno" => $_REQUEST['tn']); if ($GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updatedOrder, "orderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($order_id) . "'")) { echo "1"; } else { echo "0"; } // If the checkout module that was used for an order is still enabled and has a function // to handle a status change, then call that function $valid_checkout_modules = GetAvailableModules('checkout', true, true); $valid_checkout_module_ids = array(); foreach ($valid_checkout_modules as $valid_module) { $valid_checkout_module_ids[] = $valid_module['id']; } $query = "SELECT *\n\t\t\t\tFROM [|PREFIX|]orders\n\t\t\t\tWHERE orderid = '" . $GLOBALS['ISC_CLASS_DB']->Quote($order_id) . "'"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $order = $GLOBALS['ISC_CLASS_DB']->Fetch($result); if (in_array($order['orderpaymentmodule'], $valid_checkout_module_ids)) { GetModuleById('checkout', $checkout_module, $order['orderpaymentmodule']); if (method_exists($checkout_module, 'HandleUpdateTrackingNum')) { call_user_func(array($checkout_module, 'HandleUpdateTrackingNum'), $order_id, $trackingno); } } // Log this action $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($order_id, $trackingno); } }
/** * Show the form to create a new shipment from one or more items in an order. */ public function CreateShipment() { if (!isset($_REQUEST['orderId'])) { exit; } $order = GetOrder($_REQUEST['orderId'], true); if (!isset($order['orderid']) || $order['ordisdigital'] == 1 || $order['ordtotalqty'] - $order['ordtotalshipped'] <= 0) { exit; } $GLOBALS['OrderId'] = $order['orderid']; $GLOBALS['OrderDate'] = CDate($order['orddate']); $GLOBALS['ShippingMethod'] = isc_html_escape($order['ordshipmethod']); $GLOBALS['TrackingNumber'] = isc_html_escape($order['ordtrackingno']); $GLOBALS['OrderComments'] = isc_html_escape($order['ordcustmessage']); // Fetch out any items that have already been shipped for this order $shippedItems = array(); $query = "\n\t\t\tSELECT itemid, itemqty, itemordprodid\n\t\t\tFROM [|PREFIX|]shipment_items i\n\t\t\tINNER JOIN [|PREFIX|]shipments s ON (s.shiporderid='" . (int) $order['orderid'] . "' AND i.shipid=s.shipmentid)\n\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($shippedItem = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if (!isset($shippedItems[$shippedItem['itemordprodid']])) { $shippedItems[$shippedItem['itemordprodid']] = 0; } $shippedItems[$shippedItem['itemordprodid']] += $shippedItem['itemqty']; } // OK, now loop through all of the items in the order and build the list of what we can ship $GLOBALS['ProductList'] = ''; foreach ($order['products'] as $product) { $shippableQuantity = $product['ordprodqty']; if (isset($shippedItems[$product['orderprodid']])) { $shippableQuantity = $product['ordprodqty'] - $shippedItems[$product['orderprodid']]; } // Completely skip over this item if there's nothing to ship if ($shippableQuantity <= 0 || $product['ordprodtype'] != 'physical') { continue; } $doneProducts = true; $GLOBALS['ProductName'] = isc_html_escape($product['ordprodname']); $GLOBALS['ProductId'] = $product['ordprodid']; $GLOBALS['ProductPrice'] = FormatPrice($product['ordprodcost']); $GLOBALS['HideGiftWrapping'] = 'display: none'; $GLOBALS['WrappingName'] = ''; $GLOBALS['WrappingMessage'] = ''; if ($product['ordprodwrapid'] > 0) { $GLOBALS['HideGiftWrapping'] = ''; $GLOBALS['WrappingName'] = isc_html_escape($product['ordprodwrapname']); if ($product['ordprodwrapmessage']) { $GLOBALS['WrappingMessage'] = nl2br(isc_html_escape($product['ordprodwrapmessage'])); } else { $GLOBALS['HideGiftWrappingMessage'] = 'display: none'; } } // Show the quantity as a dropdown if (GetConfig('TagCartQuantityBoxes') == 'dropdown') { $GLOBALS['QuantityInput'] = '<select class="QtyEntry" name="quantity[' . $product['orderprodid'] . ']">'; for ($i = $shippableQuantity; $i >= 0; --$i) { $sel = ''; if ($i == $shippableQuantity) { $sel = 'selected="selected"'; } $GLOBALS['QuantityInput'] .= '<option value="' . $i . '" ' . $sel . '>' . $i . '</option>'; } $GLOBALS['QuantityInput'] .= '</select>'; } else { $GLOBALS['QuantityInput'] = '<input class="QtyEntry Field50 MaxValue' . $shippableQuantity . '" type="text" value="' . $shippableQuantity . '" name="quantity[' . $product['orderprodid'] . ']" style="text-align: center;" />'; } $GLOBALS['ProductList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CreateShipmentItem'); } if (!isset($doneProducts)) { exit; } $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate('shipments.create'); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); exit; }
public function DoVoid($orderId, $transactionId, &$message = '') { if ($this->GetValue("testmode") == 'YESLIVE') { $trainingMode = 'T'; } else { $trainingMode = 'F'; } $order = GetOrder($orderId); $request = array( 'UserName' => $this->GetValue('username'), 'Password' => $this->GetValue('password'), 'TransType' => 'Void', 'PNRef' => $transactionId, 'CardNum' => '', 'ExpDate' => '', 'MagData' => '', 'NameOnCard' => '', 'Amount' => number_format($order['total_inc_tax'], 2, '.', ''), 'InvNum' => '', 'Zip' => '', 'Street' => '', 'CVNum' => '', 'ExtData' => '<TrainingMode>' . $trainingMode . '</TrainingMode>' ); if($this->GetValue('testmode') == 'YES') { $url = $this->_testTransactionURL.$this->_testTransactionURI; } else { $url = $this->_liveTransactionURL.$this->_liveTransactionURI; } $response = PostToRemoteFileAndGetResponse($url, http_build_query($request)); try { $xml = new SimpleXMLElement($response); } catch (Exception $e) { // Something went wrong, show the error message. $message = GetLang('PayLeapVoidFailed'); return false; } $responseCode = ''; $responseMessage = ''; if (isset($xml->Result)) { $responseCode = (string)$xml->Result; } if (isset($xml->RespMSG)) { $responseMessage = (string)$xml->RespMSG; } if($responseCode == 0 && $responseMessage == 'Approved') { $message = GetLang('PayLeapPaymentVoided'); // Mark the order as captured $updatedOrder = array( 'ordpaymentstatus' => 'void' ); // Update the orders table with new transaction details $GLOBALS['ISC_CLASS_DB']->UpdateQuery('orders', $updatedOrder, "orderid='".(int)$orderId."'"); // Log the transaction in store logs $logMessage = GetLang('PayLeapPaymentVoidedLogMsg', array( 'orderId' => $orderId )); $GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess(array('payment', $this->GetName()), $logMessage); return true; } else { $message = GetLang('PayLeapVoidFailed'); $logMessage = GetLang('PayLeapVoidFailedLogMsg', array( 'orderId' => $orderId )); $logDetails = GetLang('PayLeapVoidFailedLogDetails', array( 'paymentReference' => $transactionId, 'responseCode' => $responseCode, 'responseMessage' => $responseMessage )); $GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment', $this->GetName()), $logMessage, $logDetails); return false; } }
/** * Send an email notification to a customer when the status of their order changes. * * @param int The ID of the order to email the invoice for. * @return boolean True if successful. */ function EmailOnStatusChange($orderId, $status) { // Load the order $order = GetOrder($orderId); // Load the customer we'll be contacting if ($order['ordcustid'] > 0) { $customer = GetCustomer($order['ordcustid']); $GLOBALS['ViewOrderStatusLink'] = '<a href="' . $GLOBALS['ShopPathSSL'] . '/orderstatus.php">' . GetLang('ViewOrderStatus') . '</a>'; } else { $customer['custconemail'] = $order['ordbillemail']; $customer['custconfirstname'] = $order['ordbillfirstname']; $GLOBALS['ViewOrderStatusLink'] = ''; } if (empty($customer['custconemail'])) { return; } // All prices in the emailed invoices will be shown in the default currency of the store $defaultCurrency = GetDefaultCurrency(); $statusName = GetOrderStatusById($status); $GLOBALS['ISC_LANG']['OrderStatusChangedHi'] = sprintf(GetLang('OrderStatusChangedHi'), isc_html_escape($customer['custconfirstname'])); $GLOBALS['ISC_LANG']['OrderNumberStatusChangedTo'] = sprintf(GetLang('OrderNumberStatusChangedTo'), $order['orderid'], $statusName); $GLOBALS['OrderTotal'] = FormatPrice($order['ordtotalamount'], false, true, false, $defaultCurrency, true); $GLOBALS['DatePlaced'] = CDate($order['orddate']); if ($order['orderpaymentmethod'] === 'giftcertificate') { $GLOBALS['PaymentMethod'] = GetLang('PaymentGiftCertificate'); } else { if ($order['orderpaymentmethod'] === 'storecredit') { $GLOBALS['PaymentMethod'] = GetLang('PaymentStoreCredit'); } else { $GLOBALS['PaymentMethod'] = $order['orderpaymentmethod']; } } $query = "\n\t\tSELECT COUNT(*)\n\t\tFROM [|PREFIX|]order_products\n\t\tWHERE ordprodtype='digital'\n\t\tAND orderorderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($orderId) . "'\n\t"; $numDigitalProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query); $emailTemplate = FetchEmailTemplateParser(); $GLOBALS['SNIPPETS']['CartItems'] = ""; if (OrderIsComplete($status) && $numDigitalProducts > 0) { $query = "\n\t\t\tSELECT *\n\t\t\tFROM [|PREFIX|]order_products op INNER JOIN [|PREFIX|]products p ON (op.ordprodid = p.productid)\n\t\t\tWHERE ordprodtype='digital'\n\t\t\tAND orderorderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($orderId) . "'\n\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($product_row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $GLOBALS['ProductOptions'] = ''; $GLOBALS['ProductQuantity'] = $product_row['ordprodqty']; $GLOBALS['ProductName'] = isc_html_escape($product_row['ordprodname']); $GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT'); $DownloadItemEncrypted = $GLOBALS['ISC_CLASS_ACCOUNT']->EncryptDownloadKey($product_row['orderprodid'], $product_row['ordprodid'], $orderId, $order['ordtoken']); $GLOBALS['DownloadsLink'] = $GLOBALS['ShopPathSSL'] . '/account.php?action=download_item&data=' . $DownloadItemEncrypted; $GLOBALS['SNIPPETS']['CartItems'] .= $emailTemplate->GetSnippet("StatusCompleteDownloadItem"); } } if (empty($GLOBALS['SNIPPETS']['CartItems'])) { $emailTemplate->SetTemplate("order_status_email"); } else { $emailTemplate->SetTemplate("order_status_downloads_email"); } $message = $emailTemplate->ParseTemplate(true); // Create a new email API object to send the email $store_name = GetConfig('StoreName'); $subject = GetLang('OrderStatusChangedSubject'); require_once ISC_BASE_PATH . "/lib/email.php"; $obj_email = GetEmailClass(); $obj_email->Set('CharSet', GetConfig('CharacterSet')); $obj_email->From(GetConfig('OrderEmail'), $store_name); $obj_email->Set('Subject', $subject); $obj_email->AddBody("html", $message); $obj_email->AddRecipient($customer['custconemail'], '', "h"); $email_result = $obj_email->Send(); if ($email_result['success']) { return true; } else { return false; } }
private function RefundOrder() { $message = ''; $messageStaus = MSG_ERROR; $provider = null; if (!isset($_REQUEST['orderid'])) { return false; } $orderId = $_REQUEST['orderid']; $order = GetOrder($_REQUEST['orderid']); if (!isset($order['orderid'])) { return false; } /* Validate posted data*/ $refundType = ''; if (!isset($_REQUEST['refundType'])) { return false; } $refundType = $_REQUEST['refundType']; //preset the refund amount to the available amount of the order $refundAmt = $order['ordgatewayamount'] - $order['ordrefundedamount']; //refund partial amount if ($refundType == 'partial') { //is refund amount specified if (!isset($_REQUEST['refundAmt']) || $_REQUEST['refundAmt'] == '') { $message = GetLang('EnterRefundAmount'); } else { if (!is_numeric($_REQUEST['refundAmt']) || $_REQUEST['refundAmt'] <= 0) { $message = GetLang('InvalidRefundAmountFormat'); } else { if ($_REQUEST['refundAmt'] + $order['ordrefundedamount'] > $order['ordgatewayamount']) { $message = GetLang('InvalidRefundAmount'); } else { $refundAmt = $_REQUEST['refundAmt']; } } } } //there is an error message if ($message != '') { FlashMessage($message, $messageStatus, 'index.php?ToDo=viewOrders'); } $transactionId = trim($order['ordpayproviderid']); if ($transactionId == '') { $message = GetLang('OrderTranscationIDNotFound'); } else { if (!GetModuleById('checkout', $provider, $order['orderpaymentmodule'])) { $message = GetLang('PaymentMethodNotExist'); } else { if (!$provider->IsEnabled()) { $message = GetLang('PaymentProviderIsDisabled'); } else { if (!method_exists($provider, "DoRefund")) { $message = GetLang('RefundNotAvailable'); } else { //still here, perform a delay capture if ($provider->DoRefund($order, $message, $refundAmt)) { $messageStatus = MSG_SUCCESS; //update order status $orderStatus = ORDER_STATUS_REFUNDED; UpdateOrderStatus($order['orderid'], $orderStatus, true); } } } } } FlashMessage($message, $messageStatus, 'index.php?ToDo=viewOrders'); return $message; }
/** * Generate the 'Quick View' for a particular request. * * @param int The request ID. * @return string The generated quick view for the request. */ public function PreviewRequest() { if (!isset($_REQUEST['orderId'])) { exit; } $order = GetOrder($_REQUEST['orderId'], true); /* if(!isset($order['orderid']) || $order['ordisdigital'] == 1 || ($order['ordtotalqty']-$order['ordtotalshipped']) <= 0) { exit; } */ $GLOBALS['OrderId'] = $order['orderid']; $GLOBALS['OrderDate'] = CDate($order['orddate']); if (isset($_GET['templateId'])) { $templateId = $_GET['templateId']; } else { $templateId = 1; } $GLOBALS['TemplateId'] = $templateId; $GLOBALS['PreviewTemplate'] = $this->paserRequestTemplate($templateId); $GLOBALS['RemindMessage'] = GetLang('PreviewReviewIntro'); $GLOBALS['ShowSendBtn'] = ''; $query = "\n\t\t\tSELECT *\n\t\t\tFROM [|PREFIX|]requests\n\t\t\tWHERE orderid=" . $GLOBALS['OrderId'] . "\n\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($row = $GLOBALS['ISC_CLASS_DB']->fetch($result)) { if ($row['requeststatus'] == 2) { $GLOBALS['ShowSendBtn'] = 'none'; $GLOBALS['RemindMessage'] = GetLang('NoResendWarning'); } else { $GLOBALS['RemindMessage'] = sprintf(GetLang('ResendWarning'), $row['requestdate'], $row['requestowner']); //$this->RecordReviewRequest($order['orderid'], true,$templateId,false); } } else { //$this->RecordReviewRequest($order['orderid'], true,$templateId,false); } $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate('requests.preview'); return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); }