/** * 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; }
private function ManageSettings($messages=array()) { if(!gzte11(ISC_HUGEPRINT)) { $GLOBALS['HideVendorOptions'] = 'display: none'; } $GLOBALS['Message'] = GetFlashMessageBoxes(); // Get the getting started box if we need to $GLOBALS['GettingStartedStep'] = ''; if(empty($GLOBALS['Message']) && (isset($_GET['wizard']) && $_GET['wizard']==1) && !in_array('settings', GetConfig('GettingStartedCompleted')) && !GetConfig('DisableGettingStarted')) { $GLOBALS['GettingStartedTitle'] = GetLang('ConfigureStoreSettings'); $GLOBALS['GettingStartedContent'] = GetLang('ConfigureStoreSettingsDesc'); $GLOBALS['GettingStartedStep'] = $this->template->render('Snippets/GettingStartedModal.html'); } if (GetConfig('UseWYSIWYG')) { $GLOBALS['IsWYSIWYGEnabled'] = 'checked="checked"'; } if (GetConfig('ShowThumbsInControlPanel')) { $GLOBALS['IsProductThumbnailsEnabled'] = 'checked="checked"'; } if (GetConfig('DesignMode')) { $GLOBALS['IsDesignMode'] = 'checked="checked"'; } if (GetConfig('ForceControlPanelSSL')) { $GLOBALS['IsControlPanelSSLEnabled'] = 'checked="checked"'; } if (GetConfig('DownForMaintenance')) { $GLOBALS['IsDownForMaintenance'] = 'checked="checked"'; } $GLOBALS["CharacterSet"] = GetConfig('CharacterSet'); if(in_array(GetConfig('CharacterSet'), $this->validCharacterSets)) { $selectedCharset = GetConfig('CharacterSet'); $selectedCharset = isc_strtolower($selectedCharset); $selectedCharset = str_replace(array("-", "_"), "", $selectedCharset); $GLOBALS["CharacterSet_Selected_" . $selectedCharset] = 'selected="selected"'; } else { $GLOBALS["CharacterSet_Selected_utf8"] = 'selected="selected"'; } /* if (GetConfig('UseSSL')) { $GLOBALS['IsSSLEnabled'] = 'checked="checked"'; } */ switch (GetConfig('UseSSL')) { case SSL_NORMAL: $SSLOption = "UseNormalSSL"; break; case SSL_SHARED: $SSLOption = "UseSharedSSL"; break; case SSL_SUBDOMAIN: $SSLOption = "UseSubdomainSSL"; break; default: $SSLOption = "NoSSL"; } $GLOBALS[$SSLOption . 'Checked'] = 'checked="checked"'; if(GetConfig('AllowPurchasing')) { $GLOBALS['IsPurchasingEnabled'] = 'checked="checked"'; } switch(GetConfig('WeightMeasurement')) { case 'LBS': $GLOBALS['IsPounds'] = 'selected="selected"'; break; case 'Ounces': $GLOBALS['IsOunces'] = 'selected="selected"'; break; case 'KGS': $GLOBALS['IsKilos'] = 'selected="selected"'; break; case 'Grams': $GLOBALS['IsGrams'] = 'selected="selected"'; break; case 'Tonnes': $GLOBLAS['IsTonnes'] = 'selected="selected"'; } if (GetConfig('LengthMeasurement') == "Inches") { $GLOBALS['IsInches'] = 'selected="selected"'; } else { $GLOBALS['IsCentimeters'] = 'selected="selected"'; } $GLOBALS['ShippingFactoringDimensionDepthSelected'] = ''; $GLOBALS['ShippingFactoringDimensionHeightSelected'] = ''; $GLOBALS['ShippingFactoringDimensionWidthSelected'] = ''; switch (GetConfig('ShippingFactoringDimension')) { case 'height': $GLOBALS['ShippingFactoringDimensionHeightSelected'] = 'selected="selected"'; break; case 'width': $GLOBALS['ShippingFactoringDimensionWidthSelected'] = 'selected="selected"'; break; case 'depth': default: $GLOBALS['ShippingFactoringDimensionDepthSelected'] = 'selected="selected"'; break; } if (GetConfig('TagCartQuantityBoxes') == 'dropdown') { $GLOBALS['IsDropdown'] = 'selected="selected"'; } else { $GLOBALS['IsTextbox'] = 'selected="selected"'; } // Product breadcrumbs dropdown $GLOBALS['ProductBreadcrumbs'] = GetConfig('ProductBreadcrumbs'); $GLOBALS['ProductBreadcrumbOptions'] = array( "showall" => GetLang('ShowAll'), "showone" => GetLang('ShowOneOnly'), "shownone" => GetLang('DontShow'), ); if (GetConfig('FastCartAction') == 'popup') { $GLOBALS['IsShowPopWindow'] = 'selected="selected"'; } else { $GLOBALS['IsShowCartPage'] = 'selected="selected"'; } if (GetConfig('TagCloudsEnabled')) { $GLOBALS['IsTagCloudsEnabled'] = 'checked="checked"'; } if (GetConfig('BulkDiscountEnabled')) { $GLOBALS['IsBulkDiscountEnabled'] = 'checked="checked"'; } if (GetConfig('EnableProductTabs')) { $GLOBALS['IsProductTabsEnabled'] = 'checked="checked"'; } if (GetConfig('ShowAddToCartQtyBox')) { $GLOBALS['IsShownAddToCartQtyBox'] = 'checked="checked"'; } if (GetConfig('CaptchaEnabled')) { $GLOBALS['IsCaptchaEnabled'] = 'checked="checked"'; } if(GetConfig('StoreDSTCorrection')) { $GLOBALS['IsDSTCorrectionEnabled'] = "checked=\"checked\""; } if (GetConfig('ShowCartSuggestions')) { $GLOBALS['IsShowCartSuggestions'] = 'checked="checked"'; } if (GetConfig('ShowThumbsInCart')) { $GLOBALS['IsShowThumbsInCart'] = 'checked="checked"'; } if (GetConfig('TagCloudsEnabled')) { $GLOBALS['IsTagCloudsEnabled'] = 'checked="checked"'; } if (GetConfig('ShowAddToCartQtyBox')) { $GLOBALS['IsShownAddToCartQtyBox'] = 'checked="checked"'; } if (GetConfig('AutoApproveReviews')) { $GLOBALS['IsAutoApproveReviews'] = 'checked="checked"'; } if (GetConfig('SearchSuggest')) { $GLOBALS['IsSearchSuggest'] = 'checked="checked"'; } if (GetConfig('QuickSearch')) { $GLOBALS['IsQuickSearch'] = 'checked="checked"'; } if (GetConfig('ShowInventory')) { $GLOBALS['IsShowInventory'] = 'checked="checked"'; } if (GetConfig('ShowPreOrderInventory')) { $GLOBALS['IsShowPreOrderInventory'] = 'checked="checked"'; } // Bulk Discount Settings if (GetConfig('BulkDiscountEnabled')) { $GLOBALS['IsBulkDiscountEnabled'] = 'checked="checked"'; } if (GetConfig('EnableProductTabs')) { $GLOBALS['IsProductTabsEnabled'] = 'checked="checked"'; } // RSS Settings if (GetConfig('RSSNewProducts')) { $GLOBALS['IsRSSNewProductsEnabled'] = 'checked="checked"'; } if (GetConfig('RSSPopularProducts')) { $GLOBALS['IsRSSPopularProductsEnabled'] = 'checked="checked"'; } if (GetConfig('RSSFeaturedProducts')) { $GLOBALS['IsRSSFeaturedProductsEnabled'] = 'checked="checked"'; } if (GetConfig('RSSCategories')) { $GLOBALS['IsRSSCategoriesEnabled'] = 'checked="checked"'; } if (GetConfig('RSSProductSearches')) { $GLOBALS['IsRSSProductSearchesEnabled'] = 'checked="checked"'; } if (GetConfig('RSSLatestBlogEntries')) { $GLOBALS['IsRSSLatestBlogEntriesEnabled'] = 'checked="checked"'; } if (GetConfig('RSSSyndicationIcons')) { $GLOBALS['IsRSSSyndicationIconsEnabled'] = 'checked="checked"'; } if(GetConfig('EnableCustomersAlsoViewed')) { $GLOBALS['IsCustomersAlsoViewedEnabled'] = 'checked="checked"'; } // Product Images if (GetConfig('ProductImagesTinyThumbnailsEnabled')) { $GLOBALS['IsProductImagesTinyThumbnailsEnabled'] = 'checked="checked"'; } if(GetConfig('ProductImagesImageZoomEnabled')) { $GLOBALS['IsProductImagesImageZoomEnabled'] = 'checked="checked"'; } if((int)GetConfig('ProductImagesStorewideThumbnail_width') < 1) { $GLOBALS['ISC_CFG']['ProductImagesStorewideThumbnail_width'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_THUMBNAIL; } if((int)GetConfig('ProductImagesStorewideThumbnail_height') < 1) { $GLOBALS['ISC_CFG']['ProductImagesStorewideThumbnail_height'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_THUMBNAIL; } if((int)GetConfig('ProductImagesProductPageImage_width') < 1) { $GLOBALS['ISC_CFG']['ProductImagesProductPageImage_width'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_STANDARD; } if((int)GetConfig('ProductImagesProductPageImage_height') < 1) { $GLOBALS['ISC_CFG']['ProductImagesProductPageImage_height'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_STANDARD; } if((int)GetConfig('ProductImagesGalleryThumbnail_width') < 1) { $GLOBALS['ISC_CFG']['ProductImagesGalleryThumbnail_width'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_TINY; } if((int)GetConfig('ProductImagesGalleryThumbnail_height') < 1) { $GLOBALS['ISC_CFG']['ProductImagesGalleryThumbnail_height'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_TINY; } // Backup Settings if (GetConfig('BackupsLocal')) { $GLOBALS['IsBackupsLocalEnabled'] = 'checked="checked"'; } if (GetConfig('BackupsRemoteFTP')) { $GLOBALS['IsBackupsRemoteFTPEnabled'] = 'checked="checked"'; } if (GetConfig('BackupsAutomatic')) { $GLOBALS['IsBackupsAutomaticEnabled'] = 'checked="checked"'; } if (GetConfig('HTTPSSLVerifyPeer')) { $GLOBALS['IsHTTPSSLVerifyPeerEnabled'] = 'checked="checked"'; } if (strpos(strtolower(PHP_OS), 'win') === 0) { $binary = 'php.exe'; $path_to_php = Which($binary); } else { // Check if there is a separate PHP 5 binary first foreach(array('php5', 'php') as $phpBin) { $path_to_php = Which($phpBin); if($path_to_php !== '') { break; } } } if ($path_to_php === '' && strpos(strtolower(PHP_OS), 'win') === 0) { $path_to_php = 'php.exe'; } elseif ($path_to_php === '') { $path_to_php = 'php'; } $GLOBALS['BackupsAutomaticPath'] = $path_to_php.' -f ' . realpath(ISC_BASE_PATH . "/admin")."/cron-backup.php"; if (GetConfig('BackupsAutomaticMethod') == "ftp") { $GLOBALS['IsBackupsAutomaticMethodFTP'] = 'selected="selected"'; } else { $GLOBALS['IsBackupsAutomaticMethodLocal'] = 'selected="selected"'; } if (GetConfig('BackupsAutomaticDatabase')) { $GLOBALS['IsBackupsAutomaticDatabaseEnabled'] = 'checked="checked"'; } if (GetConfig('BackupsAutomaticImages')) { $GLOBALS['IsBackupsAutomaticImagesEnabled'] = 'checked="checked"'; } if (GetConfig('BackupsAutomaticDownloads')) { $GLOBALS['IsBackupsAutomaticDownloadsEnabled'] = 'checked="checked"'; } $GLOBALS['LanguageOptions'] = $this->GetLanguageOptions(GetConfig('Language')); if (!function_exists('ftp_connect')) { $GLOBALS['FTPBackupsHide'] = "none"; } $GLOBALS['TimeZoneOptions'] = $this->GetTimeZoneOptions(GetConfig('StoreTimeZone')); $query = sprintf("select version() as version"); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result); $GLOBALS['dbVersion'] = $row['version']; // Logging Settings if (GetConfig('SystemLogging')) { $GLOBALS['IsSystemLoggingEnabled'] = "checked=\"checked\""; } if(GetConfig('DebugMode')) { $GLOBALS['IsDebugModeEnabled'] = "checked=\"checked\""; } if (GetConfig('SystemLogTypes')) { $types = explode(",", GetConfig('SystemLogTypes')); if (in_array('general', $types)) { $GLOBALS['IsGeneralLoggingEnabled'] = "selected=\"selected\""; } if (in_array('payment', $types)) { $GLOBALS['IsPaymentLoggingEnabled'] = "selected=\"selected\""; } if (in_array('shipping', $types)) { $GLOBALS['IsShippingLoggingEnabled'] = "selected=\"selected\""; } if (in_array('notification', $types)) { $GLOBALS['IsNotificationLoggingEnabled'] = "selected=\"selected\""; } if (in_array('sql', $types)) { $GLOBALS['IsSQLLoggingEnabled'] = "selected=\"selected\""; } if (in_array('php', $types)) { $GLOBALS['IsPHPLoggingEnabled'] = "selected=\"selected\""; } if (in_array('accounting', $types)) { $GLOBALS['IsAccountingLoggingEnabled'] = "selected=\"selected\""; } if (in_array('emailintegration', $types)) { $GLOBALS['IsEmailIntegrationLoggingEnabled'] = "selected=\"selected\""; } if (in_array('ebay', $types)) { $GLOBALS['IsEbayLoggingEnabled'] = "selected=\"selected\""; } if (in_array('shoppingcomparison', $types)) { $GLOBALS['IsShoppingComparisonLoggingEnabled'] = "selected=\"selected\""; } } if (GetConfig('SystemLogSeverity')) { $severities = explode(",", GetConfig('SystemLogSeverity')); if (in_array('errors', $severities)) { $GLOBALS['IsLoggingSeverityErrors'] = "selected=\"selected\""; } if (in_array('warnings', $severities)) { $GLOBALS['IsLoggingSeverityWarnings'] = "selected=\"selected\""; } if (in_array('notices', $severities)) { $GLOBALS['IsLoggingSeverityNotices'] = "selected=\"selected\""; } if (in_array('success', $severities)) { $GLOBALS['IsLoggingSeveritySuccesses'] = "selected=\"selected\""; } if (in_array('debug', $severities)) { $GLOBALS['IsLoggingSeverityDebug'] = "selected=\"selected\""; } } if (GetConfig('EnableSEOUrls') == 2) { $GLOBALS['IsEnableSEOUrlsAuto'] = "selected=\"selected\""; } else if (GetConfig('EnableSEOUrls') == 1) { $GLOBALS['IsEnableSEOUrlsEnabled'] = "selected=\"selected\""; } else { $GLOBALS['IsEnableSEOUrlsDisabled'] = "selected=\"selected\""; } if (!gzte11(ISC_MEDIUMPRINT)) { $GLOBALS['HideBackupSettings'] = "none"; } if (GetConfig('AdministratorLogging')) { $GLOBALS['IsAdministratorLoggingEnabled'] = "checked=\"checked\""; } if(GetConfig('HidePHPErrors')) { $GLOBALS['IsHidePHPErrorsEnabled'] = "checked=\"checked\""; } if(GetConfig('EnableWishlist')) { $GLOBALS['IsWishlistEnabled'] = "checked=\"checked\""; } if(GetConfig('EnableAccountCreation')) { $GLOBALS['IsEnableAccountCreation'] = "checked=\"checked\""; } if (!getProductReviewsEnabled()) { $GLOBALS['HideIfReviewsDisabled'] = 'display: none;'; } if(GetConfig('EnableProductComparisons')) { $GLOBALS['IsEnableProductComparisons'] = "checked=\"checked\""; } // Product display settings if(GetConfig('ShowProductPrice')) { $GLOBALS['IsProductPriceShown'] = 'CHECKED'; } if(GetConfig('ShowProductSKU')) { $GLOBALS['IsProductSKUShown'] = 'CHECKED'; } if(GetConfig('ShowProductWeight')) { $GLOBALS['IsProductWeightShown'] = 'CHECKED'; } if(GetConfig('ShowProductBrand')) { $GLOBALS['IsProductBrandShown'] = 'CHECKED'; } if(GetConfig('ShowProductShipping')) { $GLOBALS['IsProductShippingShown'] = 'CHECKED'; } if(GetConfig('ShowProductRating')) { $GLOBALS['IsProductRatingShown'] = 'CHECKED'; } if(GetConfig('ShowAddToCartLink')) { $GLOBALS['IsAddToCartLinkShown'] = 'CHECKED'; } if (GetConfig('ShowAddThisLink')) { $GLOBALS['IsAddThisLinkShown'] = 'checked="checked"'; } if(GetConfig('LowInventoryNotificationAddress') != '') { $GLOBALS['LowInventoryEmailsEnabledCheck'] = "checked=\"checked\""; } else { $GLOBALS['HideLowInventoryNotification'] = "none"; } if(GetConfig('ForwardInvoiceEmails') != '') { $GLOBALS['ForwardInvoiceEmailsCheck'] = "checked=\"checked\""; } else { $GLOBALS['HideForwardInvoiceEmails'] = 'none'; } if(GetConfig('MailUseSMTP')) { $GLOBALS['HideMailSMTPSettings'] = ''; $GLOBALS['MailUseSMTPChecked'] = "checked=\"checked\""; } else { $GLOBALS['HideMailSMTPSettings'] = 'none'; $GLOBALS['MailUsePHPChecked'] = "checked=\"checked\""; } if (GetConfig('ProductImageMode') == "lightbox") { $GLOBALS['ProductImageModeLightbox'] = 'selected="selected"'; } else { $GLOBALS['ProductImageModePopup'] = 'selected="selected"'; } if (GetConfig('CategoryDisplayMode') == "grid") { $GLOBALS['CategoryDisplayModeGrid'] = 'selected="selected"'; } else { $GLOBALS['CategoryDisplayModeList'] = 'selected="selected"'; } if (GetConfig('CategoryDefaultImage') !== '') { $GLOBALS['CatImageDefaultSettingMessage'] = sprintf(GetLang('CatImageDefaultSettingDesc'), GetConfig('ShopPath') . '/' . GetConfig('CategoryDefaultImage'), GetConfig('CategoryDefaultImage')); } else { $GLOBALS['CatImageDefaultSettingMessage'] = sprintf(GetLang('BrandImageDefaultSettingNoDeleteDesc'), $GLOBALS['IMG_PATH'].'/CategoryDefault.gif', $GLOBALS['IMG_PATH'].'CategoryDefault.gif'); } if (GetConfig('BrandDefaultImage') !== '') { $GLOBALS['BrandImageDefaultSettingMessage'] = sprintf(GetLang('BrandImageDefaultSettingDesc'), GetConfig('ShopPath') . '/' . GetConfig('BrandDefaultImage'), GetConfig('BrandDefaultImage')); } else { $GLOBALS['BrandImageDefaultSettingMessage'] = sprintf(GetLang('BrandImageDefaultSettingNoDeleteDesc'), $GLOBALS['IMG_PATH'].'/BrandDefault.gif', $GLOBALS['IMG_PATH'].'/BrandDefault.gif'); } $GLOBALS['HideCurrentDefaultProductImage'] = 'display: none'; switch(GetConfig('DefaultProductImage')) { case 'template': $GLOBALS['DefaultProductImageTemplateChecked'] = 'checked="checked"'; break; case '': $GLOBALS['DefaultProductImageNoneChecked'] = 'checked="checked"'; break; default: $GLOBALS['DefaultProductImageCustomChecked'] = 'checked="checked"'; $GLOBALS['HideCurrentDefaultProductImage'] = ''; $GLOBALS['DefaultProductImage'] = GetConfig('DefaultProductImage'); } if (GetConfig('CategoryListingMode') == 'children') { $GLOBALS['CategoryListModeChildren'] = "checked=\"checked\""; } else if (GetConfig('CategoryListingMode') == 'emptychildren') { $GLOBALS['CategoryListModeEmptyChildren'] = "checked=\"checked\""; } else { $GLOBALS['CategoryListModeSingle'] = "checked=\"checked\""; } // check if the images need to be resized automatically $GLOBALS['RunImageResize'] = '0'; if(isset($_SESSION['RunImageResize']) && $_SESSION['RunImageResize'] == 'yes') { $GLOBALS['RunImageResize'] = '1'; unset($_SESSION['RunImageResize']); } // Get a list of the customer groups $query = 'SELECT * FROM [|PREFIX|]customer_groups ORDER BY groupname ASC'; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $GLOBALS['CustomerGroupOptions'] = ''; while($group = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if(GetConfig('GuestCustomerGroup') == $group['customergroupid']) { $sel = 'selected="selected"'; } else { $sel = ''; } $GLOBALS['CustomerGroupOptions'] .= "<option value=\"".$group['customergroupid']."\" ".$sel.">".isc_html_escape($group['groupname'])."</option>"; } // Workout the HTTPS URL $GLOBALS['CompleteStorePath'] = fix_url($_SERVER['PHP_SELF']); $GLOBALS['HTTPSUrl'] = str_replace("http://", "https://", isc_strtolower($GLOBALS['ShopPath'])); $GLOBALS['HideVendorSettings'] = 'display: none'; if(gzte11(ISC_HUGEPRINT)) { $GLOBALS['HideVendorSettings'] = ''; } if(GetConfig('VendorLogoSize')) { $logoDimensions = explode('x', GetConfig('VendorLogoSize')); $GLOBALS['VendorLogoSizeW'] = (int)$logoDimensions[0]; $GLOBALS['VendorLogoSizeH'] = (int)$logoDimensions[1]; $GLOBALS['HideVendorLogoUploading'] = ''; $GLOBALS['VendorLogoUploadingChecked'] = 'checked="checked"'; } else { $GLOBALS['HideVendorLogoUploading'] = 'display: none'; } if(GetConfig('VendorPhotoSize')) { $photoDimensions = explode('x', GetConfig('VendorPhotoSize')); $GLOBALS['VendorPhotoSizeW'] = (int)$photoDimensions[0]; $GLOBALS['VendorPhotoSizeH'] = (int)$photoDimensions[1]; $GLOBALS['HideVendorPhotoUploading'] = ''; $GLOBALS['VendorPhotoUploadingChecked'] = 'checked="checked"'; } else { $GLOBALS['HideVendorPhotoUploading'] = 'display: none'; } foreach ($this->all_vars as $var) { if (is_string(GetConfig($var)) || is_numeric(GetConfig($var))) { $GLOBALS[$var] = isc_html_escape(GetConfig($var)); } } // the current value of auto_increment for the orders table $GLOBALS['StartingOrderNumber'] = ResetStartingOrderNumber(); if(GetConfig('DisableDatabaseDetailFields')) { $GLOBALS['dbType'] = ''; $GLOBALS['dbServer'] = ''; $GLOBALS['dbUser'] = ''; $GLOBALS['dbPass'] = ''; $GLOBALS['dbDatabase'] = ''; $GLOBALS['tablePrefix'] = ''; $GLOBALS['HideDatabaseDetails'] = 'display: none'; } if(GetConfig('DisableLicenseKeyField')) { $GLOBALS['serverStamp'] = 'N/A'; $GLOBALS['HideLicenseKey'] = 'display: none'; } if(GetConfig('DisablePathFields')) { $GLOBALS['HidePathFields'] = 'display: none'; } if(GetConfig('DisableStoreUrlField')) { $GLOBALS['HideStoreUrlField'] = 'display: none'; } if(GetConfig('DisableLoggingSettingsTab')) { $GLOBALS['HideLoggingSettingsTab'] = 'display: none'; } if(GetConfig('DisableProxyFields')) { $GLOBALS['HideProxyFields'] = 'display: none'; } if(GetConfig('DisableBackupSettings')) { $GLOBALS['HideBackupSettings'] = 'none'; } // Advance Search settings\ $GLOBALS['SearchDefaultProductSortOptions'] = getAdvanceSearchSortOptions("product"); $GLOBALS['SearchDefaultContentSortOptions'] = getAdvanceSearchSortOptions("content"); $GLOBALS['SearchProductDisplayModeOptions'] = ''; foreach (array('grid', 'list') as $type) { $GLOBALS['SearchProductDisplayModeOptions'] .= '<option value="' . $type . '"'; if (GetConfig('SearchProductDisplayMode') == $type) { $GLOBALS['SearchProductDisplayModeOptions'] .= ' selected'; } $GLOBALS['SearchProductDisplayModeOptions'] .= '>' . GetLang('SearchProductDisplayMode' . ucfirst($type)) . '</option>'; } $GLOBALS['SearchResultsPerPageOptions'] = ''; foreach (array('5', '10', '20', '50', '100') as $perpage) { $GLOBALS['SearchResultsPerPageOptions'] .= '<option value="' . $perpage . '"'; if (GetConfig('SearchResultsPerPage') == $perpage) { $GLOBALS['SearchResultsPerPageOptions'] .= ' selected'; } $GLOBALS['SearchResultsPerPageOptions'] .= '>' . $perpage . '</option>'; } $GLOBALS['SearchOptimisationOptions'] = ''; foreach (array('fulltext', 'like', 'both') as $mode) { $GLOBALS['SearchOptimisationOptions'] .= '<option value="' . $mode . '"'; if (GetConfig('SearchOptimisation') == $mode) { $GLOBALS['SearchOptimisationOptions'] .= ' selected'; } $GLOBALS['SearchOptimisationOptions'] .= '>' . GetLang('SearchOptimisation' . ucfirst(isc_strtolower($mode))) . '</option>'; } $GLOBALS["AbandonOrderLifetimeOptions"] = ""; foreach (array(1, 7, 14, 21, 30, 60, 90, 120, 150, 180) as $lifetimeType) { $GLOBALS["AbandonOrderLifetimeOptions"] .= "<option value=\"" . $lifetimeType . "\""; if ((int)GetConfig("AbandonOrderLifetime") == $lifetimeType) { $GLOBALS["AbandonOrderLifetimeOptions"] .= " selected=\"selected\""; } $GLOBALS["AbandonOrderLifetimeOptions"] .= ">" . GetLang("AbandonOrderLifetimeOption" . $lifetimeType . "Days") . "</option>\n"; } $GLOBALS['ShopPath'] = GetConfig('ShopPathNormal'); // get the maintenance message $GLOBALS['DownForMaintenanceMessage'] = Store_DownForMaintenance::getDownForMaintenanceMessage(); switch (GetConfig('RedirectWWW')) { case REDIRECT_TO_WWW: $redirectOption = 'RedirectToWWW'; break; case REDIRECT_TO_NO_WWW: $redirectOption = 'RedirectToNoWWW'; break; default: $redirectOption = 'RedirectNoPreference'; } $GLOBALS[$redirectOption . 'Selected'] = 'selected="selected"'; $GLOBALS['ShowPCISettings'] = !GetConfig('HidePCISettings'); $GLOBALS['FacebookLikeButtonEnabled'] = GetConfig('FacebookLikeButtonEnabled'); $GLOBALS['FacebookLikeButtonStyle' . GetConfig('FacebookLikeButtonStyle')] = 'selected="selected"'; $GLOBALS['FacebookLikeButtonPosition' . GetConfig('FacebookLikeButtonPosition')] = 'selected="selected"'; $GLOBALS['FacebookLikeButtonVerb' . GetConfig('FacebookLikeButtonVerb')] = 'selected="selected"'; $GLOBALS['FacebookLikeButtonShowFacesEnabled'] = GetConfig('FacebookLikeButtonShowFaces'); if (!isset($GLOBALS['TPL_CFG']['EnableFlyoutMenuSupport']) || !$GLOBALS['TPL_CFG']['EnableFlyoutMenuSupport']) { // force selection if template does not support flyout $GLOBALS['CategoryListStyle'] = 'static'; } $this->template->display('settings.manage.tpl'); }
protected function addPrehook(&$savedata, $rawInput) { if(!isset($rawInput['ordtoken'])) { $savedata['ordtoken'] = generateOrderToken(); } if(!array_key_exists("ordstatus", $rawInput)) { $savedata["ordstatus"] = 0; } $providerName = ""; $providerId = ""; // Order was paid for entirely with gift certificates if ($rawInput["orderpaymentmodule"] == "giftcertificate") { $providerName = "giftcertificate"; $providerid = ""; } // Order was paid for entirely using store credit else if ($rawInput["orderpaymentmodule"] == "storecredit") { $providerName = "storecredit"; $providerId = ""; } // Went through some sort of payment gateway else if(!empty($rawInput['orderpaymentmodule'])) { if (GetModuleById("checkout", $provider, $rawInput["orderpaymentmodule"]) && is_object($provider)) { $providerName = $provider->GetDisplayName(); $providerId = $provider->GetId(); } else { $providerId = $rawInput["orderpaymentmodule"]; $providerName = $rawInput["orderpaymentmethod"]; } } $savedata["orderpaymentmodule"] = $providerId; $savedata["orderpaymentmethod"] = $providerName; if (!array_key_exists("ordgeoipcountry", $rawInput) && !array_key_exists("ordgeoipcountrycode", $rawInput)) { // Attempt to determine the GeoIP location based on their IP address require_once ISC_BASE_PATH."/lib/geoip/geoip.php"; $gi = geoip_open(ISC_BASE_PATH."/lib/geoip/GeoIP.dat", GEOIP_STANDARD); $savedata["ordgeoipcountrycode"] = geoip_country_code_by_addr($gi, GetIP()); // If we get the country, look up the country name as well if (trim($savedata["ordgeoipcountrycode"]) !== "") { $savedata["ordgeoipcountry"] = geoip_country_name_by_addr($gi, GetIP()); } } if (!array_key_exists("extraInfo", $rawInput) || !is_array($rawInput["extraInfo"])) { $savedata["extraInfo"] = array(); } else { $savedata["extraInfo"] = $rawInput["extraInfo"]; } $giftCertificates = $rawInput['quote']->getAppliedGiftCertificates(); if(!empty($giftCertificates)) { $savedata["extraInfo"]["giftcertificates"] = $giftCertificates; } $savedata["extraInfo"] = serialize($savedata["extraInfo"]); $defaultCurrency = GetDefaultCurrency(); if (is_array($defaultCurrency) && array_key_exists("currencyid", $defaultCurrency) && isId($defaultCurrency["currencyid"])) { $savedata["orddefaultcurrencyid"] = $defaultCurrency["currencyid"]; } $savedata["orddate"] = time(); $savedata["ordlastmodified"] = time(); ResetStartingOrderNumber(); }