public function SetPanelSettings()
 {
     // Setup the cart values
     $total = $count = 0;
     $GLOBALS['SNIPPETS']['SideCartItems'] = '';
     if (!isset($_SESSION['CART']['ITEMS']) || empty($_SESSION['CART']['ITEMS'])) {
         $this->DontDisplay = true;
         return;
     }
     if (isset($_SESSION['CART']['ITEMS'])) {
         foreach ($_SESSION['CART']['ITEMS'] as $item) {
             $total += $item['product_price'] * $item['quantity'];
             $count += $item['quantity'];
             if (!isset($item['type']) || $item['type'] != "giftcertificate") {
                 $GLOBALS['ProductName'] = "<a href=\"" . ProdLink($item['product_name']) . "\">" . isc_html_escape($item['product_name']) . "</a>";
             } else {
                 $GLOBALS['ProductName'] = isc_html_escape($item['product_name']);
             }
             // Is this product a variation?
             $GLOBALS['ProductOptions'] = '';
             if (isset($item['options']) && !empty($item['options'])) {
                 $GLOBALS['ProductOptions'] .= "<br /><small>(";
                 $comma = '';
                 foreach ($item['options'] as $name => $value) {
                     if (!trim($name) || !trim($value)) {
                         continue;
                     }
                     $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                     $comma = ', ';
                 }
                 $GLOBALS['ProductOptions'] .= ")</small>";
             }
             $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($item['product_price'] * $item['quantity']);
             $GLOBALS['ProductQuantity'] = $item['quantity'];
             $GLOBALS['SNIPPETS']['SideCartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCartItem");
         }
     }
     if ($count == 1) {
         $GLOBALS['SideCartItemCount'] = GetLang('SideCartYouHave1Item');
     } else {
         $GLOBALS['SideCartItemCount'] = sprintf(GetLang('SideCartYouHaveXItems'), $count);
     }
     $GLOBALS['ISC_LANG']['SideCartTotalCost'] = sprintf(GetLang('SideCartTotalCost'), CurrencyConvertFormatPrice($total));
     // Go through all the checkout modules looking for one with a GetSidePanelCheckoutButton function defined
     $GLOBALS['AdditionalCheckoutButtons'] = '';
     $HideCheckout = false;
     foreach (GetAvailableModules('checkout', true, true) as $module) {
         if (method_exists($module['object'], 'GetSidePanelCheckoutButton')) {
             $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetSidePanelCheckoutButton();
         }
         if ($module['object']->disableNonCartCheckoutButtons) {
             $HideCheckout = true;
         }
     }
     if ($HideCheckout) {
         $GLOBALS['SNIPPETS']['SideCartContentsCheckoutLink'] = '';
     } else {
         $GLOBALS['SNIPPETS']['SideCartContentsCheckoutLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('SideCartContentsCheckoutLink');
     }
 }
Example #2
0
 public function SetPanelSettings()
 {
     if ($GLOBALS['ISC_CLASS_PRODUCT']->IsPurchasingAllowed()) {
         if (!GetConfig('ShowProductShipping')) {
             $GLOBALS['HideShipping'] = 'none';
         } else {
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetProductType() == PT_PHYSICAL) {
                 if ($GLOBALS['ISC_CLASS_PRODUCT']->GetFixedShippingCost() != 0) {
                     // Is there a fixed shipping cost?
                     $GLOBALS['ShippingPrice'] = sprintf("%s %s", CurrencyConvertFormatPrice($GLOBALS['ISC_CLASS_PRODUCT']->GetFixedShippingCost()), GetLang('FixedShippingCost'));
                 } else {
                     if ($GLOBALS['ISC_CLASS_PRODUCT']->HasFreeShipping()) {
                         // Does this product have free shipping?
                         $GLOBALS['ShippingPrice'] = GetLang('FreeShipping');
                     } else {
                         // Shipping calculated at checkout
                         $GLOBALS['ShippingPrice'] = GetLang('CalculatedAtCheckout');
                     }
                 }
             } else {
                 $GLOBALS['ShippingPrice'] = GetLang('CalculatedAtCheckout');
             }
         }
     }
 }
 public function SetPanelSettings()
 {
     $output = "";
     $lastend = 0;
     if (isset($GLOBALS['ISC_CLASS_CATEGORY'])) {
         $categorySql = $GLOBALS['ISC_CLASS_CATEGORY']->GetCategoryAssociationSQL();
     } else {
         if (isset($GLOBALS['ISC_CLASS_PRICE'])) {
             $categorySql = $GLOBALS['ISC_CLASS_PRICE']->GetCategoryAssociationSQL();
         }
     }
     $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tMIN(prodcalculatedprice) AS pmin,\n\t\t\t\t\tMAX(prodcalculatedprice) AS pmax\n\t\t\t\tFROM\n\t\t\t\t\t[|PREFIX|]products p\n\t\t\t\tWHERE\n\t\t\t\t\tp.prodvisible='1' AND\n\t\t\t\t\tp.prodhideprice=0 " . $categorySql . "\n\t\t\t\tORDER BY\n\t\t\t\t\tp.productid DESC\n\t\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $min = ceil($row['pmin']);
         $max = ceil($row['pmax']);
         // Is there enough of a variation to show a shop by price panel?
         if ($max - $min > $min) {
             $diff = ($max - $min) / 5;
             if ($diff == 0) {
                 $diff = 1;
             }
             for ($i = 0; $i < 5; $i++) {
                 if ($lastend == 0) {
                     $start = $min + $diff * $i;
                 } else {
                     $start = $lastend;
                 }
                 $end = $start + $diff;
                 if ($end == $lastend) {
                     break;
                 }
                 if ($lastend == 0) {
                     $start = 0;
                 }
                 $lastend = $end;
                 $start = round($start);
                 $end = round($end);
                 $GLOBALS['PriceLow'] = CurrencyConvertFormatPrice($start);
                 $GLOBALS['PriceHigh'] = CurrencyConvertFormatPrice($end);
                 if (is_array($GLOBALS['CatPath'])) {
                     $GLOBALS['CatPath'] = implode("/", $GLOBALS['CatPath']);
                 }
                 $GLOBALS['PriceLink'] = PriceLink($start, $end, $GLOBALS['CatId'], $GLOBALS['CatPath']);
                 $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ShopByPriceItem");
             }
         } else {
             $GLOBALS['HideSideCategoryShopByPricePanel'] = "none";
             $this->DontDisplay = true;
         }
     } else {
         $GLOBALS['HideSideCategoryShopByPricePanel'] = "none";
         $this->DontDisplay = true;
     }
     $GLOBALS['SNIPPETS']['SideCategoryShopByPrice'] = $output;
 }
 function SetPanelSettings()
 {
     $GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER');
     $customer = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerDataByToken();
     if ($customer['custstorecredit'] > 0) {
         $GLOBALS['StoreCreditAmount'] = CurrencyConvertFormatPrice($customer['custstorecredit']);
     } else {
         $GLOBALS['HideStoreCredit'] = "none";
     }
 }
 public function SetPanelSettings()
 {
     $count = 0;
     $GLOBALS['SNIPPETS']['HomeSaleProducts'] = '';
     if (GetConfig('HomeNewProducts') == 0) {
         $this->DontDisplay = true;
         return;
     }
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid)\n\t\t\t\tWHERE p.prodsaleprice != 0 AND p.prodsaleprice < p.prodprice AND p.prodvisible='1' AND (imageisthumb=1 OR ISNULL(imageisthumb))\n\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\tORDER BY RAND()\n\t\t\t";
     $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, GetConfig('HomeNewProducts'));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $GLOBALS['AlternateClass'] = '';
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         $GLOBALS['ProductId'] = $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         // Determine the price of this product
         $originalPrice = CalcRealPrice(CalcProdCustomerGroupPrice($row, $row['prodprice']), 0, 0, $row['prodistaxable']);
         $GLOBALS['OriginalProductPrice'] = CurrencyConvertFormatPrice($originalPrice);
         $GLOBALS['ProductPrice'] = CalculateProductPrice($row);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         // Workout the product description
         $desc = strip_tags($row['proddesc']);
         if (isc_strlen($desc) < 120) {
             $GLOBALS['ProductSummary'] = $desc;
         } else {
             $GLOBALS['ProductSummary'] = isc_substr($desc, 0, 120) . "...";
         }
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         $GLOBALS['SNIPPETS']['HomeSaleProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("HomeSaleProductsItem");
         if (!$GLOBALS['SNIPPETS']['HomeSaleProducts']) {
             $this->DontDisplay = true;
             return;
         }
     }
 }
Example #6
0
 public function ShowPaymentForm()
 {
     // Was there an error validating the payment? If so, pre-fill the form fields with the already-submitted values
     if ($this->HasErrors()) {
         $fields = array("CreditCardNum" => 'creditcard_ccno');
         foreach ($fields as $global => $post) {
             if (isset($_POST[$post])) {
                 $GLOBALS[$global] = isc_html_escape($_POST[$post]);
             }
         }
         $errorMessage = implode("<br />", $this->GetErrors());
         $GLOBALS['CreditCardErrorMessage'] = $errorMessage;
     } else {
         // Hide the error message box
         $GLOBALS['HideCreditCardError'] = "none";
     }
     $pendingOrder = LoadPendingOrderByToken();
     $GLOBALS['OrderAmount'] = CurrencyConvertFormatPrice($pendingOrder['ordgatewayamount'], $pendingOrder['ordcurrencyid'], $pendingOrder['ordcurrencyexchangerate']);
     // Collect their details to send through to CreditCard
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("valuteccard");
     return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
 }
Example #7
0
    /**
     * Generate an individual row for the order items table.
     *
     * @param string The unique identifier for this row.
     * @param array Array of details about the product for this row.
     * @param boolean Set to true to hide this row by default.
     * @return string The generated HTML row for this item.
     */
    public function GenerateOrderItemRow($rowId, $product = array(), $hidden = false, $resetPrices = false)
    {
        static $first = true;
        static $publicWrappingOptions = null;
        if ($hidden == true) {
            $GLOBALS['HideRow'] = 'display: none';
        } else {
            $GLOBALS['HideRow'] = '';
        }
        //2011-9-13 alandy add shipping data show.
        $GLOBALS['ShippingdataRow'] = '';
        if (is_null($publicWrappingOptions)) {
            $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
            if (empty($wrappingOptions)) {
                $publicWrappingOptions = false;
            } else {
                $publicWrappingOptions = true;
            }
        }
        if ($first != true) {
            $GLOBALS['HideInsertTip'] = 'display: none';
        }
        $first = false;
        if (empty($product)) {
            $GLOBALS['CartItemId'] = $rowId;
            $GLOBALS['ProductCode'] = '';
            $GLOBALS['vendorprefix'] = '';
            $GLOBALS['shippingDate'] = '';
            $GLOBALS['isshippingDate'] = '';
            $GLOBALS['trackingNumber'] = '';
            $GLOBALS['ProductId'] = 0;
            $GLOBALS['ProductName'] = '';
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['HideProductVariation'] = 'display: none;';
            $GLOBALS['ProductPrice'] = FormatPrice(0, false, false, true);
            $GLOBALS['ProductQuantity'] = 1;
            $GLOBALS['ProductTotal'] = FormatPrice(0);
            $GLOBALS['HideEventDate'] = 'display : none;';
            $GLOBALS['EventDate'] = '';
            $GLOBALS['ShippingdataRow'] = '';
            $GLOBALS['ResetPrice'] = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Reset_Price) ? "<input {$GLOBALS['ResetChecked']} value=\"{$GLOBALS['ResetStatus']}\" type='checkbox' name='cartItem[{$rowId}][resetPrice]' onclick='ResetPrice(this)'/>&nbsp;reset price" : '';
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
        $GLOBALS['CartItemId'] = $rowId;
        //isc_html_escape($product['cartitemid']);
        // If the item in the cart is a gift certificate, we need to show a special type of row
        if (isset($product['type']) && $product['type'] == "giftcertificate") {
            $GLOBALS['ProductCode'] = GetLang('NA');
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductPrice'] = FormatPrice($product['product_price']);
            $GLOBALS['ProductTotal'] = FormatPrice($product['product_price'] * $product['quantity']);
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItemGiftCertificate');
        } else {
            require_once ISC_BASE_PATH . '/lib/discountcalcs.php';
            /**********************************************************************
            				Code altered by Mayank Jaitly on 05 July 2010
            			/**********************************************************************/
            $GLOBALS['YMMYearTemp'] = $product['year'];
            $GLOBALS['YMMMakeTemp'] = $product['make'];
            $GLOBALS['YMMModelTemp'] = $product['model'];
            $GLOBALS['YMMbedsizeTemp'] = $product['bedsize'];
            $GLOBALS['YMMcabsizeTemp'] = $product['cabsize'];
            $GLOBALS['ProductId'] = $product['product_id'];
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductCode'] = $product['product_code'];
            $GLOBALS['vendorprefix'] = $product['vendorprefix'] . '-';
            $GLOBALS['shippingDate'] = $product['shippingDate'];
            $GLOBALS['isshippingDate'] = $product['isshippingDate'];
            $GLOBALS['trackingNumber'] = $product['trackingNumber'];
            //alandy 2011-9-13 modify shipping date.
            if (isset($GLOBALS['isshippingDate']) && $GLOBALS['isshippingDate'] != '01/01/1900' && !empty($GLOBALS['shippingDate'])) {
                $GLOBALS['ShippingdataRow'] = "<div><div style='float:left; width:180px;'>" . $GLOBALS['shippingDate'] . "</div><div style='float:left; width:400px; word-break:break-all; word-wrap:break-word;'>" . $GLOBALS['trackingNumber'] . "</div></div>";
            }
            // Don't use the discount price here as we'll be showing the coupon codes
            // down below in the summary table
            $productPrice = isset($product['discount_price']) && $product['discount_price'] < $product['product_price'] ? $product['discount_price'] : $product['product_price'];
            //20110503 alandy add resetprice.
            if ($resetPrices) {
                $GLOBALS['PriceReadonly'] = '';
                $GLOBALS['ResetChecked'] = 'checked';
                $GLOBALS['ResetStatus'] = '1';
            } else {
                $GLOBALS['PriceReadonly'] = 'readonly class="Field50 ItemPrice ReadonlyText"';
                $GLOBALS['ResetChecked'] = '';
                $GLOBALS['ResetStatus'] = '0';
            }
            $GLOBALS['ProductPrice'] = FormatPrice($productPrice, false, false, true);
            $GLOBALS['ProductTotal'] = FormatPrice($productPrice * $product['quantity']);
            // Initialize the configurable product fields
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['ProductFields'] = '';
            if (!empty($product['product_fields']) && is_array($product['product_fields'])) {
                $GLOBALS['HideProductFields'] = '';
                foreach ($product['product_fields'] as $fieldId => $field) {
                    switch ($field['fieldType']) {
                        case 'file':
                            if (isset($field['fieldExisting'])) {
                                $fileDirectory = 'configured_products';
                            } else {
                                $fileDirectory = 'configured_products_tmp';
                            }
                            $fieldValue = '<a href="' . GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $fileDirectory . '/' . $field['fileName'] . '" target="_blank">' . isc_html_escape($field['fileOriginName']) . '</a>';
                            break;
                        case 'checkbox':
                            $fieldValue = GetLang('Checked');
                            break;
                        default:
                            if (isc_strlen($field['fieldValue']) > 50) {
                                $field['fieldValue'] = isc_substr($field['fieldValue'], 0, 50) . " ..";
                            }
                            $fieldValue = isc_html_escape($field['fieldValue']);
                            // browser is decoding the entities in the ajax response which prevents the row from loading so we need to double encode
                            if (isset($_REQUEST['ajaxFormUpload'])) {
                                $fieldValue = isc_html_escape($fieldValue);
                            }
                    }
                    if (!trim($fieldValue)) {
                        continue;
                    }
                    $GLOBALS['ProductFields'] .= '
							<dt>' . isc_html_escape($field['fieldName']) . ':</dt>
							<dd>' . $fieldValue . '</dd>
						';
                }
            }
            // Can this item be wrapped?
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            if ($product['data']['prodtype'] == PT_PHYSICAL && @$product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                $GLOBALS['HideWrappingOptions'] = '';
                if (isset($product['wrapping'])) {
                    $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                    $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                    $GLOBALS['HideGiftWrappingEdit'] = '';
                    $GLOBALS['HideGiftWrappingPrice'] = '';
                    $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                } else {
                    $GLOBALS['GiftWrappingName'] = '';
                    $GLOBALS['HideGiftWrappingAdd'] = '';
                    $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
                    $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
                    $GLOBALS['GiftWrappingPrice'] = '';
                }
            }
            // Is this product a variation?
            $GLOBALS['ProductOptions'] = '';
            $GLOBALS['HideProductVariation'] = 'display: none';
            if (isset($product['options']) && !empty($product['options'])) {
                $comma = '';
                $GLOBALS['HideProductVariation'] = '';
                foreach ($product['options'] as $name => $value) {
                    if (!trim($name) || !trim($value)) {
                        continue;
                    }
                    $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                    $comma = ' / ';
                }
            } else {
                if (isset($product['data']['prodvariationid']) && $product['data']['prodvariationid'] > 0) {
                    $GLOBALS['HideProductVariation'] = '';
                    $GLOBALS['ProductOptions'] = GetLang('xNone');
                }
            }
            if (isset($product['data']['prodeventdaterequired']) && $product['data']['prodeventdaterequired']) {
                $GLOBALS['HideEventDate'] = '';
                $GLOBALS['EventDate'] = '<dl><dt>' . $product['data']['prodeventdatefieldname'] . ': </dt><dd>' . isc_date('jS M Y', $product['event_date']) . '</dd></dl>';
            } else {
                $GLOBALS['HideEventDate'] = 'display : none;';
                $GLOBALS['EventDate'] = '';
            }
            $GLOBALS['ResetPrice'] = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Reset_Price) ? "<input {$GLOBALS['ResetChecked']} value=\"{$GLOBALS['ResetStatus']}\" type='checkbox' name='cartItem[{$GLOBALS['CartItemId']}][resetPrice]' onclick='ResetPrice(this)'/>&nbsp;reset price" : '';
            $this->setOtherinfo($product['data'], true);
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
    }
 public function SetPanelSettings()
 {
     $_SESSION['you_save'] = 0;
     //blessen
     $GLOBALS['SNIPPETS']['CartItems'] = "";
     $count = 0;
     $subtotal = 0;
     $_SESSION['CHECKOUT'] = array();
     // Get a list of all products in the cart
     $GLOBALS['ISC_CLASS_CART'] = GetClass('ISC_CART');
     $product_array = $GLOBALS['ISC_CLASS_CART']->api->GetProductsInCart();
     $GLOBALS['AdditionalCheckoutButtons'] = '';
     // Go through all the checkout modules looking for one with a GetSidePanelCheckoutButton function defined
     $ShowCheckoutButton = false;
     if (!empty($product_array)) {
         foreach (GetAvailableModules('checkout', true, true) as $module) {
             if (isset($module['object']->_showBothButtons) && $module['object']->_showBothButtons) {
                 $ShowCheckoutButton = true;
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } elseif (method_exists($module['object'], 'GetCheckoutButton')) {
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } else {
                 $ShowCheckoutButton = true;
             }
         }
     }
     $GLOBALS['HideMultipleAddressShipping'] = 'display: none';
     if (gzte11(ISC_MEDIUMPRINT) && $GLOBALS['ISC_CLASS_CART']->api->GetNumPhysicalProducts() > 1 && $ShowCheckoutButton && GetConfig("MultipleShippingAddresses")) {
         $GLOBALS['HideMultipleAddressShipping'] = '';
     }
     $GLOBALS['HideCheckoutButton'] = '';
     if (!$ShowCheckoutButton) {
         $GLOBALS['HideCheckoutButton'] = 'display: none';
         $GLOBALS['HideMultipleAddressShippingOr'] = 'display: none';
     }
     $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
     if (empty($wrappingOptions)) {
         $publicWrappingOptions = false;
     } else {
         $publicWrappingOptions = true;
     }
     if (!GetConfig('ShowThumbsInCart')) {
         $GLOBALS['HideThumbColumn'] = 'display: none';
         $GLOBALS['ProductNameSpan'] = 2;
     } else {
         $GLOBALS['HideThumbColumn'] = '';
         $GLOBALS['ProductNameSpan'] = 1;
     }
     $wrappingAdjustment = 0;
     $itemTotal = 0;
     foreach ($product_array as $k => $product) {
         $GLOBALS['CartItemId'] = (int) $product['cartitemid'];
         // If the item in the cart is a gift certificate, we need to show a special type of row
         if (isset($product['type']) && $product['type'] == "giftcertificate") {
             $GLOBALS['GiftCertificateName'] = isc_html_escape($product['data']['prodname']);
             $GLOBALS['GiftCertificateAmount'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['GiftCertificateTo'] = isc_html_escape($product['certificate']['to_name']);
             $GLOBALS["Quantity" . $product['quantity']] = 'selected="selected"';
             $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($product['giftamount'] * $product['quantity']);
             $itemTotal += $product['giftamount'] * $product['quantity'];
             $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemGiftCertificate");
         } else {
             $GLOBALS['ProductLink'] = ProdLink($product['data']['prodname']);
             $GLOBALS['ProductAvailability'] = isc_html_escape($product['data']['prodavailability']);
             $GLOBALS['ItemId'] = (int) $product['data']['productid'];
             $GLOBALS['VariationId'] = (int) $product['variation_id'];
             $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
             //blessen
             $GLOBALS['prodretailprice'] = CurrencyConvertFormatPrice($product['data']['prodretailprice']);
             if ($product['data']['prodretailprice'] > $product['data']['prodcalculatedprice']) {
                 $_SESSION['you_save'] += ($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']) * $product['quantity'];
             }
             //$GLOBALS['saveprice'] =  CurrencyConvertFormatPrice($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']);
             //blessen
             // Should we show thumbnails in the cart?
             if (GetConfig('ShowThumbsInCart')) {
                 $GLOBALS['ProductImage'] = ImageThumb($product['data']['imagefile'], ProdLink($product['data']['prodname']));
             }
             $GLOBALS['UpdateCartQtyJs'] = "Cart.UpdateQuantity(this.options[this.selectedIndex].value);";
             $GLOBALS['HideCartProductFields'] = 'display:none;';
             $GLOBALS['CartProductFields'] = '';
             $this->GetProductFieldDetails($product['product_fields'], $k);
             $GLOBALS['EventDate'] = '';
             if (isset($product['event_date'])) {
                 $GLOBALS['EventDate'] = '<div style="font-style: italic; font-size:10px; color:gray">(' . $product['event_name'] . ': ' . isc_date('M jS Y', $product['event_date']) . ')</div>';
             }
             // Can this product be wrapped?
             $GLOBALS['GiftWrappingName'] = '';
             $GLOBALS['HideGiftWrappingAdd'] = '';
             $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
             $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
             $GLOBALS['GiftWrappingPrice'] = '';
             $GLOBALS['GiftMessagePreview'] = '';
             $GLOBALS['HideGiftMessagePreview'] = 'display: none';
             $GLOBALS['HideWrappingOptions'] = 'display: none';
             if ($product['data']['prodtype'] == PT_PHYSICAL && $product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                 $GLOBALS['HideWrappingOptions'] = '';
                 if (isset($product['wrapping'])) {
                     $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                     $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                     $GLOBALS['HideGiftWrappingEdit'] = '';
                     $GLOBALS['HideGiftWrappingPrice'] = '';
                     $wrappingAdjustment += $product['wrapping']['wrapprice'] * $product['quantity'];
                     $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                     if (isset($product['wrapping']['wrapmessage'])) {
                         if (isc_strlen($product['wrapping']['wrapmessage']) > 30) {
                             $product['wrapping']['wrapmessage'] = substr($product['wrapping']['wrapmessage'], 0, 27) . '...';
                         }
                         $GLOBALS['GiftMessagePreview'] = isc_html_escape($product['wrapping']['wrapmessage']);
                         if ($product['wrapping']['wrapmessage']) {
                             $GLOBALS['HideGiftMessagePreview'] = '';
                         }
                     }
                 }
             }
             $subtotalPrice = 0;
             if (isset($product['discount_price'])) {
                 $subtotalPrice = $product['discount_price'];
             } else {
                 $subtotalPrice = $product['product_price'];
             }
             if (isset($product['discount_price']) && $product['discount_price'] != $product['original_price']) {
                 $GLOBALS['ProductPrice'] = sprintf("<s class='CartStrike'>%s</s> %s", CurrencyConvertFormatPrice($product['original_price']), CurrencyConvertFormatPrice($subtotalPrice));
             } else {
                 $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($subtotalPrice);
             }
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($subtotalPrice * $product['quantity']);
             $itemTotal += $subtotalPrice * $product['quantity'];
             // If we're using a cart quantity drop down, load that
             if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
                 $GLOBALS["Quantity" . $product['quantity']] = "selected=\"selected\"";
                 if (isset($GLOBALS["Quantity0"])) {
                     $GLOBALS['QtyOptionZero'] = "<option " . $GLOBALS["Quantity0"] . " value='0'>0</option>";
                 } else {
                     $GLOBALS['QtyOptionZero'] = "<option value='0'>0</option>";
                 }
                 // Fixes products being displayed with '0' quantity when the quantity is greater than 30 (hard coded limit in snippet)
                 if ($product['quantity'] > 30) {
                     $GLOBALS["QtyOptionSelected"] = "<option " . $GLOBALS["Quantity" . $product['quantity']] . " value='" . $product['quantity'] . "'>" . $product['quantity'] . "</option>";
                 }
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
             } else {
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
             }
             // Is this product a variation?
             $GLOBALS['ProductOptions'] = '';
             if (isset($product['options']) && !empty($product['options'])) {
                 $GLOBALS['ProductOptions'] .= "<br /><small>(";
                 $comma = '';
                 foreach ($product['options'] as $name => $value) {
                     if (!trim($name) || !trim($value)) {
                         continue;
                     }
                     $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                     $comma = ', ';
                 }
                 $GLOBALS['ProductOptions'] .= ")</small>";
             }
             $GLOBALS['ProductName'] = isc_html_escape($product['data']['prodname']);
             //blessen
             $withoutdollar = str_replace("\$", "", $GLOBALS['prodretailprice']);
             if (intval($withoutdollar) <= 0) {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
             } else {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem1");
             }
             //blessen
             // original $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
         }
         $GLOBALS["Quantity" . $product['quantity']] = "";
     }
     if ($wrappingAdjustment > 0) {
         $GLOBALS['GiftWrappingTotal'] = CurrencyConvertFormatPrice($wrappingAdjustment);
     } else {
         $GLOBALS['HideGiftWrappingTotal'] = 'display: none';
     }
     $GLOBALS['HideAdjustedTotal'] = "none";
     $GLOBALS['AdjustedCartSubTotal'] = $GLOBALS['CartSubTotal'] - $GLOBALS['CartSubTotalDiscount'];
     $GLOBALS['CartItemTotal'] = CurrencyConvertFormatPrice($itemTotal);
     $GLOBALS['SNIPPETS']['Coupons'] = '';
     $coupons = $GLOBALS['ISC_CLASS_CART']->api->GetAppliedCouponCodes();
     if (count($coupons)) {
         foreach ($coupons as $coupon) {
             $GLOBALS['CouponId'] = $coupon['couponid'];
             $GLOBALS['CouponCode'] = $coupon['couponcode'];
             // percent coupon
             if ($coupon['coupontype'] == 1) {
                 $discount = $coupon['discount'] . "%";
             } else {
                 $discount = CurrencyConvertFormatPrice($coupon['discount']);
             }
             $GLOBALS['CouponDiscount'] = $discount;
             $GLOBALS['SNIPPETS']['Coupons'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartCoupon");
         }
     }
     $GLOBALS['SNIPPETS']['GiftCertificates'] = '';
     // Has the customer chosen one or more gift certificates to apply to this order? We need to show them
     if (isset($_SESSION['CART']['GIFTCERTIFICATES']) && is_array($_SESSION['CART']['GIFTCERTIFICATES'])) {
         $certificates = $_SESSION['CART']['GIFTCERTIFICATES'];
         uasort($certificates, "GiftCertificateSort");
         foreach ($certificates as $certificate) {
             $GLOBALS['GiftCertificateCode'] = isc_html_escape($certificate['giftcertcode']);
             $GLOBALS['GiftCertificateId'] = $certificate['giftcertid'];
             $GLOBALS['GiftCertificateBalance'] = $certificate['giftcertbalance'];
             if ($GLOBALS['GiftCertificateBalance'] > $GLOBALS['AdjustedCartSubTotal']) {
                 $GLOBALS['GiftCertificateRemaining'] = $certificate['giftcertbalance'] - $GLOBALS['AdjustedCartSubTotal'];
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'] - $GLOBALS['GiftCertificateRemaining'];
             } else {
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'];
                 $GLOBALS['GiftCertificateRemaining'] = 0;
             }
             // Subtract this amount from the adjusted total
             $GLOBALS['AdjustedCartSubTotal'] -= $GLOBALS['GiftCertificateBalance'];
             if ($GLOBALS['AdjustedCartSubTotal'] <= 0) {
                 $GLOBALS['AdjustedCartSubTotal'] = 0;
             }
             $GLOBALS['GiftCertificateBalance'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateBalance']);
             $GLOBALS['GiftCertificateRemaining'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateRemaining']);
             $GLOBALS['CertificateAmountUsed'] = CurrencyConvertFormatPrice($GLOBALS['CertificateAmountUsed']);
             $GLOBALS['SNIPPETS']['GiftCertificates'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartGiftCertificate");
         }
         if ($GLOBALS['SNIPPETS']['GiftCertificates']) {
             $GLOBALS['HideAdjustedTotal'] = '';
             if ($GLOBALS['AdjustedCartSubTotal'] == 0) {
                 $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
             }
         }
     }
     if ($GLOBALS['AdjustedCartSubTotal'] != $GLOBALS['CartSubTotal']) {
         $GLOBALS['HideAdjustedTotal'] = "";
         $GLOBALS['AdjustedCartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['AdjustedCartSubTotal']);
     }
     $GLOBALS['CartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['CartSubTotal']);
     $GLOBALS['CartSaveTotal'] = CurrencyConvertFormatPrice($_SESSION['you_save']);
     //blessen
     if (!gzte11(ISC_LARGEPRINT)) {
         $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
     }
     // Are there any products in the cart?
     if ($GLOBALS['ISC_CLASS_CART']->api->GetNumProductsInCart() == 0) {
         $GLOBALS['HideShoppingCartGrid'] = "none";
     } else {
         $GLOBALS['HideShoppingCartEmptyMessage'] = "none";
     }
 }
 public function SetPanelSettings()
 {
     $count = 0;
     $output = "";
     $params = $GLOBALS['ISC_CLASS_SEARCH']->_searchterms;
     $this->searchterms = $params;
     $path = GetConfig('ShopPath');
     /* the below mmy links are passed to the breadcrumbs */
     $mmy_links = "";
     /*---------- This below section is for generating search phrase----------*/
     $GLOBALS['Category'] = "";
     $GLOBALS['MMY'] = "";
     $GLOBALS['PQ'] = "";
     $GLOBALS['VQ'] = "";
     $GLOBALS['SearchPhrase'] = "";
     $ext_links = "";
     // this variable is passed to the product detail page
     $seo_delim = "&";
     if ($GLOBALS['EnableSEOUrls'] == 1) {
         $seo_delim = "/";
     }
     if (isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
         $GLOBALS['Category'] .= $GLOBALS['ISC_SRCH_CATG_NAME'];
     }
     if (isset($params['year'])) {
         $GLOBALS['MMY'] .= $params['year'] . "<br>";
         $ext_links .= $seo_delim . "year=" . $params['year'];
     }
     if (isset($params['make'])) {
         $GLOBALS['MMY'] .= strtoupper($params['make']) . "<br>";
         $ext_links .= $seo_delim . "make=" . $params['make'];
     }
     if (isset($_REQUEST['model']) && !empty($_REQUEST['model']) && (!isset($params['model_flag']) || $params['model_flag'] != 0)) {
         $GLOBALS['MMY'] .= strtoupper($_REQUEST['model']) . "<br>";
         $ext_links .= $seo_delim . "model=" . strtoupper($params['model']);
     } else {
         if (isset($params['model'])) {
             $ext_links .= $seo_delim . "model=" . $params['model'];
         }
     }
     /* this condition has been added seperately here to show submodel at last */
     if (isset($params['submodel'])) {
         $GLOBALS['MMY'] .= strtoupper($params['submodel']) . "<br>";
     }
     /*if(isset($params['year'])) {
       $ext_links .= $seo_delim."year=".$params['year'];                
       }*/
     if (isset($params['dynfilters']) && !empty($params['dynfilters'])) {
         foreach ($params['dynfilters'] as $key => $value) {
             if (eregi('vq', $key)) {
                 $key = str_ireplace('vq', '', $key);
                 $GLOBALS['VQ'] .= ucfirst($key) . ": {$value}<br>";
             } else {
                 if (eregi('pq', $key)) {
                     $key = str_ireplace('pq', '', $key);
                     $GLOBALS['PQ'] .= ucfirst($key) . ": {$value}<br>";
                 }
             }
         }
     }
     $filter_var = array('vq', 'pq');
     /* this below patch is used for getting description of the category. Here currently the selected category id will be last one in the $params['srch_category'] array. if input['category'] is used then it will be the first one */
     if (!empty($params['srch_category'])) {
         if (isset($params['category'])) {
             $selected_catg = $params['srch_category'][0];
         } else {
             $selected_catg = end($params['srch_category']);
         }
         $catg_desc_qry = "select catdesc from [|PREFIX|]categories where categoryid = " . $selected_catg;
         $catg_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($catg_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($catg_desc_res) > 0) {
             $catg_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_desc_res);
         }
         /* this below patch is used to show the display name for the qualifiers from the qualifier association table */
         $map_names = array();
         $display_names = array();
         $filter_names = "select qid , column_name , display_names from [|PREFIX|]qualifier_names where column_name regexp '^(pq|vq)'";
         $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
         while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
             $map_names[$filter_row['qid']] = $filter_row['column_name'];
             $display_names[$filter_row['qid']] = $filter_row['display_names'];
         }
         $this->GetAssocDetails($selected_catg, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
     }
     // for breadcrumbs
     $this->_BuildBreadCrumbs();
     /* the below line has been commented as client told to remove it */
     //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     if ($GLOBALS['ISC_CLASS_SEARCH']->GetNumResults() > 30) {
         $msg_qry = "select value from [|PREFIX|]display where messageid = 1";
         $msg_res = $GLOBALS['ISC_CLASS_DB']->Query($msg_qry);
         $msg_row = $GLOBALS['ISC_CLASS_DB']->FetchOne($msg_res);
         $GLOBALS['SearchPhrase'] = $msg_row;
         //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     }
     /*if(!empty($params['dynfilters']))
       $GLOBALS['SearchPhrase'] .= " ".implode(" ",$params['dynfilters']);
       /*---------- Ending section for generating search phrase----------*/
     $vq_column_title = "";
     $GLOBALS['SearchResultList'] = "";
     if ($GLOBALS['ISC_CLASS_SEARCH']->GetNumResults() > 0) {
         // We have at least one result, let's show it to the world!
         $GLOBALS['HideNoResults'] = "none";
         // Only show the "compare" option if there are 2 or more products on this page
         if (GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_DB']->CountResult($GLOBALS['SearchResults']) < 2) {
             $GLOBALS['HideCompareItems'] = "none";
         }
         if (GetConfig('EnableProductReviews') == 0) {
             $GLOBALS['HideProductRating'] = "display: none";
         }
         $GLOBALS['AlternateClass'] = '';
         $counter = 1;
         $CurCatId = 0;
         $mmy_links = $this->GetYMMLinks($params);
         $mmy_links .= $this->GetOtherLinks($params);
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['SearchResults'])) {
             /* Added by Simha to check inf prodcucts comes from different categories*/
             if (empty($params['srch_category']) || !isset($params['srch_category'])) {
                 if ($CurCatId != $row['categoryid']) {
                     $CurCatId = $row['categoryid'];
                     $map_names = array();
                     $display_names = array();
                     $filter_names = "SELECT DISTINCT qn.qid, qn.column_name, qn.display_names from \n                                                [|PREFIX|]qualifier_names qn\n                                                LEFT JOIN [|PREFIX|]qualifier_associations qa ON qa.qualifierid = qn.qid\n                                                WHERE (qa.categoryid = '{$CurCatId}') \n                                                AND qn.column_name regexp '^(pq|vq)'";
                     // || qa.categoryid IN (SELECT catparentid FROM isc_categories WHERE categoryid = '$CurCatId')
                     $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
                     while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
                         $map_names[$filter_row['qid']] = $filter_row['column_name'];
                         $display_names[$filter_row['qid']] = $filter_row['display_names'];
                     }
                     $this->GetAssocDetails($CurCatId, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
                 }
             }
             /* Added by Simha Ends */
             $GLOBALS['SearchTrackClass'] = "TrackLink";
             $imagefile = "";
             if ($GLOBALS['AlternateClass'] == 'Odd') {
                 $GLOBALS['AlternateClass'] = 'Even';
             } else {
                 $GLOBALS['AlternateClass'] = 'Odd';
             }
             $qry_string = $_SERVER['QUERY_STRING'];
             if (isset($_GET['page'])) {
                 $page = "&page=" . $_GET['page'];
                 $qry_string = str_ireplace($page, '', $qry_string);
             }
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 if (isset($_GET['search_key'])) {
                     $qry_string = str_ireplace('&search_key=' . $_GET['search_key'], '', $qry_string);
                 }
                 if (isset($params['search_query']) && !strstr($qry_string, 'search_query=')) {
                     $qry_string .= "search_query=" . MakeURLSafe($params['search_query']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model']) && !strstr($qry_string, 'model=')) {
                     $qry_string .= "&model=" . MakeURLSafe($params['model']);
                 }
                 if (isset($params['year']) && !strstr($qry_string, 'year=')) {
                     $qry_string .= "&year=" . MakeURLSafe($params['year']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model_flag']) && !strstr($qry_string, 'model_flag=')) {
                     $qry_string .= "&model_flag=" . MakeURLSafe($params['model_flag']);
                 }
                 if (isset($params['submodel']) && !strstr($qry_string, 'submodel=')) {
                     $qry_string .= "&submodel=" . MakeURLSafe($params['submodel']);
                 }
             }
             if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
                 if (isset($params['srch_category'])) {
                     $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                     // description will be added here to show it at the top of product listing page.
                 }
                 $GLOBALS['ProductCartQuantity'] = '';
                 if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
                     $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
                 }
                 if ($counter % 2 == 0) {
                     $GLOBALS['RowColor'] = 'grayrow';
                 } else {
                     $GLOBALS['RowColor'] = 'whiterow';
                 }
                 $counter++;
                 $GLOBALS['ProductId'] = (int) $row['productid'];
                 $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
                 $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
                 $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
                 $GLOBALS['BrandName'] = $row['brandname'];
                 $GLOBALS['ProdCode'] = $row['prodcode'];
                 //$GLOBALS['ProdDesc'] = $this->strip_html_tags($row['proddesc']);
                 //$GLOBALS['ProdOptions'] = $row['productoption'];
                 $GLOBALS['VehicleOptions'] = "";
                 $GLOBALS['ProdOptions'] = "";
                 foreach ($row as $key => $val) {
                     if ($val != "" && $val != "~") {
                         if (($qualifier_id = array_search($key, $map_names)) !== false) {
                             if (eregi('^vq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != "") {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentAssoc[$qualifier_id][$m]['vname'] != "") {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 $GLOBALS['VehicleOptions'] .= $key . " : " . $val . "<br>";
                             }
                             if (eregi('^pq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != '') {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentValue[$qualifier_id][$m]['vname'] != '') {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 $GLOBALS['ProdOptions'] .= $key . " : " . $val . "<br>";
                             }
                         }
                     }
                 }
                 if (isset($row['vehicleoption'])) {
                     $GLOBALS['VehicleOptions'] = $row['vehicleoption'];
                 }
                 if (isset($row['productoption'])) {
                     $GLOBALS['ProdOptions'] = $row['productoption'];
                 }
                 if (isset($row['catuniversal']) && $row['catuniversal'] == 1) {
                     $GLOBALS['VehicleOptions'] = $GLOBALS['ProductName'];
                     if ($vq_column_title == "") {
                         $vq_column_title = "Product Name";
                     } else {
                         if ($vq_column_title != "Product Name") {
                             $vq_column_title = "Product Name / Vehicle Options";
                         }
                     }
                 } else {
                     if ($vq_column_title == "") {
                         $vq_column_title = "Vehicle Options";
                     } else {
                         if ($vq_column_title != "Vehicle Options") {
                             $vq_column_title = "Product Name / Vehicle Options";
                         }
                     }
                 }
                 if (empty($GLOBALS['VehicleOptions'])) {
                     $GLOBALS['VehicleOptions'] = "&nbsp;";
                 }
                 if (empty($GLOBALS['ProdOptions'])) {
                     $GLOBALS['ProdOptions'] = "&nbsp;";
                 }
                 /*--- the below lines are added for back 2 search link in the product detail page. Also modified line no 56 & 60 --- */
                 if ($GLOBALS['EnableSEOUrls'] == 1) {
                     $GLOBALS['ProductLink'] .= "/refer=true" . $ext_links;
                 } else {
                     $GLOBALS['ProductLink'] .= "&refer=true" . $ext_links;
                 }
                 ### Added by Simha for onsale addition
                 // Determine the price of this product
                 //$GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
                 $GLOBALS['ProductPrice'] = CalculateProductPriceRetail($row);
                 $FinalPrice = $GLOBALS['ProductPrice'];
                 $SalePrice = $row['prodsaleprice'];
                 //$DiscountAmount = $FinalPrice;
                 if ((double) $SalePrice > 0 && $SalePrice < $FinalPrice) {
                     $DiscountPrice = $SalePrice;
                 } else {
                     $DiscountPrice = $FinalPrice;
                     $DiscountPrice = CalculateDiscountPrice($FinalPrice, $DiscountPrice, $row['categoryid'], $row['brandseriesid']);
                 }
                 /*
                 							foreach($DiscountInfo as $DiscountInfoSub)   {  
                     if(isset($DiscountInfoSub['catids']))    {
                 								    $catids = explode(",", $DiscountInfoSub['catids']); 
                 								    foreach($catids as $catid) {
                 									    if($catid == $row['categoryid']) {
                 										    $DiscountAmount = $FinalPrice * ((int)$DiscountInfoSub['amount']/100); 
                 										    if ($DiscountAmount < 0) {
                 											    $DiscountAmount = 0;
                 										    }                                                                         
                 										    $DiscountPrice  = $FinalPrice - $DiscountAmount;  
                 									    } 
                 								    }  
                     }
                 							}       
                 */
                 if (isset($DiscountPrice) && $DiscountPrice < $FinalPrice) {
                     //&& GetConfig('ShowOnSale')
                     $GLOBALS['ProductPrice'] = '<strike>' . CurrencyConvertFormatPrice($FinalPrice) . '</strike>';
                     $GLOBALS['ProductPrice'] .= '<br>' . CurrencyConvertFormatPrice($DiscountPrice) . '';
                     $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     if (GetConfig('ShowOnSale')) {
                         $GLOBALS['ProductPrice'] .= '<br>' . $GLOBALS['ShowOnSaleImage'] . '';
                     }
                 } else {
                     $GLOBALS['ProductPrice'] = '' . CurrencyConvertFormatPrice($FinalPrice) . '';
                 }
                 ### Added by Simha Ends
                 // commented the below line by vikas
                 //$GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
                 $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], $GLOBALS['ProductLink']);
                 if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
                 } else {
                     //$GLOBALS['ProductURL'] = CartLink($row['productid']);
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     //blessen
                     if (intval($row['prodretailprice']) <= 0) {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     } else {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     }
                     //blessen
                     // original $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
                 }
                 if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
                     $GLOBALS['HideActionAdd'] = '';
                 } else {
                     $GLOBALS['HideActionAdd'] = 'none';
                 }
                 $GLOBALS['HideProductVendorName'] = 'display: none';
                 $GLOBALS['ProductVendor'] = '';
                 if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
                     $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
                     if (isset($vendorCache[$row['prodvendorid']])) {
                         $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                         $GLOBALS['HideProductVendorName'] = '';
                     }
                 }
                 $GLOBALS['CartURL'] = CartLink($row['productid']);
                 $offer = $this->IsProductMakeanOffer($row['brandseriesid'], $row['brandname'], $row['categoryid']);
                 if ($offer == 'yes') {
                     $GLOBALS['HideOfferButton'] = 'block';
                 } else {
                     $GLOBALS['HideOfferButton'] = 'none';
                 }
                 $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItem");
             } else {
                 if ($GLOBALS['results_page_flag'] == 0) {
                     $subcatg_link = $this->LeftCatLink($mmy_links, 'subcategory', $row['catname']);
                     $link = "<a href='" . $subcatg_link . "'>";
                     if (isset($row['imagefile']) && !empty($row['imagefile'])) {
                         $images = explode("~", $row['imagefile']);
                         for ($j = 0; $j < count($images); $j++) {
                             if (!empty($images[$j])) {
                                 $imagefile = "{$link}<img src='{$path}/category_images/" . $images[$j] . "'></a>";
                                 break;
                             }
                         }
                     } else {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $imagefile = "{$link}<img src='{$path}/templates/default/images/ProductDefault.gif' border=0></a>";
                         }
                     }
                     $GLOBALS['LeftImage'] = $imagefile;
                     $GLOBALS['ProductsCount'] = "(" . $row['totalproducts'] . ") Products Available";
                     $row['brandname'] = str_replace('~', ' , ', $row['brandname']);
                     //$GLOBALS['RelatedBrands'] = $row['brandname'];
                     if (!empty($row['seriesname'])) {
                         $row['brandname'] .= "<br>" . $row['seriesname'];
                     }
                     if ($row['seriesids'] != "") {
                         $seriesids = str_ireplace("~", ",", $row['seriesids']);
                         $seriesids_qry = "select brandname , seriesname from isc_brand_series bs left join isc_brands b on bs.brandid = b.brandid where seriesid in (" . $seriesids . ")";
                         $seriesids_res = $GLOBALS['ISC_CLASS_DB']->Query($seriesids_qry);
                         if ($GLOBALS['ISC_CLASS_DB']->CountResult($seriesids_res) > 0) {
                             while ($seriesids_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($seriesids_res)) {
                                 if (!isset($params['brand'])) {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "/brand/" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "&brand=" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 } else {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 }
                             }
                         }
                     }
                     $content = $row['brandname'] . "<br>";
                     if (!isset($params['category']) && (isset($params['srch_category']) || !isset($GLOBALS['BRAND_SERIES_FLAG']))) {
                         $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                         // description will be added here to show it at the top of subcatg page.
                         $content .= "<h3><a href='" . $path . "/search.php?{$qry_string}&subcategory=" . MakeURLSafe($row['catname']) . "'>" . $row['catname'] . "</a></h3>>";
                         $GLOBALS['TitleLink'] = "<h2><a href='" . $subcatg_link . "'>" . $row['catname'] . "</a></h2>";
                     }
                     $content .= "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '') . "<br>" . $imagefile;
                     $GLOBALS['leftsidecontent'] = $content;
                     $GLOBALS['PriceRange'] = "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '');
                     $content = "<img src='{$path}/templates/default/images/free-shipping2.gif'><br>" . strip_tags($row['proddesc']) . "<br>" . $row['prodwarranty'];
                     $GLOBALS['rightsidecontent'] = $content;
                     $GLOBALS['ShippingImage'] = "<img src='{$path}/templates/default/images/free-shipping2.gif'>";
                     $GLOBALS['ProductWarranty'] = "<h3>" . $row['prodwarranty'] . "</h3>";
                     $content = "{$link}<img src='{$path}/templates/default/images/view.gif'></a>";
                     $GLOBALS['ViewDetailsImage'] = $content;
                     if (IsDiscountAvailable('category', $row['categoryid'])) {
                         $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     }
                     if ($this->IsMakeAnOffer('category', $row['categoryid']) == 'yes') {
                         $GLOBALS['ViewDetailsImage'] .= "<h3>Qualifies for Make an Offer!</h3>";
                     }
                     $GLOBALS['lowersidecontent'] = $content;
                     $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListing");
                 } else {
                     $series_link = $this->LeftCatLink($mmy_links, 'series', $row['seriesname']);
                     $link = "<a href='" . $series_link . "'>";
                     if (isset($row['imagefile']) && !empty($row['imagefile'])) {
                         $images = explode("~", $row['imagefile']);
                         for ($j = 0; $j < count($images); $j++) {
                             if (!empty($images[$j])) {
                                 $imagefile = "{$link}<img src='{$path}/category_images/" . $images[$j] . "'></a>";
                                 break;
                             }
                         }
                     } else {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $imagefile = "{$link}<img src='{$path}/templates/default/images/ProductDefault.gif' border=0></a>";
                         }
                     }
                     $GLOBALS['LeftImage'] = $imagefile;
                     $row['brandname'] = str_replace('~', ' , ', $row['brandname']);
                     $GLOBALS['RelatedBrands'] = $row['brandname'];
                     if (isset($row['seriesname']) && !empty($row['seriesname']) && (!isset($params['srch_category']) || isset($params['category'])) && isset($GLOBALS['BRAND_SERIES_FLAG'])) {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $GLOBALS['LeftImage'] = "{$link}<img src='{$path}/templates/default/images/ProductDefault.gif'></a>";
                         } else {
                             $GLOBALS['LeftImage'] = "{$link}<img src='{$path}/series_images/" . $row['imagefile'] . "' width='140px'></a>";
                         }
                         $GLOBALS['TitleLink'] = "<h2><a href='" . $series_link . "'>" . $row['brandname'] . " " . $row['seriesname'] . " " . $row['parentcatname'] . "</a></h2>";
                         //"<h3>".$row['catname']."</h3>
                         $GLOBALS['ProductsCount'] = "(" . $row['totalproducts'] . ") Products Available";
                         $GLOBALS['RelatedBrands'] = "<ul class='featurepoints'>";
                         if (!empty($row['feature_points1'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points1'] . "</li>";
                         }
                         if (!empty($row['feature_points2'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points2'] . "</li>";
                         }
                         if (!empty($row['feature_points3'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points3'] . "</li>";
                         }
                         if (!empty($row['feature_points4'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points4'] . "</li>";
                         }
                         $GLOBALS['RelatedBrands'] .= "</ul>";
                         /*if(isset($row['brandlargefile']) && !empty($row['brandlargefile'])) {
                         			$brand_image_path = "product_images/".$row['brandlargefile'];
                         			if(file_exists($brand_image_path)) {
                         				$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandlargefile']."'>";
                         			} else if(isset($row['brandimagefile']) && !empty($row['brandimagefile'])) {
                         				$brand_image_path = "product_images/".$row['brandimagefile'];
                         				if(file_exists($brand_image_path))
                         					$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandimagefile']."'>";
                         			}
                         		} else if(isset($row['brandimagefile']) && !empty($row['brandimagefile'])) {
                         				$brand_image_path = "product_images/".$row['brandimagefile'];
                         				if(file_exists($brand_image_path))
                         					$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandimagefile']."'>";
                         		}*/
                     }
                     $GLOBALS['CatgDescandBrandImage'] = $row['branddescription'];
                     if ($row['subcatgids'] != "") {
                         $subcatgids = str_ireplace("~", ",", $row['subcatgids']);
                         $subcatgids_qry = "select catname from [|PREFIX|]categories where categoryid in (" . $subcatgids . ")";
                         $subcatgids_res = $GLOBALS['ISC_CLASS_DB']->Query($subcatgids_qry);
                         if ($GLOBALS['ISC_CLASS_DB']->CountResult($subcatgids_res) > 0) {
                             while ($subcatgids_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($subcatgids_res)) {
                                 if ($GLOBALS['EnableSEOUrls'] == 1) {
                                     $GLOBALS['ProductsCount'] .= "<br><a href='" . $series_link . "/subcategory/" . MakeURLSafe(Strtolower($subcatgids_arr['catname'])) . "'>" . $subcatgids_arr['catname'] . "</a>";
                                 } else {
                                     $GLOBALS['ProductsCount'] .= "<br><a href='" . $series_link . "&subcategory=" . MakeURLSafe(Strtolower($subcatgids_arr['catname'])) . "'>" . $subcatgids_arr['catname'] . "</a>";
                                 }
                             }
                         }
                     }
                     $content = $row['brandname'] . "<br>";
                     $content .= $row['catname'] . "<br>";
                     $content .= "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '');
                     $GLOBALS['leftsidecontent'] = $content;
                     $GLOBALS['PriceRange'] = "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '');
                     $content = "<img src='{$path}/templates/default/images/free-shipping2.gif'><br>" . strip_tags($row['proddesc']) . "<br>" . $row['prodwarranty'];
                     $GLOBALS['rightsidecontent'] = $content;
                     $GLOBALS['ShippingImage'] = "<img src='{$path}/templates/default/images/free-shipping2.gif'>";
                     $GLOBALS['ProductWarranty'] = "<h3>" . $row['prodwarranty'] . "</h3>";
                     $content = "{$link}<img src='{$path}/templates/default/images/view.gif'></a>";
                     $GLOBALS['ViewDetailsImage'] = $content;
                     if (IsDiscountAvailable('series', $row['brandseriesid'])) {
                         $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     }
                     if ($this->IsMakeAnOffer('series', $row['brandseriesid']) == 'yes') {
                         $GLOBALS['ViewDetailsImage'] .= "<h3>Qualifies for Make an Offer!</h3>";
                     }
                     $GLOBALS['lowersidecontent'] = $content;
                     $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListing");
                     $GLOBALS['HideCompareItems'] = "none";
                 }
             }
         }
         $get_variables = $_GET;
         $sort_qry = "{$path}/search.php?search_query=" . urlencode($params['search_query']);
         unset($get_variables['orderby'], $get_variables['sort'], $get_variables['search_query'], $get_variables['sortby']);
         $i = 0;
         foreach ($get_variables as $key => $value) {
             $sort_qry .= "&{$key}={$value}";
         }
         if (isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'desc') {
             $sort = "asc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowDown.gif' border=0>";
         } else {
             $sort = "desc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowUp.gif' border=0>";
         }
         //$GLOBALS['SearchResults'] = $GLOBALS['SearchResultList']; // commented by vikas
         if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}{$mmy_links}/orderby/brandname/sortby/{$sort}'>Brand</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}{$mmy_links}/orderby/prodcode/sortby/{$sort}'>Part Number</a>";
                 $GLOBALS['ProductPrice'] = "<a href='{$path}{$mmy_links}/orderby/prodcalculatedprice/sortby/{$sort}'>Price</a>";
             } else {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=brandname&sortby={$sort}'>Brand</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcode&sortby={$sort}'>Part Number</a>";
                 $GLOBALS['ProductPrice'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcalculatedprice&sortby={$sort}'>Price</a>";
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'brandname') {
                 $GLOBALS['ProductBrand'] .= $img;
             }
             $GLOBALS['ProductVQ'] = $vq_column_title;
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'brandname')
             		$GLOBALS['Product_VQ'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcode') {
                 $GLOBALS['ProductPartNumber'] .= $img;
             }
             $GLOBALS['ProductPQ'] = "Product Options";
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'productoption')
             		$GLOBALS['SearchResults'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcalculatedprice') {
                 $GLOBALS['ProductPrice'] .= $img;
             }
             $GLOBALS['ProductDetails'] = "Details";
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItemHeader");
         } else {
             //		                $GLOBALS['SearchResults'] = "<div>".$GLOBALS['SearchResultList']."</div>";
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListingMain");
         }
         if ($GLOBALS['EnableSEOUrls'] == 1) {
             $back2url = $_SESSION['back2url'] = preg_replace("/^\\//", "", $_SERVER['REQUEST_URI']);
         } else {
             $back2url = $_SESSION['back2url'] = "search.php?" . $_SERVER['QUERY_STRING'];
         }
         ISC_SetCookie("back2search", $back2url, 0, "/");
         // Showing the syndication option?
         if (GetConfig('RSSNewProducts') != 0 && GetConfig('RSSCategories') != 0 && GetConfig('RSSSyndicationIcons') != 0) {
             $GLOBALS['RSSURL'] = SearchLink($GLOBALS['ISC_CLASS_SEARCH']->GetQuery(), 0, false);
             $GLOBALS['SNIPPETS']['SearchResultsFeed'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchResultsFeed");
         }
     } else {
         // No search results were found
         $GLOBALS['HideSearchResults'] = "none";
         $GLOBALS['HidePanels'][] = 'SearchPageProducts';
     }
 }
    /**
     * Generate an individual row for the order items table.
     *
     * @param string The unique identifier for this row.
     * @param array Array of details about the product for this row.
     * @param boolean Set to true to hide this row by default.
     * @return string The generated HTML row for this item.
     */
    public function GenerateOrderItemRow($rowId, $product = array(), $hidden = false)
    {
        static $first = true;
        static $publicWrappingOptions = null;
        if ($hidden == true) {
            $GLOBALS['HideRow'] = 'display: none';
        } else {
            $GLOBALS['HideRow'] = '';
        }
        if (is_null($publicWrappingOptions)) {
            $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
            if (empty($wrappingOptions)) {
                $publicWrappingOptions = false;
            } else {
                $publicWrappingOptions = true;
            }
        }
        if ($first != true) {
            $GLOBALS['HideInsertTip'] = 'display: none';
        }
        $first = false;
        if (empty($product)) {
            $GLOBALS['CartItemId'] = $rowId;
            $GLOBALS['ProductCode'] = '';
            $GLOBALS['ProductId'] = 0;
            $GLOBALS['ProductName'] = '';
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['HideProductVariation'] = 'display: none;';
            $GLOBALS['ProductPrice'] = FormatPrice(0, false, false, true);
            $GLOBALS['ProductQuantity'] = 1;
            $GLOBALS['ProductTotal'] = FormatPrice(0);
            $GLOBALS['HideEventDate'] = 'display : none;';
            $GLOBALS['EventDate'] = '';
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
        $GLOBALS['CartItemId'] = $rowId;
        //isc_html_escape($product['cartitemid']);
        // If the item in the cart is a gift certificate, we need to show a special type of row
        if (isset($product['type']) && $product['type'] == "giftcertificate") {
            $GLOBALS['ProductCode'] = GetLang('NA');
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductPrice'] = FormatPrice($product['product_price']);
            $GLOBALS['ProductTotal'] = FormatPrice($product['product_price'] * $product['quantity']);
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItemGiftCertificate');
        } else {
            $GLOBALS['ProductId'] = $product['product_id'];
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductCode'] = $product['product_code'];
            // Don't use the discount price here as we'll be showing the coupon codes
            // down below in the summary table
            $productPrice = $product['product_price'];
            $GLOBALS['ProductPrice'] = FormatPrice($productPrice, false, false, true);
            $GLOBALS['ProductTotal'] = FormatPrice($productPrice * $product['quantity']);
            // Initialize the configurable product fields
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['ProductFields'] = '';
            if (!empty($product['product_fields']) && is_array($product['product_fields'])) {
                $GLOBALS['HideProductFields'] = '';
                foreach ($product['product_fields'] as $fieldId => $field) {
                    switch ($field['fieldType']) {
                        case 'file':
                            if (isset($field['fieldExisting'])) {
                                $fileDirectory = 'configured_products';
                            } else {
                                $fileDirectory = 'configured_products_tmp';
                            }
                            $fieldValue = '<a href="' . GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $fileDirectory . '/' . $field['fileName'] . '" target="_blank">' . isc_html_escape($field['fileOriginName']) . '</a>';
                            break;
                        case 'checkbox':
                            $fieldValue = GetLang('Checked');
                            break;
                        default:
                            if (isc_strlen($field['fieldValue']) > 50) {
                                $field['fieldValue'] = isc_substr($field['fieldValue'], 0, 50) . " ..";
                            }
                            $fieldValue = isc_html_escape($field['fieldValue']);
                            // browser is decoding the entities in the ajax response which prevents the row from loading so we need to double encode
                            if (isset($_REQUEST['ajaxFormUpload'])) {
                                $fieldValue = isc_html_escape($fieldValue);
                            }
                    }
                    if (!trim($fieldValue)) {
                        continue;
                    }
                    $GLOBALS['ProductFields'] .= '
							<dt>' . isc_html_escape($field['fieldName']) . ':</dt>
							<dd>' . $fieldValue . '</dd>
						';
                }
            }
            // Can this item be wrapped?
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            if ($product['data']['prodtype'] == PT_PHYSICAL && @$product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                $GLOBALS['HideWrappingOptions'] = '';
                if (isset($product['wrapping'])) {
                    $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                    $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                    $GLOBALS['HideGiftWrappingEdit'] = '';
                    $GLOBALS['HideGiftWrappingPrice'] = '';
                    $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                } else {
                    $GLOBALS['GiftWrappingName'] = '';
                    $GLOBALS['HideGiftWrappingAdd'] = '';
                    $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
                    $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
                    $GLOBALS['GiftWrappingPrice'] = '';
                }
            }
            // Is this product a variation?
            $GLOBALS['ProductOptions'] = '';
            $GLOBALS['HideProductVariation'] = 'display: none';
            if (isset($product['options']) && !empty($product['options'])) {
                $comma = '';
                $GLOBALS['HideProductVariation'] = '';
                foreach ($product['options'] as $name => $value) {
                    if (!trim($name) || !trim($value)) {
                        continue;
                    }
                    $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                    $comma = ' / ';
                }
            } else {
                if (isset($product['data']['prodvariationid']) && $product['data']['prodvariationid'] > 0) {
                    $GLOBALS['HideProductVariation'] = '';
                    $GLOBALS['ProductOptions'] = GetLang('xNone');
                }
            }
            if (isset($product['data']['prodeventdaterequired']) && $product['data']['prodeventdaterequired']) {
                $GLOBALS['HideEventDate'] = '';
                $GLOBALS['EventDate'] = '<dl><dt>' . $product['data']['prodeventdatefieldname'] . ': </dt><dd>' . isc_date('jS M Y', $product['event_date']) . '</dd></dl>';
            } else {
                $GLOBALS['HideEventDate'] = 'display : none;';
                $GLOBALS['EventDate'] = '';
            }
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
    }
		/**
		* ShowPaymentForm
		* Show a payment form for this particular gateway if there is one.
		* This is useful for gateways that require things like credit card details
		* to be submitted and then processed on the site.
		*/
		public function ShowPaymentForm()
		{
			$GLOBALS['CreditCardMonths'] = $GLOBALS['CreditCardYears'] = '';
			$GLOBALS['CreditCardIssueDateMonths'] = $GLOBALS['CreditCardIssueDateYears'] = '';

			$cc_type = "";

			if(isset($_POST['creditcard_cctype'])) {
				$cc_type = $_POST['creditcard_cctype'];
			}

			$GLOBALS['CCTypes'] = $this->_GetCCTypes($cc_type);

			for ($i = 1; $i <= 12; $i++) {
				$stamp = mktime(0, 0, 0, $i, 15, date("Y"));

				$i = str_pad($i, 2, "0", STR_PAD_LEFT);

				if (isset($_POST['creditcard_ccexpm']) && $_POST['creditcard_ccexpm'] == $i) {
					$sel = 'selected="selected"';
				} else {
					$sel = "";
				}

				if(isset($_POST['creditcard_issuedatem']) && $_POST['creditcard_issuedatem'] == $i) {
					$issueSel = 'selected="selected"';
				}
				else {
					$issueSel = '';
				}

				$GLOBALS['CreditCardMonths'] .= sprintf("<option %s value='%s'>%s</option>", $sel, $i, date("M", $stamp));
				$GLOBALS['CreditCardIssueDateMonths'] .= sprintf("<option %s value='%s'>%s</option>", $issueSel, $i, date("M", $stamp));
			}

			for ($i = date("Y"); $i <= date("Y")+10; $i++) {
				if(isset($_POST['creditcard_ccexpy']) && $_POST['creditcard_ccexpy'] == isc_substr($i, 2, 2)) {
					$sel = 'selected="selected"';
				}
				else {
					$sel = "";
				}
				$GLOBALS['CreditCardYears'] .= sprintf("<option %s value='%s'>%s</option>", $sel, isc_substr($i, 2, 2), $i);
			}

			for ($i = date("Y"); $i > date("Y")-5; --$i) {
				if(isset($_POST['creditcard_issuedatey']) && $_POST['creditcard_issuedatey'] == isc_substr($i, 2, 2)) {
					$sel = 'selected="selected"';
				}
				else {
					$sel = "";
				}
				$GLOBALS['CreditCardIssueDateYears'] .= sprintf("<option %s value='%s'>%s</option>", $sel, isc_substr($i, 2, 2), $i);
			}

			if ($this->CardTypeRequiresCVV2($cc_type)) {
				$GLOBALS['CreditCardHideCardCode'] = '';
			}
			else {
				$GLOBALS['CreditCardHideCardCode'] = 'none';
			}

			// Was there an error validating the payment? If so, pre-fill the form fields with the already-submitted values
			if($this->HasErrors()) {
				$fields = array(
					"CreditCardName" => 'creditcard_name',
					"CreditCardNum" => 'creditcard_ccno',
					"CreditCardCardCode" => 'creditcard_cccvd',
					"CreditCardIssueNo" => 'creditcard_issueno'
				);
				foreach($fields as $global => $post) {
					if(isset($_POST[$post])) {
						$GLOBALS[$global] = isc_html_escape($_POST[$post]);
					}
				}

				$errorMessage = implode("<br />", $this->GetErrors());
				$GLOBALS['CreditCardErrorMessage'] = $errorMessage;
			}
			else {
				// Hide the error message box
				$GLOBALS['HideCreditCardError'] = "none";
			}

			$pendingOrder = LoadPendingOrderByToken();
			$GLOBALS['OrderAmount'] = CurrencyConvertFormatPrice($pendingOrder['total_inc_tax'], $pendingOrder['ordcurrencyid'], $pendingOrder['ordcurrencyexchangerate']);


			// Get additional payment page contents if there is any
			if(method_exists($this, 'GetAdditionalPaymentPageContents')) {
				$GLOBALS['AdditionalPaymentPageContents'] = $this->GetAdditionalPaymentPageContents();
			}
			// Collect their details to send through to CreditCard
			$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("genericcreditcard");
			return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
		}
Example #12
0
	/**
	 * Setup the list of gift certificates that have been applied to the
	 * shopping cart.
	 */
	public function setUpAppliedGiftCertificates()
	{
		if (!gzte11(ISC_LARGEPRINT)) {
			$GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
			return;
		}

		$GLOBALS['SNIPPETS']['GiftCertificates'] = '';

		$giftCertificates = $this->quote->getAppliedGiftCertificates();
		if(empty($giftCertificates)) {
			return;
		}

		foreach ($giftCertificates as $certificate) {
			$GLOBALS['GiftCertificateCode'] = isc_html_escape($certificate['code']);
			$GLOBALS['GiftCertificateId'] = $certificate['id'];
			$GLOBALS['GiftCertificateRemaining'] = CurrencyConvertFormatPrice($certificate['remaining']);
			$GLOBALS['CertificateAmountUsed'] = CurrencyConvertFormatPrice($certificate['used'] * -1);
			$GLOBALS['SNIPPETS']['GiftCertificates'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartGiftCertificate");
		}

		if ($GLOBALS['SNIPPETS']['GiftCertificates']) {
			if($this->quote->getGrandTotal() == 0) {
				$GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
			}
		}
	}
Example #13
0
 public function GetProductVariationCombinationJavascript()
 {
     if (empty($this->_prodvariationcombinations)) {
         return '';
     }
     $script = "<script type=\"text/javascript\">\n";
     $script .= " var VariationList = new Array();\n";
     foreach ($this->_prodvariationcombinations as $variation) {
         $variationPrice = CurrencyConvertFormatPrice(CalcProductVariationPrice($this->_prodcalculatedprice, $variation['vcpricediff'], $variation['vcprice'], $this->_product));
         $youSave = $this->_prodretailprice - CalcProductVariationPrice($this->_prodcalculatedprice, $variation['vcpricediff'], $variation['vcprice'], $this->_product);
         $variationSaveAmount = '';
         if ($youSave > 0) {
             $variationSaveAmount = CurrencyConvertFormatPrice($youSave);
         }
         $variationWeight = FormatWeight(CalcProductVariationWeight($this->_prodweight, $variation['vcweightdiff'], $variation['vcweight']), true);
         if ($variation['vcthumb'] != '') {
             $thumb = $GLOBALS['ShopPath'] . "/" . GetConfig('ImageDirectory') . "/" . $variation['vcthumb'];
         } else {
             $thumb = '';
         }
         if ($variation['vcimage'] != '') {
             $image = $GLOBALS['ShopPath'] . '/' . GetConfig('ImageDirectory') . '/' . $variation['vcimage'];
         } else {
             $image = '';
         }
         $ids = explode(",", $variation['vcoptionids']);
         $optionList = array();
         foreach ($ids as $id) {
             $key = $this->_prodvariationslookup[$id];
             $optionList[$key] = $id;
         }
         ksort($optionList);
         $optionList = implode(",", $optionList);
         $script .= " VariationList[" . $variation['combinationid'] . "] = {";
         $script .= " combination: '" . $optionList . "', ";
         $script .= " saveAmount: '" . $variationSaveAmount . "', ";
         $script .= " price: '" . $variationPrice . "', ";
         $script .= " sku: '" . isc_html_escape($variation['vcsku']) . "', ";
         $script .= " weight: '" . $variationWeight . "', ";
         $script .= " thumb: '" . $thumb . "', ";
         $script .= " image: '" . $image . "', ";
         // Tracking inventory on a product variation level
         if ($this->_prodinvtrack == 2) {
             if (GetConfig('ShowInventory') == 1) {
                 $script .= "stock: '" . $variation['vcstock'] . "', ";
             }
             if ($variation['vcstock'] <= 0) {
                 $script .= " instock: false";
             } else {
                 $script .= " instock: true";
             }
         } else {
             $script .= " instock: true";
         }
         $script .= "};\n";
     }
     $script .= "</script>";
     return $script;
 }
Example #14
0
 public function SetPanelSettings()
 {
     $_SESSION['you_save'] = 0;
     //blessen
     $GLOBALS['SNIPPETS']['CartItems'] = "";
     $count = 0;
     $subtotal = 0;
     $_SESSION['CHECKOUT'] = array();
     // Get a list of all products in the cart
     $GLOBALS['ISC_CLASS_CART'] = GetClass('ISC_CART');
     $product_array = $GLOBALS['ISC_CLASS_CART']->api->GetProductsInCart();
     /* $cprint = print_r($product_array, true);     
        $q      = "INSERT INTO isc_orderlogs (`ordervalue`) VALUES ('$cprint')";
        $r      = $GLOBALS["ISC_CLASS_DB"]->Query($q); */
     $GLOBALS['AdditionalCheckoutButtons'] = '';
     // Go through all the checkout modules looking for one with a GetSidePanelCheckoutButton function defined
     $ShowCheckoutButton = false;
     if (!empty($product_array)) {
         foreach (GetAvailableModules('checkout', true, true) as $module) {
             if (isset($module['object']->_showBothButtons) && $module['object']->_showBothButtons) {
                 $ShowCheckoutButton = true;
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } elseif (method_exists($module['object'], 'GetCheckoutButton')) {
                 $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetCheckoutButton();
             } else {
                 $ShowCheckoutButton = true;
             }
         }
     }
     $GLOBALS['HideMultipleAddressShipping'] = 'display: none';
     if (gzte11(ISC_MEDIUMPRINT) && $GLOBALS['ISC_CLASS_CART']->api->GetNumPhysicalProducts() > 1 && $ShowCheckoutButton && GetConfig("MultipleShippingAddresses")) {
         $GLOBALS['HideMultipleAddressShipping'] = '';
     }
     $GLOBALS['HideCheckoutButton'] = '';
     if (!$ShowCheckoutButton) {
         $GLOBALS['HideCheckoutButton'] = 'display: none';
         $GLOBALS['HideMultipleAddressShippingOr'] = 'display: none';
     }
     $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
     if (empty($wrappingOptions)) {
         $publicWrappingOptions = false;
     } else {
         $publicWrappingOptions = true;
     }
     if (!GetConfig('ShowThumbsInCart')) {
         $GLOBALS['HideThumbColumn'] = 'display: none';
         $GLOBALS['ProductNameSpan'] = 2;
     } else {
         $GLOBALS['HideThumbColumn'] = '';
         $GLOBALS['ProductNameSpan'] = 1;
     }
     $wrappingAdjustment = 0;
     $itemTotal = 0;
     $comptotal = 0;
     # To get all the complementary product total -- Baskaran
     $compprice = 0;
     foreach ($product_array as $k => $product) {
         $GLOBALS['CartItemId'] = (int) $product['cartitemid'];
         // If the item in the cart is a gift certificate, we need to show a special type of row
         if (isset($product['type']) && $product['type'] == "giftcertificate") {
             $GLOBALS['GiftCertificateName'] = isc_html_escape($product['data']['prodname']);
             $GLOBALS['GiftCertificateAmount'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['GiftCertificateTo'] = isc_html_escape($product['certificate']['to_name']);
             $GLOBALS["Quantity" . $product['quantity']] = 'selected="selected"';
             $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($product['giftamount']);
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($product['giftamount'] * $product['quantity']);
             $itemTotal += $product['giftamount'] * $product['quantity'];
             $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemGiftCertificate");
         } else {
             $GLOBALS['ProductLink'] = ProdLink($product['data']['prodname']);
             $GLOBALS['ProductAvailability'] = isc_html_escape($product['data']['prodavailability']);
             $GLOBALS['ItemId'] = (int) $product['data']['productid'];
             $GLOBALS['VariationId'] = (int) $product['variation_id'];
             $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
             //blessen
             $GLOBALS['prodretailprice'] = CurrencyConvertFormatPrice($product['data']['prodretailprice']);
             if ($product['data']['prodretailprice'] > $product['data']['prodcalculatedprice']) {
                 $_SESSION['you_save'] += ($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']) * $product['quantity'];
             }
             //$GLOBALS['saveprice'] =  CurrencyConvertFormatPrice($product['data']['prodretailprice'] - $product['data']['prodcalculatedprice']);
             //blessen
             // Should we show thumbnails in the cart?
             if (GetConfig('ShowThumbsInCart')) {
                 $GLOBALS['ProductImage'] = ImageThumb($product['data']['imagefile'], ProdLink($product['data']['prodname']));
             }
             $GLOBALS['UpdateCartQtyJs'] = "Cart.UpdateQuantity(this.options[this.selectedIndex].value);";
             $GLOBALS['HideCartProductFields'] = 'display:none;';
             $GLOBALS['CartProductFields'] = '';
             $this->GetProductFieldDetails($product['product_fields'], $k);
             $GLOBALS['EventDate'] = '';
             if (isset($product['event_date'])) {
                 $GLOBALS['EventDate'] = '<div style="font-style: italic; font-size:10px; color:gray">(' . $product['event_name'] . ': ' . isc_date('M jS Y', $product['event_date']) . ')</div>';
             }
             // Can this product be wrapped?
             $GLOBALS['GiftWrappingName'] = '';
             $GLOBALS['HideGiftWrappingAdd'] = '';
             $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
             $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
             $GLOBALS['GiftWrappingPrice'] = '';
             $GLOBALS['GiftMessagePreview'] = '';
             $GLOBALS['HideGiftMessagePreview'] = 'display: none';
             $GLOBALS['HideWrappingOptions'] = 'display: none';
             if ($product['data']['prodtype'] == PT_PHYSICAL && $product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                 $GLOBALS['HideWrappingOptions'] = '';
                 if (isset($product['wrapping'])) {
                     $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                     $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                     $GLOBALS['HideGiftWrappingEdit'] = '';
                     $GLOBALS['HideGiftWrappingPrice'] = '';
                     $wrappingAdjustment += $product['wrapping']['wrapprice'] * $product['quantity'];
                     $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                     if (isset($product['wrapping']['wrapmessage'])) {
                         if (isc_strlen($product['wrapping']['wrapmessage']) > 30) {
                             $product['wrapping']['wrapmessage'] = substr($product['wrapping']['wrapmessage'], 0, 27) . '...';
                         }
                         $GLOBALS['GiftMessagePreview'] = isc_html_escape($product['wrapping']['wrapmessage']);
                         if ($product['wrapping']['wrapmessage']) {
                             $GLOBALS['HideGiftMessagePreview'] = '';
                         }
                     }
                 }
             }
             $subtotalPrice = 0;
             if (isset($product['discount_price'])) {
                 $subtotalPrice = $product['discount_price'];
             } else {
                 $subtotalPrice = $product['product_price'];
             }
             $GLOBALS['ShowOnSaleImage'] = '';
             if (isset($product['discount_price']) && $product['discount_price'] != $product['original_price'] && GetConfig('ShowOnSale')) {
                 $GLOBALS['ProductPrice'] = sprintf("<s class='CartStrike'>%s</s> %s", CurrencyConvertFormatPrice($product['original_price']), CurrencyConvertFormatPrice($subtotalPrice));
                 if (isset($product['discount']) && isset($product['couponcode'])) {
                     $GLOBALS['ShowOnSaleImage'] = "Coupon Applied";
                 } else {
                     $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                 }
             } else {
                 $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($subtotalPrice);
             }
             $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($subtotalPrice * $product['quantity']);
             $itemTotal += $subtotalPrice * $product['quantity'];
             // If we're using a cart quantity drop down, load that
             if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
                 $GLOBALS["Quantity" . $product['quantity']] = "selected=\"selected\"";
                 if (isset($GLOBALS["Quantity0"])) {
                     $GLOBALS['QtyOptionZero'] = "<option " . $GLOBALS["Quantity0"] . " value='0'>0</option>";
                 } else {
                     $GLOBALS['QtyOptionZero'] = "<option value='0'>0</option>";
                 }
                 // Fixes products being displayed with '0' quantity when the quantity is greater than 30 (hard coded limit in snippet)
                 if ($product['quantity'] > 30) {
                     $GLOBALS["QtyOptionSelected"] = "<option " . $GLOBALS["Quantity" . $product['quantity']] . " value='" . $product['quantity'] . "'>" . $product['quantity'] . "</option>";
                 }
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
             } else {
                 $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
             }
             // Is this product a variation?
             $GLOBALS['ProductOptions'] = '';
             if (isset($product['options']) && !empty($product['options'])) {
                 $GLOBALS['ProductOptions'] .= "<br /><small>(";
                 $comma = '';
                 foreach ($product['options'] as $name => $value) {
                     if (!trim($name) || !trim($value)) {
                         continue;
                     }
                     $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                     $comma = ', ';
                 }
                 $GLOBALS['ProductOptions'] .= ")</small>";
             }
             //temp script to shortern the product name
             $pid = $product['data']['productid'];
             $pcode = $product['data']['prodcode'];
             $querytemp = "SELECT prodbrandid FROM  [|PREFIX|]products where productid = " . $pid . "  ";
             $resulttemp = $GLOBALS['ISC_CLASS_DB']->Query($querytemp);
             $brand = $GLOBALS['ISC_CLASS_DB']->Fetch($resulttemp);
             if ($brand['prodbrandid'] == 37) {
                 $querytemp1 = "SELECT c.catname, c.catcombine FROM [|PREFIX|]categories \tc left join [|PREFIX|]categoryassociations ca on c.categoryid = ca.categoryid  left join [|PREFIX|]products p on ca.productid = p.productid where p.productid =  '" . $pid . "' ";
                 $resulttemp1 = $GLOBALS['ISC_CLASS_DB']->Query($querytemp1);
                 $cat = $GLOBALS['ISC_CLASS_DB']->Fetch($resulttemp1);
                 if ($cat['catcombine'] != "") {
                     $GLOBALS['ProductName'] = $cat['catcombine'] . " Part Number " . $pcode;
                 } else {
                     $GLOBALS['ProductName'] = $cat['catname'] . " Part Number " . $pcode;
                 }
             } else {
                 $GLOBALS['ProductName'] = isc_html_escape($product['data']['prodname']);
             }
             //temp script to shortern the product name
             //temp script to shortern the product name
             $GLOBALS['complementaryrow'] = '';
             $compitem = $product['compitem'];
             if ($compitem == 1) {
                 for ($y = 0; $y < count($product['complementary']); $y++) {
                     /* Added for to display the complementary product in the cart -- Baskaran */
                     $compproductid = $product['complementary'][$y]['comp_productid'];
                     $compmainproductid = $product['complementary'][$y]['comp_mainproductid'];
                     $mainproductid = $product['product_id'];
                     $GLOBALS['CompCartItemId'] = $y;
                     if ($mainproductid == $compmainproductid) {
                         $GLOBALS['CompProdName'] = $compprodname = isc_html_escape($product['complementary'][$y]['comp_product_name']);
                         $compsku = isc_html_escape($product['complementary'][$y]['comp_product_code']);
                         $compprice = $product['complementary'][$y]['comp_original_price'];
                         $GLOBALS['CompProductPrice'] = $comppriceformat = CurrencyConvertFormatPrice($product['complementary'][$y]['comp_original_price']);
                         $query = $GLOBALS["ISC_CLASS_DB"]->Query("SELECT imagefile FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]product_images i ON p.productid = i.imageprodid AND i.imageisthumb = '1' where p.productid = '{$compproductid}' AND p.prodvisible = '1' ");
                         $path = '';
                         if ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($query)) {
                             $path = $row['imagefile'];
                         }
                         if ($path != '') {
                             $GLOBALS['ProdImage'] = GetConfig('ShopPath') . "/product_images/{$path}";
                         } else {
                             $GLOBALS['ProdImage'] = GetConfig('ShopPath') . "/templates/CongoWorld/images/ProductDefault.gif";
                         }
                         //Added for complementary products - By Simha..
                         // If we're using a cart quantity drop down, load that
                         if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
                             $GLOBALS["CompQuantity" . $product['complementary'][$y]['quantity']] = "selected=\"selected\"";
                             if (isset($GLOBALS["Quantity0"])) {
                                 $GLOBALS['CompCartQtyOptionZero'] = "<option " . $GLOBALS["Quantity0"] . " value='0'>0</option>";
                             } else {
                                 $GLOBALS['CompCartQtyOptionZero'] = "<option value='0'>0</option>";
                             }
                             // Fixes products being displayed with '0' quantity when the quantity is greater than 30 (hard coded limit in snippet)
                             if ($product['quantity'] > 30) {
                                 //Needed to be changed for the complementary
                                 $GLOBALS["CompCartQtyOptionSelected"] = "<option " . $GLOBALS["Quantity" . $product['complementary'][$y]['quantity']] . " value='" . $product['complementary'][$y]['quantity'] . "'>" . $product['complementary'][$y]['quantity'] . "</option>";
                             }
                             $GLOBALS['CompCartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompItemQtySelect");
                         } else {
                             $GLOBALS['CompCartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompItemQtyText");
                         }
                         //Added for complementary products Ends - By Simha..
                         $GLOBALS['CompProductTotal'] = CurrencyConvertFormatPrice($compprice * $product['complementary'][$y]['quantity']);
                         $GLOBALS['complementaryrow'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ComplementaryItem");
                         $comptotal += $compprice * $product['complementary'][$y]['quantity'];
                     }
                     $GLOBALS["CompQuantity" . $product['complementary'][$y]['quantity']] = "";
                 }
             }
             /* Code Ends */
             //$GLOBALS['ProductName'] = isc_html_escape($product['data']['prodname']);
             //blessen
             $withoutdollar = str_replace("\$", "", $GLOBALS['prodretailprice']);
             if (intval($withoutdollar) <= 0) {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
             } else {
                 $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem1");
             }
             //blessen
             // original $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem");
         }
         $GLOBALS["Quantity" . $product['quantity']] = "";
     }
     if ($wrappingAdjustment > 0) {
         $GLOBALS['GiftWrappingTotal'] = CurrencyConvertFormatPrice($wrappingAdjustment);
     } else {
         $GLOBALS['HideGiftWrappingTotal'] = 'display: none';
     }
     $GLOBALS['HideAdjustedTotal'] = "none";
     $GLOBALS['AdjustedCartSubTotal'] = $GLOBALS['CartSubTotal'] - $GLOBALS['CartSubTotalDiscount'];
     $itemTotal += $comptotal;
     # Baskaran
     $GLOBALS['CartItemTotal'] = CurrencyConvertFormatPrice($itemTotal);
     $GLOBALS['SNIPPETS']['Coupons'] = '';
     $coupons = $GLOBALS['ISC_CLASS_CART']->api->GetAppliedCouponCodes();
     if (count($coupons)) {
         foreach ($coupons as $coupon) {
             $GLOBALS['CouponId'] = $coupon['couponid'];
             $GLOBALS['CouponCode'] = $coupon['couponcode'];
             // percent coupon
             if ($coupon['coupontype'] == 1) {
                 $discount = $coupon['discount'] . "%";
             } else {
                 $discount = CurrencyConvertFormatPrice($coupon['discount']);
             }
             $GLOBALS['CouponDiscount'] = $discount;
             $GLOBALS['SNIPPETS']['Coupons'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartCoupon");
         }
     }
     $GLOBALS['SNIPPETS']['GiftCertificates'] = '';
     // Has the customer chosen one or more gift certificates to apply to this order? We need to show them
     if (isset($_SESSION['CART']['GIFTCERTIFICATES']) && is_array($_SESSION['CART']['GIFTCERTIFICATES'])) {
         $certificates = $_SESSION['CART']['GIFTCERTIFICATES'];
         uasort($certificates, "GiftCertificateSort");
         foreach ($certificates as $certificate) {
             $GLOBALS['GiftCertificateCode'] = isc_html_escape($certificate['giftcertcode']);
             $GLOBALS['GiftCertificateId'] = $certificate['giftcertid'];
             $GLOBALS['GiftCertificateBalance'] = $certificate['giftcertbalance'];
             if ($GLOBALS['GiftCertificateBalance'] > $GLOBALS['AdjustedCartSubTotal']) {
                 $GLOBALS['GiftCertificateRemaining'] = $certificate['giftcertbalance'] - $GLOBALS['AdjustedCartSubTotal'];
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'] - $GLOBALS['GiftCertificateRemaining'];
             } else {
                 $GLOBALS['CertificateAmountUsed'] = $certificate['giftcertbalance'];
                 $GLOBALS['GiftCertificateRemaining'] = 0;
             }
             // Subtract this amount from the adjusted total
             $GLOBALS['AdjustedCartSubTotal'] -= $GLOBALS['GiftCertificateBalance'];
             if ($GLOBALS['AdjustedCartSubTotal'] <= 0) {
                 $GLOBALS['AdjustedCartSubTotal'] = 0;
             }
             $GLOBALS['GiftCertificateBalance'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateBalance']);
             $GLOBALS['GiftCertificateRemaining'] = CurrencyConvertFormatPrice($GLOBALS['GiftCertificateRemaining']);
             $GLOBALS['CertificateAmountUsed'] = CurrencyConvertFormatPrice($GLOBALS['CertificateAmountUsed']);
             $GLOBALS['SNIPPETS']['GiftCertificates'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartGiftCertificate");
         }
         if ($GLOBALS['SNIPPETS']['GiftCertificates']) {
             $GLOBALS['HideAdjustedTotal'] = '';
             if ($GLOBALS['AdjustedCartSubTotal'] == 0) {
                 $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
             }
         }
     }
     if ($GLOBALS['AdjustedCartSubTotal'] != $GLOBALS['CartSubTotal']) {
         $GLOBALS['HideAdjustedTotal'] = "";
         $GLOBALS['AdjustedCartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['AdjustedCartSubTotal']);
     }
     //            $GLOBALS['CartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['CartSubTotal']);
     $GLOBALS['CartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['CartSubTotal'] + $comptotal);
     # To add the subtotal in the cart -- Baskaran
     $GLOBALS['CartSaveTotal'] = CurrencyConvertFormatPrice($_SESSION['you_save']);
     //blessen
     if (!gzte11(ISC_LARGEPRINT)) {
         $GLOBALS['HidePanels'][] = "SideGiftCertificateCodeBox";
     }
     // Are there any products in the cart?
     if ($GLOBALS['ISC_CLASS_CART']->api->GetNumProductsInCart() == 0) {
         $GLOBALS['HideShoppingCartGrid'] = "none";
     } else {
         $GLOBALS['HideShoppingCartEmptyMessage'] = "none";
     }
 }
    /**
     * Generate the payment form to collect payment details and pass them back
     * to the payment provider.
     *
     * @return string The generated payment form.
     */
    public function ShowPaymentForm()
    {
        // Authorize.net needs HTTPS, so if it's not on then stop
        if (!strtolower($_SERVER['HTTPS']) == "on") {
            ob_end_clean();
            ?>
					<script type="text/javascript">
						alert("<?php 
            echo GetLang('AuthorizeNetNoSSLError');
            ?>
");
						document.location.href="<?php 
            echo $GLOBALS['ShopPath'];
            ?>
/checkout.php?action=confirm_order";
					</script>
				<?php 
            die;
        }
        $GLOBALS['AuthorizeNetMonths'] = "";
        $GLOBALS['AuthorizeNetYears'] = "";
        for ($i = 1; $i <= 12; $i++) {
            $stamp = mktime(0, 0, 0, $i, 15, isc_date("Y"));
            $i = str_pad($i, 2, "0", STR_PAD_LEFT);
            if (@$_POST['AuthorizeNet_ccexpm'] == $i) {
                $sel = 'selected="selected"';
            } else {
                $sel = "";
            }
            $GLOBALS['AuthorizeNetMonths'] .= sprintf("<option %s value='%s'>%s</option>", $sel, $i, isc_date("M", $stamp));
        }
        for ($i = isc_date("Y"); $i < isc_date("Y") + 10; $i++) {
            if (@$_POST['AuthorizeNet_ccexpy'] == substr($i, 2, 2)) {
                $sel = 'selected="selected"';
            } else {
                $sel = "";
            }
            $GLOBALS['AuthorizeNetYears'] .= sprintf("<option %s value='%s'>%s</option>", $sel, substr($i, 2, 2), $i);
        }
        $require_cvv2 = $this->GetValue("requirecvv2");
        if ($require_cvv2 == "YES") {
            if (isset($_POST['AuthorizeNet_cccode'])) {
                $GLOBALS['AuthorizeNetCCV2'] = (int) $_POST['AuthorizeNet_cccode'];
            }
            $GLOBALS['AuthorizeNetHideCVV2'] = '';
        } else {
            $GLOBALS['AuthorizeNetHideCVV2'] = 'none';
        }
        // Grab the billing details for the order
        $billingDetails = $this->GetBillingDetails();
        $GLOBALS['AuthorizeNetName'] = isc_html_escape($billingDetails['ordbillfirstname'] . ' ' . $billingDetails['ordbilllastname']);
        $GLOBALS['AuthorizeNetBillingAddress'] = isc_html_escape($billingDetails['ordbillstreet1']);
        if ($billingDetails['ordbillstreet2'] != "") {
            $GLOBALS['AuthorizeNetBillingAddress'] .= " " . isc_html_escape($billingDetails['ordbillstreet2']);
        }
        $GLOBALS['AuthorizeNetCity'] = isc_html_escape($billingDetails['ordbillsuburb']);
        if ($billingDetails['ordbillstateid'] != 0 && GetStateISO2ById($billingDetails['ordbillstateid'])) {
            $GLOBALS['AuthorizeNetState'] = GetStateISO2ById($billingDetails['ordbillstateid']);
        } else {
            $GLOBALS['AuthorizeNetState'] = isc_html_escape($billingDetails['ordbillstate']);
        }
        $GLOBALS['AuthorizeNetBillingZip'] = isc_html_escape($billingDetails['ordbillzip']);
        // Format the amount that's going to be going through the gateway
        $GLOBALS['OrderAmount'] = CurrencyConvertFormatPrice($this->GetGatewayAmount());
        // Was there an error validating the payment? If so, pre-fill the form fields with the already-submitted values
        if ($this->HasErrors()) {
            $GLOBALS['AuthorizeNetName'] = isc_html_escape($_POST['AuthorizeNet_name']);
            $GLOBALS['AuthorizeNetNum'] = isc_html_escape($_POST['AuthorizeNet_ccno']);
            $GLOBALS['AuthorizeNetBillingAddress'] = isc_html_escape($_POST['AuthorizeNet_ccaddress']);
            $GLOBALS['AuthorizeNetCity'] = isc_html_escape($_POST['AuthorizeNet_cccity']);
            $GLOBALS['AuthorizeNetState'] = isc_html_escape($_POST['AuthorizeNet_ccstate']);
            $GLOBALS['AuthorizeNetBillingZip'] = isc_html_escape($_POST['AuthorizeNet_zip']);
            $GLOBALS['AuthorizeNetErrorMessage'] = implode("<br />", $this->GetErrors());
        } else {
            // Hide the error message box
            $GLOBALS['HideAuthorizeNetError'] = "none";
        }
        // Collect their details to send through to Authorize.NET
        $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("authorizenet");
        return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
    }
 public function SetPanelSettings()
 {
     $params = $GLOBALS['ISC_CLASS_ABTESTING']->_searchterms;
     $this->searchterms = $params;
     if ($GLOBALS['pagetype'] == 1) {
         return;
     }
     if ($GLOBALS['pagetype'] == 2 && isset($GLOBALS['pagecontent']) && $GLOBALS['pagecontent'] == 1) {
         $this->YMMSelectors($params);
         $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryListingMain");
         return;
     }
     if ($GLOBALS['ISC_CLASS_ABTESTING']->GetNumResults() == 0) {
         $this->YMMSelectors($params);
         $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryListingMain");
         return;
     }
     $count = 0;
     $output = "";
     /* Checking the search string. If it is used in any search, will be retained. else it will not be retained - starts */
     if (isset($this->searchterms['search'])) {
         $search_str = trim(str_ireplace($this->searchterms['search_string'], "", $this->searchterms['search']));
         if ($search_str == '') {
             unset($this->searchterms['search'], $params['search']);
         } else {
             $this->searchterms['search'] = $params['search'] = $search_str;
         }
     }
     $path = GetConfig('ShopPath');
     /* the below mmy links are passed to the breadcrumbs */
     $mmy_links = "";
     /*---------- This below section is for generating search phrase----------*/
     $GLOBALS['Category'] = "";
     $GLOBALS['MMY'] = "";
     $GLOBALS['PQ'] = "";
     $GLOBALS['VQ'] = "";
     $GLOBALS['SearchPhrase'] = "";
     $ext_links = "";
     // this variable is passed to the product detail page
     $seo_delim = "&";
     if ($GLOBALS['EnableSEOUrls'] == 1) {
         $seo_delim = "/";
     }
     if (isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
         $GLOBALS['Category'] .= $GLOBALS['ISC_SRCH_CATG_NAME'];
     }
     if (isset($params['year'])) {
         $GLOBALS['MMY'] .= $params['year'] . "<br>";
         $ext_links .= $seo_delim . "year=" . $params['year'];
     }
     if (isset($params['make'])) {
         $GLOBALS['MMY'] .= strtoupper($params['make']) . "<br>";
         $ext_links .= $seo_delim . "make=" . MakeURLSafe($params['make']);
     }
     if (isset($params['model']) && (!isset($params['model_flag']) || $params['model_flag'] == 1)) {
         $GLOBALS['MMY'] .= strtoupper($params['model']) . "<br>";
         $ext_links .= $seo_delim . "model=" . MakeURLSafe($params['model']);
     }
     /*else if(isset($params['model']))
       $ext_links .= $seo_delim."model=".$params['model'];*/
     /* this condition has been added seperately here to show submodel at last */
     if (isset($params['submodel'])) {
         $GLOBALS['MMY'] .= MakeURLSafe($params['submodel']) . "<br>";
     }
     /*if(isset($params['year'])) {
       $ext_links .= $seo_delim."year=".$params['year'];                
       }*/
     if (isset($params['dynfilters']) && !empty($params['dynfilters'])) {
         foreach ($params['dynfilters'] as $key => $value) {
             if (eregi('vq', $key)) {
                 $key = str_ireplace('vq', '', $key);
                 $GLOBALS['VQ'] .= ucfirst($key) . ": {$value}<br>";
             } else {
                 if (eregi('pq', $key)) {
                     $key = str_ireplace('pq', '', $key);
                     $GLOBALS['PQ'] .= ucfirst($key) . ": {$value}<br>";
                 }
             }
         }
     }
     $filter_var = array('vq', 'pq');
     /* this below patch is used for getting description of the category. Here currently the selected category id will be last one in the $params['srch_category'] array. if input['category'] is used then it will be the first one */
     if (!empty($params['srch_category'])) {
         if (isset($params['category'])) {
             $selected_catg = $params['srch_category'][0];
         } else {
             $selected_catg = end($params['srch_category']);
         }
         //wirror_20100806: add selected files like pagecontenttype and customcontentid;
         $catg_desc_qry = "select pagecontenttype, customcontentid, catdesc , categoryfooter  from [|PREFIX|]categories where categoryid = " . $selected_catg;
         $catg_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($catg_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($catg_desc_res) > 0) {
             $catg_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_desc_res);
         }
         /* this below patch is used to show the display name for the qualifiers from the qualifier association table */
         $map_names = array();
         $display_names = array();
         $filter_names = "select qid , column_name , display_names from [|PREFIX|]qualifier_names where column_name regexp '^(pq|vq)'";
         $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
         while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
             $map_names[$filter_row['qid']] = $filter_row['column_name'];
             $display_names[$filter_row['qid']] = $filter_row['display_names'];
         }
         $this->GetAssocDetails($selected_catg, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
     }
     if (isset($params['brand'])) {
         $brand_desc_arr = array();
         $brand_desc_qry = "select branddescription , brandfooter from [|PREFIX|]brands where brandname = '" . $params['brand'] . "'";
         $brand_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($brand_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($brand_desc_res) > 0) {
             $brand_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($brand_desc_res);
         }
     }
     // for breadcrumbs
     $this->_BuildBreadCrumbs();
     /* the below line has been commented as client told to remove it */
     //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     if ($GLOBALS['ISC_CLASS_ABTESTING']->GetNumResults() > 30) {
         $msg_qry = "select value from [|PREFIX|]display where messageid = 1";
         $msg_res = $GLOBALS['ISC_CLASS_DB']->Query($msg_qry);
         $msg_row = $GLOBALS['ISC_CLASS_DB']->FetchOne($msg_res);
         $GLOBALS['SearchPhrase'] = $msg_row;
         //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     }
     /*if(!empty($params['dynfilters']))
       $GLOBALS['SearchPhrase'] .= " ".implode(" ",$params['dynfilters']);
       /*---------- Ending section for generating search phrase----------*/
     $vq_column_title = "";
     $GLOBALS['SearchResultList'] = "";
     if ($GLOBALS['ISC_CLASS_ABTESTING']->GetNumResults() > 0) {
         $brand_rating = 0;
         $category_rating = 0;
         if ($GLOBALS['results_page_flag'] == 1) {
             $brand_rating_qry = "select avg(revrating) as rating from [|PREFIX|]reviews r left join [|PREFIX|]products p on r.revproductid = p.productid left join [|PREFIX|]brands b on p.prodbrandid = b.brandid  where r.revstatus = 1 and b.brandname = '" . $params['brand'] . "'";
             $brand_rating_res = $GLOBALS['ISC_CLASS_DB']->Query($brand_rating_qry);
             $brand_rating_arr = $GLOBALS['ISC_CLASS_DB']->FetchOne($brand_rating_res);
             if (isset($brand_rating_arr['rating'])) {
                 $brand_rating = (int) $brand_rating_arr['rating'];
             }
         } else {
             if ($GLOBALS['results_page_flag'] == 0 && isset($selected_catg)) {
                 // 3rdAug2010: added the condition "isset($selected_catg)" as no need to show rating when only YMM is selected
                 // lguan_20100612: Category page mode, calculate the rating
                 $catquery = $GLOBALS['ISC_CLASS_DB']->Query("SELECT categoryid FROM [|PREFIX|]categories where catparentid = {$selected_catg}");
                 $catlistid = array();
                 while ($catrow = $GLOBALS['ISC_CLASS_DB']->Fetch($catquery)) {
                     $catlistid[] = $catrow['categoryid'];
                 }
                 $catcountlist = implode(",", $catlistid);
                 //lguan_20100612: Changed following codes to get product rating for categories
                 if (count($catlistid) > 0) {
                     $catcountlist = $selected_catg . "," . $catcountlist;
                 }
                 $cat_rating_res = $GLOBALS['ISC_CLASS_DB']->Query("SELECT floor(SUM(p.prodratingtotal)/SUM(p.prodnumratings))AS prodavgrating FROM [|PREFIX|]categoryassociations c INNER JOIN [|PREFIX|]products p on c.productid=p.productid where c.categoryid IN ({$catcountlist})");
                 $cat_rating_arr = $GLOBALS['ISC_CLASS_DB']->FetchOne($cat_rating_res);
                 if (isset($cat_rating_arr['prodavgrating'])) {
                     $category_rating = (int) $cat_rating_arr['prodavgrating'];
                 }
             }
         }
         /* displaying the dropdowns for YMM */
         if (!isset($params['make']) || !isset($params['year']) || !isset($params['model']) || isset($params['model_flag']) && $params['model_flag'] == 0) {
             $this->YMMSelectors($params);
         }
         // We have at least one result, let's show it to the world!
         $GLOBALS['HideNoResults'] = "none";
         // Only show the "compare" option if there are 2 or more products on this page
         if (GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_DB']->CountResult($GLOBALS['SearchResults']) < 2) {
             $GLOBALS['HideCompareItems'] = "none";
         }
         if (GetConfig('EnableProductReviews') == 0) {
             $GLOBALS['HideProductRating'] = "display: none";
         }
         $GLOBALS['AlternateClass'] = '';
         $counter = 1;
         $CurCatId = 0;
         $mmy_links = $this->GetYMMLinks($params);
         $mmy_links .= $this->GetOtherLinks($params);
         //wirror_code_mark_begin
         //wirror_20100809: record the searched productids
         $searchedProductIds = array();
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['SearchResults'])) {
             /* Added by Simha to check inf prodcucts comes from different categories*/
             if (empty($params['srch_category']) || !isset($params['srch_category'])) {
                 if ($CurCatId != $row['categoryid']) {
                     $CurCatId = $row['categoryid'];
                     $map_names = array();
                     $display_names = array();
                     $filter_names = "SELECT DISTINCT qn.qid, qn.column_name, qn.display_names from \n                                                [|PREFIX|]qualifier_names qn\n                                                LEFT JOIN [|PREFIX|]qualifier_associations qa ON qa.qualifierid = qn.qid\n                                                WHERE (qa.categoryid = '{$CurCatId}') \n                                                AND qn.column_name regexp '^(pq|vq)'";
                     // || qa.categoryid IN (SELECT catparentid FROM isc_categories WHERE categoryid = '$CurCatId')
                     $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
                     while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
                         $map_names[$filter_row['qid']] = $filter_row['column_name'];
                         $display_names[$filter_row['qid']] = $filter_row['display_names'];
                     }
                     $this->GetAssocDetails($CurCatId, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
                 }
             }
             /* Added by Simha Ends */
             $GLOBALS['SearchTrackClass'] = "TrackLink";
             $imagefile = "";
             if ($GLOBALS['AlternateClass'] == 'Odd') {
                 $GLOBALS['AlternateClass'] = 'Even';
             } else {
                 $GLOBALS['AlternateClass'] = 'Odd';
             }
             $qry_string = $_SERVER['QUERY_STRING'];
             if (isset($_GET['page'])) {
                 $page = "&page=" . $_GET['page'];
                 $qry_string = str_ireplace($page, '', $qry_string);
             }
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 if (isset($_GET['search_key'])) {
                     $qry_string = str_ireplace('&search_key=' . $_GET['search_key'], '', $qry_string);
                 }
                 if (isset($params['search_query']) && !strstr($qry_string, 'search_query=')) {
                     $qry_string .= "search_query=" . MakeURLSafe($params['search_query']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model']) && !strstr($qry_string, 'model=')) {
                     $qry_string .= "&model=" . MakeURLSafe($params['model']);
                 }
                 if (isset($params['year']) && !strstr($qry_string, 'year=')) {
                     $qry_string .= "&year=" . MakeURLSafe($params['year']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model_flag']) && !strstr($qry_string, 'model_flag=')) {
                     $qry_string .= "&model_flag=" . MakeURLSafe($params['model_flag']);
                 }
                 if (isset($params['submodel']) && !strstr($qry_string, 'submodel=')) {
                     $qry_string .= "&submodel=" . MakeURLSafe($params['submodel']);
                 }
             }
             if ($GLOBALS['results_page_flag'] == 0 && !isset($params['srch_category'])) {
                 break;
             }
             if ($GLOBALS['pagetype'] == 3) {
                 //wirror_mark_condition1
                 /*if( isset($params['srch_category']) )  {
                 			$GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : ''; // description will be added here to show it at the top of product listing page.
                 		}*/
                 /*if(isset($params['category']) || ( !isset($params['subcategory']) && isset($params['series']) ))
                 							{
                 								$GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
                 								//$GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
                 								$GLOBALS['CatgBrandSeriesFooter'] = "";
                 
                 								if( ( isset($params['category']) || isset($params['subcategory']) ) && $GLOBALS['CatgDescandBrandImage'] == "" )
                 								{
                 									$GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                 									//$GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                 									$GLOBALS['CatgBrandSeriesFooter'] = "";
                 								}
                 
                 							}
                 							else if(isset($params['srch_category']))
                 							{
                 								$GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';	
                 								$GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                 								if( isset($params['series']) && $row['seriesdescription'] != "" )
                 								{
                 									$GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
                 									//$GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
                 									$GLOBALS['CatgBrandSeriesFooter'] = "";
                 								}
                 
                 								if($GLOBALS['CatgDescandBrandImage'] == '' && $GLOBALS['CatgBrandSeriesFooter'] == '' && isset($params['brand']))
                 								{
                 									$GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                 									//$GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                 									$GLOBALS['CatgBrandSeriesFooter'] = "";
                 								}
                 
                 							}
                 							else if(isset($params['brand']))
                 							{
                 								$GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                 								$GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                 							}*/
                 /* No need to show footer description when YMM are selected */
                 /*if( isset($params['make']) || isset($params['model']) || isset($params['year']) )
                 		{
                 			$GLOBALS['CatgBrandSeriesFooter'] = "";
                 		}*/
                 $GLOBALS['ProductCartQuantity'] = '';
                 if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
                     $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
                 }
                 if ($counter % 2 == 0) {
                     $GLOBALS['RowColor'] = 'grayrow';
                 } else {
                     $GLOBALS['RowColor'] = 'whiterow';
                 }
                 $counter++;
                 $GLOBALS['ProductId'] = (int) $row['productid'];
                 $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
                 $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
                 $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
                 //$GLOBALS['BrandName'] = $row['brandname'];
                 /* -- The below code is added to display the brand and series logo -- */
                 $GLOBALS['BrandName'] = "";
                 $brandlogo = realpath(ISC_BASE_PATH . '/product_images/' . $row['brandimagefile']);
                 if ($row['brandimagefile'] != '' && file_exists($brandlogo)) {
                     $GLOBALS['BrandName'] .= "<img src=\"" . $GLOBALS['ShopPath'] . "/product_images/" . $row['brandimagefile'] . "\" class=\"BrandSeriesLogo\" />";
                 } else {
                     $GLOBALS['BrandName'] .= $row['brandname'];
                 }
                 $serieslogo = realpath(ISC_BASE_PATH . '/series_images/' . $row['serieslogoimage']);
                 if ($row['serieslogoimage'] != '' && file_exists($serieslogo)) {
                     $GLOBALS['BrandName'] .= "<br><img src=\"" . $GLOBALS['ShopPath'] . "/series_images/" . $row['serieslogoimage'] . "\" />";
                 } else {
                     $GLOBALS['BrandName'] .= "<br>" . $row['seriesname'];
                 }
                 /* --- ends --- */
                 $GLOBALS['ProdCode'] = $row['prodcode'];
                 //$GLOBALS['ProdDesc'] = $this->strip_html_tags($row['proddesc']);
                 //$GLOBALS['ProdOptions'] = $row['productoption'];
                 $GLOBALS['VehicleOptions'] = "";
                 $GLOBALS['ProdOptions'] = "";
                 foreach ($row as $key => $val) {
                     if ($val != "" && $val != "~") {
                         if (($qualifier_id = array_search($key, $map_names)) !== false) {
                             if (eregi('^vq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != "") {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentAssoc[$qualifier_id][$m]['vname'] != "") {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 //$GLOBALS['VehicleOptions'] .= "<b>".$key."</b> : ".$val."<br>";
                                 $GLOBALS['VehicleOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $val . "</div>";
                             }
                             if (eregi('^pq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != '') {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentValue[$qualifier_id][$m]['vname'] != '') {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 //$GLOBALS['ProdOptions'] .= "<b>".$key."</b> : ".$val."<br>";
                                 $GLOBALS['ProdOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $val . "</div>";
                             }
                         }
                     }
                 }
                 if (isset($row['vehicleoption'])) {
                     $GLOBALS['VehicleOptions'] = $row['vehicleoption'];
                 }
                 if (isset($row['productoption'])) {
                     $GLOBALS['ProdOptions'] = $row['productoption'];
                 }
                 if (isset($row['catuniversal']) && $row['catuniversal'] == 1) {
                     $GLOBALS['VehicleOptions'] = $GLOBALS['ProductName'];
                     if ($vq_column_title == "") {
                         $vq_column_title = "Product Name";
                     } else {
                         if ($vq_column_title != "Product Name") {
                             $vq_column_title = "Product Name / Vehicle";
                         }
                     }
                 } else {
                     if ($vq_column_title == "") {
                         $vq_column_title = "Vehicle Options";
                     } else {
                         if ($vq_column_title != "Vehicle Options") {
                             $vq_column_title = "Product Name / Vehicle";
                         }
                     }
                 }
                 if (empty($GLOBALS['ProdOptions']) && empty($GLOBALS['VehicleOptions'])) {
                     $GLOBALS['ProdOptions'] = "&nbsp;";
                 }
                 if (empty($GLOBALS['VehicleOptions'])) {
                     $GLOBALS['VehicleOptions'] = "&nbsp;";
                 }
                 /*--- the below lines are added for back 2 search link in the product detail page. Also modified line no 56 & 60 --- */
                 if ($GLOBALS['EnableSEOUrls'] == 1) {
                     $GLOBALS['ProductLink'] .= "/refer=true" . $ext_links;
                     if (isset($GLOBALS['SearchId'])) {
                         $GLOBALS['ProductLink'] .= '/SearchLogId/' . $GLOBALS['SearchId'];
                     }
                 } else {
                     $GLOBALS['ProductLink'] .= "&refer=true" . $ext_links;
                     if (isset($GLOBALS['SearchId'])) {
                         $GLOBALS['ProductLink'] .= '&SearchLogId=' . $GLOBALS['SearchId'];
                     }
                 }
                 ### Added by Simha for onsale addition
                 // Determine the price of this product
                 //$GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
                 $GLOBALS['ProductPrice'] = CalculateProductPriceRetail($row);
                 $FinalPrice = $GLOBALS['ProductPrice'];
                 $SalePrice = $row['prodsaleprice'];
                 //$DiscountAmount = $FinalPrice;
                 $discounttype = 0;
                 $discountname = '';
                 if ((double) $SalePrice > 0 && $SalePrice < $FinalPrice) {
                     $DiscountPrice = $SalePrice;
                 } else {
                     $DiscountPrice = $FinalPrice;
                     $DiscountPrice = CalculateDiscountPrice($FinalPrice, $DiscountPrice, $row['categoryid'], $row['brandseriesid'], $discounttype, $discountname);
                     /*if($discounttype == 0)    {
                           $DiscountPrice = $FinalPrice;
                       }*/
                 }
                 /*
                 							foreach($DiscountInfo as $DiscountInfoSub)   {  
                     if(isset($DiscountInfoSub['catids']))    {
                 								    $catids = explode(",", $DiscountInfoSub['catids']); 
                 								    foreach($catids as $catid) {
                 									    if($catid == $row['categoryid']) {
                 										    $DiscountAmount = $FinalPrice * ((int)$DiscountInfoSub['amount']/100); 
                 										    if ($DiscountAmount < 0) {
                 											    $DiscountAmount = 0;
                 										    }                                                                         
                 										    $DiscountPrice  = $FinalPrice - $DiscountAmount;  
                 									    } 
                 								    }  
                     }
                 							}       
                 */
                 if (isset($DiscountPrice) && $DiscountPrice < $FinalPrice && $discounttype == 0) {
                     //&& GetConfig('ShowOnSale')
                     $GLOBALS['ProductPrice'] = '<strike>' . CurrencyConvertFormatPrice($FinalPrice) . '</strike>';
                     $GLOBALS['ProductPrice'] .= '<br><div class="finalprice">' . CurrencyConvertFormatPrice($DiscountPrice) . '</div> ';
                     if (strtolower($discountname) == "clearance") {
                         $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/clearance.gif" alt="">';
                     } else {
                         $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     }
                     if (GetConfig('ShowOnSale')) {
                         $GLOBALS['ProductPrice'] .= '' . $GLOBALS['ShowOnSaleImage'] . '';
                     }
                 } else {
                     $GLOBALS['ProductPrice'] = '<div class="finalprice">' . CurrencyConvertFormatPrice($FinalPrice) . '</div>';
                 }
                 ### Added by Simha Ends
                 // commented the below line by vikas
                 //$GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
                 $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], $GLOBALS['ProductLink']);
                 if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
                 } else {
                     //$GLOBALS['ProductURL'] = CartLink($row['productid']);
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     //blessen
                     if (intval($row['prodretailprice']) <= 0) {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     } else {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     }
                     //blessen
                     // original $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
                 }
                 if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
                     $GLOBALS['HideActionAdd'] = '';
                 } else {
                     $GLOBALS['HideActionAdd'] = 'none';
                 }
                 $GLOBALS['HideProductVendorName'] = 'display: none';
                 $GLOBALS['ProductVendor'] = '';
                 if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
                     $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
                     if (isset($vendorCache[$row['prodvendorid']])) {
                         $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                         $GLOBALS['HideProductVendorName'] = '';
                     }
                 }
                 $GLOBALS['CartURL'] = CartLink($row['productid']);
                 if (isset($GLOBALS['SearchId'])) {
                     $GLOBALS['CartURL'] .= '&SearchLogId=' . $GLOBALS['SearchId'];
                 }
                 $offer = $this->IsProductMakeanOffer($row['brandseriesid'], $row['brandname'], $row['categoryid']);
                 if ($offer == 'yes') {
                     $GLOBALS['HideOfferButton'] = 'block';
                 } else {
                     $GLOBALS['HideOfferButton'] = 'none';
                 }
                 $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItem");
             } else {
                 if ($GLOBALS['pagetype'] == 2) {
                     //wirror_mark_condition2
                     $isDynamicPage = $catg_desc_arr['pagecontenttype'] == 0 ? true : false;
                     $mmy_links_modified = $mmy_links;
                     if (!isset($GLOBALS['ISC_SRCH_CATG_ID'])) {
                         $parentid = $GLOBALS['categories_all'][$row['categoryid']]['catparentid'];
                         if ($parentid != 0) {
                             if (isset($GLOBALS['categories_all'][$parentid])) {
                                 // if parent catg is not visible
                                 $mmy_links_modified = $mmy_links;
                             } else {
                                 $mmy_links_modified = $mmy_links;
                             }
                         } else {
                             $mmy_links_modified = $mmy_links;
                         }
                     }
                     $subcatg_link = $this->LeftCatLink($mmy_links_modified, 'subcategory', $row['catname']);
                     $link = "<a href='" . $subcatg_link . "'>";
                     $tiplink = "<a class='thickbox1' href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "'  title=''><img src='{$path}/templates/default/images/fastlook_red.gif' border=0></a>";
                     $imagelink = "<a class='thickbox' href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "' title='' onmouseover='createtip(" . $row['categoryid'] . ")' onmouseout='UnTip()'>";
                     //$imagelink = "<a href='".$GLOBALS['ShopPath']."/catgbrand.php?categoryid=".$row['categoryid']."&url=$subcatg_link' class='thickbox' title=''>";
                     if (isset($row['imagefile']) && !empty($row['imagefile'])) {
                         $images = explode("~", $row['imagefile']);
                         for ($j = 0; $j < count($images); $j++) {
                             if (!empty($images[$j])) {
                                 $imagefile = "{$imagelink}<img src='{$path}/category_images/" . $images[$j] . "' alt='" . $row['catimagealt'] . "' title='" . $row['catimagealt'] . "'></a>";
                                 $imagefile .= "<span id='span" . $row['categoryid'] . "' style='display:none'>" . $tiplink . "</span>";
                                 break;
                             }
                         }
                     } else {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $imagefile = "{$imagelink}<img src='{$path}/templates/default/images/ProductDefault.gif' border=0></a>";
                             $imagefile .= "<span id='span" . $row['categoryid'] . "' style='display:none'>" . $tiplink . "</span>";
                         }
                     }
                     $GLOBALS['LeftImage'] = $imagefile;
                     $GLOBALS['ProductsCount'] = "(" . $row['totalproducts'] . ") Products Available";
                     $row['brandname'] = str_replace('~', ' , ', $row['brandname']);
                     //$GLOBALS['RelatedBrands'] = $row['brandname'];
                     if (!empty($row['seriesname'])) {
                         $row['brandname'] .= "<br>" . $row['seriesname'];
                     }
                     $GLOBALS['CatgSeriesList'] = "";
                     if ($row['seriesids'] != "") {
                         $seriesids = str_ireplace("~", ",", $row['seriesids']);
                         $seriesids_qry = "select seriesid , brandname , seriesname from isc_brand_series bs left join isc_brands b on bs.brandid = b.brandid where seriesid in (" . $seriesids . ")";
                         $seriesids_res = $GLOBALS['ISC_CLASS_DB']->Query($seriesids_qry);
                         if ($GLOBALS['ISC_CLASS_DB']->CountResult($seriesids_res) > 0) {
                             while ($seriesids_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($seriesids_res)) {
                                 if ($GLOBALS['CatgSeriesList'] == "") {
                                     $GLOBALS['CatgSeriesList'] .= "<br><a href='javascript:' onclick=\"checkanimate('" . $row['categoryid'] . "')\">View Brands ></a><div id='" . $row['categoryid'] . "' style='display:block'>";
                                 } else {
                                     $GLOBALS['CatgSeriesList'] .= "<br>";
                                 }
                                 $tooltipscript = "onmouseover='createtip(" . $row['categoryid'] . $seriesids_arr['seriesid'] . ")' onmouseout='UnTip()'";
                                 if (!isset($params['brand'])) {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $series_link = $subcatg_link . "/brand/" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "/brand/" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $series_link = $subcatg_link . "&brand=" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "&brand=" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 } else {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $series_link = $subcatg_link . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $series_link = $subcatg_link . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 }
                                 //wirror20100728: keep the catname consistent with the displayname
                                 $GLOBALS['CatgSeriesList'] .= "<span id='span" . $row['categoryid'] . $seriesids_arr['seriesid'] . "' style='display:none'><a class='thickbox1'  href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?seriesid=" . $seriesids_arr['seriesid'] . "&catname=" . rawurlencode($row['catname']) . "&url=" . urlencode($series_link) . "' class='' ><img src='{$path}/templates/default/images/fastlook_red.gif' border=0></a></span>";
                             }
                             $GLOBALS['CatgSeriesList'] .= "</br></div>";
                         }
                     }
                     $content = $row['brandname'] . "<br>";
                     if (!isset($params['category']) && (isset($params['srch_category']) || !isset($GLOBALS['BRAND_SERIES_FLAG']))) {
                         /*$GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                         		if( isset($params['make']) || isset($params['model']) || isset($params['year']) || isset($params['brand']) )
                         		{
                         			$GLOBALS['CatgBrandSeriesFooter'] = "";
                         		}*/
                         $content .= "<h3><a href='" . $path . "/search.php?{$qry_string}&subcategory=" . MakeURLSafe($row['catname']) . "'>" . $row['catname'] . "</a></h3>>";
                         $GLOBALS['TitleLink'] = "<h2><a href='" . $subcatg_link . "' onmouseover='createtip(" . $row['categoryid'] . ")' onmouseout='UnTip()'>" . $row['catname'] . "</a></h2>";
                     }
                     /*	copy the code to outer		
                     			//lguan_20100612: Show overal product rating at category landing page
                     			if($category_rating != 0)
                     			{
                     				$GLOBALS['CatgDescandBrandImage'] .= "<br><h2>Rating : <img width='64' height='12' src='".$GLOBALS['TPL_PATH']."/images/IcoRating$category_rating.gif' alt='' /></h2>";
                     			}
                     			*/
                     /*$ProdStartPrice = GetStartingPrice($row['categoryid'], $row['prodcalculatedprice']);
                                            
                     		$content .= "Price starting from $".number_format($ProdStartPrice, 2, '.', '')."<br>".$imagefile;*/
                     $GLOBALS['leftsidecontent'] = $content;
                     if (number_format($row['prodminprice'], 2, '.', '') < number_format($row['prodmaxprice'], 2, '.', '')) {
                         $GLOBALS['PriceRange'] = "Price range from \$" . number_format($row['prodminprice'], 2, '.', '') . " to \$" . number_format($row['prodmaxprice'], 2, '.', '');
                     } else {
                         $GLOBALS['PriceRange'] = "Available at \$" . number_format($row['prodminprice'], 2, '.', '');
                     }
                     //lguan_20100612: Show product ratings in categories/sub-categories page
                     $GLOBALS['Rating'] = isset($row['prodavgrating']) ? $row['prodavgrating'] : 0;
                     $GLOBALS['RatingVisible'] = $GLOBALS['Rating'] == 0 ? 'display:none' : '';
                     $content = "<img src='{$path}/templates/default/images/free-shipping2.gif'><br>" . strip_tags($row['proddesc']) . "<br>" . $row['prodwarranty'];
                     $GLOBALS['rightsidecontent'] = $content;
                     $GLOBALS['ShippingImage'] = "<img src='{$path}/templates/default/images/free-shipping2.gif'>";
                     $GLOBALS['ProductWarranty'] = "<h3>" . $row['prodwarranty'] . "</h3>";
                     $GLOBALS['ViewDetailsImage'] = "<a href='{$path}/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "' class='thickbox'><img src='{$path}/templates/default/images/fastlook_red.gif'></a> ";
                     $content = "{$link}<img src='{$path}/templates/default/images/viewproducts.gif'></a>";
                     $GLOBALS['ViewDetailsImage'] .= $content;
                     $discountname = '';
                     if (IsDiscountAvailable('category', $row['categoryid'], $discountname)) {
                         if (strtolower($discountname) == "clearance") {
                             $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/clearance.gif" alt="">';
                         } else {
                             $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                         }
                     }
                     if ($this->IsMakeAnOffer('category', $row['categoryid']) == 'yes') {
                         $GLOBALS['ViewDetailsImage'] .= "<h3>Qualifies for Make an Offer!</h3>";
                     }
                     $GLOBALS['RelatedBrands'] = $row['featurepoints'];
                     $GLOBALS['lowersidecontent'] = $content;
                     $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListing");
                 }
             }
         }
         ///wirror_code_mark_end
         $get_variables = $_GET;
         $sort_qry = "{$path}/search.php?search_query=" . urlencode($params['search_query']);
         unset($get_variables['orderby'], $get_variables['sort'], $get_variables['search_query'], $get_variables['sortby']);
         $i = 0;
         foreach ($get_variables as $key => $value) {
             $sort_qry .= "&{$key}={$value}";
         }
         if (isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'desc') {
             $sort = "asc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowDown.gif' border=0>";
         } else {
             $sort = "desc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowUp.gif' border=0>";
         }
         //wirror_code_mark_begin
         //$GLOBALS['SearchResults'] = $GLOBALS['SearchResultList']; // commented by vikas
         if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
             $path = $path . "/a-b-testing";
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}{$mmy_links}/orderby/brandname/sortby/{$sort}'>Brand / Series</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}{$mmy_links}/orderby/prodcode/sortby/{$sort}'>Image / Part#</a>";
                 $GLOBALS['ProductDetails'] = "<a href='{$path}{$mmy_links}/orderby/prodfinalprice/sortby/{$sort}'>Price</a>";
             } else {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=brandname&sortby={$sort}'>Brand / Series</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcode&sortby={$sort}'>Image / Part#</a>";
                 $GLOBALS['ProductDetails'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodfinalprice&sortby={$sort}'>Price</a>";
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'brandname') {
                 $GLOBALS['ProductBrand'] .= $img;
             }
             $GLOBALS['ProductVQ'] = $vq_column_title;
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'brandname')
             		$GLOBALS['Product_VQ'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcode') {
                 $GLOBALS['ProductPartNumber'] .= $img;
             }
             $GLOBALS['ProductPQ'] = "Product Options";
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'productoption')
             		$GLOBALS['SearchResults'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcalculatedprice') {
                 $GLOBALS['ProductPrice'] .= $img;
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodfinalprice') {
                 $GLOBALS['ProductDetails'] .= $img;
             }
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryProductsItemHeader");
         } else {
             //lguan_20100612: Show overal product rating at category landing page
             /*if($category_rating != 0)
             		{
             			$GLOBALS['CatgDescandBrandImage'] .= "<br><h2>Rating : <img width='64' height='12' src='".$GLOBALS['TPL_PATH']."/images/IcoRating$category_rating.gif' alt='' /></h2>";
             		}*/
             //		                $GLOBALS['SearchResults'] = "<div>".$GLOBALS['SearchResultList']."</div>";
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryListingMain");
             if ($GLOBALS['results_page_flag'] == 0 && !isset($params['srch_category'])) {
                 $GLOBALS['SearchLink'] = "";
                 if (isset($params['searchtext'])) {
                     $GLOBALS['SearchLink'] .= "/searchtext/" . MakeURLSafe(strtolower($params['searchtext']));
                 }
                 if (isset($params['search'])) {
                     $GLOBALS['SearchLink'] .= "/searchtext/" . MakeURLSafe(strtolower($params['search']));
                 }
                 if (isset($params['model']) && !isset($params['make'])) {
                     $GLOBALS['SearchLink'] .= "/model/" . MakeURLSafe(strtolower($params['model']));
                 }
                 if (isset($params['model_flag']) && $params['model_flag'] == 0 && !isset($params['make'])) {
                     $GLOBALS['SearchLink'] .= "/model_flag/" . MakeURLSafe(strtolower($params['model_flag']));
                 }
                 $GLOBALS['SearchResults'] = "";
                 if (isset($GLOBALS['YMMTable'])) {
                     $GLOBALS['SearchResults'] .= "<div>" . $GLOBALS['YMMTable'] . "</div>";
                 }
                 if ($_REQUEST['is_smart_search']) {
                     $GLOBALS['SearchResults'] .= '<p class="ErrorMessage">' . GetLang('SearchYourSearch') . ' <strong>"' . htmlspecialchars($GLOBALS['OriginalSearchQuery']) . '"</strong> ' . GetLang('SearchDidNotMatch') . '</p>';
                     if ($GLOBALS['OriginalSearchQuery'] == '') {
                         $GLOBALS['SearchTitle'] = '';
                     } else {
                         $GLOBALS['SearchTitle'] = " " . sprintf(GetLang('SearchResultsFor'), $GLOBALS['OriginalSearchQuery']);
                     }
                 }
                 //$GLOBALS['SearchResults'] .= "<div style='width:100%'><p class='InfoMessage'>Please choose a category or brand</p></div>";
                 $GLOBALS['CategoryBrandList'] = "%%Panel.StaticFeaturedCategories%%\n\t\t\t\t\t\t\t%%Panel.StaticFeaturedBrands%%";
                 $GLOBALS['HidePanels'][] = 'SearchPagingTop';
             }
         }
         $GLOBALS['SearchResults'] .= "<script type=\"text/javascript\"> \$('.focushiddendiv').css({'position':'absolute', 'margin-top':'-200px', 'display':'block'}); </script>";
         if ($GLOBALS['EnableSEOUrls'] == 1) {
             $back2url = $_SESSION['back2url'] = preg_replace("/^\\//", "", $_SERVER['REQUEST_URI']);
         } else {
             $back2url = $_SESSION['back2url'] = "search.php?" . $_SERVER['QUERY_STRING'];
         }
         ISC_SetCookie("back2search", $back2url, 0, "/");
     } else {
         $this->YMMSelectors($params);
         $GLOBALS['SearchResults'] = "<div>" . $GLOBALS['YMMTable'] . "</div>";
         $GLOBALS['CategoryBrandList'] = "%%Panel.StaticFeaturedCategories%%\n\t\t\t\t%%Panel.StaticFeaturedBrands%%";
         // No search results were found
         // commented below code as need to show the favorite categories and brands as in homepage
         /*$GLOBALS['HideSearchResults'] = "none";
         		$GLOBALS['HidePanels'][] = 'SearchPageProducts';*/
     }
 }
 public function SetPanelSettings()
 {
     $GLOBALS['HideProductErrorMessage'] = 'display:none';
     if (isset($_SESSION['ProductErrorMessage']) && $_SESSION['ProductErrorMessage'] != '') {
         $GLOBALS['HideProductErrorMessage'] = '';
         $GLOBALS['ProductErrorMessage'] = $_SESSION['ProductErrorMessage'];
         unset($_SESSION['ProductErrorMessage']);
     }
     $GLOBALS['ProductCartQuantity'] = '';
     if (isset($GLOBALS['CartQuantity' . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()])) {
         $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()];
     }
     $GLOBALS['ProductName'] = isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName());
     $GLOBALS['ProductId'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId();
     $GLOBALS['ProductPrice'] = '';
     // Get the vendor information
     $vendorInfo = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVendor();
     $GLOBALS['HideVendorDetails'] = 'display: none';
     $GLOBALS['VendorName'] = '';
     if (is_array($vendorInfo)) {
         //$GLOBALS['HideVendorDetails'] = '';
         $GLOBALS['VendorName'] = '<a href="' . VendorLink($vendorInfo) . '">' . isc_html_escape($vendorInfo['vendorname']) . '</a>';
     }
     // Can this product be gift wrapped? And do we have any gift wrapping options set up?
     if ($GLOBALS['ISC_CLASS_PRODUCT']->CanBeGiftWrapped() && $GLOBALS['ISC_CLASS_PRODUCT']->GetProductType() == PT_PHYSICAL) {
         $GLOBALS['HideGiftWrapMessage'] = '';
         $GLOBALS['GiftWrappingAvailable'] = GetLang('GiftWrappingOptionsAvailable');
     } else {
         $GLOBALS['HideGiftWrapMessage'] = 'display: none';
     }
     $thumb = '';
     $GLOBALS['ImagePopupJavascript'] = "showProductImageNew('" . $this->ProdImageLink($GLOBALS['ProductId']) . "', 0, 0);";
     //$GLOBALS['VideoPopupJavascript'] =  "showProductVideoNew('".GetConfig('ShopPath')."/productvideo.php', ".$GLOBALS['ProductId'].");";
     $GLOBALS['VideoPopupJavascript'] = "showProductVideoNew('" . $this->ProdVideoLink($GLOBALS['ProductId']) . "');";
     //$GLOBALS['AudioPopupJavascript'] =  "showProductVideoNew('".GetConfig('ShopPath')."/productaudio.php', ".$GLOBALS['ProductId'].");";
     $GLOBALS['AudioPopupJavascript'] = "showProductVideoNew('" . $this->ProdAudioLink($GLOBALS['ProductId']) . "');";
     // If we're showing images as a lightbox, we need to load up the URLs for the other images for this product
     if (GetConfig('ProductImageMode') == 'lightbox') {
         $GLOBALS['AdditionalStylesheets'] = array(GetConfig('ShopPath') . '/javascript/jquery/plugins/lightbox/lightbox.css');
         $GLOBALS['LightBoxImageList'] = '';
         $query = "\n\t\t\t\t\tSELECT imagefile\n\t\t\t\t\tFROM [|PREFIX|]product_images\n\t\t\t\t\tWHERE imageprodid='" . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId() . "' AND imageisthumb=0\n\t\t\t\t\tORDER BY imagesort ASC\n\t\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($image = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             $GLOBALS['LightBoxImageList'] .= '<a ';
             $GLOBALS['LightBoxImageList'] .= 'href="' . $GLOBALS['ShopPath'] . '/' . GetConfig('ImageDirectory') . '/' . $image['imagefile'] . '" ';
             $GLOBALS['LightBoxImageList'] .= 'title="' . isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName()) . '"';
             $GLOBALS['LightBoxImageList'] .= '>&nbsp;</a>';
         }
         $GLOBALS['ImagePopupJavascript'] = "showProductImageLightBox(); return false;";
         $GLOBALS['LightBoxImageJavascript'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ProductImagesLightBox');
     }
     // Is there a thumbnail image we can show?
     $thumb = $GLOBALS['ISC_CLASS_PRODUCT']->GetThumb();
     $thumbImage = '';
     if ($thumb == '' && GetConfig('DefaultProductImage') != '') {
         if (GetConfig('DefaultProductImage') == 'template') {
             $thumb = GetConfig('ShopPath') . '/templates/' . GetConfig('template') . '/images/ProductDefault.gif';
         } else {
             $thumb = GetConfig('ShopPath') . '/' . GetConfig('DefaultProductImage');
         }
         $thumbImage = '<img src="' . $thumb . '" alt="" />';
     } else {
         if ($thumb != '') {
             $thumbImage = '<img src="' . GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $thumb . '" alt="" />';
         }
     }
     // Is there more than one image? If not, hide the "See more pictures" link
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumImages() == 0) {
         $GLOBALS['HideMorePicturesLink'] = "none";
         $GLOBALS['ThumbImage'] = $thumbImage;
     } else {
         $GLOBALS['ThumbImage'] = '<a href="#" onclick="' . $GLOBALS['ImagePopupJavascript'] . '">' . $thumbImage . '</a>';
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumImages() == 2) {
             $var = "MorePictures1";
         } else {
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumImages() == 1) {
                 $var = "SeeLargerImage";
             } else {
                 $var = "MorePictures2";
             }
         }
         $GLOBALS['SeeMorePictures'] = sprintf(GetLang($var), $GLOBALS['ISC_CLASS_PRODUCT']->GetNumImages() - 1);
         $this->SetAdditionalView();
     }
     // Is there more than one video? If not, hide the "See videos" link     Added by Simha
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumVideos() == 0 && $GLOBALS['ISC_CLASS_PRODUCT']->GetNumAudios() == 0) {
         $GLOBALS['HideVideosLink'] = "none";
     } else {
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumVideos() > 0) {
             $var = "SeeVideos";
         } else {
             $GLOBALS['HideSpecVideosLink'] = "none";
         }
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumAudios() > 0) {
             $avar = "SeeAudios";
         } else {
             $GLOBALS['HideSpecAudiosLink'] = "none";
         }
         $GLOBALS['SeeVideos'] = sprintf(GetLang($var), $GLOBALS['ISC_CLASS_PRODUCT']->GetNumVideos());
         $GLOBALS['SeeAudios'] = sprintf(GetLang($avar), $GLOBALS['ISC_CLASS_PRODUCT']->GetNumAudios());
     }
     //more Videos link ends Added by Simha
     // Is there more than one video? If not, hide the "See Ins videos" link     Added by Simha
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumInsVideos() == 0) {
         $GLOBALS['HideInsVideosLink'] = "none";
     } else {
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumInsVideos() > 0) {
             $var = "SeeInsVideos";
         }
         $GLOBALS['SeeInsVideos'] = sprintf(GetLang($var), $GLOBALS['ISC_CLASS_PRODUCT']->GetNumInsVideos());
     }
     //more Ins Videos link ends Added by Simha
     //Added by Simha to hide Not For Sale Msg
     $GLOBALS['DisplayNotForSaleMsg'] = 'none';
     if ($GLOBALS['ISC_CLASS_PRODUCT']->IsPurchasingAllowed()) {
         if (!GetConfig('ShowProductShipping')) {
             $GLOBALS['HideShipping'] = 'none';
         } else {
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetProductType() == PT_PHYSICAL) {
                 if ($GLOBALS['ISC_CLASS_PRODUCT']->GetFixedShippingCost() != 0) {
                     // Is there a fixed shipping cost?
                     $GLOBALS['ShippingPrice'] = sprintf("%s %s", CurrencyConvertFormatPrice($GLOBALS['ISC_CLASS_PRODUCT']->GetFixedShippingCost()), GetLang('FixedShippingCost'));
                 } else {
                     if ($GLOBALS['ISC_CLASS_PRODUCT']->HasFreeShipping()) {
                         // Does this product have free shipping?
                         $GLOBALS['ShippingPrice'] = GetLang('FreeShipping');
                     } else {
                         // Shipping calculated at checkout
                         $GLOBALS['ShippingPrice'] = GetLang('CalculatedAtCheckout');
                     }
                 }
             } else {
                 $GLOBALS['ShippingPrice'] = GetLang('CalculatedAtCheckout');
             }
         }
         // Is tax already included in this price?
         if (GetConfig('TaxTypeSelected') > 0 && $GLOBALS['ISC_CLASS_PRODUCT']->GetProductTaxable()) {
             if (GetConfig('PricesIncludeTax')) {
                 if (GetConfig('TaxTypeSelected') == 2 && GetConfig('DefaultTaxRateName')) {
                     //not included
                     $GLOBALS['IncludingExcludingTax'] = sprintf(GetLang('ProductIncludingTax1'), isc_html_escape(GetConfig('DefaultTaxRateName')));
                 } else {
                     $GLOBALS['IncludingExcludingTax'] = GetLang('ProductIncludingTax2');
                 }
             } else {
                 if (GetConfig('TaxTypeSelected') == 2) {
                     if (GetConfig('DefaultTaxRateName')) {
                         $GLOBALS['IncludingExcludingTax'] = sprintf(GetLang('ProductIncludingTax1'), isc_html_escape(GetConfig('DefaultTaxRateName')));
                     } else {
                         $GLOBALS['IncludingExcludingTax'] = GetLang('ProductIncludingTax2');
                     }
                 } else {
                     $GLOBALS['IncludingExcludingTax'] = GetLang('ProductExcludingTax2');
                 }
             }
         }
         $GLOBALS['ProductPrice'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetCalculatedPrice();
         $catquery = " SELECT DISTINCT c.categoryid\n                FROM isc_categories c                                                 \n                LEFT JOIN isc_categoryassociations ca ON c.categoryid = ca.categoryid \n                LEFT JOIN isc_products p ON ca.productid = p.productid AND p.prodvisible='1'\n                WHERE p.productid= " . $GLOBALS['ProductId'] . "";
         $relcats = array();
         $catresult = $GLOBALS['ISC_CLASS_DB']->Query($catquery);
         while ($catrow = $GLOBALS['ISC_CLASS_DB']->Fetch($catresult)) {
             $relcats[] = $catrow['categoryid'];
         }
         $productCats = $relcats;
         $DiscountInfo = GetRuleModuleInfo();
         $FinalPrice = $GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice();
         foreach ($DiscountInfo as $DiscountInfoSub) {
             $catids = explode(",", $DiscountInfoSub['catids']);
             foreach ($catids as $catid) {
                 if (in_array($catid, $productCats)) {
                     $DiscountAmount = $FinalPrice * ((int) $DiscountInfoSub['amount'] / 100);
                     if ($DiscountAmount < 0) {
                         $DiscountAmount = 0;
                     }
                     $DiscountAmount = $FinalPrice - $DiscountAmount;
                 }
             }
         }
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice() < $GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice()) {
             $GLOBALS['RetailPrice'] = "<strike>" . CurrencyConvertFormatPrice($GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice()) . "</strike>";
             // blessen
             //$GLOBALS['PriceLabel'] = GetLang('YourPrice');
             $GLOBALS['PriceLabel'] = GetLang('Price');
             $savings = $GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice() - $GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice();
             $GLOBALS['HideRRP'] = "none";
             //$GLOBALS['YouSave'] = "<span class=\"YouSave\">".sprintf(GetLang('YouSave'), "<span class=
             //'YouSaveAmount'>".CurrencyConvertFormatPrice($savings)."</span>")."</span>";
         } else {
             $GLOBALS['PriceLabel'] = GetLang('Price');
             $GLOBALS['HideRRP'] = "none";
         }
     } else {
         $GLOBALS['PriceLabel'] = GetLang('Price');
         $GLOBALS['HideShipping'] = 'none';
         if ($GLOBALS['ISC_CLASS_PRODUCT']->ArePricesHidden() || !GetConfig('ShowProductPrice')) {
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetProductCallForPricingLabel()) {
                 $GLOBALS['ProductPrice'] = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseGL($GLOBALS['ISC_CLASS_PRODUCT']->GetProductCallForPricingLabel());
             } else {
                 $GLOBALS['HidePrice'] = "display: none;";
             }
         } else {
             $GLOBALS['ProductPrice'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetCalculatedPrice();
         }
         $GLOBALS['HideRRP'] = 'none';
         //To display not for sale message Added by Simha
         $GLOBALS['DisplayNotForSaleMsg'] = '';
     }
     // Is this product linked to a brand?
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetBrandName() != "" && GetConfig('ShowProductBrand')) {
         $GLOBALS['BrandName'] = isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetBrandName());
         $GLOBALS['BrandLink'] = BrandLink($GLOBALS['ISC_CLASS_PRODUCT']->GetBrandName());
     } else {
         $GLOBALS['HideBrandLink'] = "none";
     }
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetProductType() == PT_PHYSICAL && GetConfig('ShowProductWeight')) {
         // It's a physical product
         $prodweight = $GLOBALS['ISC_CLASS_PRODUCT']->GetWeight();
         # Added to hide the weight lable while the value is 0.00 Baskaran
         if ($prodweight == '0.00 LBS') {
             $GLOBALS['HideWeight'] = "none";
         } else {
             $GLOBALS['ProductWeight'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetWeight();
         }
     } else {
         // It's a digital product
         $GLOBALS['HideWeight'] = "none";
     }
     $product = $GLOBALS['ISC_CLASS_PRODUCT']->GetProduct();
     $dimensions = array('ProductHeight' => 'prodheight', 'ProductWidth' => 'prodwidth', 'ProductDepth' => 'proddepth');
     foreach ($dimensions as $global => $field) {
         if ($product[$field] > 0) {
             $GLOBALS[$global] = FormatWeight($product[$field], false);
             $hasDimensions = true;
         } else {
             $GLOBALS['Hide' . $global] = 'display: none';
         }
     }
     if (!isset($hasDimensions)) {
         $GLOBALS['HideDimensions'] = 'display: none';
     }
     // Are reviews disabled? Then don't show anything related to reviews
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideReviewLink'] = "none";
         $GLOBALS['HideRating'] = "none";
         $GLOBALS['HideReviews'] = "none";
     } else {
         // How many reviews are there?
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews() == 0) {
             $GLOBALS['HideReviewLink'] = "none";
         } else {
             $GLOBALS['HideNoReviewsMessage'] = "none";
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews() == 1) {
                 $GLOBALS['ReviewLinkText'] = GetLang('ReviewLinkText1');
             } else {
                 $GLOBALS['ReviewLinkText'] = sprintf(GetLang('ReviewLinkText2'), $GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews());
             }
         }
     }
     // Has a product availability been given?
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetAvailability() != "") {
         $GLOBALS['Availability'] = isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetAvailability());
     } else {
         $GLOBALS['HideAvailability'] = "none";
     }
     // Is there an SKU for this product?
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetSKU() != "" && GetConfig('ShowProductSKU')) {
         $GLOBALS['SKU'] = isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetSKU());
     } else {
         $GLOBALS['HideSKU'] = "none";
     }
     if (!GetConfig('ShowProductRating')) {
         $GLOBALS['HideRating'] = "none";
     }
     $GLOBALS['Rating'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetRating();
     $GLOBALS['CartLink'] = CartLink();
     /* Baskaran added to display image in product detail page */
     $brandimage = $GLOBALS['ISC_CLASS_PRODUCT']->GetProdbrandimagefile();
     $imageurl = '';
     if ($brandimage != '' || !empty($brandimage)) {
         $imageurl = GetConfig('ShopPath') . "/product_images/" . $brandimage;
     } else {
         $imageurl = GetConfig('ShopPath') . "/templates/CongoWorld/images/ProductDefault.gif";
     }
     $GLOBALS['ImageUrl'] = $imageurl;
     /* Baskaran ends */
     $GLOBALS['ProductId'] = (int) $GLOBALS['ISC_CLASS_PRODUCT']->_prodid;
     $GLOBALS['ImagePage'] = sprintf("%s/productimage.php", $GLOBALS['ShopPath']);
     $GLOBALS['ProductNumReviews'] = (int) $GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews();
     // Does this product have any bulk discount?
     if ($GLOBALS['ISC_CLASS_PRODUCT']->CanUseBulkDiscounts()) {
         $GLOBALS['HideBulkDiscountLink'] = '';
         $GLOBALS['BulkDiscountThickBoxTitle'] = sprintf(GetLang('BulkDiscountThickBoxTitle'), isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName()));
         require_once ISC_BASE_PATH . '/includes/display/SideProductAddToCart.php';
         $GLOBALS['BulkDiscountThickBoxRates'] = ISC_SIDEPRODUCTADDTOCART_PANEL::GetProductBulkDiscounts();
         $GLOBALS['ProductBulkDiscountThickBox'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductBulkDiscountThickBox");
     } else {
         $GLOBALS['HideBulkDiscountLink'] = 'none';
     }
     if (GetConfig('ShowInventory') == 1 && $GLOBALS['ISC_CLASS_PRODUCT']->GetProductInventoryTracking() > 0) {
         $GLOBALS['InventoryList'] = '';
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetProductInventoryTracking() == 2) {
             $variations = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVariations();
             if (empty($options)) {
                 $GLOBALS['HideCurrentStock'] = "display: none;";
             }
         } else {
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetProductInventoryTracking() == 1) {
                 $currentStock = $GLOBALS['ISC_CLASS_PRODUCT']->GetInventoryLevel();
                 if ($currentStock <= 0) {
                     $GLOBALS['InventoryList'] = GetLang('SoldOut');
                 } else {
                     $GLOBALS['InventoryList'] = $currentStock;
                 }
             }
         }
     } else {
         $GLOBALS['HideCurrentStock'] = "display: none;";
     }
     /* Added for to display the "Make an offer" Button -- Baskaran */
     # Checked for the selected series offer is 'yes'
     $GLOBALS['HideOfferButton'] = 'none';
     if (GetConfig('ShowBestOffer') == '1') {
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetSeriesOffer() == 'yes') {
             $GLOBALS['HideOfferButton'] = '';
         } else {
             # Checking for the selected sub category offer is 'yes'
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetCategoryOffer() == 'yes') {
                 $GLOBALS['HideOfferButton'] = '';
             } else {
                 # Checking brand offer is 'yes' and corresponding series offer are 'no'
                 if ($GLOBALS['ISC_CLASS_PRODUCT']->GetBrandOffer() == 'yes' and $GLOBALS['ISC_CLASS_PRODUCT']->GetSeriesCntOffer() == 0) {
                     $GLOBALS['HideOfferButton'] = '';
                 } else {
                     # Checking for Root category offer is 'yes' and corresponding sub category offer are 'no'
                     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetRootCategoryOffer() == 'yes' and $GLOBALS['ISC_CLASS_PRODUCT']->GetSubCategoryCntOffer() == 0) {
                         $GLOBALS['HideOfferButton'] = '';
                     } else {
                         $GLOBALS['HideOfferButton'] = 'none';
                     }
                 }
             }
         }
     }
     /* Code Ends */
     if (GetConfig('AddToCartButtonPosition') == 'middle' && $GLOBALS['ISC_CLASS_PRODUCT']->IsPurchasingAllowed()) {
         require_once ISC_BASE_PATH . '/includes/display/SideProductAddToCart.php';
         ISC_SIDEPRODUCTADDTOCART_PANEL::LoadAddToCartOptions('middle');
         //blessen
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice() < $GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice()) {
             $GLOBALS['SNIPPETS']['ProductAddToCart'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductAddToCart1");
         } else {
             $GLOBALS['SNIPPETS']['ProductAddToCart'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductAddToCart");
         }
         //blessen
         // original $GLOBALS['SNIPPETS']['ProductAddToCart'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductAddToCart");
     }
     //blessen
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice() < $GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice()) {
         $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice());
         $GLOBALS['ProductPrice'] = "<strike>" . $GLOBALS['ProductPrice'] . "</strike>&nbsp;&nbsp;<b alt='Price may be adjusted. Add to your cart and see the final price.'  Title='Price may be adjusted. Add to your cart and see the final price.'>(" . GetLang('CheckPriceInCart') . ")</b>";
     }
     $GLOBALS['ShowOnSaleImage'] = '';
     if (isset($DiscountAmount) && $DiscountAmount < $FinalPrice) {
         //&& GetConfig('ShowOnSale')
         $GLOBALS['ProductPrice'] = "<strike>" . CurrencyConvertFormatPrice($FinalPrice) . "</strike>";
         $GLOBALS['DiscountPrice'] = "" . CurrencyConvertFormatPrice($DiscountAmount) . "";
         if (GetConfig('ShowOnSale')) {
             $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
         }
     }
     //blessen
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle($GLOBALS['ISC_CLASS_PRODUCT']->BuildTitle());
 }
 public function GenerateGiftCertificate($certificate, $type)
 {
     $giftid = $_REQUEST['id'];
     if (!isset($certificate['giftcerttemplate']) || $certificate['giftcerttemplate'] == "") {
         $certificate['giftcerttemplate'] = 'General';
     }
     $certificate['giftcerttemplate'] = basename($certificate['giftcerttemplate']);
     // The selected gift certificate does not exist - just use the first enabled theme
     if (!$certificate['giftcerttemplate'] || !file_exists(APP_ROOT . "/templates/__gift_themes/" . $certificate['giftcerttemplate'])) {
         $enabledThemes = explode(",", GetConfig('GiftCertificateThemes'));
         $certificate['giftcertemplate'] = $enabledThemes[0];
     }
     $oldExt = $GLOBALS['ISC_CLASS_TEMPLATE']->templateExt;
     $GLOBALS['ISC_CLASS_TEMPLATE']->templateExt = "html";
     if (defined("ISC_ADMIN_CP")) {
         $tplPath = "../../templates/" . GetConfig('template') . "/";
         //$snippetPath = "../".$tplPath . "/Snippets/";
     } else {
         $tplPath = '';
         //$snippetPath = '';
     }
     $certificate['giftcerttemplate'] = str_replace(".html", "", $certificate['giftcerttemplate']);
     if (!isset($GLOBALS['ShopPathNormal'])) {
         $GLOBALS['ShopPathNormal'] = $GLOBALS['ShopPath'];
     }
     // Fetch the store logo or store title
     if (GetConfig('UseAlternateTitle')) {
         $text = GetConfig('AlternateTitle');
     } else {
         $text = GetConfig('StoreName');
     }
     //echo "<pre>";
     //print_r($text);
     $text = explode(" ", $text, 2);
     $text[0] = "<span class=\"Logo1stWord\">" . $text[0] . "</span>";
     $GLOBALS['LogoText'] = implode(" ", $text);
     $snippetPath = "../../../templates/__master/Snippets/";
     $GLOBALS['HeaderLogo'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippetPath . "LogoText");
     $GLOBALS['CharacterSet'] = GetConfig('CharacterSet');
     $GLOBALS['GiftCertificateTo'] = isc_html_escape($certificate['giftcertto']);
     $GLOBALS['GiftCertificateToEmail'] = isc_html_escape($certificate['giftcerttoemail']);
     $GLOBALS['GiftCertificateFrom'] = isc_html_escape($certificate['giftcertfrom']);
     $GLOBALS['GiftCertificateFromEmail'] = isc_html_escape($certificate['giftcertfromemail']);
     $GLOBALS['GiftCertificateAmount'] = CurrencyConvertFormatPrice($certificate['giftcertamount']);
     $GLOBALS['GiftCertificateMessage'] = isc_html_escape($certificate['giftcertmessage']);
     $GLOBALS['GiftCertificateCode'] = isc_html_escape($certificate['giftcertcode']);
     if (isset($certificate['giftcertexpirydate']) && $certificate['giftcertexpirydate'] != 0) {
         $GLOBALS['GiftCertificateExpiryInfo'] = sprintf(GetLang('GiftCertificateExpiresOn'), CDate($certificate['giftcertexpirydate']));
     } else {
         $GLOBALS['GiftCertificateExpiryInfo'] = '';
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate($tplPath . "../__gift_themes/" . $certificate['giftcerttemplate']);
     $certificate = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
     $resentform = '<BR><div align ="center"><FORM METHOD=POST ACTION="index.php?ToDo=viewGiftcertificatesPopup" name="f1"><INPUT TYPE="hidden" name="orderId" value =' . $giftid . '><INPUT TYPE="submit" name = "sendmail" value = "Resend Certificate">	</FORM></div>';
     if ($type == 'preview') {
         $certificate .= $resentform;
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->templateExt = $oldExt;
     return $certificate;
 }
Example #19
0
	private function EmailReturnStatusChange($return)
	{
		// Get the customer's details
		$query = sprintf("SELECT custconfirstname, custconlastname, custconemail FROM [|PREFIX|]customers WHERE customerid='%d'", $return['retcustomerid']);
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
		$customer = $GLOBALS['ISC_CLASS_DB']->Fetch($result);

		$GLOBALS['ReturnId'] = $return['returnid'];

		$GLOBALS['CustomerFirstName'] = $customer['custconfirstname'];
		$GLOBALS['CustomerName'] = $customer['custconfirstname'] . " " . $customer['custconlastname'];
		$GLOBALS['CustomerEmail'] = $customer['custconemail'];

		$GLOBALS['ProductQuantity'] = $return['retprodqty'];
		$GLOBALS['ProductName'] = $return['retprodname'];

		$GLOBALS['ReturnStatus'] = $this->_FetchReturnStatus($return['retstatus']);

		$GLOBALS['SNIPPETS']['Products'] = '';
		if($return['retstatus'] == 5) {

			// Manually convert the cost to the exchage rate when it was bought
			$GLOBALS['StoreCreditAmount'] = CurrencyConvertFormatPrice($return['retprodcost'] * $return['retprodqty'], $return['ordcurrencyid'], $return['ordcurrencyexchangerate']);
			$GLOBALS['ReturnReceivedCredit'] = sprintf(GetLang('RefundAccountCredited'), $GLOBALS['StoreCreditAmount']);
		}
		else if($return['retstatus'] == 3) {
			$instructions = nl2br($GLOBALS['ReturnInstructions']);
			if($instructions) {
				$GLOBALS['ReturnInstructions'] = '<p><strong>'.GetLang('ReturnInstructions').':</strong><br />'.$instructions.'</p>';
			}
		}

		$emailTemplate = FetchEmailTemplateParser();
		$emailTemplate->SetTemplate("return_statuschange_email");
		$message = $emailTemplate->ParseTemplate(true);

		// Create a new email API object to send the email
		$store_name = str_replace("&#39;", "'", GetConfig('StoreName'));

		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", sprintf(GetLang('ReturnStatusUpdate'), $store_name));
		$obj_email->AddBody("html", $message);
		$obj_email->AddRecipient($customer['custconemail'], "", "h");
		$email_result = $obj_email->Send();

		// If the email was sent ok, show a confirmation message
		if($email_result['success']) {
			return true;
		}
		else {
			// Email error
			return false;
		}
	}
Example #20
0
 public function SetPanelSettings()
 {
     // Setup the cart values
     $GLOBALS['ISC_CLASS_CART'] = GetClass('ISC_CART');
     $GLOBALS['ISC_CLASS_CART']->SetCartValues();
     $GLOBALS['SNIPPETS']['MiniCartProductAdded'] = "";
     $GLOBALS['SNIPPETS']['MiniCartOtherProduct'] = "";
     foreach (GetAvailableModules('checkout', true, true) as $module) {
         if ($module['object']->disableNonCartCheckoutButtons) {
             $GLOBALS['HideCheckoutButton'] = 'none';
             break;
         }
     }
     $GLOBALS['AdditionalCheckoutButtons'] = '';
     $HideCheckout = false;
     foreach (GetAvailableModules('checkout', true, true) as $module) {
         if (method_exists($module['object'], 'GetSidePanelCheckoutButton')) {
             $GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetSidePanelCheckoutButton();
         }
         if ($module['object']->disableNonCartCheckoutButtons) {
             $HideCheckout = true;
         }
     }
     $count = 0;
     $subtotal = 0;
     // Get a list of all products in the cart
     $product_array = $GLOBALS['ISC_CLASS_CART']->api->GetProductsInCart();
     foreach ($product_array as $itemId => $product) {
         $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
         // Is this product a variation?
         $GLOBALS['ProductOptions'] = '';
         if (isset($product['options']) && !empty($product['options'])) {
             $GLOBALS['ProductOptions'] .= "<small class='CartProductOptionList'>(";
             $comma = '';
             foreach ($product['options'] as $name => $value) {
                 if (!trim($name) || !trim($value)) {
                     continue;
                 }
                 $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                 $comma = ', ';
             }
             $GLOBALS['ProductOptions'] .= ")</small>";
         }
         $GLOBALS['ProductLink'] = '';
         if (!isset($product['type']) || $product['type'] != "giftcertificate") {
             $GLOBALS['ProductImage'] = ImageThumb($product['data']['imagefile'], ProdLink($product['data']['prodname']));
         }
         $GLOBALS['ProductLink'] = ProdLink($product['data']['prodname']);
         $GLOBALS['ProductQuantity'] = $product['quantity'];
         if (isset($product['discount_price'])) {
             $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($product['discount_price']);
             $price = $product['discount_price'];
         } else {
             if (isset($product['type']) && $product['type'] == "giftcertificate") {
                 $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($product['giftamount']);
                 $price = $product['giftamount'];
             } else {
                 $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($product['product_price']);
                 $price = $product['product_price'];
             }
         }
         // Update the subtotal
         $subtotal += (int) $product['quantity'] * $price;
         if ($GLOBALS['ISC_CLASS_CART']->newCartItem == $itemId) {
             $GLOBALS['SNIPPETS']['MiniCartProductAdded'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("MiniCartProductAdded");
         } else {
             $GLOBALS['SNIPPETS']['MiniCartOtherProduct'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("MiniCartOtherProduct");
         }
     }
     $GLOBALS['CartSubTotal'] = CurrencyConvertFormatPrice($GLOBALS['CartSubTotal']);
     // Should we hide extra info on the mini cart panel?
     if ($GLOBALS['ISC_CLASS_CART']->api->GetNumProductsInCart() < 2) {
         $GLOBALS['HideExtraMiniCartInfo'] = "none";
     }
 }
 public function SetPanelSettings()
 {
     $GLOBALS['HideProductErrorMessage'] = 'display:none';
     if (isset($_SESSION['ProductErrorMessage']) && $_SESSION['ProductErrorMessage'] != '') {
         $GLOBALS['HideProductErrorMessage'] = '';
         $GLOBALS['ProductErrorMessage'] = $_SESSION['ProductErrorMessage'];
         unset($_SESSION['ProductErrorMessage']);
     }
     $GLOBALS['ProductCartQuantity'] = '';
     if (isset($GLOBALS['CartQuantity' . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()])) {
         $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()];
     }
     //temp script to shortern the product name
     $pid = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId();
     $querytemp = "SELECT prodbrandid FROM  [|PREFIX|]products where productid = " . $pid . "  ";
     $resulttemp = $GLOBALS['ISC_CLASS_DB']->Query($querytemp);
     $brand = $GLOBALS['ISC_CLASS_DB']->Fetch($resulttemp);
     if ($brand['prodbrandid'] == 37) {
         $querytemp1 = "SELECT c.catname, c.catcombine FROM [|PREFIX|]categories \tc left join [|PREFIX|]categoryassociations ca on c.categoryid = ca.categoryid  left join [|PREFIX|]products p on ca.productid = p.productid where p.productid =  '" . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId() . "' ";
         $resulttemp1 = $GLOBALS['ISC_CLASS_DB']->Query($querytemp1);
         $cat = $GLOBALS['ISC_CLASS_DB']->Fetch($resulttemp1);
         if ($cat['catcombine'] != "") {
             $GLOBALS['ProductName'] = $cat['catcombine'] . " Part Number " . isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetSKU());
         } else {
             $GLOBALS['ProductName'] = $cat['catname'] . " Part Number " . isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetSKU());
         }
     } else {
         $GLOBALS['ProductName'] = isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName());
     }
     //temp script to shortern the product name
     //$GLOBALS['ProductName'] = isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName());
     $GLOBALS['ProductId'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId();
     $GLOBALS['ProductPrice'] = '';
     // Get the vendor information
     $vendorInfo = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVendor();
     $GLOBALS['HideVendorDetails'] = 'display: none';
     $GLOBALS['VendorName'] = '';
     if (is_array($vendorInfo)) {
         //$GLOBALS['HideVendorDetails'] = '';
         $GLOBALS['VendorName'] = '<a href="' . VendorLink($vendorInfo) . '">' . isc_html_escape($vendorInfo['vendorname']) . '</a>';
     }
     // Can this product be gift wrapped? And do we have any gift wrapping options set up?
     if ($GLOBALS['ISC_CLASS_PRODUCT']->CanBeGiftWrapped() && $GLOBALS['ISC_CLASS_PRODUCT']->GetProductType() == PT_PHYSICAL) {
         $GLOBALS['HideGiftWrapMessage'] = '';
         $GLOBALS['GiftWrappingAvailable'] = GetLang('GiftWrappingOptionsAvailable');
     } else {
         $GLOBALS['HideGiftWrapMessage'] = 'display: none';
     }
     $thumb = '';
     $GLOBALS['ImagePopupJavascript'] = "showProductImageNew('" . $this->ProdImageLink($GLOBALS['ProductId']) . "', 0, 0);";
     //$GLOBALS['VideoPopupJavascript'] =  "showProductVideoNew('".GetConfig('ShopPath')."/productvideo.php', ".$GLOBALS['ProductId'].");";
     $GLOBALS['VideoPopupJavascript'] = "showProductVideoNew('" . $this->ProdVideoLink($GLOBALS['ProductId']) . "');";
     //$GLOBALS['AudioPopupJavascript'] =  "showProductVideoNew('".GetConfig('ShopPath')."/productaudio.php', ".$GLOBALS['ProductId'].");";
     $GLOBALS['AudioPopupJavascript'] = "showProductVideoNew('" . $this->ProdAudioLink($GLOBALS['ProductId']) . "');";
     // If we're showing images as a lightbox, we need to load up the URLs for the other images for this product
     if (GetConfig('ProductImageMode') == 'lightbox') {
         $GLOBALS['AdditionalStylesheets'] = array(GetConfig('ShopPath') . '/javascript/jquery/plugins/lightbox/lightbox.css');
         $GLOBALS['LightBoxImageList'] = '';
         $query = "\n\t\t\t\t\tSELECT imagefile\n\t\t\t\t\tFROM [|PREFIX|]product_images\n\t\t\t\t\tWHERE imageprodid='" . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId() . "' AND imageisthumb=0\n\t\t\t\t\tORDER BY imagesort ASC\n\t\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($image = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             $GLOBALS['LightBoxImageList'] .= '<a ';
             $GLOBALS['LightBoxImageList'] .= 'href="' . $GLOBALS['ShopPath'] . '/' . GetConfig('ImageDirectory') . '/' . $image['imagefile'] . '" ';
             $GLOBALS['LightBoxImageList'] .= 'title="' . isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName()) . '"';
             $GLOBALS['LightBoxImageList'] .= '>&nbsp;</a>';
         }
         $GLOBALS['ImagePopupJavascript'] = "showProductImageLightBox(); return false;";
         $GLOBALS['LightBoxImageJavascript'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ProductImagesLightBox');
     }
     // Is there a thumbnail image we can show?
     $thumb = $GLOBALS['ISC_CLASS_PRODUCT']->GetThumb();
     $thumbImage = '';
     if ($thumb == '' && GetConfig('DefaultProductImage') != '') {
         if (GetConfig('DefaultProductImage') == 'template') {
             $thumb = GetConfig('ShopPath') . '/templates/' . GetConfig('template') . '/images/ProductDefault.gif';
         } else {
             $thumb = GetConfig('ShopPath') . '/' . GetConfig('DefaultProductImage');
         }
         $thumbImage = '<img src="' . $thumb . '" alt="" />';
     } else {
         if ($thumb != '') {
             $thumbImage = '<img src="' . GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $thumb . '" alt="" />';
         }
     }
     // Is there more than one image? If not, hide the "See more pictures" link
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumImages() == 0) {
         $GLOBALS['HideMorePicturesLink'] = "none";
         $GLOBALS['ThumbImage'] = $thumbImage;
     } else {
         $GLOBALS['ThumbImage'] = '<a href="#" onclick="' . $GLOBALS['ImagePopupJavascript'] . '">' . $thumbImage . '</a>';
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumImages() == 2) {
             $var = "MorePictures1";
         } else {
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumImages() == 1) {
                 $var = "SeeLargerImage";
             } else {
                 $var = "MorePictures2";
             }
         }
         $GLOBALS['SeeMorePictures'] = sprintf(GetLang($var), $GLOBALS['ISC_CLASS_PRODUCT']->GetNumImages() - 1);
         $this->SetAdditionalView();
     }
     // Is there more than one video? If not, hide the "See videos" link     Added by Simha
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumVideos() == 0 && $GLOBALS['ISC_CLASS_PRODUCT']->GetNumAudios() == 0) {
         $GLOBALS['HideVideosLink'] = "none";
     } else {
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumVideos() > 0) {
             $var = "SeeVideos";
         } else {
             $GLOBALS['HideSpecVideosLink'] = "none";
         }
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumAudios() > 0) {
             $avar = "SeeAudios";
         } else {
             $GLOBALS['HideSpecAudiosLink'] = "none";
         }
         $GLOBALS['SeeVideos'] = sprintf(GetLang($var), $GLOBALS['ISC_CLASS_PRODUCT']->GetNumVideos());
         $GLOBALS['SeeAudios'] = sprintf(GetLang($avar), $GLOBALS['ISC_CLASS_PRODUCT']->GetNumAudios());
     }
     //more Videos link ends Added by Simha
     // Is there more than one video? If not, hide the "See Ins videos" link     Added by Simha
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumInsVideos() == 0) {
         $GLOBALS['HideInsVideosLink'] = "none";
     } else {
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumInsVideos() > 0) {
             $var = "SeeInsVideos";
         }
         $GLOBALS['SeeInsVideos'] = sprintf(GetLang($var), $GLOBALS['ISC_CLASS_PRODUCT']->GetNumInsVideos());
     }
     //more Ins Videos link ends Added by Simha
     //Added by Simha to hide Not For Sale Msg
     $GLOBALS['DisplayNotForSaleMsg'] = 'none';
     if ($GLOBALS['ISC_CLASS_PRODUCT']->IsPurchasingAllowed()) {
         if (!GetConfig('ShowProductShipping')) {
             $GLOBALS['HideShipping'] = 'none';
         } else {
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetProductType() == PT_PHYSICAL) {
                 if ($GLOBALS['ISC_CLASS_PRODUCT']->GetFixedShippingCost() != 0) {
                     // Is there a fixed shipping cost?
                     $GLOBALS['ShippingPrice'] = sprintf("%s %s", CurrencyConvertFormatPrice($GLOBALS['ISC_CLASS_PRODUCT']->GetFixedShippingCost()), GetLang('FixedShippingCost'));
                 } else {
                     if ($GLOBALS['ISC_CLASS_PRODUCT']->HasFreeShipping()) {
                         // Does this product have free shipping?
                         $GLOBALS['ShippingPrice'] = GetLang('FreeShipping');
                     } else {
                         // Shipping calculated at checkout
                         $GLOBALS['ShippingPrice'] = GetLang('CalculatedAtCheckout');
                     }
                 }
             } else {
                 $GLOBALS['ShippingPrice'] = GetLang('CalculatedAtCheckout');
             }
         }
         // Is tax already included in this price?
         if (GetConfig('TaxTypeSelected') > 0 && $GLOBALS['ISC_CLASS_PRODUCT']->GetProductTaxable()) {
             if (GetConfig('PricesIncludeTax')) {
                 if (GetConfig('TaxTypeSelected') == 2 && GetConfig('DefaultTaxRateName')) {
                     //not included
                     $GLOBALS['IncludingExcludingTax'] = sprintf(GetLang('ProductIncludingTax1'), isc_html_escape(GetConfig('DefaultTaxRateName')));
                 } else {
                     $GLOBALS['IncludingExcludingTax'] = GetLang('ProductIncludingTax2');
                 }
             } else {
                 if (GetConfig('TaxTypeSelected') == 2) {
                     if (GetConfig('DefaultTaxRateName')) {
                         $GLOBALS['IncludingExcludingTax'] = sprintf(GetLang('ProductIncludingTax1'), isc_html_escape(GetConfig('DefaultTaxRateName')));
                     } else {
                         $GLOBALS['IncludingExcludingTax'] = GetLang('ProductIncludingTax2');
                     }
                 } else {
                     $GLOBALS['IncludingExcludingTax'] = GetLang('ProductExcludingTax2');
                 }
             }
         }
         $GLOBALS['ProductPrice'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetCalculatedPrice();
         $catquery = " SELECT DISTINCT c.categoryid, p.brandseriesid\n                FROM isc_categories c                                                 \n                LEFT JOIN isc_categoryassociations ca ON c.categoryid = ca.categoryid \n                LEFT JOIN isc_products p ON ca.productid = p.productid AND p.prodvisible='1'\n                WHERE p.productid= " . $GLOBALS['ProductId'] . "";
         $relcats = array();
         $brandseries = 0;
         $catresult = $GLOBALS['ISC_CLASS_DB']->Query($catquery);
         while ($catrow = $GLOBALS['ISC_CLASS_DB']->Fetch($catresult)) {
             $relcats[] = $catrow['categoryid'];
             $brandseries = $catrow['brandseriesid'];
         }
         $productCats = $relcats;
         $discounttype = 0;
         //$DiscountInfo = GetRuleModuleInfo();
         //$FinalPrice    = $GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice();
         //$FinalPrice    = $GLOBALS['ProductPrice'];
         $FinalPrice = $GLOBALS['ISC_CLASS_PRODUCT']->GetPrice();
         $SalePrice = $GLOBALS['ISC_CLASS_PRODUCT']->GetSalePrice();
         if ((double) $SalePrice > 0 && $SalePrice < $FinalPrice) {
             $DiscountPrice = $SalePrice;
         } else {
             $DiscountPrice = $FinalPrice;
             $DiscountPrice = CalculateDiscountPrice($FinalPrice, $DiscountPrice, $productCats[0], $brandseries, $discounttype);
         }
         /*
         foreach($DiscountInfo as $DiscountInfoSub)   {  
             $catids = explode(",", $DiscountInfoSub['catids']);
             foreach($catids as $catid) {
                 if(in_array($catid, $productCats)) {     
                     $DiscountAmount = $FinalPrice * ((int)$DiscountInfoSub['amount']/100); 
                     if ($DiscountAmount < 0) {
                         $DiscountAmount = 0;
                     }
                     $DiscountAmount  = $FinalPrice - $DiscountAmount; 
                 } 
             }  
         }
         */
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice() > $GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice()) {
             $GLOBALS['RetailPrice'] = "<strike>" . CurrencyConvertFormatPrice($GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice()) . "</strike>";
             // blessen
             //$GLOBALS['PriceLabel'] = GetLang('YourPrice');
             $GLOBALS['PriceLabel'] = GetLang('Price');
             $savings = $GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice() - $GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice();
             $GLOBALS['HideRRP'] = "none";
             //$GLOBALS['YouSave'] = "<span class=\"YouSave\">".sprintf(GetLang('YouSave'), "<span class=
             //'YouSaveAmount'>".CurrencyConvertFormatPrice($savings)."</span>")."</span>";
         } else {
             $GLOBALS['PriceLabel'] = GetLang('Price');
             $GLOBALS['HideRRP'] = "none";
         }
     } else {
         $GLOBALS['PriceLabel'] = GetLang('Price');
         $GLOBALS['HideShipping'] = 'none';
         if ($GLOBALS['ISC_CLASS_PRODUCT']->ArePricesHidden() || !GetConfig('ShowProductPrice')) {
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetProductCallForPricingLabel()) {
                 $GLOBALS['ProductPrice'] = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseGL($GLOBALS['ISC_CLASS_PRODUCT']->GetProductCallForPricingLabel());
             } else {
                 $GLOBALS['HidePrice'] = "display: none;";
             }
         } else {
             $GLOBALS['ProductPrice'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetCalculatedPrice();
         }
         $GLOBALS['HideRRP'] = 'none';
         //To display not for sale message Added by Simha
         $GLOBALS['DisplayNotForSaleMsg'] = '';
     }
     // Is this product linked to a brand?
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetBrandName() != "" && GetConfig('ShowProductBrand')) {
         $GLOBALS['BrandName'] = isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetBrandName());
         $GLOBALS['BrandLink'] = BrandLink($GLOBALS['ISC_CLASS_PRODUCT']->GetBrandName());
     } else {
         $GLOBALS['HideBrandLink'] = "none";
     }
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetProductType() == PT_PHYSICAL && GetConfig('ShowProductWeight')) {
         // It's a physical product
         $prodweight = $GLOBALS['ISC_CLASS_PRODUCT']->GetWeight();
         # Added to hide the weight lable while the value is 0.00 Baskaran
         if ($prodweight == '0.00 LBS') {
             $GLOBALS['HideWeight'] = "none";
         } else {
             $GLOBALS['ProductWeight'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetWeight();
         }
     } else {
         // It's a digital product
         $GLOBALS['HideWeight'] = "none";
     }
     $product = $GLOBALS['ISC_CLASS_PRODUCT']->GetProduct();
     $dimensions = array('ProductHeight' => 'prodheight', 'ProductWidth' => 'prodwidth', 'ProductDepth' => 'proddepth');
     foreach ($dimensions as $global => $field) {
         if ($product[$field] > 0) {
             $GLOBALS[$global] = FormatWeight($product[$field], false);
             $hasDimensions = true;
         } else {
             $GLOBALS['Hide' . $global] = 'display: none';
         }
     }
     if (!isset($hasDimensions)) {
         $GLOBALS['HideDimensions'] = 'display: none';
     }
     // Are reviews disabled? Then don't show anything related to reviews
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideReviewLink'] = "none";
         $GLOBALS['HideRating'] = "none";
         $GLOBALS['HideReviews'] = "none";
     } else {
         // How many reviews are there?
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews() == 0) {
             $GLOBALS['HideReviewLink'] = "none";
         } else {
             $GLOBALS['HideNoReviewsMessage'] = "none";
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews() == 1) {
                 $GLOBALS['ReviewLinkText'] = GetLang('ReviewLinkText1');
             } else {
                 $GLOBALS['ReviewLinkText'] = sprintf(GetLang('ReviewLinkText2'), $GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews());
             }
         }
     }
     // Has a product availability been given?
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetAvailability() != "") {
         $GLOBALS['Availability'] = isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetAvailability());
     } else {
         $GLOBALS['HideAvailability'] = "none";
     }
     // Is there an SKU for this product?
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetSKU() != "" && GetConfig('ShowProductSKU')) {
         $GLOBALS['SKU'] = isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetSKU());
     } else {
         $GLOBALS['HideSKU'] = "none";
     }
     if (!GetConfig('ShowProductRating')) {
         $GLOBALS['HideRating'] = "none";
     }
     $GLOBALS['Rating'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetRating();
     $GLOBALS['CartLink'] = CartLink();
     /* Baskaran added to display image in product detail page */
     $brandimage = $GLOBALS['ISC_CLASS_PRODUCT']->GetProdbrandimagefile();
     $imageurl = '';
     if ($brandimage != '' || !empty($brandimage)) {
         $imageurl = GetConfig('ShopPath') . "/product_images/" . $brandimage;
     } else {
         $imageurl = GetConfig('ShopPath') . "/templates/CongoWorld/images/ProductDefault.gif";
     }
     $GLOBALS['ImageUrl'] = $imageurl;
     /* Baskaran ends */
     $GLOBALS['ProductId'] = (int) $GLOBALS['ISC_CLASS_PRODUCT']->_prodid;
     $GLOBALS['ImagePage'] = sprintf("%s/productimage.php", $GLOBALS['ShopPath']);
     $GLOBALS['ProductNumReviews'] = (int) $GLOBALS['ISC_CLASS_PRODUCT']->GetNumReviews();
     // Does this product have any bulk discount?
     if ($GLOBALS['ISC_CLASS_PRODUCT']->CanUseBulkDiscounts()) {
         $GLOBALS['HideBulkDiscountLink'] = '';
         $GLOBALS['BulkDiscountThickBoxTitle'] = sprintf(GetLang('BulkDiscountThickBoxTitle'), isc_html_escape($GLOBALS['ISC_CLASS_PRODUCT']->GetProductName()));
         require_once ISC_BASE_PATH . '/includes/display/SideProductAddToCart.php';
         $GLOBALS['BulkDiscountThickBoxRates'] = ISC_SIDEPRODUCTADDTOCART_PANEL::GetProductBulkDiscounts();
         $GLOBALS['ProductBulkDiscountThickBox'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductBulkDiscountThickBox");
     } else {
         $GLOBALS['HideBulkDiscountLink'] = 'none';
     }
     if (GetConfig('ShowInventory') == 1 && $GLOBALS['ISC_CLASS_PRODUCT']->GetProductInventoryTracking() > 0) {
         $GLOBALS['InventoryList'] = '';
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetProductInventoryTracking() == 2) {
             $variations = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVariations();
             if (empty($options)) {
                 $GLOBALS['HideCurrentStock'] = "display: none;";
             }
         } else {
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetProductInventoryTracking() == 1) {
                 $currentStock = $GLOBALS['ISC_CLASS_PRODUCT']->GetInventoryLevel();
                 if ($currentStock <= 0) {
                     $GLOBALS['InventoryList'] = GetLang('SoldOut');
                 } else {
                     $GLOBALS['InventoryList'] = $currentStock;
                 }
             }
         }
     } else {
         $GLOBALS['HideCurrentStock'] = "display: none;";
     }
     /* Added for to display the "Make an offer" Button -- Baskaran */
     # Checked for the selected series offer is 'yes'
     $GLOBALS['HideOfferButton'] = 'none';
     if (GetConfig('ShowBestOffer') == '1') {
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetSeriesOffer() == 'yes') {
             $GLOBALS['HideOfferButton'] = '';
         } else {
             # Checking for the selected sub category offer is 'yes'
             if ($GLOBALS['ISC_CLASS_PRODUCT']->GetCategoryOffer() == 'yes') {
                 $GLOBALS['HideOfferButton'] = '';
             } else {
                 # Checking brand offer is 'yes' and corresponding series offer are 'no'
                 if ($GLOBALS['ISC_CLASS_PRODUCT']->GetBrandOffer() == 'yes' and $GLOBALS['ISC_CLASS_PRODUCT']->GetSeriesCntOffer() == 0) {
                     $GLOBALS['HideOfferButton'] = '';
                 } else {
                     # Checking for Root category offer is 'yes' and corresponding sub category offer are 'no'
                     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetRootCategoryOffer() == 'yes' and $GLOBALS['ISC_CLASS_PRODUCT']->GetSubCategoryCntOffer() == 0) {
                         $GLOBALS['HideOfferButton'] = '';
                     } else {
                         $GLOBALS['HideOfferButton'] = 'none';
                     }
                 }
             }
         }
     }
     //Check for item in Cart Session
     $CartItems = $_SESSION['CART']['ITEMS'];
     $compids = array();
     $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId();
     //print_r($CartItems);
     foreach ($CartItems as $key => $item) {
         if ($item['product_id'] == $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()) {
             if ($item['compitem'] == 1) {
                 foreach ($item['complementary'] as $citem) {
                     $compids[$citem['comp_productid']] = $citem['quantity'];
                 }
             }
             break;
         }
     }
     //Check for item in Cart Session Ends
     # Complementary items -- Baskaran
     $productid = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId();
     $make = '';
     $model = '';
     $year = '';
     if ($GLOBALS['EnableSEOUrls'] == 0) {
         if (isset($_REQUEST['make']) && $_REQUEST['make'] != '') {
             $make = MakeURLNormal($_REQUEST['make']);
         }
         if (isset($_REQUEST['model']) && $_REQUEST['model'] != '') {
             $model = MakeURLNormal($_REQUEST['model']);
         }
         if (isset($_REQUEST['year']) && $_REQUEST['year'] != '') {
             $year = $_REQUEST['year'];
         }
     } else {
         if (count($GLOBALS['PathInfo']) > 0) {
             foreach ($GLOBALS['PathInfo'] as $key => $value) {
                 if (eregi('make=', $value)) {
                     $make = MakeURLNormal(substr($value, strpos($value, '=') + 1));
                 } else {
                     if (eregi('model=', $value)) {
                         $model = MakeURLNormal(substr($value, strpos($value, '=') + 1));
                     } else {
                         if (eregi('year=', $value)) {
                             $year = substr($value, strpos($value, '=') + 1);
                         }
                     }
                 }
             }
         }
     }
     $where = '';
     if ($make != '') {
         $where .= "and (prodmake = '" . $make . "' or prodmake = 'NON-SPEC VEHICLE')";
     }
     if ($model != '') {
         $where .= " and (prodmodel = '" . $model . "' or prodmodel = 'ALL')";
     }
     if ($year != '') {
         $where .= " and (({$year} between prodstartyear and prodendyear) or (prodstartyear = 'ALL'and prodendyear = 'ALL'))";
     }
     $result = $GLOBALS["ISC_CLASS_DB"]->Query("SELECT id,productid FROM [|PREFIX|]import_variations where productid = '" . $productid . "' {$where} order by id");
     $impvariationid = '';
     while ($improw = $GLOBALS["ISC_CLASS_DB"]->Fetch($result)) {
         $impvariationid[] = $improw['id'];
     }
     $impid = implode("','", $impvariationid);
     $impquery = $GLOBALS["ISC_CLASS_DB"]->Query("SELECT complementaryitems FROM [|PREFIX|]application_data where variationid in('" . $impid . "') AND complementaryitems != ''");
     if ($GLOBALS["ISC_CLASS_DB"]->countResult($impquery) > 0) {
         $compitems = '';
         while ($joinrecord = $GLOBALS["ISC_CLASS_DB"]->Fetch($impquery)) {
             $compitems .= $joinrecord['complementaryitems'] . ",";
         }
         $comp = substr($compitems, 0, -1);
         if ($comp != '') {
             # Spliting the string with [ ] with regular expression -- Baskaran
             $temp = $comp;
             $temp = htmlspecialchars_decode($temp);
             preg_match_all('/\\[([^\\]]+)\\]/', $temp, $matches);
             $compexplode = $matches[1];
             $cntproducts = count($compexplode);
             /*$arraycnt = array_count_values($compexplode);    
               asort($arraycnt);
               $compunique = array_keys($arraycnt);
               rsort($compunique);
               $cntproducts = count($compunique);*/
             $originalarray = array();
             $tempArr = array();
             $tempArr1 = array();
             # Checking whether the SKU are valid and present in the db -- Baskaran
             for ($i = 0; $i < $cntproducts; $i++) {
                 $split = split(",", $compexplode[$i]);
                 $sku = $GLOBALS["ISC_CLASS_DB"]->Query("SELECT productid, prodname, prodcode, proddescfeature, imagefile, brandname, catname FROM [|PREFIX|]brands b, [|PREFIX|]categories c, [|PREFIX|]products p LEFT JOIN [|PREFIX|]product_images i ON p.productid = i.imageprodid AND i.imageisthumb = '1' WHERE prodcode = '" . $split[0] . "' AND p.prodbrandid = b.brandid AND p.prodcatids = c.categoryid AND p.prodvisible = '1'");
                 if ($GLOBALS["ISC_CLASS_DB"]->countResult($sku) == 1 and $split[0] != 0) {
                     if (in_array($split[0], $tempArr)) {
                         continue;
                     }
                     $originalarray[] = $split[0] . "," . $split[1] . "," . $split[2];
                     $tempArr[] = $split[0];
                 } else {
                     if ($GLOBALS["ISC_CLASS_DB"]->countResult($sku) != 1 and $split[0] == 0) {
                         if (in_array($split[0], $tempArr1)) {
                             continue;
                         }
                         $originalarray[] = $split[0] . "," . $split[1] . "," . $split[2];
                         $tempArr1[] = $split[0];
                     }
                 }
             }
             $cntoriginal = count($originalarray);
             # Ordering the resultent array which is come from above one with the no thanks option '0' is the key to create the array -- Baskaran
             $arrManipulate = array();
             $nothanks = array();
             for ($i = 0; $i < $cntoriginal; $i++) {
                 $orsplit = split(",", $originalarray[$i]);
                 if ($i == 0 and $orsplit[0] == 0) {
                     $arrManipulate[] = $orsplit[0] . "," . $orsplit[1] . "," . $orsplit[2];
                 } else {
                     if ($i != 0 and $orsplit[0] == 0) {
                         $nothanks[] = $orsplit[0] . "," . $orsplit[1] . "," . $orsplit[2];
                     } else {
                         $arrManipulate[] = $orsplit[0] . "," . $orsplit[1] . "," . $orsplit[2];
                     }
                 }
             }
             if (count($nothanks) > 0) {
                 $arrOrder = array_merge($arrManipulate, $nothanks);
             } else {
                 $arrOrder = $arrManipulate;
             }
             $cntarrOrder = count($arrOrder);
             if ($cntarrOrder > 0) {
                 $complementary = "<table cellspacing='2' cellpadding='0' border='0' width='100%'>";
                 for ($i = 0; $i < $cntarrOrder; $i++) {
                     $split = split(",", $arrOrder[$i]);
                     $sku = $GLOBALS["ISC_CLASS_DB"]->Query("SELECT productid, prodname, prodcode, proddescfeature, imagefile, brandname, catname FROM [|PREFIX|]brands b, [|PREFIX|]categories c, [|PREFIX|]products p LEFT JOIN [|PREFIX|]product_images i ON p.productid = i.imageprodid AND i.imageisthumb = '1' WHERE prodcode = '" . $split[0] . "' AND p.prodbrandid = b.brandid AND p.prodcatids = c.categoryid AND p.prodvisible = '1'");
                     $skurow = $GLOBALS["ISC_CLASS_DB"]->Fetch($sku);
                     $brandname = $skurow['brandname'];
                     $catname = $skurow['catname'];
                     $skucode = $skurow['prodcode'];
                     $productid = $split[0] != 0 ? $skurow['productid'] : '0';
                     # $split[0] is sku code, $split[1] is comp. price
                     $path = $skurow['imagefile'];
                     $feature = $skurow['proddescfeature'];
                     $prodimage = '';
                     if ($skurow['imagefile'] != '') {
                         $prodimage = GetConfig('ShopPath') . "/product_images/{$path}";
                     } else {
                         $prodimage = GetConfig('ShopPath') . "/templates/CongoWorld/images/ProductDefault.gif";
                     }
                     $compdesc = html_entity_decode($split[2]);
                     $compprice = "<b>Price :" . CurrencyConvertFormatPrice($split[1]) . "</b>";
                     $price = CurrencyConvertFormatPrice($split[1]);
                     $feature = addslashes($feature);
                     $esc = htmlentities($feature, ENT_QUOTES);
                     $pricefeature = $esc . isc_html_escape($compprice);
                     $pricefeature = $esc . isc_html_escape($compprice);
                     if (isset($compids[$productid])) {
                         $sel = $compids[$productid];
                         $styleval = "style='display: block;'";
                         $checked = "checked = 'checked'";
                     } else {
                         $sel = 0;
                         $styleval = "style='display: none;'";
                         $checked = "";
                     }
                     if ($i == 0 and $productid != 0) {
                         if (count($compids) == 0) {
                             $styleval = "style='display: block;'";
                             $checked = " checked = 'checked' ";
                         }
                         $complementary .= '<input type="hidden" name="hidmake" value="' . $make . '" id="hidmake" />';
                         $complementary .= '<input type="hidden" name="hidmodel" value="' . $model . '" id="hidmodel" />';
                         $complementary .= '<input type="hidden" name="hidyear" value="' . $year . '" id="hidyear" />';
                         $complementary .= "<tr><td><input type='checkbox' name='rdprod[]' id='rdprod_" . $i . "' value='" . $productid . "' {$checked} onclick='ActiveProductTab(\"CompItem_Tab\");ShowCompDesc(\"{$skucode}\",this.id);unCheck()'>" . "<label id='complabel' for='rdprod_" . $i . "' onmouseover= 'loadHoverImage(event, \"{$prodimage}\", \"{$pricefeature}\");' onmouseout = 'hideTip();'>&nbsp;<a href='#Compl'>{$catname} {$brandname} {$skucode}</a></label>" . "{$compdesc}" . "</td>\n                            <td><div {$styleval} id='compqty_" . $productid . "'>" . $this->BuildOption('compqty[' . $productid . ']', $sel) . "</div></td><td><div id='pr_" . $productid . "' {$styleval}><b>{$price}<b></div></td>\n                                </tr>";
                     } else {
                         if ($i == 0 and $productid == 0) {
                             if (count($compids) == 0) {
                                 $checked = " checked = 'checked' ";
                             }
                             $complementary .= '<input type="hidden" name="hidmake" value="' . $make . '" id="hidmake" />';
                             $complementary .= '<input type="hidden" name="hidmodel" value="' . $model . '" id="hidmodel" />';
                             $complementary .= '<input type="hidden" name="hidyear" value="' . $year . '" id="hidyear" />';
                             //						$complementary .= "<tr><td><input type='checkbox' name='rdprod[]' id='rdprod_".$i."' value='".$productid."' checked = 'checked'>"."<label for='rdprod_".$i."'>&nbsp;$split[2]</label>"."</td></tr>";
                             $complementary .= "<tr><td><input type='checkbox' name='nothanks' id='nothanks' value='{$productid}' {$checked} onclick='Check()'>" . "<label for='nothanks'>&nbsp;{$split['2']}</label><input type = 'hidden' name = 'isremovable' value = '1' />" . "</td></tr>";
                         } else {
                             if ($i != 0 and $productid != 0) {
                                 $complementary .= "<tr><td><input type='checkbox' name='rdprod[]' id='rdprod_" . $i . "' value='" . $productid . "' {$checked} onclick='ActiveProductTab(\"CompItem_Tab\");ShowCompDesc(\"{$skucode}\",this.id);unCheck()'>" . "<label id='complabel' for='rdprod_" . $i . "' onmouseover= 'loadHoverImage(event, \"{$prodimage}\", \"{$pricefeature}\");' onmouseout = 'hideTip();'>&nbsp;<a href='#Compl'>{$catname} {$brandname} {$skucode}</a></label>" . "{$compdesc}" . "</td>\n                            <td><div {$styleval} id='compqty_" . $productid . "'>" . $this->BuildOption('compqty[' . $productid . ']', $sel) . "</div></td><td><div id='pr_" . $productid . "' {$styleval}><b>{$price}</b></div></td>\n                                </tr>";
                             } else {
                                 if ($i != 0 and $productid == 0) {
                                     $complementary .= "<tr><td><input type='checkbox' name='nothanks' id='nothanks' value='{$productid}' onclick='Check()'>" . "<label for='nothanks'>&nbsp;{$split['2']}</label><input type = 'hidden' name = 'isremovable' value = '1' />" . "</td></tr>";
                                 }
                             }
                         }
                     }
                     $complementary .= '<input type="hidden" name="hidRadio" value="' . $brandname . " " . $skucode . '" id="hid_rdprod_' . $i . '" />';
                 }
                 $complementary .= "</table>";
                 $GLOBALS['complementaryproducts'] = $complementary;
                 $GLOBALS['complementarypaneltoshow'] = "%%Panel.ComplementartyItems%%<hr />";
             }
         }
     }
     /* Code Ends */
     if (GetConfig('AddToCartButtonPosition') == 'middle' && $GLOBALS['ISC_CLASS_PRODUCT']->IsPurchasingAllowed()) {
         require_once ISC_BASE_PATH . '/includes/display/SideProductAddToCart.php';
         ISC_SIDEPRODUCTADDTOCART_PANEL::LoadAddToCartOptions('middle');
         //blessen
         if ($GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice() > $GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice()) {
             $GLOBALS['SNIPPETS']['ProductAddToCart'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductAddToCart1");
         } else {
             $GLOBALS['SNIPPETS']['ProductAddToCart'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductAddToCart");
         }
         //Added by Simha
         if (isc_strtolower($GLOBALS['ISC_CLASS_PRODUCT']->IsTestData()) == 'yes') {
             $GLOBALS['SNIPPETS']['ProductAddToCart'] = "<hr>" . GetLang('ThisIsTestData');
         }
         //blessen
         // original $GLOBALS['SNIPPETS']['ProductAddToCart'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductAddToCart");
     }
     $price_for_shipping = $GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice();
     //blessen
     //$GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice() replaced by GetPrice
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice() > $GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice() && (double) $GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice() > 0) {
         $price_for_shipping = $GLOBALS['ISC_CLASS_PRODUCT']->GetRetailPrice();
         $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice());
         $GLOBALS['ProductPrice'] = "<strike>" . $GLOBALS['ProductPrice'] . "</strike>&nbsp;&nbsp;<b alt='Price may be adjusted. Add to your cart and see the final price.'  Title='Price may be adjusted. Add to your cart and see the final price.'>(" . GetLang('CheckPriceInCart') . ")</b>";
     }
     if ($GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice() > $DiscountPrice && $discounttype == 1) {
         $price_for_shipping = $DiscountPrice;
         $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($GLOBALS['ISC_CLASS_PRODUCT']->GetFinalPrice());
         $GLOBALS['ProductPrice'] = "<strike>" . $GLOBALS['ProductPrice'] . "</strike>&nbsp;&nbsp;<b alt='Price may be adjusted. Add to your cart and see the final price.'  Title='Price may be adjusted. Add to your cart and see the final price.'>(" . GetLang('CheckPriceInCart') . ")</b>";
     }
     $GLOBALS['ShowOnSaleImage'] = '';
     if (isset($DiscountPrice) && $discounttype == 0 && $DiscountPrice < $FinalPrice) {
         //&& GetConfig('ShowOnSale')
         $price_for_shipping = $DiscountPrice;
         $GLOBALS['ProductPrice'] = "<strike>" . CurrencyConvertFormatPrice($FinalPrice) . "</strike>";
         $GLOBALS['DiscountPrice'] = "" . CurrencyConvertFormatPrice($DiscountPrice) . "";
         if (GetConfig('ShowOnSale')) {
             $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
         }
     }
     $price = 0;
     $upper_price = 0;
     $shipping_qry = "SELECT variablename, variableval FROM isc_shipping_vars WHERE methodid='1' AND modulename='shipping_bytotal' AND ( variablename LIKE 'cost_0' OR variablename LIKE 'lower_0' OR variablename LIKE 'upper_0' )";
     $shipping_res = $GLOBALS['ISC_CLASS_DB']->Query($shipping_qry);
     while ($shipping_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($shipping_res)) {
         if ($shipping_arr['variablename'] == 'cost_0') {
             $price = $shipping_arr['variableval'];
         }
         if ($shipping_arr['variablename'] == 'upper_0') {
             $upper_price = $shipping_arr['variableval'];
         }
     }
     if ($price_for_shipping < $upper_price) {
         $GLOBALS['ShippingPrice'] = "\$" . $price;
     } else {
         $GLOBALS['ShippingPrice'] = "Ships Freight Free, see <a href='" . $GLOBALS['ShopPath'] . "/pages/8'>policy</a> for details";
     }
     //blessen
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle($GLOBALS['ISC_CLASS_PRODUCT']->BuildTitle());
 }
 /**
  * Show the modal dialogue to choose the gift wrapping for an item in an order.
  */
 private function OrderSelectGiftWrap()
 {
     if (!isset($_REQUEST['itemId']) || !isset($_REQUEST['orderSession'])) {
         exit;
     }
     $orderClass = GetClass('ISC_ADMIN_ORDERS');
     $cartProduct = $orderClass->GetCartApi($_REQUEST['orderSession'])->GetProductInCart($_REQUEST['itemId'], true);
     if (!is_array($cartProduct)) {
         exit;
     }
     $GLOBALS['GiftWrappingTitle'] = sprintf(GetLang('GiftWrappingForX'), isc_html_escape($cartProduct['product_name']));
     $GLOBALS['ProductName'] = $cartProduct['product_name'];
     $GLOBALS['ItemId'] = $_REQUEST['itemId'];
     $wrapOptions = "";
     if (isset($cartProduct['data']['prodwrapoptions'])) {
         $wrapOptions = $cartProduct['data']['prodwrapoptions'];
     }
     if ($cartProduct["product_id"]) {
         // if the product does exist still, get the actual set of wrap options
         $query = "SELECT prodwrapoptions FROM [|PREFIX|]products WHERE productid = " . $cartProduct["product_id"];
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         if ($wo = $GLOBALS['ISC_CLASS_DB']->FetchOne($result, 'prodwrapoptions')) {
             $wrapOptions = $wo;
         }
     }
     // Get the available gift wrapping options for this product
     if ($cartProduct['data']['prodwrapoptions'] == 0) {
         $giftWrapWhere = "wrapvisible='1'";
     } else {
         if ($cartProduct['data']['prodwrapoptions'] == -1) {
             exit;
         } else {
             $wrapOptions = implode(',', array_map('intval', explode(',', $wrapOptions)));
             $giftWrapWhere = "wrapid IN (" . $wrapOptions . ")";
         }
     }
     $query = "\n\t\t\t\tSELECT *\n\t\t\t\tFROM [|PREFIX|]gift_wrapping\n\t\t\t\tWHERE " . $giftWrapWhere . "\n\t\t\t\tORDER BY wrapname ASC\n\t\t\t";
     $wrappingOptions = array();
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($wrap = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $wrappingOptions[$wrap['wrapid']] = $wrap;
     }
     // This product is already wrapped, select the existing value
     $selectedWrapping = 0;
     $GLOBALS['GiftWrapMessage'] = '';
     if (isset($cartProduct['wrapping'])) {
         $selectedWrapping = $cartProduct['wrapping']['wrapid'];
     }
     if (isset($cartProduct['wrapping']['wrapmessage'])) {
         $GLOBALS['GiftWrapMessage'] = isc_html_escape($cartProduct['wrapping']['wrapmessage']);
     }
     $GLOBALS['HideGiftWrapMessage'] = 'display: none';
     // Build the list of wrapping options
     $GLOBALS['WrappingOptions'] = '';
     $GLOBALS['GiftWrapPreviewLinks'] = '';
     foreach ($wrappingOptions as $option) {
         $sel = '';
         if ($selectedWrapping == $option['wrapid']) {
             $sel = 'selected="selected"';
             if ($option['wrapallowcomments']) {
                 $GLOBALS['HideGiftWrapMessage'] = '';
             }
         }
         $classAdd = '';
         if ($option['wrapallowcomments']) {
             $classAdd = 'AllowComments';
         }
         if ($option['wrappreview']) {
             $classAdd .= ' HasPreview';
             $previewLink = GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $option['wrappreview'];
             if ($sel) {
                 $display = '';
             } else {
                 $display = 'display: none';
             }
             $GLOBALS['GiftWrapPreviewLinks'] .= '<a id="GiftWrappingPreviewLink' . $option['wrapid'] . '" class="GiftWrappingPreviewLinks" target="_blank" href="' . $previewLink . '" style="' . $display . '">' . GetLang('Preview') . '</a>';
         }
         $GLOBALS['WrappingOptions'] .= '<option class="' . $classAdd . '" value="' . $option['wrapid'] . '" ' . $sel . '>' . isc_html_escape($option['wrapname']) . ' (' . CurrencyConvertFormatPrice($option['wrapprice']) . ')</option>';
     }
     if ($cartProduct['quantity'] > 1) {
         $GLOBALS['ExtraClass'] = 'PL40';
         $GLOBALS['GiftWrapModalClass'] = 'SelectGiftWrapMultiple';
         $GLOBALS['GiftWrappingOptions'] = '';
         for ($i = 1; $i <= $cartProduct['quantity']; ++$i) {
             $GLOBALS['GiftWrappingId'] = $i;
             $GLOBALS['GiftWrappingOptions'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderGiftWrappingOptions');
         }
     } else {
         $GLOBALS['HideSplitWrappingOptions'] = 'display: none';
     }
     $GLOBALS['HideWrappingTitle'] = 'display: none';
     $GLOBALS['HideWrappingSeparator'] = 'display: none';
     $GLOBALS['GiftWrappingId'] = 'all';
     $GLOBALS['GiftWrappingOptionsSingle'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderGiftWrappingOptions');
     echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderSelectGiftWrapping');
     exit;
 }
	/**
	 * Generates the HTML for a gift certificate using this theme.
	 *
	 * @param array gift certificate placeholder data
	 *
	 * @return string the generated gift certificate html
	 */
	public function generateGiftCertificateHTML($certificate)
	{
		$template = TEMPLATE::getInstance();

		if(!isset($GLOBALS['ShopPathNormal'])) {
			$GLOBALS['ShopPathNormal'] = $GLOBALS['ShopPath'];
		}

		// Fetch the store logo or store title
		if(GetConfig('UseAlternateTitle')) {
			$text = GetConfig('AlternateTitle');
		}
		else {
			$text = GetConfig('StoreName');
		}
		$text = explode(" ", $text, 2);
		$text[0] = "<span class=\"Logo1stWord\">".$text[0]."</span>";
		$GLOBALS['LogoText'] = implode(" ", $text);
		$GLOBALS['HeaderLogo'] = $template->GetSnippet("LogoText");

		// Set gift certificate details
		$GLOBALS['CharacterSet']=GetConfig('CharacterSet');
		$GLOBALS['GiftCertificateTo'] = isc_html_escape($certificate['giftcertto']);
		$GLOBALS['GiftCertificateToEmail'] = isc_html_escape($certificate['giftcerttoemail']);
		$GLOBALS['GiftCertificateFrom'] = isc_html_escape($certificate['giftcertfrom']);
		$GLOBALS['GiftCertificateFromEmail'] = isc_html_escape($certificate['giftcertfromemail']);
		$GLOBALS['GiftCertificateAmount'] = CurrencyConvertFormatPrice($certificate['giftcertamount']);
		$GLOBALS['GiftCertificateMessage'] = isc_html_escape($certificate['giftcertmessage']);
		$GLOBALS['GiftCertificateCode'] = isc_html_escape($certificate['giftcertcode']);
		if(isset($certificate['giftcertexpirydate']) && $certificate['giftcertexpirydate'] != 0) {
			$GLOBALS['GiftCertificateExpiryInfo'] = sprintf(GetLang('GiftCertificateExpiresOn'), CDate($certificate['giftcertexpirydate']));
		}
		else {
			$GLOBALS['GiftCertificateExpiryInfo'] = '';
		}

		// Build the html
		$html = $template->ParseTemplate(true, $this->getTemplateContents());

		return $html;
	}
Example #24
0
 function ShowProductList($mmy_links, $params, $catg_desc_arr, $ext_links, $vq_column_title)
 {
     // dada.wang 2012-04-13 for display script
     $GLOBALS['DisplayScript'] = '';
     $displayScript = array();
     $filter_var = array('vq', 'pq');
     $path = GetConfig('ShopPath');
     $GLOBALS['AlternateClass'] = '';
     $counter = 1;
     $CurCatId = 0;
     $map_names = array();
     $display_names = array();
     $qimg_arr = array();
     $qcmt_arr = array();
     $qimg_par_arr = array();
     $qcmt_par_arr = array();
     //$GLOBALS['SearchResults'] is an array for product data.
     //while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['SearchResults'])) {
     foreach ($GLOBALS["SearProductsInfos"] as $row) {
         /* Added by Simha to check inf prodcucts comes from different categories*/
         //if(empty($params['srch_category']) || !isset($params['srch_category']))
         //{
         if ($CurCatId != $row['categoryid']) {
             $CurCatId = $row['categoryid'];
             $filter_names = "SELECT DISTINCT qn.qid, qn.column_name, qn.display_names, qa.hoverimage as qimg, qa.comments as qcmt from\n                                                [|PREFIX|]qualifier_names qn\n                                                LEFT JOIN [|PREFIX|]qualifier_associations qa ON qa.qualifierid = qn.qid\n                                                WHERE (qa.categoryid = '{$CurCatId}') \n                                                AND qn.column_name regexp '^(pq|vq)'";
             // || qa.categoryid IN (SELECT catparentid FROM isc_categories WHERE categoryid = '$CurCatId')
             $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
             while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
                 $map_names[$filter_row['qid']] = $filter_row['column_name'];
                 $display_names[$filter_row['qid']] = $filter_row['display_names'];
             }
             $this->GetAssocDetails($CurCatId, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
             $new_filter = "SELECT qualifierid as qid, hoverimage as qimg, comments as qcmt \n\t\t\t\t\tFROM [|PREFIX|]qualifier_associations \n\t\t\t\t\tWHERE categoryid = '{$CurCatId}'";
             $new_result = $GLOBALS['ISC_CLASS_DB']->Query($new_filter);
             while ($new_row = $GLOBALS['ISC_CLASS_DB']->Fetch($new_result)) {
                 $qimg_arr[$new_row['qid']] = $new_row['qimg'];
                 $qcmt_arr[$new_row['qid']] = $new_row['qcmt'];
             }
             $prt_filter = "SELECT c.catparentid as cpc, qa.qualifierid as qid, qa.hoverimage as qimg, qa.comments as qcmt \n\t\t\t\t\tFROM [|PREFIX|]categories as c\n\t\t\t\t\tLEFT JOIN [|PREFIX|]qualifier_associations as qa ON c.catparentid = qa.categoryid\n\t\t\t\t\tWHERE c.categoryid = '{$CurCatId}'";
             $par_result = $GLOBALS['ISC_CLASS_DB']->Query($prt_filter);
             while ($prt_row = $GLOBALS['ISC_CLASS_DB']->Fetch($par_result)) {
                 $qimg_par_arr[$prt_row['qid']] = $prt_row['qimg'];
                 $qcmt_par_arr[$prt_row['qid']] = $prt_row['qcmt'];
             }
         }
         //}
         /* Added by Simha Ends */
         $GLOBALS['SearchTrackClass'] = "TrackLink";
         $imagefile = "";
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $qry_string = $this->GetQueryString($params);
         if ($GLOBALS['results_page_flag'] == 0 && !isset($params['srch_category'])) {
             break;
         }
         //wirror_mark_condition1
         /*if( isset($params['srch_category']) )  {
         	 $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : ''; // description will be added here to show it at the top of product listing page.
         	 }*/
         if (isset($params['category']) || !isset($params['subcategory']) && isset($params['series'])) {
             $GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
             //$GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
             $GLOBALS['CatgBrandSeriesFooter'] = "";
             if ((isset($params['category']) || isset($params['subcategory'])) && $GLOBALS['CatgDescandBrandImage'] == "") {
                 $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                 //$GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                 $GLOBALS['CatgBrandSeriesFooter'] = "";
             }
         } else {
             if (isset($params['srch_category'])) {
                 $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                 $GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                 if (isset($params['series']) && $row['seriesdescription'] != "") {
                     $GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
                     //$GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
                     $GLOBALS['CatgBrandSeriesFooter'] = "";
                 }
                 if ($GLOBALS['CatgDescandBrandImage'] == '' && $GLOBALS['CatgBrandSeriesFooter'] == '' && isset($params['brand'])) {
                     $GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                     //$GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                     $GLOBALS['CatgBrandSeriesFooter'] = "";
                 }
             } else {
                 if (isset($params['brand'])) {
                     $GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                     $GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                 }
             }
         }
         /* No need to show footer description when YMM are selected */
         if (isset($params['make']) || isset($params['model']) || isset($params['year'])) {
             $GLOBALS['CatgBrandSeriesFooter'] = "";
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         if ($counter % 2 == 0) {
             $GLOBALS['RowColor'] = 'grayrow';
         } else {
             $GLOBALS['RowColor'] = 'whiterow';
         }
         $counter++;
         $GLOBALS['ProductId'] = (int) $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         //alandy_2012-2-20 modify product url = vendorprefix_sku
         //$GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         $prodcode = encode_sku($row['prodcode']);
         $GLOBALS['ProductLink'] = ProdLinkSKU($row['prodvendorprefix'], $prodcode);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         //$GLOBALS['BrandName'] = $row['brandname'];
         /* -- The below code is added to display the brand and series logo -- */
         $GLOBALS['BrandName'] = "";
         $brandlogo = realpath(ISC_BASE_PATH . '/product_images/' . $row['brandimagefile']);
         if ($row['brandimagefile'] != '' && file_exists($brandlogo)) {
             $GLOBALS['BrandName'] .= "<img src=\"" . $GLOBALS['ShopPath'] . "/product_images/" . $row['brandimagefile'] . "\" class=\"BrandSeriesLogo\" />";
         } else {
             $GLOBALS['BrandName'] .= $row['brandname'];
         }
         $serieslogo = realpath(ISC_BASE_PATH . '/series_images/' . $row['serieslogoimage']);
         if ($row['serieslogoimage'] != '' && file_exists($serieslogo)) {
             $GLOBALS['BrandName'] .= "<br><img src=\"" . $GLOBALS['ShopPath'] . "/series_images/" . $row['serieslogoimage'] . "\" />";
         } else {
             $GLOBALS['BrandName'] .= "<br>" . $row['seriesname'];
         }
         /* --- ends --- */
         $GLOBALS['ProdCode'] = $row['prodcode'];
         //$GLOBALS['ProdDesc'] = $this->strip_html_tags($row['proddesc']);
         $GLOBALS['icon_file'] = '';
         if (isset($row['icon_file'])) {
             if (stripos($row['icon_file'], 'http://') >= 0) {
                 $GLOBALS['icon_file'] = "<img src='" . $row['icon_file'] . "' border=0 class='icon_image_class' width='125' />";
             } else {
                 $GLOBALS['icon_file'] = "<img src='" . $GLOBALS["SHOP_PATH"] . "/" . $row['icon_file'] . "' border=0 class='icon_image_class' width='125'/>";
             }
         }
         //$GLOBALS['ProductId']
         //$GLOBALS['ProdOptions'] = $row['productoption'];
         $GLOBALS['VehicleOptions'] = "";
         $GLOBALS['ProdOptions'] = "";
         foreach ($row as $key => $val) {
             if ($val != "" && $val != "~") {
                 if (($qualifier_id = array_search($key, $map_names)) !== false) {
                     if (eregi('^vq', $key)) {
                         $val = trim($val, "~");
                         $val = preg_split('/[~;]+/', $val);
                         $val = array_unique($val);
                         $val = array_values($val);
                         $val = implode(",", $val);
                         /* -- Setting display name for qualifier name -- */
                         if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                             $key = $OwnAssoc[$qualifier_id][0]['qname'];
                         } else {
                             if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                 $key = $ParentAssoc[$qualifier_id][0]['qname'];
                             } else {
                                 if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                     $key = $display_names[$qualifier_id];
                                 } else {
                                     $key = ucfirst(str_ireplace($filter_var, "", $key));
                                 }
                             }
                         }
                         /* -- Setting display name for qualifier name ends -- */
                         /* -- Setting display name for qualifier value -- */
                         if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != "") {
                             $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                         } else {
                             if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentAssoc[$qualifier_id][$m]['vname'] != "") {
                                 $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                             }
                         }
                         /* -- Setting display name for qualifier value ends-- */
                         $qimg = $qimg_arr[$qualifier_id];
                         $qcmt = $qcmt_arr[$qualifier_id];
                         if ($qimg == '' && $qcmt == '') {
                             $qimg = $qimg_par_arr[$qualifier_id];
                             $qcmt = $qcmt_par_arr[$qualifier_id];
                         }
                         $qcmt = nl2br($qcmt);
                         $qcmt = str_replace("\n", "", $qcmt);
                         $qcmt = str_replace("\r", "", $qcmt);
                         $qcmt = str_replace('"', "&quot;", $qcmt);
                         $qcmt = str_replace("'", "\\'", $qcmt);
                         $helpdiv = "<img id='" . $qualifier_id . "' onmouseover=\"showPqVqHelp(this,255, '" . $qimg . "', '" . $qcmt . "');\" onmouseout=\"hidePqVqHelp('" . $qualifier_id . "');\" src='/images/pqvq_help.gif'/></img> ";
                         if ($qimg != '' && $qcmt != '') {
                             $GLOBALS['VehicleOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $helpdiv . $val . "</div>";
                         } else {
                             //$GLOBALS['VehicleOptions'] .= "<b>".$key."</b> : ".$val."<br>";
                             $GLOBALS['VehicleOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $val . "</div>";
                         }
                     }
                     if (eregi('^pq', $key)) {
                         $val = trim($val, "~");
                         $val = preg_split('/[~;]+/', $val);
                         $val = array_unique($val);
                         $val = array_values($val);
                         $val = implode(",", $val);
                         /* -- Setting display name for qualifier name -- */
                         if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                             $key = $OwnAssoc[$qualifier_id][0]['qname'];
                         } else {
                             if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                 $key = $ParentAssoc[$qualifier_id][0]['qname'];
                             } else {
                                 if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                     $key = $display_names[$qualifier_id];
                                 } else {
                                     $key = ucfirst(str_ireplace($filter_var, "", $key));
                                 }
                             }
                         }
                         /* -- Setting display name for qualifier name ends -- */
                         /* -- Setting display name for qualifier value -- */
                         if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != '') {
                             $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                         } else {
                             if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentValue[$qualifier_id][$m]['vname'] != '') {
                                 $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                             }
                         }
                         /* -- Setting display name for qualifier value ends-- */
                         $qimg = $qimg_arr[$qualifier_id];
                         $qcmt = $qcmt_arr[$qualifier_id];
                         if ($qimg == '' && $qcmt == '') {
                             $qimg = $qimg_par_arr[$qualifier_id];
                             $qcmt = $qcmt_par_arr[$qualifier_id];
                         }
                         $qcmt = nl2br($qcmt);
                         $qcmt = str_replace("\n", "", $qcmt);
                         $qcmt = str_replace("\r", "", $qcmt);
                         $qcmt = str_replace('"', "&quot;", $qcmt);
                         $qcmt = str_replace("'", "\\'", $qcmt);
                         $helpdiv = "<img id='" . $qualifier_id . "' onmouseover=\"showPqVqHelp(this,255, '" . $qimg . "', '" . $qcmt . "');\" onmouseout=\"hidePqVqHelp('" . $qualifier_id . "');\" src='/images/pqvq_help.gif'/></img> ";
                         if ($qimg != '' && $qcmt != '') {
                             $GLOBALS['ProdOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $helpdiv . $val . "</div>";
                         } else {
                             //$GLOBALS['ProdOptions'] .= "<b>".$key."</b> : ".$val."<br>";
                             $GLOBALS['ProdOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $val . "</div>";
                         }
                     }
                 }
             }
         }
         if (isset($row['vehicleoption'])) {
             $GLOBALS['VehicleOptions'] = $row['vehicleoption'];
         }
         if (isset($row['productoption'])) {
             $GLOBALS['ProdOptions'] = $row['productoption'];
         }
         if (isset($row['catuniversal']) && $row['catuniversal'] == 1) {
             $GLOBALS['VehicleOptions'] = $GLOBALS['ProductName'];
             if ($vq_column_title == "") {
                 $vq_column_title = "Product Name";
             } else {
                 if ($vq_column_title != "Product Name") {
                     $vq_column_title = "Product Name / Vehicle";
                 }
             }
         } else {
             if ($vq_column_title == "") {
                 $vq_column_title = "Vehicle Options";
             } else {
                 if ($vq_column_title != "Vehicle Options") {
                     $vq_column_title = "Product Name / Vehicle";
                 }
             }
         }
         if (empty($GLOBALS['ProdOptions']) && empty($GLOBALS['VehicleOptions'])) {
             $GLOBALS['ProdOptions'] = "&nbsp;";
         }
         if (empty($GLOBALS['VehicleOptions'])) {
             $GLOBALS['VehicleOptions'] = "&nbsp;";
         }
         /*--- the below lines are added for back 2 search link in the product detail page. Also modified line no 56 & 60 --- */
         if ($GLOBALS['EnableSEOUrls'] == 1) {
             //alandy-2012-1-12 modify.
             //$GLOBALS['ProductLink'] .= "/refer=true".$ext_links;
             if (isset($GLOBALS['SearchId'])) {
                 //$GLOBALS['ProductLink'] .= '/SearchLogId/'.$GLOBALS['SearchId'];
                 $_SESSION['SearchLogId'] = $GLOBALS['SearchId'];
             }
         } else {
             //alandy-2012-1-12 modify.
             //$GLOBALS['ProductLink'] .= "&refer=true".$ext_links;
             if (isset($GLOBALS['SearchId'])) {
                 //$GLOBALS['ProductLink'] .= '&SearchLogId='.$GLOBALS['SearchId'];
                 $_SESSION['SearchLogId'] = $GLOBALS['SearchId'];
             }
         }
         ### Added by Simha for onsale addition
         // Determine the price of this product
         //$GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
         $GLOBALS['ProductPrice'] = CalculateProductPriceRetail($row);
         $FinalPrice = $GLOBALS['ProductPrice'];
         $SalePrice = $row['prodsaleprice'];
         //$DiscountAmount = $FinalPrice;
         $discounttype = 0;
         $discountname = '';
         if ((double) $SalePrice > 0 && $SalePrice < $FinalPrice) {
             $DiscountPrice = $SalePrice;
         } else {
             $DiscountPrice = $FinalPrice;
             $DiscountPrice = CalculateDiscountPrice($FinalPrice, $DiscountPrice, $row['categoryid'], $row['brandseriesid'], $discounttype, $discountname);
             /*if($discounttype == 0)    {
             	 $DiscountPrice = $FinalPrice;
             	 }*/
         }
         /*
         foreach($DiscountInfo as $DiscountInfoSub)   {
         if(isset($DiscountInfoSub['catids']))    {
         $catids = explode(",", $DiscountInfoSub['catids']);
         foreach($catids as $catid) {
         if($catid == $row['categoryid']) {
         $DiscountAmount = $FinalPrice * ((int)$DiscountInfoSub['amount']/100);
         if ($DiscountAmount < 0) {
         $DiscountAmount = 0;
         }
         $DiscountPrice  = $FinalPrice - $DiscountAmount;
         }
         }
         }
         }
         */
         if (isset($DiscountPrice) && $DiscountPrice < $FinalPrice && $discounttype == 0) {
             //&& GetConfig('ShowOnSale')
             $GLOBALS['ProductPrice'] = '<strike>' . CurrencyConvertFormatPrice($FinalPrice) . '</strike>';
             $GLOBALS['ProductPrice'] .= '<br><div class="finalprice">' . CurrencyConvertFormatPrice($DiscountPrice) . '</div> ';
             if (strtolower($discountname) == "clearance") {
                 $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/clearance.gif" alt="">';
             } else {
                 $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
             }
             if (GetConfig('ShowOnSale')) {
                 $GLOBALS['ProductPrice'] .= '' . $GLOBALS['ShowOnSaleImage'] . '';
             }
         } else {
             $GLOBALS['ProductPrice'] = '<div class="finalprice">' . CurrencyConvertFormatPrice($FinalPrice) . '</div>';
         }
         ### Added by Simha Ends
         // commented the below line by vikas
         //$GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], $GLOBALS['ProductLink']);
         if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
             //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
             $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
             $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
         } else {
             //$GLOBALS['ProductURL'] = CartLink($row['productid']);
             //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
             $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
             //blessen
             if (intval($row['prodretailprice']) <= 0) {
                 //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); // commented by vikas on 15-7-09
                 $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
             } else {
                 //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); // commented by vikas on 15-7-09
                 $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
             }
             //blessen
             // original $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
         }
         if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
             $GLOBALS['HideActionAdd'] = '';
         } else {
             $GLOBALS['HideActionAdd'] = 'none';
         }
         $GLOBALS['HideProductVendorName'] = 'display: none';
         $GLOBALS['ProductVendor'] = '';
         if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
             $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
             if (isset($vendorCache[$row['prodvendorid']])) {
                 $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                 $GLOBALS['HideProductVendorName'] = '';
             }
         }
         $qpvq_search = $_SESSION['searchterms']['dynfilters'];
         if (empty($qpvq_search)) {
             $GLOBALS['pqvqSearch'] = 0;
         } else {
             $GLOBALS['pqvqSearch'] = 1;
         }
         //alandy_2011-6-15 modify. add prodallowpurchase check!
         //$GLOBALS['CartURL'] = CartLink($row['productid']);
         $GLOBALS['CartURL'] = NewCartLink($row['productid'], $row['prodallowpurchases']);
         //$GLOBALS['ClickCartButton']=ClickCartButton($row['prodallowpurchases'],$row['productid']);
         //alandy_2011-12-21 modify.continue to check product attribute.
         //if(empty($GLOBALS['ClickCartButton'])){
         //$GLOBALS['ClickCartButton'] = CheckProductAttribute($row['productid']);
         //}
         if (isset($GLOBALS['SearchId'])) {
             $GLOBALS['CartURL'] .= '&SearchLogId=' . $GLOBALS['SearchId'];
         }
         $offer = $this->IsProductMakeanOffer($row['brandseriesid'], $row['brandname'], $row['categoryid']);
         if ($offer == 'yes') {
             $GLOBALS['HideOfferButton'] = 'block';
             $GLOBALS['OfferButtonLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("OfferButtonLink");
             //zcs=
         } else {
             $GLOBALS['HideOfferButton'] = 'none';
             $GLOBALS['OfferButtonLink'] = '';
             //zcs=
         }
         // dada.wang 2012.04.12 call for best price
         $callForBestPrice = GetClass('ISC_PRODUCT_HELPER')->GetProductCallForBestPrice($row);
         $GLOBALS['BestPrice'] = '';
         if ($callForBestPrice) {
             $displayScript[] = $callForBestPrice['displayScript'];
             $GLOBALS['BestPrice'] = '<div data="' . htmlspecialchars($callForBestPrice['popupMessage']) . '" onmouseover="showcallbestprice(this,385);" onmouseout="hidecallbestprice(this)"><img src="/images/call-in-trans.gif"/></div>';
         }
         $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItem");
     }
     if (!empty($displayScript) && count(array_unique($displayScript)) == 1) {
         $GLOBALS['DisplayScript'] = $displayScript[0];
     }
 }
Example #25
0
/**
 *	Email the invoice from an order to a customer
 *
 * @param int The ID of the order to email the invoice for.
 * @param int The optional ID of the order status. Will default to the already stored status ID of the order
 */
function EmailInvoiceToCustomer($orderId, $newStatusId = null)
{
    // Load the details for this order
    $is_digital_download = true;
    $order_row = GetOrder($orderId, true);
    if ($order_row === false) {
        return fase;
    }
    // All prices in the emailed invoices will be shown in the default currency of the store
    $defaultCurrency = GetDefaultCurrency();
    $GLOBALS['OrderNumber'] = $orderId;
    if (isId($newStatusId)) {
        $order_status = $newStatusId;
    } else {
        $order_status = $order_row['ordstatus'];
    }
    $order_payment_module = $order_row['orderpaymentmodule'];
    if ($order_row['ordcustid'] > 0) {
        $GLOBALS['ViewOrderStatusMsg'] = GetLang('ASummaryIsShownBelow') . " <a href='" . $GLOBALS['ShopPath'] . "/orderstatus.php'>" . GetLang('ClickHere') . "</a>.";
    } else {
        $GLOBALS['ViewOrderStatusMsg'] = "";
    }
    $emailTemplate = FetchEmailTemplateParser();
    // Is there a shipping address, or is it a digital download?
    if ($order_row['ordshipfirstname'] == "") {
        $GLOBALS['ShippingAddress'] = GetLang('NA');
    } else {
        $GLOBALS['ShipFullName'] = isc_html_escape($order_row['ordshipfirstname'] . ' ' . $order_row['ordshiplastname']);
        $GLOBALS['ShipCompany'] = '';
        if ($order_row['ordshipcompany']) {
            $GLOBALS['ShipCompany'] = '<br />' . isc_html_escape($order_row['ordshipcompany']);
        }
        $GLOBALS['ShipAddressLine1'] = isc_html_escape($order_row['ordshipstreet1']);
        if ($order_row['ordshipstreet2'] != "") {
            $GLOBALS['ShipAddressLine2'] = isc_html_escape($order_row['ordshipstreet2']);
        } else {
            $GLOBALS['ShipAddressLine2'] = '';
        }
        $GLOBALS['ShipSuburb'] = isc_html_escape($order_row['ordshipsuburb']);
        $GLOBALS['ShipState'] = isc_html_escape($order_row['ordshipstate']);
        $GLOBALS['ShipZip'] = isc_html_escape($order_row['ordshipzip']);
        $GLOBALS['ShipCountry'] = isc_html_escape($order_row['ordshipcountry']);
        $GLOBALS['ShipPhone'] = "";
        $GLOBALS['ShippingAddress'] = $emailTemplate->GetSnippet("AddressLabel");
    }
    // Format the billing address
    $GLOBALS['ShipFullName'] = isc_html_escape($order_row['ordbillfirstname'] . ' ' . $order_row['ordbilllastname']);
    $GLOBALS['ShipCompany'] = '';
    if ($order_row['ordbillcompany']) {
        $GLOBALS['ShipCompany'] = '<br />' . isc_html_escape($order_row['ordbillcompany']);
    }
    $GLOBALS['ShipAddressLine1'] = isc_html_escape($order_row['ordbillstreet1']);
    if ($order_row['ordbillstreet2'] != "") {
        $GLOBALS['ShipAddressLine2'] = isc_html_escape($order_row['ordbillstreet2']);
    } else {
        $GLOBALS['ShipAddressLine2'] = '';
    }
    $GLOBALS['ShipSuburb'] = isc_html_escape($order_row['ordbillsuburb']);
    $GLOBALS['ShipState'] = isc_html_escape($order_row['ordbillstate']);
    $GLOBALS['ShipZip'] = isc_html_escape($order_row['ordbillzip']);
    $GLOBALS['ShipCountry'] = isc_html_escape($order_row['ordbillcountry']);
    $GLOBALS['ShipPhone'] = "";
    $GLOBALS['BillingAddress'] = $emailTemplate->GetSnippet("AddressLabel");
    // Format the shipping provider's details
    $ship_method = $order_row['ordshipmethod'];
    $ship_cost = $order_row['ordshipcost'];
    $GLOBALS['ItemTotal'] = FormatPrice($order_row['ordsubtotal'], false, true, false, $defaultCurrency, true);
    if ($order_row['ordshipcost'] > 0) {
        $GLOBALS['ShippingCost'] = FormatPrice($order_row['ordshipcost'], false, true, false, $defaultCurrency, true);
        $GLOBALS['SNIPPETS']['InvoiceEmailShippingTotal'] = $emailTemplate->GetSnippet('InvoiceEmailShippingTotal');
    }
    if ($order_row['ordhandlingcost'] > 0) {
        $GLOBALS['HandlingCost'] = FormatPrice($order_row['ordhandlingcost'], false, true, false, $defaultCurrency, true);
        $GLOBALS['SNIPPETS']['InvoiceEmailHandlingTotal'] = $emailTemplate->GetSnippet('InvoiceEmailHandlingTotal');
    }
    if ($order_row['ordtaxtotal'] > 0) {
        if ($order_row['ordtaxname']) {
            $taxName = $order_row['ordtaxname'];
        } else {
            $taxName = GetLang('InvoiceSalesTax');
        }
        $GLOBALS['TaxCost'] = FormatPrice($order_row['ordtaxtotal'], false, true, false, $defaultCurrency, true);
        if ($order_row['ordtotalincludestax']) {
            $GLOBALS['TaxName'] = isc_html_escape(sprintf(GetLang('IncludedInvoiceTax'), $taxName));
            $GLOBALS['SNIPPETS']['InvoiceEmailTaxTotalIncluded'] = $emailTemplate->GetSnippet('InvoiceEmailTaxTotal');
            $GLOBALS['SNIPPETS']['InvoiceEmailTaxTotal'] = '';
        } else {
            $GLOBALS['TaxName'] = isc_html_escape($taxName);
            $GLOBALS['SNIPPETS']['InvoiceEmailTaxTotal'] = $emailTemplate->GetSnippet('InvoiceEmailTaxTotal');
            $GLOBALS['SNIPPETS']['InvoiceEmailTaxTotalIncluded'] = '';
        }
    }
    $GLOBALS['TotalCost'] = FormatPrice($order_row['ordtotalamount'], false, true, false, $defaultCurrency, true);
    $email = $order_row['ordbillemail'];
    if (!$order_row['ordbillemail']) {
        // Get the customer's email address
        $query = sprintf("select custconemail from [|PREFIX|]customers where customerid='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($order_row['ordcustid']));
        $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
        if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
            $email = $row['custconemail'];
        }
    }
    if (!$email) {
        return false;
    }
    $WrapCost = 0;
    $fieldArray = GetOrderProductFieldsData($orderId);
    $GLOBALS['SNIPPETS']['CartItems'] = '';
    foreach ($order_row['products'] as $product_row) {
        if ($product_row['ordprodtype'] == "physical") {
            $is_digital_download = false;
        }
        $pOptions = '';
        if ($product_row['ordprodoptions'] != '') {
            $options = @unserialize($product_row['ordprodoptions']);
            if (!empty($options)) {
                $pOptions = "<br /><small>(";
                $comma = '';
                foreach ($options as $name => $value) {
                    $pOptions .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                    $comma = ', ';
                }
                $pOptions .= ")</small>";
            }
        }
        $GLOBALS['ProductOptions'] = $pOptions;
        $GLOBALS['EventDate'] = '';
        if ($product_row['ordprodeventdate'] != null) {
            $GLOBALS['EventDate'] = '<br /><span style="padding-left : 10px; padding-bottom:10px; font-size:11px; font-style:italic">(' . $product_row['ordprodeventname'] . ': ' . isc_date('dS M Y', $product_row['ordprodeventdate']) . ')</span>';
        }
        $GLOBALS['ProductPrice'] = FormatPrice($product_row['ordprodcost'], false, true, false, $defaultCurrency, true);
        $GLOBALS['ProductTotal'] = FormatPrice($product_row['ordprodcost'] * $product_row['ordprodqty'], false, true, false, $defaultCurrency, true);
        $GLOBALS['ProductQuantity'] = $product_row['ordprodqty'];
        $GLOBALS['ProductName'] = isc_html_escape($product_row['ordprodname']);
        // If this is a digital download and the order is complete, append a download link to the name of the product
        if ($product_row['ordprodtype'] == 'digital' && OrderIsComplete($order_status)) {
            $GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT');
            $downloadEncrypted = $GLOBALS['ISC_CLASS_ACCOUNT']->EncryptDownloadKey($product_row['orderprodid'], $product_row['ordprodid'], $orderId, $order_row['ordtoken']);
            $downloadLink = $GLOBALS['ShopPathSSL'] . '/account.php?action=download_item&amp;data=' . $downloadEncrypted;
            $GLOBALS['ProductName'] .= ' (<a href="' . $downloadLink . '">' . GetLang('DownloadLink') . '</a>)';
        }
        $GLOBALS['CartProductFields'] = '';
        if (isset($fieldArray[$product_row['orderprodid']])) {
            $GLOBALS['CartProductFields'] = LoadEmailOrderProductFields($fieldArray[$product_row['orderprodid']]);
        }
        if (isset($product_row['ordprodwrapcost'])) {
            $WrapCost += $product_row['ordprodwrapcost'];
        }
        $GLOBALS['SNIPPETS']['CartItems'] .= $emailTemplate->GetSnippet("InvoiceCartItem");
    }
    if ($WrapCost > 0) {
        $GLOBALS['GiftWrapCost'] = FormatPrice($WrapCost, false, true, false, $defaultCurrency, true);
        $GLOBALS['SNIPPETS']['InvoiceEmailGiftWrapTotal'] = $emailTemplate->GetSnippet('InvoiceEmailGiftWrapTotal');
    }
    // Set the shipping method
    if ($ship_method == "") {
        if ($is_digital_download) {
            $GLOBALS['ShippingMethod'] = GetLang('ImmediateDownload');
        } else {
            $GLOBALS['ShippingMethod'] = sprintf(GetLang('FreeShippingFromX'), $GLOBALS['StoreName']);
        }
    } else {
        $GLOBALS['ShippingMethod'] = sprintf("%s %s %s", isc_html_escape($order_row['ordshipmethod']), GetLang('For'), FormatPrice($ship_cost, false, true, false, $defaultCurrency, true));
    }
    // What's the status of the order? If it's awaiting payment (7) then show the awaiting payment notice
    if ($order_status == 7) {
        // Get the awaiting payment snippet, for offline payment providers also show the "how to pay for your order" message"
        $checkout_provider = null;
        GetModuleById('checkout', $checkout_provider, $order_payment_module);
        if (is_object($checkout_provider) && $checkout_provider->getpaymenttype() == PAYMENT_PROVIDER_OFFLINE && method_exists($checkout_provider, 'GetOfflinePaymentMessage')) {
            $paymentData = array('orders' => array($order_row['orderid'] => $order_row));
            $checkout_provider->SetOrderData($paymentData);
            $GLOBALS['PaymentGatewayAmount'] = CurrencyConvertFormatPrice($order_row['ordgatewayamount'], $order_row['ordcurrencyid'], $order_row['ordcurrencyexchangerate'], true);
            $GLOBALS['PaymentMessage'] = str_replace("\n", "<br />", $checkout_provider->GetOfflinePaymentMessage());
            $GLOBALS['PendingPaymentDetails'] = $emailTemplate->GetSnippet("InvoicePendingPaymentDetails");
            $GLOBALS['PendingPaymentNotice'] = $emailTemplate->GetSnippet("InvoicePendingPaymentNotice");
        }
    }
    if ($order_row['ordcustmessage'] != '') {
        $GLOBALS['OrderComments'] = "<h3 style='font-size:18px'>" . GetLang('OrderComments') . "</h3>" . isc_html_escape($order_row['ordcustmessage']);
    }
    $emailTemplate->SetTemplate("invoice_email");
    $message = $emailTemplate->ParseTemplate(true);
    // Create a new email API object to send the email
    $store_name = GetConfig('StoreName');
    $obj_email = GetEmailClass();
    $obj_email->From(GetConfig('OrderEmail'), $store_name);
    $obj_email->Set("Subject", sprintf(GetLang('YourOrderFrom'), $store_name));
    $obj_email->AddBody("html", $message);
    $obj_email->AddRecipient($email, "", "h");
    $email_result = $obj_email->Send();
    $forwardEmails = array();
    if ($order_row['ordvendorid'] > 0) {
        $query = "\n\t\t\tSELECT vendororderemail\n\t\t\tFROM [|PREFIX|]vendors\n\t\t\tWHERE vendorid='" . (int) $order_row['ordvendorid'] . "'\n\t\t";
        $vendorOrderEmails = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
        $forwardEmails = array_merge($forwardEmails, explode(',', $vendorOrderEmails));
    }
    // If there are any additional recipients (forward invoices to addresses), send them as well
    if (GetConfig('ForwardInvoiceEmails')) {
        $forwardEmails = array_merge($forwardEmails, explode(',', GetConfig('ForwardInvoiceEmails')));
    }
    $forwardEmails = array_unique($forwardEmails);
    foreach ($forwardEmails as $address) {
        if (!trim($address)) {
            continue;
        }
        $emailClass = GetEmailClass();
        $emailClass->Set('CharSet', GetConfig('CharacterSet'));
        $emailClass->From(GetConfig('OrderEmail'), $store_name);
        $emailClass->Set("Subject", "Fwd: " . sprintf(GetLang('YourOrderFrom'), $store_name) . " (#" . $order_row['orderid'] . ")");
        $emailClass->AddBody("html", $message);
        $emailClass->AddRecipient($address, "", "h");
        $status = $emailClass->Send();
    }
    // If the email was sent ok, show a confirmation message
    if ($email_result['success']) {
        return true;
    } else {
        // Email error
        return false;
    }
}
	/**
	 * This function will check against the rules if there is any remaining amount to the cart, in order to get the free shipping.
	 * @param ISC_QUOTE $quote The quote object that used to check the free shipping eligibility
	 * @return boolean Return true if there is we found free shipping eligibility. Otherwise, return false
	 */
	public function checkFreeShippingEligibility(ISC_QUOTE $quote)
	{
		foreach($quote->getItems() as $item) {
			if($quote->getBaseSubTotal() < $this->amount) {
				$remainingAmount = $this->amount - $quote->getBaseSubTotal();
				$productName = $item->getName();
				$placeHolders = array(
					'%%PRODUCT_NAME%%' => $productName,
					'%%REMAINING_QUANTITY%%' => '',
					'%%TOTAL_QUANTITY%%' => $this->amount,
					'%%CART_QUANTITY%%' => $item->getQuantity(),
					'%%REMAINING_AMOUNT%%' => CurrencyConvertFormatPrice($remainingAmount),
					'%%TOTAL_AMOUNT%%' => CurrencyConvertFormatPrice($this->amount),
					'%%CART_AMOUNT%%' => CurrencyConvertFormatPrice($quote->getBaseSubTotal()),
				);
				$this->freeShippingEligibilityData = array(
					'message' => str_replace(array_keys($placeHolders), array_values($placeHolders), $this->freeShippingMessage),
					'location' => $this->freeShippingMessageLocation,
					'name' => $this->getName(),
				);
				return true;
			}
		}
		return false;
	}
Example #27
0
		/**
		*	Show the details of an order and allow them to print an invoice
		*/
		private function ViewOrderDetails()
		{
			$GLOBALS['SNIPPETS']['AccountOrderItemRow'] = "";
			$count = 0;

			if (!isset($_GET['order_id']) || !is_numeric($_GET['order_id'])) {
				redirect('account.php?action=view_orders');
			}

			$GLOBALS['FlassMessage'] = GetFlashMessageBoxes();

			// Retrieve the completed order that matches the customers user id
			$orderId = (int)$_GET['order_id'];
			$GLOBALS['OrderId'] = $orderId;

			$customerId = getClass('ISC_CUSTOMER')->getcustomerId();
			$query = "
				SELECT *, (
						SELECT CONCAT(custconfirstname, ' ', custconlastname)
						FROM [|PREFIX|]customers
						WHERE customerid=ordcustid
					) AS custname, (
						SELECT statusdesc
						FROM [|PREFIX|]order_status
						WHERE statusid=ordstatus
					) AS ordstatustext
				FROM [|PREFIX|]orders
				WHERE ordcustid='".(int)$customerId."' AND orderid='".(int)$orderId."' AND deleted = 0
			";
			$result = $GLOBALS['ISC_CLASS_DB']->query($query);
			$row = $GLOBALS['ISC_CLASS_DB']->fetch($result);
			if(!$row) {
				redirect('account.php?action=view_orders');
			}

			$GLOBALS['DisableReturnButton'] = "";
			if (!gzte11(ISC_LARGEPRINT)) {
				$GLBOALS['DisableReturnButton'] = "none";
			}

			$order = $row;

			// Fetch the shipping addresses for this order
			$addresses = array();
			$query = "
				SELECT *
				FROM [|PREFIX|]order_addresses
				WHERE order_id='".$order['orderid']."'
			";
			$result = $GLOBALS['ISC_CLASS_DB']->query($query);
			while($address = $GLOBALS['ISC_CLASS_DB']->fetch($result)) {
				$addresses[$address['id']] = $address;
			}

			// Fetch the shipping details for the order
			$query = "
				SELECT *
				FROM [|PREFIX|]order_shipping
				WHERE order_id=".$order['orderid'];
			$result = $GLOBALS['ISC_CLASS_DB']->query($query);
			while($shipping = $GLOBALS['ISC_CLASS_DB']->fetch($result)) {
				$addresses[$shipping['order_address_id']]['shipping'] = $shipping;
			}

			$GLOBALS['OrderComments'] = '';
			if($row['ordcustmessage'] != '') {
				$GLOBALS['OrderComments'] = nl2br(isc_html_escape($row['ordcustmessage']));
			}
			else {
				$GLOBALS['HideOrderComments'] = 'display: none';
			}

			if(OrderIsComplete($row['ordstatus'])) {
				if (!gzte11(ISC_LARGEPRINT)) {
					$GLOBALS['DisableReturnButton'] = "none";
				}

				if ($row['ordstatus'] == 4 || GetConfig('EnableReturns') == 0) {
					$GLOBALS['DisableReturnButton'] = "none";
				}

				$GLOBALS['HideOrderStatus'] = "none";
				$orderComplete = true;
			}
			else {
				$GLOBALS['HideOrderStatus'] = '';
				$GLOBALS['OrderStatus'] = $row['ordstatustext'];
				$GLOBALS['DisableReturnButton'] = "none";
				$orderComplete = false;
			}

			// Hide print order invoive if it's a incomplete order
			$GLOBALS['ShowOrderActions'] = '';
			if(!$row['ordstatus']) {
				$GLOBALS['ShowOrderActions'] = 'display:none';
			}

			$GLOBALS['OrderDate'] = isc_date(GetConfig('ExtendedDisplayDateFormat'), $row['orddate']);

			$GLOBALS['OrderTotal'] = CurrencyConvertFormatPrice($row['total_inc_tax'], $row['ordcurrencyid'], $row['ordcurrencyexchangerate'], true);

			// Format the billing address
			$GLOBALS['ShipFullName'] = isc_html_escape($row['ordbillfirstname'].' '.$row['ordbilllastname']);
			$GLOBALS['ShipCompany'] = '';
			if($row['ordbillcompany']) {
				$GLOBALS['ShipCompany'] = '<br />'.isc_html_escape($row['ordbillcompany']);
			}

			$GLOBALS['ShipAddressLines'] = isc_html_escape($row['ordbillstreet1']);

			if ($row['ordbillstreet2'] != "") {
				$GLOBALS['ShipAddressLines'] .= '<br />' . isc_html_escape($row['ordbillstreet2']);
			}

			$GLOBALS['ShipSuburb'] = isc_html_escape($row['ordbillsuburb']);
			$GLOBALS['ShipState'] = isc_html_escape($row['ordbillstate']);
			$GLOBALS['ShipZip'] = isc_html_escape($row['ordbillzip']);
			$GLOBALS['ShipCountry'] = isc_html_escape($row['ordbillcountry']);
			$GLOBALS['ShipPhone'] = "";
			$GLOBALS['BillingAddress'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AddressLabel");

			// Is there a shipping address, or is it a digital download?
			if ($order['ordisdigital']) {
				$GLOBALS['HideSingleShippingAddress'] = 'display: none';
			}
			else if ($order['shipping_address_count'] > 1) {
				$GLOBALS['ShippingAddress'] = GetLang('OrderWillBeShippedToMultipleAddresses');
				$GLOBALS['HideItemDetailsHeader'] = 'display:none;';
			}
			else {
				$shippingAddress = current($addresses);
				$GLOBALS['ShipFullName'] = isc_html_escape($shippingAddress['first_name'].' '.$shippingAddress['last_name']);

				$GLOBALS['ShipCompany'] = '';
				if($shippingAddress['company']) {
					$GLOBALS['ShipCompany'] = '<br />'.isc_html_escape($shippingAddress['company']);
				}

				$GLOBALS['ShipAddressLines'] = isc_html_escape($shippingAddress['address_1']);

				if ($shippingAddress['address_2'] != "") {
					$GLOBALS['ShipAddressLines'] .= '<br />' . isc_html_escape($shippingAddress['address_2']);
				}

				$GLOBALS['ShipSuburb'] = isc_html_escape($shippingAddress['city']);
				$GLOBALS['ShipState'] = isc_html_escape($shippingAddress['state']);
				$GLOBALS['ShipZip'] = isc_html_escape($shippingAddress['zip']);
				$GLOBALS['ShipCountry'] = isc_html_escape($shippingAddress['country']);

				$GLOBALS['ShipPhone'] = "";
				$GLOBALS['ShippingAddress'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AddressLabel");
			}

			$itemTotalColumn = 'total_ex_tax';
			if(getConfig('taxDefaultTaxDisplayOrders') == TAX_PRICES_DISPLAY_INCLUSIVE) {
				$itemTotalColumn = 'total_inc_tax';
			}

			$GLOBALS['OrderTotalRows'] = '';
			$totalRows = getOrderTotalRows($order);
			foreach($totalRows as $id => $totalRow) {
				$GLOBALS['ISC_CLASS_TEMPLATE']->assign('label', $totalRow['label']);
				$GLOBALS['ISC_CLASS_TEMPLATE']->assign('classNameAppend', ucfirst($id));
				$value = currencyConvertFormatPrice(
					$totalRow['value'],
					$row['ordcurrencyid'],
					$row['ordcurrencyexchangerate']
				);
				$GLOBALS['ISC_CLASS_TEMPLATE']->assign('value', $value);
				$GLOBALS['OrderTotalRows'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->getSnippet('AccountOrderTotalRow');
			}

			$OrderProducts = array();
			$ProductIds = array();
			// Load up the items in this order
			$query = "
				SELECT
					o.*,
					op.*,
					oa.address_1,
					oa.address_2,
					oa.city,
					oa.zip,
					oa.country,
					oa.state,
					p.productid,
					p.prodpreorder,
					p.prodreleasedate,
					p.prodpreordermessage
				FROM
					[|PREFIX|]orders o
					LEFT JOIN [|PREFIX|]order_products op ON op.orderorderid
					LEFT JOIN [|PREFIX|]products p ON p.productid = op.ordprodid
					LEFT JOIN [|PREFIX|]order_addresses oa ON oa.`id` = op.order_address_id
				WHERE
					orderorderid = " . (int)$order['orderid'] ."
				ORDER BY
					op.order_address_id";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

			//check if products are reorderable
			while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$OrderProducts[$row['orderprodid']] = $row;
				$ProductIds[] = $row['ordprodid'];
			}

			$UnreorderableProducts = $this->GetUnreorderableProducts($OrderProducts, $ProductIds);

			// for grouping of shipping addresses in template output
			$previousAddressId = null;
			$destinationCounter = 0;

			foreach ($OrderProducts as $row) {
				if ($count++ % 2 != 0) {
					$GLOBALS['ItemClass'] = "OrderItem2";
				} else {
					$GLOBALS['ItemClass'] = "OrderItem1";
				}

				$GLOBALS['OrderProductId'] = $row['orderprodid'];
				$GLOBALS['DisableReorder'] = '';

				$GLOBALS['ReorderMessage'] = "";
				$GLOBALS['HideItemMessage'] = 'display:none;';
				if(isset($UnreorderableProducts[$row['orderprodid']])) {
					$GLOBALS['DisableReorder'] = 'Disabled';
					$GLOBALS['ReorderMessage'] = $UnreorderableProducts[$row['orderprodid']];
					if(isset($_REQUEST['reorder']) && $_REQUEST['reorder']==1) {
						$GLOBALS['HideItemMessage'] = '';
					}
				}

				$GLOBALS['Qty'] = (int) $row['ordprodqty'];
				$GLOBALS['Name'] = isc_html_escape($row['ordprodname']);
				$GLOBALS['EventDate'] = '';

				if ($row['ordprodeventdate'] != 0) {
					$GLOBALS['EventDate'] = $row['ordprodeventname'] . ': '. isc_date('M jS Y', $row['ordprodeventdate']);
				}

				// Does the product still exist or has it been deleted?
				$prod_name = GetProdNameById($row['ordprodid']);

				if ($prod_name == "" && $row['ordprodtype'] == 'giftcertificate') {
					$GLOBALS['Link'] = "javascript:product_giftcertificate()";
					$GLOBALS['Target'] = "";
				}else if ($prod_name == "") {
					$GLOBALS['Link'] = "javascript:product_removed()";
					$GLOBALS['Target'] = "";
				}
				else {
					$GLOBALS['Link'] = ProdLink(GetProdNameById($row['ordprodid']));
					$GLOBALS['Target'] = "_blank";
				}

				$GLOBALS['DownloadsLink'] = '';
				if ($row['ordprodtype'] == "digital" && $orderComplete) {
					$GLOBALS['DownloadItemEncrypted'] = $this->EncryptDownloadKey($row['orderprodid'], $row['ordprodid'], $row['orderorderid'], $row['ordtoken']);
					$GLOBALS['DownloadsLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AccountOrderItemDownloadLink");
				}

				$GLOBALS['Refunded'] = '';
				$GLOBALS['StrikeEnd'] = '';
				$GLOBALS['StrikeStart'] = '';

				if ($row['ordprodrefunded'] > 0) {
					if ($row['ordprodrefunded'] == $row['ordprodqty']) {
						$GLOBALS['StrikeStart'] = "<s>";
						$GLOBALS['StrikeEnd'] = "</s>";
						$GLOBALS['Refunded'] = '<span class="Refunded">'.GetLang('OrderProductRefunded').'</span>';
					}
					else {
						$GLOBALS['Refunded'] = '<span class="Refunded">'.sprintf(GetLang('OrderProductsRefundedX'), $row['ordprodrefunded']).'</span>';
					}
				}

				$GLOBALS['Price'] = CurrencyConvertFormatPrice(
					$row[$itemTotalColumn],
					$order['ordcurrencyid'],
					$order['ordcurrencyexchangerate']
				);

				// Were there one or more options selected?
				$GLOBALS['ProductOptions'] = '';
				if($row['ordprodoptions'] != '') {
					$options = @unserialize($row['ordprodoptions']);
					if(!empty($options)) {
						$GLOBALS['ProductOptions'] = "<br /><small class='OrderItemOptions'>(";
						$comma = '';
						foreach($options as $name => $value) {
							$GLOBALS['ProductOptions'] .= $comma.isc_html_escape($name).": ".isc_html_escape($value);
							$comma = ', ';
						}
						$GLOBALS['ProductOptions'] .= ")</small>";
					}
				}

				if($row['ordprodwrapname']) {
					$GLOBALS['GiftWrappingName'] = isc_html_escape($row['ordprodwrapname']);
					$GLOBALS['HideWrappingOptions'] = '';
				}
				else {
					$GLOBALS['GiftWrappingName'] = '';
					$GLOBALS['HideWrappingOptions'] = 'display: none';
				}

				$GLOBALS['HideExpectedReleaseDate'] = 'display:none;';
				$GLOBALS['ExpectedReleaseDate'] = '';

				if ($row['prodpreorder']) {
					if ($row['prodreleasedate']) {
						$message = $row['prodpreordermessage'];
						if (!$message) {
							$message = GetConfig('DefaultPreOrderMessage');
						}
						$GLOBALS['ExpectedReleaseDate'] = '(' . str_replace('%%DATE%%', isc_date(GetConfig('DisplayDateFormat'), $row['prodreleasedate']), $message) . ')';
					} else {
						$GLOBALS['ExpectedReleaseDate'] = '(' . GetLang('PreOrderProduct') . ')';
					}
					$GLOBALS['HideExpectedReleaseDate'] = '';
				}

				$GLOBALS['ItemShippingRow'] = '';
				if ($order['shipping_address_count'] > 1 && ($previousAddressId != $row['order_address_id'])) {
					$destinationCounter++;

					$GLOBALS['Destination_Number'] = GetLang('Destination_Number', array('number' => $destinationCounter));

					$addressLine = array_filter(array(
						$row['address_1'],
						$row['address_2'],
						$row['city'],
						$row['state'],
						$row['zip'],
						$row['country'],
					));

					$GLOBALS['ItemShippingRow_AddressLine'] = Store_String::rightTruncate(implode(', ', $addressLine), 60);

					$GLOBALS['ItemShippingRow'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('AccountOrderItemShippingRow');
				}

				$GLOBALS['SNIPPETS']['AccountOrderItemRow'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AccountOrderItemRow");
				$previousAddressId = $row['order_address_id'];
			}

			$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle(sprintf("%s - %s%d", GetConfig('StoreName'), GetLang('OrderIdHash'), $orderId));
			$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("account_order");
			$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
		}
Example #28
0
		/**
		 * Generate the payment form to allow users to make a payment via this provider.
		 *
		 * @return string The generated payment form.
		 */
		public function ShowPaymentForm()
		{
			$GLOBALS['EWayMonths'] = "";
			$GLOBALS['EWayYears'] = "";

			for($i = 1; $i <= 12; $i++) {
				$stamp = mktime(0, 0, 0, $i, 15, isc_date("Y"));

				$i = str_pad($i, 2, "0", STR_PAD_LEFT);

				if(@$_POST['eway_ccexpm'] == $i) {
					$sel = 'selected="selected"';
				} else {
					$sel = "";
				}

				$GLOBALS['EWayMonths'] .= sprintf("<option %s value='%s'>%s</option>", $sel, $i, isc_date("M", $stamp));
			}

			for($i = isc_date("Y"); $i < isc_date("Y")+10; $i++) {

				if(@$_POST['eway_ccexpy'] == isc_substr($i, 2, 2)) {
					$sel = 'selected="selected"';
				} else {
					$sel = "";
				}

				$GLOBALS['EWayYears'] .= sprintf("<option %s value='%s'>%s</option>", $sel, isc_substr($i, 2, 2), $i);
			}

			$require_cvv2 = $this->GetValue("requirecvn");
			if($require_cvv2 == "YES") {
				if(isset($_POST['eway_cvn'])) {
					$GLOBALS['EWayCardCode'] = $_POST['eway_cvn'];
				}
				$GLOBALS['EWayHideCardCode'] = '';
			}
			else {
				$GLOBALS['EWayHideCardCode'] = 'none';
			}

			// Grab the billing details
			$billingDetails = $this->GetBillingDetails();

			$GLOBALS['EWayName'] = isc_html_escape($billingDetails['ordbillfirstname'].' '.$billingDetails['ordbilllastname']);

			// Format the amount that's going to be going through the gateway
			$gatewayAmount = $this->GetGatewayAmount();
			$GLOBALS['OrderAmount'] = CurrencyConvertFormatPrice($gatewayAmount);

			// Was there an error validating the payment? If so, pre-fill the form fields with the already-submitted values
			if($this->HasErrors()) {
				$GLOBALS['EWayName'] = isc_html_escape($_POST['eway_name']);
				$GLOBALS['EWayNum'] = isc_html_escape($_POST['eway_ccno']);

				$eway_error = implode("<br />", $this->GetErrors());
				$eway_error = str_replace("Error: ", "", $eway_error);
				$eway_error = str_replace(" You have not been billed for this transaction.", "", $eway_error);
				$GLOBALS['EWayErrorMessage'] = $eway_error;
			}
			else {
				// Hide the error message box
				$GLOBALS['HideEWayError'] = "none";
			}

			// Collect their details to send through to eWay
			$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("eway");
			return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
		}
Example #29
0
	public function SetPanelSettings()
	{
		$GLOBALS['SNIPPETS']['SideCartItems'] = '';

		// We check $_SESSION['QUOTE'] directly here as to not
		// instantiate the quote if it doesn't already exist.
		if(!isset($_SESSION['QUOTE']) && getCustomerQuote()->getNumItems() == 0) {
			$this->DontDisplay = true;
			return;
		}

		$incTax = false;
		if(getConfig('taxDefaultTaxDisplayCart') != TAX_PRICES_DISPLAY_EXCLUSIVE) {
			$incTax = true;
		}

		$quote = getCustomerQuote();
		$items = $quote->getItems();
		foreach($items as $item) {
			if($item->getProductId()) {
				$GLOBALS['ProductName'] = "<a href=\"".ProdLink($item->getName())."\">".isc_html_escape($item->getName())."</a>";
			}
			else {
				$GLOBALS['ProductName'] = isc_html_escape($item->getName());
			}

			// Is this product a variation?
			$GLOBALS['ProductOptions'] = '';
			$options = $item->getVariationOptions();
			if(!empty($options)) {
				$GLOBALS['ProductOptions'] .= "<br /><small>(";
				$comma = '';
				foreach($options as $name => $value) {
					if(!trim($name) || !trim($value)) {
						continue;
					}
					$GLOBALS['ProductOptions'] .= $comma.isc_html_escape($name).": ".isc_html_escape($value);
					$comma = ', ';
				}
				$GLOBALS['ProductOptions'] .= ")</small>";
			}

			$GLOBALS['ProductPrice'] = currencyConvertFormatPrice($item->getTotal($incTax));
			$GLOBALS['ProductQuantity'] = $item->getQuantity();
			$GLOBALS['SNIPPETS']['SideCartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCartItem");
		}

		$numItems = $quote->getNumItems();
		if($numItems == 1) {
			$GLOBALS['SideCartItemCount'] = GetLang('SideCartYouHave1Item');
		} else {
			$GLOBALS['SideCartItemCount'] = sprintf(GetLang('SideCartYouHaveXItems'), $numItems);
		}

		$total = $quote->getSubTotal($incTax);
		$GLOBALS['ISC_LANG']['SideCartTotalCost'] = sprintf(GetLang('SideCartTotalCost'), CurrencyConvertFormatPrice($total));

		// Go through all the checkout modules looking for one with a GetSidePanelCheckoutButton function defined
		$GLOBALS['AdditionalCheckoutButtons'] = '';
		$HideCheckout = false;
		foreach (GetAvailableModules('checkout', true, true) as $module) {
			if (method_exists($module['object'], 'GetSidePanelCheckoutButton')) {
				$GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetSidePanelCheckoutButton();
			}

			if ($module['object']->disableNonCartCheckoutButtons) {
				$HideCheckout = true;
			}

		}

		if ($HideCheckout) {
			$GLOBALS['SNIPPETS']['SideCartContentsCheckoutLink'] = '';
		} else {
			require_once ISC_BASE_PATH.'/includes/display/CartHeader.php';

			$cartPanel = getClass('ISC_CARTHEADER_PANEL');
			$cartPanel -> insertOptimizerLinkScript();
			$GLOBALS['SNIPPETS']['SideCartContentsCheckoutLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('SideCartContentsCheckoutLink');
		}

	}
Example #30
0
/**
 *	Email the invoice from an order to a customer
 *
 * @param int The ID of the order to email the invoice for.
 * @param int The optional ID of the order status. Will default to the already stored status ID of the order
 */
function EmailInvoiceToCustomer($orderId, $newStatusId=null)
{
	// Load the details for this order
	$order_row = GetOrder($orderId, true);
	if($order_row === false) {
		return false;
	}

	// All prices in the emailed invoices will be shown in the default currency of the store
	$defaultCurrency = GetDefaultCurrency();

	$GLOBALS['OrderNumber'] = $orderId;

	if (isId($newStatusId)) {
		$order_status = $newStatusId;
	} else {
		$order_status = $order_row['ordstatus'];
	}

	$order_payment_module = $order_row['orderpaymentmodule'];

	if($order_row['ordcustid'] > 0) {
		$GLOBALS['ViewOrderStatusMsg'] = GetLang('ASummaryIsShownBelow')." <a href='".$GLOBALS['ShopPath']."/orderstatus.php'>".GetLang('ClickHere')."</a>.";
	} else {
		$GLOBALS['ViewOrderStatusMsg'] = "";
	}

	$emailTemplate = FetchEmailTemplateParser();

	if ($order_row['shipping_address_count'] > 1) {
		// multiple shipping addresses
		$GLOBALS['ShippingAddress'] = GetLang('OrderWillBeShippedToMultipleAddresses');
	} else if ($order_row['shipping_address_count'] == 0) {
		// no shipping addresses (digital order)
		$GLOBALS['ShippingAddress'] = GetLang('ShippingImmediateDownload');
	} else {
		// single shipping address
		$address = $GLOBALS['ISC_CLASS_DB']->FetchRow("
			SELECT
				oa.*
			FROM
				`[|PREFIX|]order_addresses` oa
			WHERE
				oa.order_id = " . (int)$order_row['orderid'] . "
		");

		$GLOBALS['ShipFullName'] = isc_html_escape($address['first_name'].' '.$address['last_name']);

		$GLOBALS['ShipCompany'] = '';
		if($address['company']) {
			$GLOBALS['ShipCompany'] = '<br />'.isc_html_escape($address['company']);
		}

		$GLOBALS['ShipAddressLines'] = isc_html_escape($address['address_1']);

		if ($address['address_2'] != "") {
			$GLOBALS['ShipAddressLines'] .= '<br />' . isc_html_escape($address['address_2']);
		}

		$GLOBALS['ShipSuburb'] = isc_html_escape($address['city']);
		$GLOBALS['ShipState'] = isc_html_escape($address['state']);
		$GLOBALS['ShipZip'] = isc_html_escape($address['zip']);
		$GLOBALS['ShipCountry'] = isc_html_escape($address['country']);
		$GLOBALS['ShipPhone'] = isc_html_escape($address['phone']);

		// show shipping email, if any
		if(!$address['email']) {
			$GLOBALS['HideShippingEmail'] = 'display: none';
		} else {
			$GLOBALS['ShippingEmail'] = $address['email'];
		}

		$GLOBALS['ShippingAddress'] = $emailTemplate->GetSnippet("AddressLabel");
	}

	// Format the billing address
	$GLOBALS['ShipFullName'] = isc_html_escape($order_row['ordbillfirstname'].' '.$order_row['ordbilllastname']);

	$GLOBALS['ShipCompany'] = '';
	if($order_row['ordbillcompany']) {
		$GLOBALS['ShipCompany'] = '<br />'.isc_html_escape($order_row['ordbillcompany']);
	}

	$GLOBALS['ShipAddressLines'] = isc_html_escape($order_row['ordbillstreet1']);

	if ($order_row['ordbillstreet2'] != "") {
		$GLOBALS['ShipAddressLines'] .= '<br />' . isc_html_escape($order_row['ordbillstreet2']);
	}

	$GLOBALS['ShipSuburb'] = isc_html_escape($order_row['ordbillsuburb']);
	$GLOBALS['ShipState'] = isc_html_escape($order_row['ordbillstate']);
	$GLOBALS['ShipZip'] = isc_html_escape($order_row['ordbillzip']);
	$GLOBALS['ShipCountry'] = isc_html_escape($order_row['ordbillcountry']);
	$GLOBALS['ShipPhone'] = isc_html_escape($order_row['ordbillphone']);

	// show billing email, if any
	if(!$order_row['ordbillemail']) {
		$GLOBALS['HideBillingEmail'] = 'display: none';
	} else {
		$GLOBALS['BillingEmail'] = $order_row['ordbillemail'];
	}

	$GLOBALS['BillingAddress'] = $emailTemplate->GetSnippet("AddressLabel");

	// Format the shipping provider's details
	$shippingCostColumn = 'cost_ex_tax';
	$itemPriceColumn = 'price_ex_tax';
	$itemTotalColumn = 'total_ex_tax';
	$subTotalColumn = 'subtotal_ex_tax';

	if(getConfig('taxDefaultTaxDisplayOrders') == TAX_PRICES_DISPLAY_INCLUSIVE) {
		$shippingCostColumn = 'cost_inc_tax';
		$itemPriceColumn = 'price_inc_tax';
		$itemTotalColumn = 'total_inc_tax';
		$subTotalColumn = 'subtotal_inc_tax';
	}

	$GLOBALS['TotalCost'] = FormatPrice($order_row['total_inc_tax'], false, true, false, $defaultCurrency, true);

	$email = $order_row['ordbillemail'];
	if(!$order_row['ordbillemail']) {
		// Get the customer's email address
		$query = sprintf("select custconemail from [|PREFIX|]customers where customerid='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($order_row['ordcustid']));
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

		if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$email = $row['custconemail'];
		}
	}

	if(!$email) {
		return false;
	}

	$prodHasSKU = false;
	$WrapCost = 0;
	$fieldArray = GetOrderProductFieldsData($orderId);

	// We need to loop throuh all the prodcts to see if any of them have an SKU
	foreach($order_row['products'] as $product_row) {
		if (trim($product_row['ordprodsku']) !== '') {
			$prodHasSKU = true;
		}
	}

	// OK, now set the proper columns for the product list
	if ($prodHasSKU) {
		$GLOBALS['CartItemColumns'] = $emailTemplate->GetSnippet("InvoiceProductColumns");
	} else {
		$GLOBALS['CartItemColumns'] = $emailTemplate->GetSnippet("InvoiceProductColumnsNoSKU");
	}

	$GLOBALS['SNIPPETS']['CartItems'] = '';
	$previousAddressId = null;
	foreach($order_row['products'] as $product_row) {
		if ($order_row['shipping_address_count'] > 1 && $product_row['order_address_id'] != $previousAddressId) {
			if ($product_row['order_address_id']) {
				$addressLine = array_filter(array(
					$product_row['address_1'],
					$product_row['address_2'],
					$product_row['city'],
					$product_row['state'],
					$product_row['zip'],
					$product_row['country'],
				));
				$addressLine = GetLang('ItemsShippedTo') . ' ' . Store_String::rightTruncate(implode(', ', $addressLine), 70);
			} else {
				$addressLine = GetLang('ItemsShippedToDigital');
			}

			$GLOBALS['AddressLine'] = $addressLine;
			$GLOBALS['SNIPPETS']['CartItems'] .= $emailTemplate->GetSnippet("InvoiceProductShipRow");
			$previousAddressId = $product_row['order_address_id'];
		}

		$pOptions = '';
		if($product_row['ordprodoptions'] != '') {
			$options = @unserialize($product_row['ordprodoptions']);
			if(!empty($options)) {
				$pOptions = "<br /><small>(";
				$comma = '';
				foreach($options as $name => $value) {
					$pOptions .= $comma.isc_html_escape($name).": ".isc_html_escape($value);
					$comma = ', ';
				}
				$pOptions .= ")</small>";
			}
		}
		$GLOBALS['ProductOptions'] = $pOptions;
		$GLOBALS['EventDate'] = '';
		if ($product_row['ordprodeventdate']) {
			$GLOBALS['EventDate'] = '<br /><span style="padding-left : 10px; padding-bottom:10px; font-size:11px; font-style:italic">('.$product_row['ordprodeventname'] . ': ' . isc_date('dS M Y', $product_row['ordprodeventdate']) . ')</span>';
		}
		$GLOBALS['ProductPrice'] = FormatPrice($product_row[$itemPriceColumn], false, true, false, $defaultCurrency, true);
		$GLOBALS['ProductTotal'] = FormatPrice($product_row[$itemTotalColumn], false, true, false, $defaultCurrency, true);
		$GLOBALS['ProductQuantity'] = $product_row['ordprodqty'];

		$GLOBALS['ProductName'] = isc_html_escape($product_row['ordprodname']);

		$GLOBALS['ProductSku'] = ' ';
		if ($prodHasSKU && trim($product_row['ordprodsku']) !== '') {
			$GLOBALS['ProductSku'] = isc_html_escape($product_row['ordprodsku']);
		}

		// If this is a digital download and the order is complete, append a download link to the name of the product
		if($product_row['ordprodtype'] == 'digital' && OrderIsComplete($order_status)) {
			$GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT');
			$downloadEncrypted = $GLOBALS['ISC_CLASS_ACCOUNT']->EncryptDownloadKey($product_row['orderprodid'], $product_row['ordprodid'], $orderId, $order_row['ordtoken']);
			$downloadLink = $GLOBALS['ShopPathSSL'].'/account.php?action=download_item&amp;data=' . $downloadEncrypted;
			$GLOBALS['ProductName'] .= ' (<a href="'.$downloadLink.'">'.GetLang('DownloadLink').'</a>)';
		}

		$GLOBALS['CartProductFields'] = '';
		if(isset($fieldArray[$product_row['orderprodid']])) {
			$GLOBALS['CartProductFields'] = LoadEmailOrderProductFields($fieldArray[$product_row['orderprodid']]);
		}

		if(isset($product_row['ordprodwrapcost'])) {
			$WrapCost += $product_row['ordprodwrapcost'];
		}

		$GLOBALS['ExpectedReleaseDate'] = '';

		if ($product_row['prodpreorder']) {
			if ($product_row['prodreleasedate']) {
				$message = $product_row['prodpreordermessage'];
				if (!$message) {
					$message = GetConfig('DefaultPreOrderMessage');
				}
				$GLOBALS['ExpectedReleaseDate'] = '(' . str_replace('%%DATE%%', isc_date(GetConfig('DisplayDateFormat'), $product_row['prodreleasedate']), $message) . ')';
			} else {
				$GLOBALS['ExpectedReleaseDate'] = '(' . GetLang('PreOrderProduct') . ')';
			}
		}

		if ($prodHasSKU) {
			$GLOBALS['SNIPPETS']['CartItems'] .= $emailTemplate->GetSnippet("InvoiceCartItem");
		} else {
			$GLOBALS['SNIPPETS']['CartItems'] .= $emailTemplate->GetSnippet("InvoiceCartItemNoSKU");
		}
	}

	$totalRows = getOrderTotalRows($order_row);
	$GLOBALS['SNIPPETS']['TotalRows'] = '';
	foreach($totalRows as $row) {
		$emailTemplate->assign('label', isc_html_escape($row['label']));
		$emailTemplate->assign('value', formatPrice($row['value'], false, true, false, $defaultCurrency, true));
		$GLOBALS['SNIPPETS']['TotalRows'] .= $emailTemplate->getSnippet('InvoiceTotalRow');
	}

	// Set the shipping method
	if ($order_row['ordisdigital']) {
		$GLOBALS['ShippingMethod'] = GetLang('ImmediateDownload');
	} else {
		$GLOBALS['ShippingMethod'] = sprintf(GetLang('FreeShippingFromX'), $GLOBALS['StoreName']);
	}

	// What's the status of the order? If it's awaiting payment (7) then show the awaiting payment notice
	if ($order_status == 7) {
		// Get the awaiting payment snippet, for offline payment providers also show the "how to pay for your order" message"
		$checkout_provider = null;
		GetModuleById('checkout', $checkout_provider, $order_payment_module);
		if (is_object($checkout_provider) && $checkout_provider->getpaymenttype() == PAYMENT_PROVIDER_OFFLINE && method_exists($checkout_provider, 'GetOfflinePaymentMessage')) {
			$paymentData = array(
				'orders' => array($order_row['orderid'] => $order_row)
			);
			$checkout_provider->SetOrderData($paymentData);
			$GLOBALS['PaymentGatewayAmount'] = CurrencyConvertFormatPrice($order_row['total_inc_tax'], $order_row['ordcurrencyid'], $order_row['ordcurrencyexchangerate'], true);
			$GLOBALS['PaymentMessage'] = $checkout_provider->GetOfflinePaymentMessage();
			$GLOBALS['PendingPaymentDetails'] = $emailTemplate->GetSnippet("InvoicePendingPaymentDetails");
			$GLOBALS['PendingPaymentNotice'] = $emailTemplate->GetSnippet("InvoicePendingPaymentNotice");
		}
	}

	$GLOBALS['OrderCommentBlock'] = '';
	if($order_row['ordcustmessage'] != '') {
		$GLOBALS['OrderComments'] = isc_html_escape($order_row['ordcustmessage']);
		$GLOBALS['OrderCommentBlock'] = $emailTemplate->GetSnippet("InvoiceOrderComment");
	}

	$emailTemplate->SetTemplate("invoice_email");
	$message = $emailTemplate->ParseTemplate(true);

	// Create a new email API object to send the email
	$store_name = GetConfig('StoreName');

	$obj_email = GetEmailClass();
	$obj_email->From(GetConfig('OrderEmail'), $store_name);
	$obj_email->Set("Subject", sprintf(GetLang('YourOrderFrom'), $store_name));
	$obj_email->AddBody("html", $message);
	$obj_email->AddRecipient($email, "", "h");
	$email_result = $obj_email->Send();

	$forwardEmails = array();
	if($order_row['ordvendorid'] > 0) {
		$query = "
			SELECT vendororderemail
			FROM [|PREFIX|]vendors
			WHERE vendorid='".(int)$order_row['ordvendorid']."'
		";
		$vendorOrderEmails = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
		$forwardEmails = array_merge($forwardEmails, explode(',', $vendorOrderEmails));
	}

	// If there are any additional recipients (forward invoices to addresses), send them as well
	if(GetConfig('ForwardInvoiceEmails')) {
		$forwardEmails = array_merge($forwardEmails, explode(',', GetConfig('ForwardInvoiceEmails')));
	}

	$forwardEmails = array_unique($forwardEmails);
	foreach($forwardEmails as $address) {
		if(!trim($address)) {
			continue;
		}
		$emailClass = GetEmailClass();
		$emailClass->Set('CharSet', GetConfig('CharacterSet'));
		$emailClass->From(GetConfig('OrderEmail'), $store_name);
		$emailClass->Set("Subject", "Fwd: ".sprintf(GetLang('YourOrderFrom'), $store_name)." (#".$order_row['orderid'].")");
		$emailClass->AddBody("html", $message);
		$emailClass->AddRecipient($address, "", "h");
		$status = $emailClass->Send();
	}

	// If the email was sent ok, show a confirmation message
	if ($email_result['success']) {
		return true;
	}
	else {
		// Email error
		return false;
	}
}