Advertisement
Guest User

Untitled

a guest
May 24th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.45 KB | None | 0 0
  1. <?php
  2.  
  3. CLASS ISC_INTEGRACAOCART_PANEL extends PANEL
  4. {
  5. /**
  6. * @var ISC_PRODUCT Instance of the product class that this panel is loading details for.
  7. */
  8. private $productClass = null;
  9.  
  10. /**
  11. * @var MySQLDb Instance of the database class.
  12. */
  13. private $db = null;
  14.  
  15. private $hasRequiredFileFields = false;
  16.  
  17. /**
  18. * Set the display settings for this panel.
  19. */
  20. public function SetPanelSettings()
  21. {
  22. $this->productClass = GetClass('ISC_PRODUCT');
  23. $this->db = $GLOBALS['ISC_CLASS_DB'];
  24.  
  25. if(!empty($_SESSION['ProductErrorMessage'])) {
  26. FlashMessage($_SESSION['ProductErrorMessage'], 'error');
  27. }
  28. $GLOBALS['ProductDetailFlashMessages'] = GetFlashMessageBoxes();
  29.  
  30. $GLOBALS['ProductName'] = isc_html_escape($this->productClass->GetProductName());
  31. $GLOBALS['ProductId'] = $this->productClass->GetProductId();
  32. $GLOBALS['ProductPrice'] = '';
  33.  
  34.  
  35. if(isset($_SESSION['ProductErrorMessage']) && $_SESSION['ProductErrorMessage']!='') {
  36. $GLOBALS['HideProductErrorMessage']='';
  37. $GLOBALS['ProductErrorMessage']=$_SESSION['ProductErrorMessage'];
  38. unset($_SESSION['ProductErrorMessage']);
  39. }
  40.  
  41. $GLOBALS['ProductCartQuantity'] = '';
  42. if(isset($GLOBALS['CartQuantity'.$this->productClass->GetProductId()])) {
  43. $GLOBALS['ProductCartQuantity'] = (int)$GLOBALS['CartQuantity'.$this->productClass->GetProductId()];
  44. }
  45.  
  46. $product = $this->productClass->getProduct();
  47. if($product['prodvariationid'] > 0 || $product['prodconfigfields'] || $product['prodeventdaterequired']) {
  48. $GLOBALS['ISC_CLASS_TEMPLATE']->assign('ConfigurableProductClass', 'ConfigurableProduct');
  49. }
  50. else {
  51. $GLOBALS['ISC_CLASS_TEMPLATE']->assign('ConfigurableProductClass', 'NonConfigurableProduct');
  52. }
  53.  
  54. // We've got a lot to do on this page, so to make it easier to follow,
  55. // everything is broken down in to smaller functions.
  56. $this->SetVendorDetails();
  57. $this->SetWrappingDetails();
  58. $this->SetProductImages();
  59. $this->SetShippingCost();
  60. $this->SetPricingDetails();
  61. $this->SetProductDimensions();
  62. $this->SetProductReviews();
  63. $this->SetBulkDiscounts();
  64. $this->SetBrandDetails();
  65. $this->SetInventoryDetails();
  66. $this->SetMiscAttributes();
  67. $this->SetPurchasingOptions();
  68. $this->SetProductVariations();
  69. $this->SetPreorderData();
  70. $this->SetMinMaxQty();
  71.  
  72. // Mobile devices don't support file uploads, so if this is a mobile device then don't show
  73. // any configuration for the product and show a message that the product must be purchased
  74. // on the full site.
  75. if($this->hasRequiredFileFields && $GLOBALS['ISC_CLASS_TEMPLATE']->getIsMobileDevice()) {
  76. $GLOBALS['SNIPPETS']['ProductFieldsList'] = '';
  77. $GLOBALS['SNIPPETS']['VariationList'] = '';
  78. $GLOBALS['SNIPPETS']['EventDate'] = '';
  79. $GLOBALS['ConfigurableProductClass'] = 'NonConfigurableProduct';
  80. $GLOBALS['DisplayAdd'] = 'none';
  81. $GLOBALS['SNIPPETS']['SideAddItemSoldOut'] = $GLOBALS['ISC_CLASS_TEMPLATE']->getSnippet('ProductNotOrderableOnMobiles');
  82. }
  83. //se logado
  84. $ss = GetModuleVariable('addon_somentelogado','lg');
  85. if(!CustomerIsSignedIn() && $ss=='sim'){
  86. //$GLOBALS['SNIPPETS']['ProductAddToCart'] = '<center><br><a href="%%GLOBAL_ShopPath%%/login.php"><button type="submit"class="positive ui button">Somente Logado!</button></a></center>';
  87. $GLOBALS['SNIPPETS']['ProductAddToCart'] = '';
  88. }else{
  89. $GLOBALS['SNIPPETS']['ProductAddToCart'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductAddToCart");
  90. }
  91.  
  92. $ss = GetModuleVariable('addon_somentelogado','lg');
  93. if(!CustomerIsSignedIn() && $ss=='sim'){
  94. $GLOBALS['Logado'] = '<div class="single-product-add-cart"><a href="%%GLOBAL_ShopPath%%/login.php" class="add-cart-text">Somente Logado!</a></div>';
  95. } else {
  96. $GLOBALS['Logado'] = '';
  97. }
  98.  
  99. /* CLIQUEMANIA - COMENTÁRIO DO PRODUTO DIRETO NO FACEBOOK */
  100. $achouCaracterAcentuacao = false;
  101. $arrayCaracterAcentuacao = "%E1,%E9,%ED,%F3,%FA,%C1,%C9,%CD,%D3,%DA,%E7,%C7,%E3,%F5,%C3,%D5,%E2,%F4,%C2,%D4";
  102. foreach(explode(",", $arrayCaracterAcentuacao) as $caracterEspecial){
  103. if(strpos($_SERVER['REQUEST_URI'], $caracterEspecial)){
  104. $achouCaracterAcentuacao = true;
  105. break;
  106. }
  107. }
  108. $GLOBALS['HideComentarioFacebook'] = ($achouCaracterAcentuacao) ? "displayNone" : "";
  109. $GLOBALS['REQUEST_URI'] = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
  110.  
  111.  
  112. }
  113.  
  114. /**
  115. }
  116.  
  117. /**
  118. * Set display options for a preorder product
  119. *
  120. */
  121. private function SetPreorderData()
  122. {
  123. $GLOBALS['SNIPPETS']['ProductExpectedReleaseDate'] = '';
  124.  
  125. if (!$this->productClass->IsPreOrder()) {
  126. return;
  127. }
  128.  
  129. if ($this->productClass->GetReleaseDate()) {
  130. $GLOBALS['ReleaseDate'] = isc_html_escape($this->productClass->GetPreOrderMessage());
  131. if (!$GLOBALS['ReleaseDate']) {
  132. return;
  133. }
  134. } else {
  135. $GLOBALS['ReleaseDate'] = GetLang('PreOrderProduct');
  136. }
  137.  
  138. $GLOBALS['SNIPPETS']['ProductExpectedReleaseDate'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ProductExpectedReleaseDate');
  139. }
  140.  
  141. /**
  142. * Set the display options for min/max qty
  143. */
  144. private function SetMinMaxQty()
  145. {
  146. $js = '';
  147.  
  148. if ($this->productClass->GetMinQty()) {
  149. $GLOBALS['HideMinQty'] = '';
  150. $GLOBALS['MinQty'] = $this->productClass->GetMinQty();
  151. $js .= 'productMinQty=' . $this->productClass->GetMinQty() . ';';
  152. $js .= 'lang.ProductMinQtyError = ' . isc_json_encode(GetLang('ProductMinQtyError', array(
  153. 'product' => $this->productClass->GetProductName(),
  154. 'qty' => $this->productClass->GetMinQty(),
  155. ))) . ';';
  156. } else {
  157. $GLOBALS['HideMinQty'] = 'display:none;';
  158. $GLOBALS['MinQty'] = '';
  159. $js .= 'productMinQty=0;';
  160. }
  161.  
  162. if ($this->productClass->GetMaxQty() !== INF) {
  163. $GLOBALS['HideMaxQty'] = '';
  164. $GLOBALS['MaxQty'] = $this->productClass->GetMaxQty();
  165. $js .= 'productMaxQty=' . $this->productClass->GetMaxQty() . ';';
  166. $js .= 'lang.ProductMaxQtyError = ' . isc_json_encode(GetLang('ProductMaxQtyError', array(
  167. 'product' => $this->productClass->GetProductName(),
  168. 'qty' => $this->productClass->GetMaxQty(),
  169. ))) . ';';
  170. } else {
  171. $GLOBALS['HideMaxQty'] = 'display:none;';
  172. $GLOBALS['MaxQty'] = '';
  173. $js .= 'productMaxQty=Number.POSITIVE_INFINITY;';
  174. }
  175.  
  176. $GLOBALS['ProductMinMaxQtyJavascript'] = $js;
  177. }
  178.  
  179. /**
  180. * Set the display options for the shipping pricing.
  181. */
  182. private function SetShippingCost()
  183. {
  184. if(!GetConfig('ShowProductShipping') || $this->productClass->GetProductType() != PT_PHYSICAL) {
  185. $GLOBALS['HideShipping'] = 'none';
  186. return;
  187. }
  188.  
  189. if ($this->productClass->GetFixedShippingCost() != 0) {
  190. // Is there a fixed shipping cost?
  191. $GLOBALS['ShippingPrice'] = sprintf("%s %s", CurrencyConvertFormatPrice($this->productClass->GetFixedShippingCost()), GetLang('FixedShippingCost'));
  192. }
  193. else if ($this->productClass->HasFreeShipping()) {
  194. // Does this product have free shipping?
  195. $GLOBALS['ShippingPrice'] = '<img src="%%GLOBAL_AppPath%%/modificacoes/frete_gratis.gif" border="0">';
  196. $GLOBALS['fretegratis'] = '<img src="%%GLOBAL_AppPath%%/modificacoes/frete_gratis.gif" border="0">';
  197. $GLOBALS['ocultfreteimg'] = 'inline';
  198. $GLOBALS['hideShippingPrice'] = 'none';
  199. $GLOBALS['Hidefretegratis'] = 'none';
  200. }
  201. // Purchasing is allowed, so show calculated at checkout
  202. else if($this->productClass->IsPurchasingAllowed()) {
  203. $GLOBALS['ShippingPrice'] = '<a href="#" onClick="Frete.Abrir(%%GLOBAL_ProductId%%);"><img src="%%GLOBAL_AppPath%%/modificacoes/frete.gif" border="0"></a>';
  204. }
  205. else {
  206. $GLOBALS['HideShipping'] = 'none';
  207. }
  208. }
  209.  
  210. /**
  211. * Set general pricing details for the product.
  212. */
  213. private function SetPricingDetails()
  214. {
  215. $product = $this->productClass->getProduct();
  216.  
  217. $GLOBALS['PriceLabel'] = GetLang('Price');
  218. $GLOBALS['hidesslogado'] = 'inline';//nono
  219. if($this->productClass->GetProductCallForPricingLabel()) {
  220. //$GLOBALS['ProductPrice'] = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseGL($this->productClass->GetProductCallForPricingLabel());
  221. $id_real = $this->productClass->GetProductId();
  222. $GLOBALS['ProductPrice'] = '';
  223. $GLOBALS['Hideorc'] = '';
  224. //$GLOBALS['ProductPrice'] = '';
  225. //$GLOBALS['Orcamento'] = 'block';
  226. $GLOBALS['sslogado'] = 'none';
  227. $GLOBALS['hideindique'] = 'inline';//nono
  228.  
  229.  
  230. }
  231.  
  232. // If prices are hidden, then we don't need to go any further
  233. else if($this->productClass->ArePricesHidden()) {
  234. $GLOBALS['HidePrice'] = "display: none;";
  235. $GLOBALS['HideRRP'] = 'none';
  236. $GLOBALS['ProductPrice'] = '';
  237. $GLOBALS['Orcamento'] = 'none';
  238.  
  239. return;
  240. }
  241. else {
  242. $options = array('strikeRetail' => false);
  243. $GLOBALS['Orcamento'] = 'none';
  244. $GLOBALS['ProductPrice'] = formatProductDetailsPrice($product, $options);
  245. $GLOBALS['Hideorc'] = 'none';
  246. }
  247.  
  248. // Determine if we need to show the RRP for this product or not
  249. // by comparing the price of the product including any taxes if
  250. // there are any
  251. $GLOBALS['HideRRP'] = "none";
  252. $productPrice = $product['prodcalculatedprice'];
  253. $formatapreco = number_format($productPrice, 2, '.', '');
  254. $GLOBALS['preco'] = $formatapreco;
  255. $retailPrice = $product['prodretailprice'];
  256. if($retailPrice) {
  257. // Get the tax display format
  258. $displayFormat = getConfig('taxDefaultTaxDisplayProducts');
  259. $options['displayInclusive'] = $displayFormat;
  260.  
  261. // Convert to the browsing currency, and apply group discounts
  262. $productPrice = formatProductPrice($product, $productPrice, array(
  263. 'localeFormat' => false, 'displayInclusive' => $displayFormat
  264. ));
  265. $retailPrice = formatProductPrice($product, $retailPrice, array(
  266. 'localeFormat' => false, 'displayInclusive' => $displayFormat
  267. ));
  268.  
  269. if($productPrice < $retailPrice) {
  270. $GLOBALS['HideRRP'] = '';
  271.  
  272. // Showing call for pricing, so just show the RRP and that's all
  273. if($this->productClass->GetProductCallForPricingLabel()) {
  274. $GLOBALS['RetailPrice'] = CurrencyConvertFormatPrice($retailPrice);
  275. }
  276. else {
  277. // ISC-1057: do not apply customer discount to RRP in this case
  278. $retailPrice = formatProductPrice($product, $product['prodretailprice'], array(
  279. 'localeFormat' => false,
  280. 'displayInclusive' => $displayFormat,
  281. 'customerGroup' => 0,
  282. ));
  283. $GLOBALS['RetailPrice'] = '<strike>' . formatPrice($retailPrice) . '</strike>';
  284. $GLOBALS['PriceLabel'] = GetLang('YourPrice');
  285. $savings = $retailPrice - $productPrice;
  286. $string = sprintf(getLang('YouSave'), '<span class="YouSaveAmount">'.formatPrice($savings).'</span>');
  287. $GLOBALS['YouSave'] = '<span class="YouSave">'.$string.'</span>';
  288. }
  289. }
  290. }
  291.  
  292. $productId2 = $this->productClass->GetProductId();
  293. $GLOBALS['ProZ'] = simulador_de_rodape($productId2);
  294.  
  295. $valordoproduto = ValorProduto($this->productClass->GetProductId());
  296. $sem_juros_pagseguro = GetModuleVariable('checkout_pagseguro','semjuros');
  297. $desconto_a_vista = GetModuleVariable('addon_parcelas','descontoboletodeposito');
  298. $splitss = (int) ($valordoproduto/5);
  299.  
  300. if($splitss<=$sem_juros_pagseguro){
  301. $div = $splitss;
  302. }else{
  303. $div = $sem_juros_pagseguro;
  304. }
  305.  
  306. if($valordoproduto<=5){
  307. $div = 1;
  308. }
  309.  
  310. for($j=1; $j<=$div;$j++) {
  311. if($div==$j){
  312. $pag ="<br><b>".$j."x</b> de <u>".CurrencyConvertFormatPrice(($valordoproduto/$j), 1, 0)."</u> sem juros!";
  313. }
  314. }
  315.  
  316. $GLOBALS['PG'] = $pag;
  317.  
  318. if($desconto_a_vista>0){
  319. $valordoproduto = $valordoproduto-(($valordoproduto/100)*$desconto_a_vista);
  320. $dep = '<br>ou <u>'.CurrencyConvertFormatPrice($valordoproduto, 1, 0).'</u>';
  321. }else{
  322. $dep = 'ou <u>'.CurrencyConvertFormatPrice($valordoproduto, 1, 0).'</u>';
  323. }
  324.  
  325. if($desconto_a_vista>0){
  326. $GLOBALS['Hidedesc'] = "";
  327. }else{
  328. $GLOBALS['Hidedesc'] = 'none';
  329. }
  330.  
  331. if($desconto_a_vista>0){
  332. $valordoproduto = $valordoproduto-(($valordoproduto/100)*$desconto_a_vista);
  333. $dep2 = '&Agrave; vista ('.$desconto_a_vista.'% desconto)';
  334. }else{
  335. $dep2 = '<b>&Agrave; vista</b>';
  336. }
  337.  
  338. $GLOBALS['AV'] = $dep;
  339. $GLOBALS['AV2'] = $dep2;
  340.  
  341. $ss = GetModuleVariable('addon_somentelogado','lg');
  342. if(!CustomerIsSignedIn() && $ss=='sim'){
  343. $GLOBALS['PG'] = '';
  344. $GLOBALS['AV'] = '';
  345. $GLOBALS['HideShipping'] = 'none';
  346. $GLOBALS['HidePrice'] = "display: none;";
  347. $GLOBALS['HideRRP'] = 'none';
  348. }
  349. }
  350.  
  351. /**
  352. * Setup the purchasing options such as quantity box, stock messages,
  353. * add to cart button, product fields etc.
  354. */
  355. private function SetPurchasingOptions()
  356. {
  357. if(!$this->productClass->IsPurchasingAllowed()) {
  358. $GLOBALS['DisplayAdd'] = 'none';
  359. return;
  360. }
  361.  
  362. $GLOBALS['AddToCartButton'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ProductAddToCartButton');
  363.  
  364. $GLOBALS['CartLink'] = CartLink();
  365.  
  366. $GLOBALS['ProductCartQuantity'] = '';
  367. if(isset($GLOBALS['CartQuantity'.$this->productClass->GetProductId()])) {
  368. $GLOBALS['ProductCartQuantity'] = (int)$GLOBALS['CartQuantity'.$this->productClass->GetProductId()];
  369. }
  370.  
  371. // If we're using a cart quantity drop down, load that
  372. if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
  373. if ($this->productClass->GetMinQty()) {
  374. $GLOBALS['Quantity' . $this->productClass->GetMinQty()] = 'selected="selected"';
  375. } else {
  376. $GLOBALS['Quantity1'] = 'selected="selected"';
  377. }
  378. $GLOBALS['QtyOptionZero'] = "";
  379. $GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
  380. }
  381. // Otherwise, load the textbox
  382. else {
  383. $GLOBALS['ProductQuantity'] = 1;
  384. $GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
  385. }
  386.  
  387. // Can we sell this product/option
  388. $saleable = IsProductSaleable($this->productClass->GetProduct());
  389. $variations = $this->productClass->GetProductVariationOptions();
  390. if(!empty($variations) && $this->productClass->GetProductInventoryTracking() == 2) {
  391. $productInStock = true;
  392. }
  393. else {
  394. $productInStock = $saleable;
  395. }
  396.  
  397. if($productInStock == true) {
  398. $GLOBALS['SNIPPETS']['SideAddItemSoldOut'] = '';
  399. $GLOBALS['DisplayAdd'] = "";
  400.  
  401. if (GetConfig('FastCartAction') == 'popup' && GetConfig('ShowCartSuggestions')) {
  402. $GLOBALS['FastCartButtonJs'] = ' && fastCartAction(event)';
  403. }
  404. }
  405. else if($this->productClass->IsPurchasingAllowed()) {
  406. $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideAddItemSoldOut");
  407. $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
  408. $GLOBALS['SNIPPETS']['SideAddItemSoldOut'] = $output;
  409.  
  410. $GLOBALS['BuyBoxSoldOut'] = "ProductBuyBoxSoldOut";
  411. $GLOBALS['DisplayAdd'] = "none";
  412. $GLOBALS['ISC_LANG']['BuyThisItem'] = GetLang('ItemUnavailable');
  413. }
  414.  
  415. if(GetConfig('ShowAddToCartQtyBox') == 1) {
  416. $GLOBALS['DisplayAddQty'] = $GLOBALS['DisplayAdd'];
  417. }
  418. else {
  419. $GLOBALS['DisplayAddQty'] = "none";
  420. }
  421.  
  422. if($this->productClass->IsPurchasingAllowed()) {
  423. $this->LoadEventDate();
  424. $this->LoadProductFieldsLayout();
  425. }
  426.  
  427. $GLOBALS['ShowAddToCartQtyBox'] = GetConfig('ShowAddToCartQtyBox');
  428. }
  429.  
  430. /**
  431. * Setup the list of variations for this product if it has any.
  432. */
  433. private function SetProductVariations()
  434. {
  435. $GLOBALS['VariationList'] = '';
  436. $GLOBALS['SNIPPETS']['VariationList'] = '';
  437. $GLOBALS['HideVariationList'] = '';
  438. $GLOBALS['ProductOptionRequired'] = "false";
  439.  
  440. // Are there any product variations?
  441. $variationOptions = $this->productClass->GetProductVariationOptions();
  442.  
  443. if(empty($variationOptions)) {
  444. $GLOBALS['HideVariationList'] = 'display:none;';
  445. return;
  446. }
  447.  
  448. $variationValues = $this->productClass->GetProductVariationOptionValues();
  449.  
  450. // Is a product option required when adding the product to the cart?
  451. if($this->productClass->IsOptionRequired()) {
  452. $GLOBALS['ProductOptionRequired'] = "true";
  453. }
  454.  
  455. if(count($variationOptions) == 1) {
  456. $onlyOneVariation = true;
  457. $GLOBALS['OptionMessage'] = GetLang('ChooseAnOption');
  458. }
  459. else {
  460. $GLOBALS['OptionMessage'] = GetLang('ChooseOneOrMoreOptions');
  461. $onlyOneVariation = false;
  462. }
  463. $useSelect = false;
  464. $GLOBALS['VariationNumber'] = 0;
  465.  
  466. foreach($variationOptions as $optionName) {
  467. // If this is the only variation then instead of select boxes, just show radio buttons
  468. $GLOBALS['VariationChooseText'] = "";
  469. $GLOBALS['VariationNumber']++;
  470. $GLOBALS['VariationName'] = isc_html_escape($optionName);
  471. $GLOBALS['SNIPPETS']['OptionList'] = '';
  472.  
  473. // Fixes cases where for one reason or another there are no options for a specific variation
  474. // Botched import?
  475. if(empty($variationValues[$optionName])) {
  476. continue;
  477. }
  478.  
  479. if($onlyOneVariation && count($variationValues[$optionName]) <= 5 && !$this->productClass->IsOptionRequired()) {
  480. $GLOBALS['OptionId'] = 0;
  481. $GLOBALS['OptionValue'] = GetLang('zNone');
  482. $GLOBALS['OptionChecked'] = "checked=\"checked\"";
  483. $GLOBALS['SNIPPETS']['OptionList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVariationListSingleItem");
  484. }
  485. else if($onlyOneVariation && count($variationValues[$optionName]) > 5) {
  486. $useSelect = true;
  487. }
  488.  
  489. // Build the list of options
  490. $GLOBALS['OptionChecked'] = '';
  491. if (isset($variationValues[$optionName])) {
  492. foreach($variationValues[$optionName] as $optionid => $value) {
  493. $GLOBALS['OptionId'] = (int)$optionid;
  494. $GLOBALS['OptionValue'] = isc_html_escape($value);
  495. if($onlyOneVariation && !$useSelect) {
  496. $GLOBALS['SNIPPETS']['OptionList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVariationListSingleItem");
  497. }
  498. else {
  499. $GLOBALS['SNIPPETS']['OptionList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVariationListMultipleItem");
  500. }
  501. }
  502. }
  503.  
  504. if($onlyOneVariation == true && !$useSelect) {
  505. $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVariationListSingle");
  506. }
  507. else {
  508. $GLOBALS['VariationChooseText'] = GetLang('ChooseA')." ".isc_html_escape($optionName);
  509. $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVariationListMultiple");
  510. }
  511. $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
  512. $GLOBALS['SNIPPETS']['VariationList'] .= $output;
  513. }
  514. }
  515.  
  516. /**
  517. * Set the event date entry fields up.
  518. */
  519. public function LoadEventDate()
  520. {
  521. $output = '';
  522. $productId = $this->productClass->GetProductId();
  523. $fields = ($this->productClass->GetEventDateFields());
  524.  
  525.  
  526. if (empty($fields['prodeventdaterequired'])) {
  527. return;
  528. }
  529.  
  530. $GLOBALS['EventDateName'] = '<span class="Required">*</span>'.$fields['prodeventdatefieldname'];
  531.  
  532. $from_stamp = $fields['prodeventdatelimitedstartdate'];
  533. $to_stamp = $fields['prodeventdatelimitedenddate'];
  534.  
  535. $to_day = isc_date("d", $to_stamp);
  536. $from_day = isc_date("d", $from_stamp);
  537.  
  538. $to_month = isc_date("m", $to_stamp);
  539. $from_month = isc_date("m", $from_stamp);
  540.  
  541. $to_year = isc_date("Y", $to_stamp);
  542. $from_year = isc_date("Y", $from_stamp);
  543.  
  544. $to_date = isc_date('jS M Y',$to_stamp);
  545. $from_date = isc_date('jS M Y',$from_stamp);
  546.  
  547. $eventDateInvalidMessage = sprintf(GetLang('EventDateInvalid'), strtolower($fields['prodeventdatefieldname']));
  548.  
  549. $comp_date = '';
  550. $comp_date_end = '';
  551. $eventDateErrorMessage = '';
  552.  
  553. $edlimited = $fields['prodeventdatelimited'];
  554. if (empty($edlimited)) {
  555. $from_year = isc_date('Y');
  556. $to_year = isc_date('Y',isc_gmmktime(0, 0, 0, 0,0,isc_date('Y')+5));
  557. $GLOBALS['EventDateLimitations'] = '';
  558. } else {
  559. if ($fields['prodeventdatelimitedtype'] == 1) {
  560. $GLOBALS['EventDateLimitations'] = sprintf(GetLang('EventDateLimitations1'),$from_date,$to_date);
  561.  
  562. $comp_date = isc_date('Y/m/d', $from_stamp);
  563. $comp_date_end = isc_date('Y/m/d', $to_stamp);
  564.  
  565. $eventDateErrorMessage = sprintf(GetLang('EventDateLimitationsLong1'), strtolower($fields['prodeventdatefieldname']),$from_date, $to_date);
  566.  
  567. } else if ($fields['prodeventdatelimitedtype'] == 2) {
  568. $to_year = isc_date('Y', isc_gmmktime(0, 0, 0, isc_date('m',$from_stamp),isc_date('d',$from_stamp),isc_date('Y',$from_stamp)+5));
  569. $GLOBALS['EventDateLimitations'] = sprintf(GetLang('EventDateLimitations2'), $from_date);
  570.  
  571. $comp_date = isc_date('Y/m/d', $from_stamp);
  572.  
  573. $eventDateErrorMessage = sprintf(GetLang('EventDateLimitationsLong2'), strtolower($fields['prodeventdatefieldname']),$from_date);
  574.  
  575.  
  576. } else if ($fields['prodeventdatelimitedtype'] == 3) {
  577. $from_year = isc_date('Y', time());
  578. $GLOBALS['EventDateLimitations'] = sprintf(GetLang('EventDateLimitations3'),$to_date);
  579.  
  580. $comp_date = isc_date('Y/m/d', $to_stamp);
  581.  
  582. $eventDateErrorMessage = sprintf(GetLang('EventDateLimitationsLong3'), strtolower($fields['prodeventdatefieldname']),$to_date);
  583. }
  584. }
  585.  
  586.  
  587. $GLOBALS['OverviewToDays'] = $this->GetDayOptions();
  588. $GLOBALS['OverviewToMonths'] = $this->GetMonthOptions();
  589. $GLOBALS['OverviewToYears'] = $this->GetYearOptions($from_year,$to_year);
  590.  
  591. $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('EventDate');
  592. $GLOBALS['SNIPPETS']['EventDate'] = $output;
  593.  
  594. $GLOBALS['EventDateJavascript'] = sprintf("<script type=\"text/javascript\"> var eventDateData = {type:'%s',compDate:'%s',compDateEnd:'%s',invalidMessage:'%s',errorMessage:'%s'}; </script>",
  595. $fields['prodeventdatelimitedtype'],
  596. $comp_date,
  597. $comp_date_end,
  598. $eventDateInvalidMessage,
  599. $eventDateErrorMessage
  600. );
  601. }
  602.  
  603. /**
  604. * Generate a list of the day options available for event dates.
  605. *
  606. * @return string HTML string containing option tags for days 1 to 31.
  607. */
  608. private function GetDayOptions()
  609. {
  610. $output = '<option value=\'-1\'>---</option>';
  611. for($i = 1; $i <= 31; $i++) {
  612. $output .= sprintf("<option value='%d'>%s</option>", $i, $i);
  613. }
  614.  
  615. return $output;
  616. }
  617.  
  618. /**
  619. * Generate select options for selecting a delivery date month.
  620. *
  621. * @return string HTML string containing option tags for available months.
  622. */
  623. private function GetMonthOptions()
  624. {
  625. $output = '<option value=\'-1\'>---</option>';
  626. for($i = 1; $i <= 12; $i++) {
  627. $stamp = isc_gmmktime(0, 0, 0, $i, 1, 2000);
  628. $month = isc_date("M", $stamp);
  629. $output .= sprintf("<option value='%d'>%s</option>", $i, $month);
  630. }
  631.  
  632. return $output;
  633. }
  634.  
  635. /**
  636. * Generate select options for selecting a delivery date year.
  637. *
  638. * @param int $from The year to start from.
  639. * @param int $to The year to end at.
  640. * @return string HTML string containing option tags for available years.
  641. */
  642. private function GetYearOptions($from, $to)
  643. {
  644. $output = '<option value=\'-1\'>---</option>';
  645. for($i = $from; $i <= $to; $i++) {
  646. $output .= sprintf("<option value='%d'>%s</option>", $i, $i);
  647. }
  648.  
  649. return $output;
  650. }
  651.  
  652. /**
  653. * Generate the configurable product fields if this product has any.
  654. */
  655. public function LoadProductFieldsLayout()
  656. {
  657. $output = '';
  658. $productId = $this->productClass->GetProductId();
  659. $fields = $this->productClass->GetProductFields($productId);
  660. if(empty($fields)) {
  661. return;
  662. }
  663.  
  664. foreach($fields as $field) {
  665. $GLOBALS['ProductFieldType'] = isc_html_escape($field['type']);
  666. $GLOBALS['ItemId'] = 0;
  667. $GLOBALS['ProductFieldId'] = (int)$field['id'];
  668. $GLOBALS['ProductFieldName'] = isc_html_escape($field['name']);
  669. $GLOBALS['ProductFieldInputSize'] = '';
  670. $GLOBALS['ProductFieldRequired'] = '';
  671. $GLOBALS['FieldRequiredClass'] = '';
  672. $GLOBALS['CheckboxFieldNameLeft'] = '';
  673. $GLOBALS['CheckboxFieldNameRight'] = '';
  674. $GLOBALS['HideCartFileName'] = 'display:none';
  675. $GLOBALS['HideDeleteFileLink'] = 'display:none';
  676. $GLOBALS['HideFileHelp'] = "display:none";
  677. $snippetFile = 'ProductFieldInput';
  678.  
  679. switch ($field['type']) {
  680. case 'textarea': {
  681. $snippetFile = 'ProductFieldTextarea';
  682. break;
  683. }
  684. case 'file': {
  685. if(!$GLOBALS['ISC_CLASS_TEMPLATE']->getIsMobileDevice()) {
  686. $GLOBALS['HideFileHelp'] = "";
  687. $GLOBALS['FileSize'] = Store_Number::niceSize($field['fileSize']*1024);
  688. $GLOBALS['FileTypes'] = $field['fileType'];
  689. }
  690. if($field['required']) {
  691. $this->hasRequiredFileFields = true;
  692. }
  693. break;
  694. }
  695. case 'checkbox': {
  696. $GLOBALS['CheckboxFieldNameLeft'] = isc_html_escape($field['name']);
  697. $snippetFile = 'ProductFieldCheckbox';
  698. break;
  699. }
  700. case 'select':
  701. $options = explode(',', $field['selectOptions']);
  702. $optionStr = '<option value="">' . GetLang('PleaseChooseAnOption') . '</option>';
  703. foreach ($options as $option) {
  704. $option = trim($option);
  705. $optionStr .= "<option value=\"" . isc_html_escape($option) . "\">" . isc_html_escape($option) . "</option>\n";
  706. }
  707. $GLOBALS['SelectOptions'] = $optionStr;
  708. $snippetFile = 'ProductFieldSelect';
  709. break;
  710. default: break;
  711. }
  712.  
  713. if($field['required']) {
  714. $GLOBALS['ProductFieldRequired'] = '<span class="Required">*</span>';
  715. $GLOBALS['FieldRequiredClass'] = 'FieldRequired';
  716. }
  717. $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippetFile);
  718. }
  719. $GLOBALS['SNIPPETS']['ProductFieldsList'] = $output;
  720. }
  721.  
  722. /**
  723. * Generate the bulk discounts window if this product has any.
  724. */
  725. public function SetBulkDiscounts()
  726. {
  727. // Does this product have any bulk discount?
  728. if (!$this->productClass->CanUseBulkDiscounts()) {
  729. $GLOBALS['HideBulkDiscountLink'] = 'none';
  730. return;
  731. }
  732.  
  733. $GLOBALS['HideBulkDiscountLink'] = '';
  734. $GLOBALS['BulkDiscountThickBoxTitle'] = sprintf(GetLang('BulkDiscountThickBoxTitle'), isc_html_escape($this->productClass->GetProductName()));
  735.  
  736. $rates = '';
  737. $prevMax = 0;
  738. $query = "
  739. SELECT *
  740. FROM [|PREFIX|]product_discounts
  741. WHERE discountprodid = " . (int)$this->productClass->GetProductId() . "
  742. ORDER BY IF(discountquantitymax > 0, discountquantitymax, discountquantitymin) ASC
  743. ";
  744.  
  745. $result = $this->db->Query($query);
  746. while ($row = $this->db->Fetch($result)) {
  747.  
  748. $range = '';
  749. if ($row['discountquantitymin'] == 0) {
  750. $range = isc_html_escape(intval($prevMax+1) . ' - ' . (int)$row['discountquantitymax']);
  751. } else if ($row['discountquantitymax'] == 0) {
  752. $range = isc_html_escape(sprintf(GetLang('BulkDiscountThickBoxDiscountOrAbove'), (int)$row['discountquantitymin']));
  753. } else {
  754. $range = isc_html_escape((int)$row['discountquantitymin'] . ' - ' . (int)$row['discountquantitymax']);
  755. }
  756.  
  757. $discount = '';
  758. switch (isc_strtolower(isc_html_escape($row['discounttype']))) {
  759. case 'price':
  760. $discount = sprintf(GetLang('BulkDiscountThickBoxDiscountPrice'), $range, CurrencyConvertFormatPrice(isc_html_escape($row['discountamount'])));
  761. break;
  762.  
  763. case 'percent':
  764. $discount = sprintf(GetLang('BulkDiscountThickBoxDiscountPercent'), $range, (int)$row['discountamount'] . '%');
  765. break;
  766.  
  767. case 'fixed';
  768. $price = CalculateCustGroupDiscount($this->productClass->GetProductId(),$row['discountamount']);
  769. $discount = sprintf(GetLang('BulkDiscountThickBoxDiscountFixed'), $range, CurrencyConvertFormatPrice(isc_html_escape($price)));
  770. break;
  771. }
  772.  
  773. $rates .= '<li>' . isc_html_escape($discount) . '</li>';
  774.  
  775. if ($row['discountquantitymax'] !== 0) {
  776. $prevMax = $row['discountquantitymax'];
  777. }
  778. }
  779.  
  780. $GLOBALS['BulkDiscountThickBoxRates'] = $rates;
  781. $GLOBALS['ProductBulkDiscountThickBox'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductBulkDiscountThickBox");
  782. }
  783.  
  784. /**
  785. * Fetch the vendor name/details if there is one for this product.
  786. */
  787. private function SetVendorDetails()
  788. {
  789. // Get the vendor information
  790. $vendorInfo = $this->productClass->GetProductVendor();
  791. $GLOBALS['HideVendorDetails'] = 'display: none';
  792. $GLOBALS['VendorName'] = '';
  793. if(is_array($vendorInfo)) {
  794. $GLOBALS['HideVendorDetails'] = '';
  795. $GLOBALS['VendorName'] = '<a href="'.VendorLink($vendorInfo).'">'.isc_html_escape($vendorInfo['vendorname']).'</a>';
  796. }
  797. }
  798.  
  799. /**
  800. * Setup gift wrapping message if it is available for this product.
  801. */
  802. private function SetWrappingDetails()
  803. {
  804. // Can this product be gift wrapped? And do we have any gift wrapping options set up?
  805. if(!$this->productClass->CanBeGiftWrapped() || $this->productClass->GetProductType() != PT_PHYSICAL) {
  806. $GLOBALS['HideGiftWrapMessage'] = 'display: none';
  807. return;
  808. }
  809.  
  810. $GLOBALS['HideGiftWrapMessage'] = '';
  811. $GLOBALS['GiftWrappingAvailable'] = GetLang('GiftWrappingOptionsAvailable');
  812. }
  813.  
  814. /**
  815. * Generate the product images/thumbnails to be shown.
  816. */
  817. private function SetProductImages()
  818. {
  819.  
  820. $GLOBALS['ProductThumbWidth'] = ISC_PRODUCT_IMAGE::getSizeWidth(ISC_PRODUCT_IMAGE_SIZE_STANDARD);
  821. $GLOBALS['ProductThumbHeight'] = ISC_PRODUCT_IMAGE::getSizeHeight(ISC_PRODUCT_IMAGE_SIZE_STANDARD);
  822.  
  823. $GLOBALS['ProductMaxTinyWidth'] = ISC_PRODUCT_IMAGE::getSizeWidth(ISC_PRODUCT_IMAGE_SIZE_TINY);
  824. $GLOBALS['ProductMaxTinyHeight'] = ISC_PRODUCT_IMAGE::getSizeHeight(ISC_PRODUCT_IMAGE_SIZE_TINY);
  825.  
  826.  
  827.  
  828. $GLOBALS['ProductTinyBoxWidth'] = $GLOBALS['ProductMaxTinyWidth']+4;
  829. $GLOBALS['ProductTinyBoxHeight'] = $GLOBALS['ProductMaxTinyHeight']+4;
  830.  
  831.  
  832. $GLOBALS['ProductMaxZoomWidth'] = ISC_PRODUCT_IMAGE::getSizeWidth(ISC_PRODUCT_IMAGE_SIZE_ZOOM);
  833. $GLOBALS['ProductMaxZoomHeight'] = ISC_PRODUCT_IMAGE::getSizeHeight(ISC_PRODUCT_IMAGE_SIZE_ZOOM);
  834.  
  835. $GLOBALS['ProductZoomWidth'] = ISC_PRODUCT_IMAGE::getSizeWidth(ISC_PRODUCT_IMAGE_SIZE_ZOOM);
  836. $GLOBALS['ProductZoomHeight'] = ISC_PRODUCT_IMAGE::getSizeHeight(ISC_PRODUCT_IMAGE_SIZE_ZOOM);
  837.  
  838.  
  839. $productImages = ISC_PRODUCT_IMAGE::getProductImagesFromDatabase($GLOBALS['ProductId']);
  840. $GLOBALS['NumProdImages'] = count($productImages);
  841.  
  842. $GLOBALS['CurrentProdThumbImage'] = 0;
  843. $thumb = '';
  844. $curZoomImage = '';
  845. $GLOBALS['SNIPPETS']['ProductTinyImages'] = '';
  846. $GLOBALS['HideImageCarousel'] = 'display:none;';
  847. $GLOBALS['HideMorePicturesLink'] = 'display:none;';
  848. $thumbImageDescription = '';
  849. $i = 0;
  850.  
  851. $GLOBALS['ProdImageJavascript'] = '';
  852. $GLOBALS['ProdImageZoomJavascript'] = '';
  853. $GLOBALS['LightBoxImageList'] = '';
  854. $GLOBALS['ZoomImageMaxWidth'] = 0;
  855. $GLOBALS['ZoomImageMaxHeight'] = 0;
  856. $GLOBALS['ZoomImageMaxWidthHeight'] = 0;
  857. $GLOBALS['HideAlwaysLinkedMorePicturesLink'] = 'display: none';
  858.  
  859. if ($GLOBALS['NumProdImages']) {
  860. //Show image carousel
  861.  
  862. if ($GLOBALS['NumProdImages'] == 2) {
  863. $var = "MorePictures1";
  864. } else if ($GLOBALS['NumProdImages'] == 1) {
  865. $var = "SeeLargerImage";
  866. } else {
  867. $var = "MorePictures2";
  868. }
  869.  
  870. $GLOBALS['SeeMorePictures'] = sprintf(GetLang($var), count($productImages) - 1);
  871. $GLOBALS['HideAlwaysLinkedMorePicturesLink'] = '';
  872.  
  873. if (GetConfig('ProductImagesTinyThumbnailsEnabled')) {
  874. $GLOBALS['HideImageCarousel'] = '';
  875. } else {
  876. $GLOBALS['HideMorePicturesLink'] = '';
  877. }
  878.  
  879. $continue=false;
  880.  
  881. foreach ($productImages as $productImage) {
  882.  
  883. $thumbURL = '';
  884. $zoomImageURL = '';
  885.  
  886. try{
  887. $thumbURL = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true);
  888. //$GLOBALS['ProductThumbURL'] = $thumbURL;
  889. } catch (Exception $exception) {
  890. // do nothing, will result in returning blank string, which is fine
  891. }
  892.  
  893. try{
  894. $zoomImageURL = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true);
  895. } catch (Exception $exception) {
  896. // do nothing, will result in returning blank string, which is fine
  897. }
  898.  
  899. if($thumbURL == '' && $zoomImageURL == '') {
  900. continue;
  901. }
  902.  
  903. $resizedZoomDimension = $productImage->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_ZOOM);
  904. $resizedTinyDimension = $productImage->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_TINY);
  905.  
  906. //calculate the max zoom image width and height
  907. if ($GLOBALS['ZoomImageMaxWidth'] < $resizedZoomDimension[ISC_PRODUCT_IMAGE_DIMENSIONS_WIDTH]) {
  908.  
  909. $GLOBALS['ZoomImageMaxWidth'] = $resizedZoomDimension[ISC_PRODUCT_IMAGE_DIMENSIONS_WIDTH];
  910. //the height of the image has got the max width needed to calulate the image fancy box size.
  911. $GLOBALS['ZoomImageMaxWidthHeight'] = $resizedZoomDimension[ISC_PRODUCT_IMAGE_DIMENSIONS_HEIGHT];
  912. }
  913.  
  914. if ($GLOBALS['ZoomImageMaxHeight'] < $resizedZoomDimension[ISC_PRODUCT_IMAGE_DIMENSIONS_HEIGHT]) {
  915. $GLOBALS['ZoomImageMaxHeight'] = $resizedZoomDimension[ISC_PRODUCT_IMAGE_DIMENSIONS_HEIGHT];
  916. //the width of the image has got the max height needed to calulate the image fancy box size.
  917. $GLOBALS['ZoomImageMaxHeightWidth'] = $resizedZoomDimension[ISC_PRODUCT_IMAGE_DIMENSIONS_HEIGHT];
  918. }
  919.  
  920. $GLOBALS['ImageDescription'] = isc_html_escape($productImage->getDescription());
  921. if($GLOBALS['ImageDescription'] == '') {
  922. $GLOBALS['ImageDescription'] = GetLang("Image") . " " . ($i + 1);
  923. }
  924.  
  925. //show image carousel
  926. if(GetConfig('ProductImagesTinyThumbnailsEnabled')==1) {
  927.  
  928. $GLOBALS['ProdImageJavascript'] .= "
  929. ThumbURLs[".$i."] = " . isc_json_encode($thumbURL) . ";
  930. ProductImageDescriptions[".$i."] = " . isc_json_encode($GLOBALS['ImageDescription']) . ";
  931. ";
  932. $GLOBALS['TinyImageOverJavascript'] = "showProductThumbImage(".$i.")";
  933. //$GLOBALS['ProductTinyImageURL'] = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_TINY, true);
  934.  
  935. try{
  936. $GLOBALS['ProductTinyImageURL'] = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_TINY, true);
  937. $GLOBALS['ProductThumbURL'] = $thumbURL;
  938. } catch (Exception $exception) {
  939. // do nothing, will result in returning blank string, which is fine
  940. }
  941.  
  942. $GLOBALS['ProductTinyZoom'] = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true);
  943.  
  944. $GLOBALS['ProductThumbIndex'] = $i;
  945. if(GetConfig('ProductImageMode') == 'lightbox') {
  946. $GLOBALS['TinyImageClickJavascript'] = "showProductImageLightBox(".$i."); return false;";
  947.  
  948. } else {
  949. $GLOBALS['TinyImageClickJavascript'] = "showProductImage('".GetConfig('ShopPath')."/productimage.php', ".$GLOBALS['ProductId'].", ".$i.");";
  950. }
  951.  
  952. $GLOBALS['TinyImageWidth'] = $resizedTinyDimension[ISC_PRODUCT_IMAGE_DIMENSIONS_WIDTH];
  953. $GLOBALS['TinyImageHeight'] = $resizedTinyDimension[ISC_PRODUCT_IMAGE_DIMENSIONS_HEIGHT];
  954.  
  955. $GLOBALS['TinyImageTopPadding'] = floor(($GLOBALS['ProductMaxTinyHeight'] - $GLOBALS['TinyImageHeight']) / 2);
  956. $GLOBALS['SNIPPETS']['ProductTinyImages'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductTinyImage");
  957. $continue = true;
  958. }
  959.  
  960. if(GetConfig('ProductImagesImageZoomEnabled') == 1) {
  961. //check if zoom image is large enough for image zoomer
  962. if($resizedZoomDimension[ISC_PRODUCT_IMAGE_DIMENSIONS_WIDTH]<ISC_PRODUCT_IMAGE_MIN_ZOOM_WIDTH && $resizedZoomDimension[ISC_PRODUCT_IMAGE_DIMENSIONS_HEIGHT]<ISC_PRODUCT_IMAGE_MIN_ZOOM_HEIGHT) {
  963. $zoomImageURL = '';
  964. }
  965. $GLOBALS['ProdImageZoomJavascript'] .= "
  966. ZoomImageURLs[".$i."] = " . isc_json_encode($zoomImageURL) . ";
  967. ";
  968. $continue = true;
  969. }
  970.  
  971. // $GLOBALS['ProductZoomImageURL'] = $zoomImageURL;
  972.  
  973. //this image is the product page thumbnail
  974. if($i==0) {
  975. //get the thumb image for product page
  976. $thumb = $thumbURL;
  977. $curZoomImage = $zoomImageURL;
  978. $thumbImageDescription = $GLOBALS['ImageDescription'];
  979. //if there is no need to loop through images anymore, get out from the loop.
  980. if($continue === false) {
  981. break;
  982. }
  983. }
  984. $i++;
  985. }
  986. }
  987.  
  988. $GLOBALS['VisibleImageTotal'] = $i+1;
  989.  
  990. $GLOBALS['ShowImageZoomer'] = GetConfig('ProductImagesImageZoomEnabled');
  991. if ($GLOBALS['ShowImageZoomer']) {
  992. $GLOBALS['SNIPPETS']['ProductImageZoomer'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductImageZoomer");
  993. }
  994. $GLOBALS['ZoomImageURL'] = $curZoomImage;
  995.  
  996. //if no product thumb images
  997. if($thumb == '') {
  998. if(GetConfig('DefaultProductImage') == 'template') {
  999. $thumb = $GLOBALS['IMG_PATH'].'/ProductDefault.gif';
  1000. }
  1001. else {
  1002. $thumb = GetConfig('ShopPath').'/'.GetConfig('DefaultProductImage');
  1003. }
  1004. }
  1005.  
  1006. // need to check for variation images
  1007. //$GLOBALS['HideOnNoImages'] = 'display: none;';
  1008. $GLOBALS['ImageDescription'] = $thumbImageDescription;
  1009. $GLOBALS['ThumbImageURL'] = $thumb;
  1010.  
  1011.  
  1012. //image popup javascript for the thumbnail image when the page is loaded
  1013. $imagePopupLink = "showProductImage('".GetConfig('ShopPath')."/productimage.php', ".$GLOBALS['ProductId'].");";
  1014. $GLOBALS['ImagePopupLink'] = $imagePopupLink;
  1015. $GLOBALS['TinyImageClickJavascript'] = $imagePopupLink;
  1016.  
  1017. // If we're showing images as a lightbox, we need to load up the URLs for the other images for this product
  1018. if(GetConfig('ProductImageMode') == 'lightbox') {
  1019. $GLOBALS['TinyImageClickJavascript'] = "showProductImageLightBox(); return false;";
  1020. $GLOBALS['LightBoxImageJavascript'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ProductImagesLightBox');
  1021. }
  1022.  
  1023. if ($GLOBALS['NumProdImages']) {
  1024. $GLOBALS['SNIPPETS']['ProductThumbImage'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ProductThumbImage');
  1025. } else {
  1026. $GLOBALS['SNIPPETS']['ProductThumbImage'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ProductThumbImagePlaceholder');
  1027. }
  1028. }
  1029.  
  1030. /**
  1031. * Setup product dimension details.
  1032. */
  1033. private function SetProductDimensions()
  1034. {
  1035. if ($this->productClass->GetProductType() == PT_PHYSICAL && GetConfig('ShowProductWeight')) {
  1036. // It's a physical product
  1037. $GLOBALS['ProductWeight'] = $this->productClass->GetWeight();
  1038. }
  1039. else {
  1040. // It's a digital product
  1041. $GLOBALS['HideWeight'] = "none";
  1042. }
  1043.  
  1044. $product = $this->productClass->GetProduct();
  1045. $dimensions = array(
  1046. 'ProductHeight' => 'prodheight',
  1047. 'ProductWidth' => 'prodwidth',
  1048. 'ProductDepth' => 'proddepth'
  1049. );
  1050. foreach($dimensions as $global => $field) {
  1051. if($product[$field] > 0) {
  1052. $GLOBALS[$global] = FormatWeight($product[$field], false);
  1053. $hasDimensions = true;
  1054. }
  1055. else {
  1056. $GLOBALS['Hide'.$global] = 'display: none';
  1057. }
  1058. }
  1059.  
  1060. if(!isset($hasDimensions)) {
  1061. $GLOBALS['HideDimensions'] = 'display: none';
  1062. }
  1063. }
  1064.  
  1065. /**
  1066. * Setup the number of product reviews etc if this product has any.
  1067. */
  1068. private function SetProductReviews()
  1069. {
  1070. if(!GetConfig('ShowProductRating')) {
  1071. $GLOBALS['HideRating'] = "none";
  1072. }
  1073.  
  1074. $GLOBALS['Rating'] = $this->productClass->GetRating();
  1075. if($GLOBALS['Rating'] == 0) {
  1076. $GLOBALS['HideRating'] = 'none';
  1077. }
  1078. $GLOBALS['ProductNumReviews'] = (int) $this->productClass->GetNumReviews();
  1079.  
  1080. // Calcula a quantidade de avaliações e coloca dentro de um
  1081. $GLOBALS['ProductRating'] = '<div class="rating-box" style="float: none;">';
  1082. for ($i=0; $i < 5; $i++) {
  1083. if($i <= $this->productClass->GetRating()){
  1084. $GLOBALS['ProductRating'] .= '<i class="fa fa-star"></i>';
  1085. } else {
  1086. $GLOBALS['ProductRating'] .= '<i class="fa fa-star-half-empty"></i>';
  1087. }
  1088. }
  1089. $GLOBALS['ProductRating'] .= '</div>';
  1090.  
  1091. // Are reviews disabled? Then don't show anything related to reviews
  1092. if(!getProductReviewsEnabled()) {
  1093. $GLOBALS['HideReviewLink'] = "none";
  1094. $GLOBALS['HideRating'] = "none";
  1095. $GLOBALS['HideReviews'] = "none";
  1096. }
  1097. else {
  1098. // How many reviews are there?
  1099. if ($this->productClass->GetNumReviews() == 0) {
  1100. $GLOBALS['HideReviewLink'] = "none";
  1101. }
  1102. else {
  1103. $GLOBALS['HideNoReviewsMessage'] = "none";
  1104. if ($this->productClass->GetNumReviews() == 1) {
  1105. $GLOBALS['ReviewLinkText'] = GetLang('ReviewLinkText1');
  1106. } else {
  1107. $GLOBALS['ReviewLinkText'] = sprintf(GetLang('ReviewLinkText2'), $this->productClass->GetNumReviews());
  1108. }
  1109. if (GetConfig('EnableProductTabs')) {
  1110. $GLOBALS['ReviewLinkOnClick'] = "ActiveProductTab('ProductReviews_Tab'); return false;";
  1111. }
  1112. }
  1113. }
  1114.  
  1115. }
  1116.  
  1117. /**
  1118. * Setup selected brand for this product.
  1119. */
  1120. public function SetBrandDetails()
  1121. {
  1122. if(!$this->productClass->GetBrandName() || !GetConfig('ShowProductBrand')) {
  1123. $GLOBALS['HideBrandLink'] = 'none';
  1124. return false;
  1125. }
  1126.  
  1127. $GLOBALS['BrandName'] = isc_html_escape($this->productClass->GetBrandName());
  1128. $GLOBALS['BrandLink'] = BrandLink($this->productClass->GetBrandName());
  1129. }
  1130.  
  1131. /**
  1132. * Setup any other misc attributes such as the condition, availability, etc.
  1133. */
  1134. public function SetMiscAttributes()
  1135. {
  1136. if (!$this->productClass->IsConditionVisible()) {
  1137. $GLOBALS['HideCondition'] = "none";
  1138. }
  1139. else {
  1140. $GLOBALS['ProductCondition'] = isc_html_escape(GetLang('Condition' . $this->productClass->GetCondition()));
  1141. }
  1142.  
  1143. // Has a product availability been given?
  1144. if ($this->productClass->GetAvailability() != "") {
  1145. $GLOBALS['Availability'] = isc_html_escape($this->productClass->GetAvailability());
  1146. } else {
  1147. $GLOBALS['HideAvailability'] = "none";
  1148. }
  1149.  
  1150. // Is there an SKU for this product?
  1151. if ($this->productClass->GetSKU() != "" && GetConfig('ShowProductSKU')) {
  1152. $GLOBALS['SKU'] = isc_html_escape($this->productClass->GetSKU());
  1153. }
  1154. else {
  1155. $GLOBALS['HideSKU'] = "none";
  1156. }
  1157.  
  1158. $GLOBALS['UPC'] = isc_html_escape(trim($this->productClass->GetProductUPC()));
  1159. if (!$GLOBALS['UPC']) {
  1160. $GLOBALS['HideUPC'] = "none";
  1161. }
  1162.  
  1163. // do we want to show an AddThis.com link on our product?
  1164. if (GetConfig('ShowAddThisLink')) {
  1165. $GLOBALS['AddThisLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('AddThisLink');
  1166. }
  1167.  
  1168. $likeButtonPosition = GetConfig('FacebookLikeButtonPosition');
  1169. if (GetConfig('FacebookLikeButtonEnabled') && GetConfig('FacebookLikeButtonAdminIds')) {
  1170. $GLOBALS['FacebookLikeButton' . ucfirst($likeButtonPosition)] = ISC_FACEBOOKLIKEBUTTON::getButtonHTML();
  1171. }
  1172. }
  1173.  
  1174. /**
  1175. * If we're showing inventory, setup the inventory details for this product.
  1176. */
  1177. private function SetInventoryDetails()
  1178. {
  1179. if (!GetConfig('ShowInventory') || $this->productClass->GetProductInventoryTracking() == 0 || ($this->productClass->IsPreOrder() && !GetConfig('ShowPreOrderInventory'))) {
  1180. $GLOBALS['HideCurrentStock'] = "display: none;";
  1181. return;
  1182. }
  1183.  
  1184. if ($this->productClass->IsPreOrder()) {
  1185. $GLOBALS['CurrentStockLabel'] = GetLang('PreOrderStock');
  1186. } else {
  1187. $GLOBALS['CurrentStockLabel'] = GetLang('CurrentStock');
  1188. }
  1189.  
  1190. $GLOBALS['InventoryList'] = '';
  1191. if ($this->productClass->GetProductInventoryTracking() == 2) {
  1192. $options = $this->productClass->GetProductVariationOptions();
  1193. if (empty($options)) {
  1194. $GLOBALS['HideCurrentStock'] = "display: none;";
  1195. }
  1196. }
  1197. else if ($this->productClass->GetProductInventoryTracking() == 1) {
  1198. $currentStock = $this->productClass->GetInventoryLevel();
  1199. if ($currentStock <= 0) {
  1200. $GLOBALS['InventoryList'] = GetLang('SoldOut');
  1201. }
  1202. else {
  1203. $GLOBALS['InventoryList'] = $currentStock;
  1204. }
  1205. }
  1206. }
  1207. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement