Jump to content

[SOLVED] Thickbox / Fancybox not functioning on products with combinations v1.6.1.11


Uptomen

Recommended Posts

Hi,

 

I wonder if someone could point me in the right direction please?

 

As the title suggests, product pages, where the product has combinations (for example size) will not operate the thickbox pop out. However, all products without combinations have the thickbox working fine. Please see links below:

 

Working:

http://www.uptomen.co.uk/bags-and-covers/745-brown-leather-flight-bag-5055312713716.html?live_configurator_token=834f72fe920e061c035f68198468d639&id_shop=1&id_employee=1&theme=&theme_font=font9

 

Not working:

http://www.uptomen.co.uk/jackets/715-urban-classics-bomber-jacket-oliveblack-4053838102442.html?live_configurator_token=834f72fe920e061c035f68198468d639&id_shop=1&id_employee=1&theme=&theme_font=font9

 

I have looked at the javascript console and all products with combinations seem to have "ReferenceError: productPrice is not defined" error. However, these products do have prices and they show on the product page so I'm not sure this is related.

 

Please take a look for me and see if you can give me any advice. Upgraded from previous version with blackink theme and prestashop directory selected. None of the code has been changed.

 

Thank you

Edited by Uptomen (see edit history)
Link to comment
Share on other sites

That JavaScript error is the reason the popup doesn't work. You need to fix it. I can see the following in your code:

var productPriceTaxExcluded=54.991667-0.000000;

You'll need to find the code that adds that and created a similar var productPrice that has tax included.

Link to comment
Share on other sites

That JavaScript error is the reason the popup doesn't work. You need to fix it. I can see the following in your code:

var productPriceTaxExcluded=54.991667-0.000000;

You'll need to find the code that adds that and created a similar var productPrice that has tax included.

Thank you so much for looking at this. I'm not a coder by any means but I can insert and adapt code if I'm led by the hand a little.

Would this need to be in the product.tpl or the product.js for my theme? If so, can you give me an idea of what I would need to insert please?

Thank you

Edited by Uptomen (see edit history)
Link to comment
Share on other sites

Hi Rocky,

 

Thanks for getting back to me.

Here's the product.tpl text

I hope it can help. It's such a small problem but it's driving me mad.

Clothing is something customers definitely want to have a closer look at.

 

Thanks

Mike

 

{*

* 2007-2012 PrestaShop

*

* NOTICE OF LICENSE

*

* This source file is subject to the Academic Free License (AFL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/afl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to [email protected] so we can send you a copy immediately.

*

* DISCLAIMER

*

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <[email protected]>

* @copyright 2007-2012 PrestaShop SA

* @version Release: $Revision: 14514 $

* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)

* International Registered Trademark & Property of PrestaShop SA

*}

 

{include file="$tpl_dir./errors.tpl"}

{if $errors|@count == 0}

<script type="text/javascript">

// <![CDATA[

 

// PrestaShop internal settings

var currencySign = '{$currencySign|html_entity_decode:2:"UTF-8"}';

var currencyRate = '{$currencyRate|floatval}';

var currencyFormat = '{$currencyFormat|intval}';

var currencyBlank = '{$currencyBlank|intval}';

var taxRate = {$tax_rate|floatval};

var jqZoomEnabled = {if $jqZoomEnabled}true{else}false{/if};

 

//JS Hook

var oosHookJsCodeFunctions = new Array();

 

// Parameters

var id_product = '{$product->id|intval}';

var productHasAttributes = {if isset($groups)}true{else}false{/if};

var quantitiesDisplayAllowed = {if $display_qties == 1}true{else}false{/if};

var quantityAvailable = {if $display_qties == 1 && $product->quantity}{$product->quantity}{else}0{/if};

var allowBuyWhenOutOfStock = {if $allow_oosp == 1}true{else}false{/if};

var availableNowValue = '{$product->available_now|escape:'quotes':'UTF-8'}';

var availableLaterValue = '{$product->available_later|escape:'quotes':'UTF-8'}';

var productPriceTaxExcluded = {$product->getPriceWithoutReduct(true)|default:'null'} - {$product->ecotax};

var reduction_percent = {if $product->specificPrice AND $product->specificPrice.reduction AND $product->specificPrice.reduction_type == 'percentage'}{$product->specificPrice.reduction*100}{else}0{/if};

var reduction_price = {if $product->specificPrice AND $product->specificPrice.reduction AND $product->specificPrice.reduction_type == 'amount'}{$product->specificPrice.reduction}{else}0{/if};

var specific_price = {if $product->specificPrice AND $product->specificPrice.price}{$product->specificPrice.price}{else}0{/if};

var specific_currency = {if $product->specificPrice AND $product->specificPrice.id_currency}true{else}false{/if};

var group_reduction = '{$group_reduction}';

var default_eco_tax = {$product->ecotax};

var ecotaxTax_rate = {$ecotaxTax_rate};

var currentDate = '{$smarty.now|date_format:'%Y-%m-%d %H:%M:%S'}';

var maxQuantityToAllowDisplayOfLastQuantityMessage = {$last_qties};

var noTaxForThisProduct = {if $no_tax == 1}true{else}false{/if};

var displayPrice = {$priceDisplay};

var productReference = '{$product->reference|escape:'htmlall':'UTF-8'}';

var productAvailableForOrder = {if (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE}'0'{else}'{$product->available_for_order}'{/if};

var productShowPrice = '{if !$PS_CATALOG_MODE}{$product->show_price}{else}0{/if}';

var productUnitPriceRatio = '{$product->unit_price_ratio}';

var idDefaultImage = {if isset($cover.id_image_only)}{$cover.id_image_only}{else}0{/if};

var ipa_default = {if isset($ipa_default)}{$ipa_default}{else}0{/if};

 

// Customizable field

var img_ps_dir = '{$img_ps_dir}';

var customizationFields = new Array();

{assign var='imgIndex' value=0}

{assign var='textFieldIndex' value=0}

{foreach from=$customizationFields item='field' name='customizationFields'}

{assign var="key" value="pictures_`$product->id`_`$field.id_customization_field`"}

customizationFields[{$smarty.foreach.customizationFields.index|intval}] = new Array();

customizationFields[{$smarty.foreach.customizationFields.index|intval}][0] = '{if $field.type|intval == 0}img{$imgIndex++}{else}textField{$textFieldIndex++}{/if}';

customizationFields[{$smarty.foreach.customizationFields.index|intval}][1] = {if $field.type|intval == 0 && isset($pictures.$key) && $pictures.$key}2{else}{$field.required|intval}{/if};

{/foreach}

 

// Images

var img_prod_dir = '{$img_prod_dir}';

var combinationImages = new Array();

 

{if isset($combinationImages)}

{foreach from=$combinationImages item='combination' key='combinationId' name='f_combinationImages'}

combinationImages[{$combinationId}] = new Array();

{foreach from=$combination item='image' name='f_combinationImage'}

combinationImages[{$combinationId}][{$smarty.foreach.f_combinationImage.index}] = {$image.id_image|intval};

{/foreach}

{/foreach}

{/if}

 

combinationImages[0] = new Array();

{if isset($images)}

{foreach from=$images item='image' name='f_defaultImages'}

combinationImages[0][{$smarty.foreach.f_defaultImages.index}] = {$image.id_image};

{/foreach}

{/if}

 

// Translations

var doesntExist = '{l s='The product does not exist in this model. Please choose another.' js=1}';

var doesntExistNoMore = '{l s='This product is no longer in stock' js=1}';

var doesntExistNoMoreBut = '{l s='with those attributes but is available with others' js=1}';

var uploading_in_progress = '{l s='Uploading in progress, please wait...' js=1}';

var fieldRequired = '{l s='Please fill in all required fields, then save the customization.' js=1}';

 

{if isset($groups)}

// Combinations

{foreach from=$combinations key=idCombination item=combination}

addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}', {$combination.unit_impact}, {$combination.minimal_quantity});

{/foreach}

// Colors

{if $colors|@count > 0}

{if $product->id_color_default}var id_color_default = {$product->id_color_default|intval};{/if}

{/if}

{/if}

//]]>

</script>

 

{include file="$tpl_dir./breadcrumb.tpl"}

<div id="primary_block" class="clearfix">

<h1>{$product->name|escape:'htmlall':'UTF-8'}</h1>

 

{if isset($adminActionDisplay) && $adminActionDisplay}

<div id="admin-action">

<p>{l s='This product is not visible to your customers.'}

<input type="hidden" id="admin-action-product-id" value="{$product->id}" />

<input type="submit" value="{l s='Publish'}" class="exclusive" onclick="submitPublishProduct('{$base_dir}{$smarty.get.ad}', 0)"/>

<input type="submit" value="{l s='Back'}" class="exclusive" onclick="submitPublishProduct('{$base_dir}{$smarty.get.ad}', 1)"/>

</p>

<div class="clear" ></div>

<p id="admin-action-result"></p>

</p>

</div>

{/if}

 

{if isset($confirmation) && $confirmation}

<p class="confirmation">

{$confirmation}

</p>

{/if}

 

<!-- right infos-->

<div id="pb-right-column">

<!-- product img-->

<div id="image-block">

{if $have_image}

<img src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'large')}"

{if $jqZoomEnabled}class="jqzoom" alt="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'thickbox')}"{else} title="{$product->name|escape:'htmlall':'UTF-8'}" alt="{$product->name|escape:'htmlall':'UTF-8'}" {/if} id="bigpic" width="{$largeSize.width}" height="{$largeSize.height}" />

{else}

<img src="{$img_prod_dir}{$lang_iso}-default-large.jpg" id="bigpic" alt="" title="{$cover.legend|escape:'htmlall':'UTF-8'}" width="{$largeSize.width}" height="{$largeSize.height}" />

{/if}

</div>

 

{if isset($images) && count($images) > 0}

<!-- thumbnails -->

<div id="views_block" {if isset($images) && count($images) < 2}class="hidden"{/if}>

{if isset($images) && count($images) > 3}<span class="view_scroll_spacer"><a id="view_scroll_left" class="hidden" title="{l s='Other views'}" href="javascript:{ldelim}{rdelim}">{l s='Previous'}</a></span>{/if}

<div id="thumbs_list">

<ul id="thumbs_list_frame">

{if isset($images)}

{foreach from=$images item=image name=thumbnails}

{assign var=imageIds value="`$product->id`-`$image.id_image`"}

<li id="thumbnail_{$image.id_image}">

<a href="{$link->getImageLink($product->link_rewrite, $imageIds, 'thickbox')}" rel="other-views" class="thickbox {if (isset($image.cover) AND $image.cover == 1) OR (!isset($image.cover) AND $smarty.foreach.thumbnails.first)}shown{/if}" title="{$image.legend|htmlspecialchars}">

<img id="thumb_{$image.id_image}" src="{$link->getImageLink($product->link_rewrite, $imageIds, 'medium')}" alt="{$image.legend|htmlspecialchars}" height="{$mediumSize.height}" width="{$mediumSize.width}" />

</a>

</li>

{/foreach}

{/if}

</ul>

</div>

{if isset($images) && count($images) > 3}<a id="view_scroll_right" title="{l s='Other views'}" href="javascript:{ldelim}{rdelim}">{l s='Next'}</a>{/if}

</div>

{/if}

{if isset($images) && count($images) > 1}<p class="align_center clear"><span id="wrapResetImages" style="display: none;"><img src="{$img_dir}icon/cancel_16x18.gif" alt="{l s='Cancel'}" width="16" height="18"/> <a id="resetImages" href="{$link->getProductLink($product)}" onclick="$('span#wrapResetImages').hide('slow');return (false);">{l s='Display all pictures'}</a></span></p>{/if}

<!-- usefull links-->

<ul id="usefull_link_block">

{if $HOOK_EXTRA_LEFT}{$HOOK_EXTRA_LEFT}{/if}

//<!-- <li><a href="javascript:print();">{l s='Print'}</a><br class="clear" /></li> -->

{if $have_image && !$jqZoomEnabled}

<li><span id="view_full_size" class="span_link">{l s='View full size'}</span></li>

{/if}

</ul>

</div>

 

<!-- left infos-->

<div id="pb-left-column">

{if $product->description_short OR $packItems|@count > 0}

<div id="short_description_block">

{if $product->description_short}

<div id="short_description_content" class="rte align_justify">{$product->description_short}</div>

{/if}

{if $product->description}

<p class="buttons_bottom_block"><a href="javascript:{ldelim}{rdelim}" class="button">{l s='More details'}</a></p>

{/if}

{if $packItems|@count > 0}

<h3>{l s='Pack content'}</h3>

{foreach from=$packItems item=packItem}

<div class="pack_content">

{$packItem.pack_quantity} x <a href="{$link->getProductLink($packItem.id_product, $packItem.link_rewrite, $packItem.category)}">{$packItem.name|escape:'htmlall':'UTF-8'}</a>

<p>{$packItem.description_short}</p>

</div>

{/foreach}

{/if}

</div>

{/if}

 

{if isset($colors) && $colors}

<!-- colors -->

<div id="color_picker">

<p>{l s='Pick a color:' js=1}</p>

<div class="clear"></div>

<ul id="color_to_pick_list">

{foreach from=$colors key='id_attribute' item='color'}

<li><a id="color_{$id_attribute|intval}" class="color_pick" style="background: {$color.value};" onclick="updateColorSelect({$id_attribute|intval});$('#wrapResetImages').show('slow');" title="{$color.name}">{if file_exists($col_img_dir|cat:$id_attribute|cat:'.jpg')}<img src="{$img_col_dir}{$id_attribute}.jpg" alt="{$color.name}" width="20" height="20" />{/if}</a></li>

{/foreach}

</ul>

<div class="clear"></div>

</div>

{/if}

 

{if ($product->show_price AND !isset($restricted_country_mode)) OR isset($groups) OR $product->reference OR (isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS)}

<!-- add to cart form-->

<form id="buy_block" {if $PS_CATALOG_MODE AND !isset($groups) AND $product->quantity > 0}class="hidden"{/if} action="{$link->getPageLink('cart.php')}" method="post">

 

<!-- hidden datas -->

<p class="hidden">

<input type="hidden" name="token" value="{$static_token}" />

<input type="hidden" name="id_product" value="{$product->id|intval}" id="product_page_product_id" />

<input type="hidden" name="add" value="1" />

<input type="hidden" name="id_product_attribute" id="idCombination" value="" />

</p>

 

<!-- prices -->

{if $product->show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}

<p class="price">

{if !$priceDisplay || $priceDisplay == 2}

{assign var='productPrice' value=$product->getPrice(true, $smarty.const.NULL, 2)}

{assign var='productPriceWithoutRedution' value=$product->getPriceWithoutReduct(false, $smarty.const.NULL)}

{elseif $priceDisplay == 1}

{assign var='productPrice' value=$product->getPrice(false, $smarty.const.NULL, 2)}

{assign var='productPriceWithoutRedution' value=$product->getPriceWithoutReduct(true, $smarty.const.NULL)}

{/if}

{if $product->on_sale}

<img src="{$img_dir}onsale_{$lang_iso}.gif" alt="{l s='On sale'}" class="on_sale_img"/>

<span class="on_sale">{l s='On sale!'}</span>

{elseif $product->specificPrice AND $product->specificPrice.reduction AND $productPriceWithoutRedution > $productPrice}

<span class="discount">{l s='Reduced price!'}</span>

{/if}

<br />

<span class="our_price_display">

{if $priceDisplay >= 0 && $priceDisplay <= 2}

<span id="our_price_display">{convertPrice price=$productPrice}</span>

{if $tax_enabled && ((isset($display_tax_label) && $display_tax_label == 1) OR !isset($display_tax_label))}

{if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}

{/if}

{/if}

</span>

{if $priceDisplay == 2}

<br />

<span id="pretaxe_price"><span id="pretaxe_price_display">{convertPrice price=$product->getPrice(false, $smarty.const.NULL, 2)}</span> {l s='tax excl.'}</span>

{/if}

<br />

</p>

{if $product->specificPrice AND $product->specificPrice.reduction}

<p id="old_price"><span class="bold">

{if $priceDisplay >= 0 && $priceDisplay <= 2}

{if $productPriceWithoutRedution > $productPrice}

<span id="old_price_display">{convertPrice price=$productPriceWithoutRedution}</span>

{if $tax_enabled && $display_tax_label == 1}

{if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if}

{/if}

{/if}

{/if}

</span>

</p>

 

{/if}

{if $product->specificPrice AND $product->specificPrice.reduction_type == 'percentage'}

<p id="reduction_percent">{l s='(price reduced by'} <span id="reduction_percent_display">{$product->specificPrice.reduction*100}</span> %{l s=')'}</p>

{/if}

{if $packItems|@count}

<p class="pack_price">{l s='instead of'} <span style="text-decoration: line-through;">{convertPrice price=$product->getNoPackPrice()}</span></p>

<br class="clear" />

{/if}

{if $product->ecotax != 0}

<p class="price-ecotax">{l s='include'} <span id="ecotax_price_display">{if $priceDisplay == 2}{$ecotax_tax_exc|convertAndFormatPrice}{else}{$ecotax_tax_inc|convertAndFormatPrice}{/if}</span> {l s='for green tax'}

{if $product->specificPrice AND $product->specificPrice.reduction}

<br />{l s='(not impacted by the discount)'}

{/if}

</p>

{/if}

{if !empty($product->unity) && $product->unit_price_ratio > 0.000000}

{math equation="pprice / punit_price" pprice=$productPrice punit_price=$product->unit_price_ratio assign=unit_price}

<p class="unit-price"><span id="unit_price_display">{convertPrice price=$unit_price}</span> {l s='per'} {$product->unity|escape:'htmlall':'UTF-8'}</p>

{/if}

{*close if for show price*}

{/if}

 

{if isset($groups)}

<!-- attributes -->

<div id="attributes">

{foreach from=$groups key=id_attribute_group item=group}

{if $group.attributes|@count}

<p>

<label for="group_{$id_attribute_group|intval}">{$group.name|escape:'htmlall':'UTF-8'} :</label>

{assign var="groupName" value="group_$id_attribute_group"}

<select name="{$groupName}" id="group_{$id_attribute_group|intval}" onchange="javascript:findCombination();{if $colors|@count > 0}$('#wrapResetImages').show('slow');{/if};">

{foreach from=$group.attributes key=id_attribute item=group_attribute}

<option value="{$id_attribute|intval}"{if (isset($smarty.get.$groupName) && $smarty.get.$groupName|intval == $id_attribute) || $group.default == $id_attribute} selected="selected"{/if} title="{$group_attribute|escape:'htmlall':'UTF-8'}">{$group_attribute|escape:'htmlall':'UTF-8'}</option>

{/foreach}

</select>

</p>

{/if}

{/foreach}

</div>

{/if}

 

<p id="product_reference" {if isset($groups) OR !$product->reference}style="display: none;"{/if}><label for="product_reference">{l s='Reference :'} </label><span class="editable">{$product->reference|escape:'htmlall':'UTF-8'}</span></p>

 

<!-- quantity wanted -->

<p id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) OR $virtual OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>

<label>{l s='Quantity :'}</label>

<input type="text" name="qty" id="quantity_wanted" class="text" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}" size="2" maxlength="3" {if $product->minimal_quantity > 1}onkeyup="checkMinimalQuantity({$product->minimal_quantity});"{/if} />

</p>

 

<!-- minimal quantity wanted -->

<p id="minimal_quantity_wanted_p"{if $product->minimal_quantity <= 1 OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>{l s='You must add '} <b id="minimal_quantity_label">{$product->minimal_quantity}</b> {l s=' as a minimum quantity to buy this product.'}</p>

{if $product->minimal_quantity > 1}

<script type="text/javascript">

checkMinimalQuantity();

</script>

{/if}

 

<!-- availability -->

<p id="availability_statut"{if ($product->quantity <= 0 && !$product->available_later && $allow_oosp) OR ($product->quantity > 0 && !$product->available_now) OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>

<span id="availability_label">{l s='Availability:'}</span>

<span id="availability_value"{if $product->quantity <= 0} class="warning_inline"{/if}>

{if $product->quantity <= 0}{if $allow_oosp}{$product->available_later}{else}{l s='This product is no longer in stock'}{/if}{else}{$product->available_now}{/if}

</span>

</p>

 

<!-- number of item in stock -->

{if ($display_qties == 1 && !$PS_CATALOG_MODE && $product->available_for_order)}

<p id="pQuantityAvailable"{if $product->quantity <= 0} style="display: none;"{/if}>

<span id="quantityAvailable">{$product->quantity|intval}</span>

<span {if $product->quantity > 1} style="display: none;"{/if} id="quantityAvailableTxt">{l s='item in stock'}</span>

<span {if $product->quantity == 1} style="display: none;"{/if} id="quantityAvailableTxtMultiple">{l s='items in stock'}</span>

</p>

{/if}

<!-- Out of stock hook -->

{if !$allow_oosp}

<p id="oosHook"{if $product->quantity > 0} style="display: none;"{/if}>

{$HOOK_PRODUCT_OOS}

</p>

{/if}

 

<p class="warning_inline" id="last_quantities"{if ($product->quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if} >{l s='Warning: Last items in stock!'}</p>

 

{if $product->online_only}

<p>{l s='Online only'}</p>

{/if}

 

<p{if (!$allow_oosp && $product->quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE} style="display: none;"{/if} id="add_to_cart" class="buttons_bottom_block"><input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" /></p>

{if isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS}{$HOOK_PRODUCT_ACTIONS}{/if}

<div class="clear"></div>

</form>

{/if}

{if $HOOK_EXTRA_RIGHT}{$HOOK_EXTRA_RIGHT}{/if}

</div>

</div>

 

{if $quantity_discounts}

<!-- quantity discount -->

<ul class="idTabs">

<li><a style="cursor: pointer" class="selected">{l s='Quantity discount'}</a></li>

</ul>

<div id="quantityDiscount">

<table class="std">

<tr>

{foreach from=$quantity_discounts item='quantity_discount' name='quantity_discounts'}

<th>{$quantity_discount.quantity|intval}

{if $quantity_discount.quantity|intval > 1}

{l s='quantities'}

{else}

{l s='quantity'}

{/if}

</th>

{/foreach}

</tr>

<tr>

{foreach from=$quantity_discounts item='quantity_discount' name='quantity_discounts'}

<td>

{if $quantity_discount.price != 0 OR $quantity_discount.reduction_type == 'amount'}

-{convertPrice price=$quantity_discount.real_value|floatval}

{else}

-{$quantity_discount.real_value|floatval}%

{/if}

</td>

{/foreach}

</tr>

</table>

</div>

{/if}

 

{$HOOK_PRODUCT_FOOTER}

 

<!-- description and features -->

{if $product->description || $features || $accessories || $HOOK_PRODUCT_TAB || $attachments}

<div id="more_info_block" class="clear">

<ul id="more_info_tabs" class="idTabs idTabsShort">

{if $product->description}<li><a id="more_info_tab_more_info" href="#idTab1">{l s='More info'}</a></li>{/if}

{if $features}<li><a id="more_info_tab_data_sheet" href="#idTab2">{l s='Data sheet'}</a></li>{/if}

{if $attachments}<li><a id="more_info_tab_attachments" href="#idTab9">{l s='Download'}</a></li>{/if}

{if isset($accessories) AND $accessories}<li><a href="#idTab4">{l s='Accessories'}</a></li>{/if}

{$HOOK_PRODUCT_TAB}

</ul>

<div id="more_info_sheets" class="sheets align_justify">

{if $product->description}

<!-- full description -->

<div id="idTab1" class="rte">{$product->description}</div>

{/if}

{if $features}

<!-- product's features -->

<ul id="idTab2" class="bullet">

{foreach from=$features item=feature}

<li><span>{$feature.name|escape:'htmlall':'UTF-8'}</span> {$feature.value|escape:'htmlall':'UTF-8'}</li>

{/foreach}

</ul>

{/if}

{if $attachments}

<ul id="idTab9" class="bullet">

{foreach from=$attachments item=attachment}

<li><a href="{$link->getPageLink('attachment.php', true)}?id_attachment={$attachment.id_attachment}">{$attachment.name|escape:'htmlall':'UTF-8'}</a><br />{$attachment.description|escape:'htmlall':'UTF-8'}</li>

{/foreach}

</ul>

{/if}

{if isset($accessories) AND $accessories}

<!-- accessories -->

<ul id="idTab4" class="bullet">

<div class="block products_block accessories_block clearfix">

<div class="block_content">

<ul>

{foreach from=$accessories item=accessory name=accessories_list}

{assign var='accessoryLink' value=$link->getProductLink($accessory.id_product, $accessory.link_rewrite, $accessory.category)}

<li class="ajax_block_product {if $smarty.foreach.accessories_list.first}first_item{elseif $smarty.foreach.accessories_list.last}last_item{else}item{/if} product_accessories_description">

<h5><a href="{$accessoryLink|escape:'htmlall':'UTF-8'}">{$accessory.name|truncate:22:'...':true|escape:'htmlall':'UTF-8'}</a></h5>

<div class="product_desc">

<a href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{$accessory.legend|escape:'htmlall':'UTF-8'}" class="product_image"><img src="{$link->getImageLink($accessory.link_rewrite, $accessory.id_image, 'medium')}" alt="{$accessory.legend|escape:'htmlall':'UTF-8'}" width="{$mediumSize.width}" height="{$mediumSize.height}" /></a>

<a href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{l s='More'}" class="product_description">{$accessory.description_short|strip_tags|truncate:70:'...'}</a>

</div>

<p class="product_accessories_price">

{if $accessory.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<span class="price">{if $priceDisplay != 1}{displayWtPrice p=$accessory.price}{else}{displayWtPrice p=$accessory.price_tax_exc}{/if}</span>{/if}

<a class="button" href="{$accessoryLink|escape:'htmlall':'UTF-8'}" title="{l s='View'}">{l s='View'}</a>

{if ($accessory.allow_oosp || $accessory.quantity > 0) AND $accessory.available_for_order AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}

<a class="exclusive button ajax_add_to_cart_button" href="{$link->getPageLink('cart.php')}?qty=1&id_product={$accessory.id_product|intval}&token={$static_token}&add" rel="ajax_id_product_{$accessory.id_product|intval}" title="{l s='Add to cart'}">{l s='Add to cart'}</a>

{else}

<span class="exclusive">{l s='Add to cart'}</span>

<span class="availability">{if (isset($accessory.quantity_all_versions) && $accessory.quantity_all_versions > 0)}{l s='Product available with different options'}{else}{l s='Out of stock'}{/if}</span>

{/if}

</p>

</li>

 

{/foreach}

</ul>

</div>

</div>

</ul>

{/if}

{$HOOK_PRODUCT_TAB_CONTENT}

</div>

</div>

{/if}

 

<!-- Customizable products -->

{if $product->customizable}

<ul class="idTabs">

<li><a style="cursor: pointer">{l s='Product customization'}</a></li>

</ul>

<div class="customization_block">

<form method="post" action="{$customizationFormTarget}" enctype="multipart/form-data" id="customizationForm">

<p>

<img src="{$img_dir}icon/infos.gif" alt="Informations" />

{l s='After saving your customized product, remember to add it to your cart.'}

{if $product->uploadable_files}<br />{l s='Allowed file formats are: GIF, JPG, PNG'}{/if}

</p>

{if $product->uploadable_files|intval}

<h2>{l s='Pictures'}</h2>

<ul id="uploadable_files">

{counter start=0 assign='customizationField'}

{foreach from=$customizationFields item='field' name='customizationFields'}

{if $field.type == 0}

<li class="customizationUploadLine{if $field.required} required{/if}">{assign var='key' value='pictures_'|cat:$product->id|cat:'_'|cat:$field.id_customization_field}

{if isset($pictures.$key)}<div class="customizationUploadBrowse">

<img src="{$pic_dir}{$pictures.$key}_small" alt="" />

<a href="{$link->getProductDeletePictureLink($product, $field.id_customization_field)}" title="{l s='Delete'}" >

<img src="{$img_dir}icon/delete.gif" alt="{l s='Delete'}" class="customization_delete_icon" width="11" height="13" />

</a>

</div>{/if}

<div class="customizationUploadBrowse"><input type="file" name="file{$field.id_customization_field}" id="img{$customizationField}" class="customization_block_input {if isset($pictures.$key)}filled{/if}" />{if $field.required}<sup>*</sup>{/if}

<div class="customizationUploadBrowseDescription">{if !empty($field.name)}{$field.name}{else}{l s='Please select an image file from your hard drive'}{/if}</div></div>

</li>

{counter}

{/if}

{/foreach}

</ul>

{/if}

<div class="clear"></div>

{if $product->text_fields|intval}

<h2>{l s='Texts'}</h2>

<ul id="text_fields">

{counter start=0 assign='customizationField'}

{foreach from=$customizationFields item='field' name='customizationFields'}

{if $field.type == 1}

<li class="customizationUploadLine{if $field.required} required{/if}">{assign var='key' value='textFields_'|cat:$product->id|cat:'_'|cat:$field.id_customization_field}

{if !empty($field.name)}{$field.name}{/if}{if $field.required}<sup>*</sup>{/if}<textarea type="text" name="textField{$field.id_customization_field}" id="textField{$customizationField}" rows="1" cols="40" class="customization_block_input" />{if isset($textFields.$key)}{$textFields.$key|stripslashes}{/if}</textarea>

</li>

{counter}

{/if}

{/foreach}

</ul>

{/if}

<p style="clear: left;" id="customizedDatas">

<input type="hidden" name="ipa_customization" id="ipa_customization" value="{$ipa_customization}" />

<input type="hidden" name="quantityBackup" id="quantityBackup" value="" />

<input type="hidden" name="submitCustomizedDatas" value="1" />

<input type="button" class="button" value="{l s='Save'}" onclick="javascript:saveCustomization()" />

<span id="ajax-loader" style="display:none"><img src="{$img_ps_dir}loader.gif" alt="loader" /></span>

</p>

</form>

<p class="clear required"><sup>*</sup> {l s='required fields'}</p>

</div>

{/if}

 

{if $packItems|@count > 0}

<div>

<h2>{l s='Pack content'}</h2>

{include file="$tpl_dir./product-list.tpl" products=$packItems}

</div>

{/if}

 

{/if}

Edited by Uptomen (see edit history)
Link to comment
Share on other sites

You can try changing the following line:
var productPriceTaxExcluded = {$product->getPriceWithoutReduct(true)|default:'null'} - {$product->ecotax};

to:

var productPriceTaxExcluded = {$product->getPriceWithoutReduct(true)|default:'null'} - {$product->ecotax};
var productPrice = {$product->getPriceWithoutReduct()|default:'null'};

But after further inspection, I think that might not be enough. I may need access to your website to investigate further.

 

Is it possible for you to upgrade to PrestaShop v1.6? Your PrestaShop version is very old.

Link to comment
Share on other sites

Many thanks again Rocky,

I have added the extra line and it doesn't seem to have fixed the problem. I still get the same java error.

 

If it's any help, I have attached the product.js to show you

 

As the thread title suggests, I am already updated to

v1.6.1.11 but the theme I am using is old. However, I like the look of it and can't afford to buy any themes right now to get a nice up to date one.

Unless you can suggest a free theme that will give me a similar look?

 



//global variables
var combinations = [];
var selectedCombination = [];
var globalQuantity = 0;
var colors = [];

//check if a function exists
function function_exists(function_name)
{
    if (typeof function_name == 'string')
        return (typeof window[function_name] == 'function');
    return (function_name instanceof Function);
}

//execute oosHook js code
function oosHookJsCode()
{
    for (var i = 0; i < oosHookJsCodeFunctions.length; i++)
    {
        if (function_exists(oosHookJsCodeFunctions))
            setTimeout(oosHookJsCodeFunctions + '()', 0);
    }
}

//add a combination of attributes in the global JS sytem
function addCombination(idCombination, arrayOfIdAttributes, quantity, price, ecotax, id_image, reference, unit_price, minimal_quantity, available_date, combination_specific_price)
{
    globalQuantity += quantity;

    var combination = [];
    combination['idCombination'] = idCombination;
    combination['quantity'] = quantity;
    combination['idsAttributes'] = arrayOfIdAttributes;
    combination['price'] = price;
    combination['ecotax'] = ecotax;
    combination['image'] = id_image;
    combination['reference'] = reference;
    combination['unit_price'] = unit_price;
    combination['minimal_quantity'] = minimal_quantity;
    combination['available_date'] = [];
    combination['available_date'] = available_date;
    combination['specific_price'] = [];
    combination['specific_price'] = combination_specific_price;
    combinations.push(combination);
}

// search the combinations' case of attributes and update displaying of availability, prices, ecotax, and image
function findCombination(firstTime)
{
    $('#minimal_quantity_wanted_p').fadeOut();
    $('#quantity_wanted').val(1);
    //create a temporary 'choice' array containing the choices of the customer
    var choice = [];
    $('#attributes select, #attributes input[type=hidden], #attributes input[type=radio]:checked').each(function(){
        choice.push($(this).val());
    });

    //testing every combination to find the conbination's attributes' case of the user
    for (var combination = 0; combination < combinations.length; ++combination)
    {
        //verify if this combinaison is the same that the user's choice
        var combinationMatchForm = true;
        $.each(combinations[combination]['idsAttributes'], function(key, value)
        {
            if (!in_array(value, choice))
                combinationMatchForm = false;
        });

        if (combinationMatchForm)
        {
            if (combinations[combination]['minimal_quantity'] > 1)
            {
                $('#minimal_quantity_label').html(combinations[combination]['minimal_quantity']);
                $('#minimal_quantity_wanted_p').fadeIn();
                $('#quantity_wanted').val(combinations[combination]['minimal_quantity']);
                $('#quantity_wanted').bind('keyup', function() {checkMinimalQuantity(combinations[combination]['minimal_quantity']);});
            }
            //combination of the user has been found in our specifications of combinations (created in back office)
            selectedCombination['unavailable'] = false;
            selectedCombination['reference'] = combinations[combination]['reference'];
            $('#idCombination').val(combinations[combination]['idCombination']);

            //get the data of product with these attributes
            quantityAvailable = combinations[combination]['quantity'];
            selectedCombination['price'] = combinations[combination]['price'];
            selectedCombination['unit_price'] = combinations[combination]['unit_price'];
            selectedCombination['specific_price'] = combinations[combination]['specific_price'];
            if (combinations[combination]['ecotax'])
                selectedCombination['ecotax'] = combinations[combination]['ecotax'];
            else
                selectedCombination['ecotax'] = default_eco_tax;

            //show the large image in relation to the selected combination
            if (combinations[combination]['image'] && combinations[combination]['image'] != -1)
                displayImage($('#thumb_' + combinations[combination]['image']).parent());

            //show discounts values according to the selected combination
            if (combinations[combination]['idCombination'] && combinations[combination]['idCombination'] > 0)
                displayDiscounts(combinations[combination]['idCombination']);

            //get available_date for combination product
            selectedCombination['available_date'] = combinations[combination]['available_date'];
            
            //update the display
            updateDisplay();

            if(typeof(firstTime) != 'undefined' && firstTime)
                refreshProductImages(0);
            else
                refreshProductImages(combinations[combination]['idCombination']);
            //leave the function because combination has been found
            return;
        }
    }
    //this combination doesn't exist (not created in back office)
    selectedCombination['unavailable'] = true;
    if (typeof(selectedCombination['available_date']) != 'undefined')
        delete selectedCombination['available_date'];
    updateDisplay();
}

//update display of the availability of the product AND the prices of the product
function updateDisplay()
{
    var productPriceDisplay = productPrice;
    var productPriceWithoutReductionDisplay = productPriceWithoutReduction;

    if (!selectedCombination['unavailable'] && quantityAvailable > 0 && productAvailableForOrder == 1)
    {
        //show the choice of quantities
        $('#quantity_wanted_p:hidden').show('slow');

        //show the "add to cart" button ONLY if it was hidden
        $('#add_to_cart:hidden').fadeIn(600);

        //hide the hook out of stock
        $('#oosHook').hide();
        
        $('#availability_date').fadeOut();

        //availability value management
        if (availableNowValue != '')
        {
            //update the availability statut of the product
            $('#availability_value').removeClass('warning_inline');
            $('#availability_value').text(availableNowValue);
            if(stock_management == 1)
                $('#availability_statut:hidden').show();
        }
        else
            $('#availability_statut:visible').hide();

        //'last quantities' message management
        if (!allowBuyWhenOutOfStock)
        {
            if (quantityAvailable <= maxQuantityToAllowDisplayOfLastQuantityMessage)
                $('#last_quantities').show('slow');
            else
                $('#last_quantities').hide('slow');
        }

        if (quantitiesDisplayAllowed)
        {
            $('#pQuantityAvailable:hidden').show('slow');
            $('#quantityAvailable').text(quantityAvailable);

            if (quantityAvailable < 2) // we have 1 or less product in stock and need to show "item" instead of "items"
            {
                $('#quantityAvailableTxt').show();
                $('#quantityAvailableTxtMultiple').hide();
            }
            else
            {
                $('#quantityAvailableTxt').hide();
                $('#quantityAvailableTxtMultiple').show();
            }
        }
    }
    else
    {
        //show the hook out of stock
        if (productAvailableForOrder == 1)
        {
            $('#oosHook').show();
            if ($('#oosHook').length > 0 && function_exists('oosHookJsCode'))
                oosHookJsCode();
        }

        //hide 'last quantities' message if it was previously visible
        $('#last_quantities:visible').hide('slow');

        //hide the quantity of pieces if it was previously visible
        $('#pQuantityAvailable:visible').hide('slow');

        //hide the choice of quantities
        if (!allowBuyWhenOutOfStock)
            $('#quantity_wanted_p:visible').hide('slow');

        //display that the product is unavailable with theses attributes
        if (!selectedCombination['unavailable'])
            $('#availability_value').text(doesntExistNoMore + (globalQuantity > 0 ? ' ' + doesntExistNoMoreBut : '')).addClass('warning_inline');
        else
        {
            $('#availability_value').text(doesntExist).addClass('warning_inline');
            $('#oosHook').hide();
        }
        if(stock_management == 1 && !allowBuyWhenOutOfStock)
            $('#availability_statut:hidden').show();

        if (typeof(selectedCombination['available_date']) != 'undefined' && selectedCombination['available_date']['date'].length != 0)
        {
            var available_date = selectedCombination['available_date']['date'];
            var tab_date = available_date.split('-');
            var time_available = new Date(tab_date[0], tab_date[1], tab_date[2]);
            time_available.setMonth(time_available.getMonth()-1);
            var now = new Date();
            if (now.getTime() < time_available.getTime() && $('#availability_date_value').text() != selectedCombination['available_date']['date_formatted'])
            {
                $('#availability_date').fadeOut('normal', function(){
                    $('#availability_date_value').text(selectedCombination['available_date']['date_formatted']);
                    $(this).fadeIn();
                });
            }
            else if(now.getTime() < time_available.getTime())
                $('#availability_date').fadeIn();
        }
        else
            $('#availability_date').fadeOut();

        //show the 'add to cart' button ONLY IF it's possible to buy when out of stock AND if it was previously invisible
        if (allowBuyWhenOutOfStock && !selectedCombination['unavailable'] && productAvailableForOrder == 1)
        {
            $('#add_to_cart:hidden').fadeIn(600);

            if (availableLaterValue != '')
            {
                $('#availability_value').text(availableLaterValue);
                if(stock_management == 1)
                    $('#availability_statut:hidden').show('slow');
            }
            else
                $('#availability_statut:visible').hide('slow');
        }
        else
        {
            $('#add_to_cart:visible').fadeOut(600);
            if(stock_management == 1)
                $('#availability_statut:hidden').show('slow');
        }

        if (productAvailableForOrder == 0)
            $('#availability_statut:visible').hide();
    }

    if (selectedCombination['reference'] || productReference)
    {
        if (selectedCombination['reference'])
            $('#product_reference span').text(selectedCombination['reference']);
        else if (productReference)
            $('#product_reference span').text(productReference);
        $('#product_reference:hidden').show('slow');
    }
    else
        $('#product_reference:visible').hide('slow');

    //update display of the the prices in relation to tax, discount, ecotax, and currency criteria
    if (!selectedCombination['unavailable'] && productShowPrice == 1)
    {
        var priceTaxExclWithoutGroupReduction = '';

        // retrieve price without group_reduction in order to compute the group reduction after
        // the specific price discount (done in the JS in order to keep backward compatibility)        
        priceTaxExclWithoutGroupReduction = ps_round(productPriceTaxExcluded, 6) * (1 / group_reduction);

        var tax = (taxRate / 100) + 1;
        var taxExclPrice = priceTaxExclWithoutGroupReduction + (selectedCombination['price'] * currencyRate);

        if (selectedCombination.specific_price && selectedCombination.specific_price['id_product_attribute'])
        {
            if (selectedCombination.specific_price['price'] && selectedCombination.specific_price['price'] >=0)
                var taxExclPrice = (specific_currency ? selectedCombination.specific_price['price'] : selectedCombination.specific_price['price'] * currencyRate);
            else
                var taxExclPrice = productBasePriceTaxExcluded * currencyRate + (selectedCombination['price'] * currencyRate);
        }
        else if (product_specific_price.price && product_specific_price.price >= 0)
            var taxExclPrice = (specific_currency ? product_specific_price.price : product_specific_price.price * currencyRate) + (selectedCombination['price'] * currencyRate);

        if (!displayPrice && !noTaxForThisProduct)
            productPriceDisplay = ps_round(taxExclPrice * tax, 2); // Need to be global => no var
        else
            productPriceDisplay = ps_round(taxExclPrice, 2); // Need to be global => no var

        productPriceWithoutReductionDisplay = productPriceDisplay * group_reduction;
        var reduction = 0;
        if (selectedCombination['specific_price'].reduction_price || selectedCombination['specific_price'].reduction_percent)
        {
            reduction_price = (specific_currency ? selectedCombination['specific_price'].reduction_price : selectedCombination['specific_price'].reduction_price * currencyRate);
            reduction = productPriceDisplay * (parseFloat(selectedCombination['specific_price'].reduction_percent) / 100) + reduction_price;
            if (reduction_price && (displayPrice || noTaxForThisProduct))
                reduction = ps_round(reduction / tax, 6);

        }
        else if (product_specific_price && product_specific_price.reduction && !selectedCombination.specific_price)
        {
            if (product_specific_price.reduction_type == 'amount')
                reduction_price = (specific_currency ? product_specific_price.reduction : product_specific_price.reduction * currencyRate);
            else
                reduction_price = 0;

            if (product_specific_price.reduction_type == 'percentage')
                reduction_percent = productPriceDisplay * parseFloat(product_specific_price.reduction);

            reduction = reduction_price + reduction_percent;
            if (reduction_price && (displayPrice || noTaxForThisProduct))
                reduction = ps_round(reduction / tax, 6);
        }

        if (selectedCombination.specific_price)
        {
            if (selectedCombination['specific_price'] && selectedCombination['specific_price'].reduction_type == 'percentage')
            {
                $('#reduction_amount').hide();
                $('#reduction_percent_display').html('-' + parseFloat(selectedCombination['specific_price'].reduction_percent) + '%');
                $('#reduction_percent').show();
            } else if (selectedCombination['specific_price'].reduction_type == 'amount' && selectedCombination['specific_price'].reduction_price != 0) {
                $('#reduction_amount_display').html('-' + formatCurrency(reduction_price, currencyFormat, currencySign, currencyBlank));
                $('#reduction_percent').hide();
                $('#reduction_amount').show();
            } else {
                $('#reduction_percent').hide();
                $('#reduction_amount').hide();
            }
        }

        if (product_specific_price['reduction_type'] != '' || selectedCombination['specific_price'].reduction_type != '')
            $('#discount_reduced_price,#old_price').show();
        else
            $('#discount_reduced_price,#old_price').hide();
        if ((product_specific_price['reduction_type'] == 'percentage' && selectedCombination['specific_price'].reduction_type == 'percentage') || selectedCombination['specific_price'].reduction_type == 'percentage')
            $('#reduction_percent').show();
        else
            $('#reduction_percent').hide();
        if (product_specific_price['price'] || (selectedCombination.specific_price && selectedCombination.specific_price['price']))
            $('#not_impacted_by_discount').show();
        else
            $('#not_impacted_by_discount').hide();

        productPriceDisplay -= reduction;
        productPriceDisplay = ps_round(productPriceDisplay * group_reduction, 2);

        var ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax'];

        if (ecotaxAmount != default_eco_tax)
            productPriceDisplay += ecotaxAmount - default_eco_tax;
        else
            productPriceDisplay += ecotaxAmount;

        if (ecotaxAmount != default_eco_tax)
            productPriceWithoutReductionDisplay += ecotaxAmount - default_eco_tax;
        else
            productPriceWithoutReductionDisplay += ecotaxAmount;

        var our_price = '';
        if (productPriceDisplay > 0) {
            our_price = formatCurrency(productPriceDisplay, currencyFormat, currencySign, currencyBlank);
        } else {
            our_price = formatCurrency(0, currencyFormat, currencySign, currencyBlank);
        }
        $('#our_price_display').text(our_price);
        $('#old_price_display').text(formatCurrency(productPriceWithoutReductionDisplay, currencyFormat, currencySign, currencyBlank));

        if (productPriceWithoutReductionDisplay > productPriceDisplay)
            $('#old_price,#old_price_display,#old_price_display_taxes').show();
        else
            $('#old_price,#old_price_display,#old_price_display_taxes').hide();
        // Special feature: "Display product price tax excluded on product page"
        var productPricePretaxed = '';
        if (!noTaxForThisProduct)
            productPricePretaxed = productPriceDisplay / tax;
        else
            productPricePretaxed = productPriceDisplay;
        $('#pretaxe_price_display').text(formatCurrency(productPricePretaxed, currencyFormat, currencySign, currencyBlank));
        // Unit price
        productUnitPriceRatio = parseFloat(productUnitPriceRatio);
        if (productUnitPriceRatio > 0 )
        {
            newUnitPrice = (productPriceDisplay / parseFloat(productUnitPriceRatio)) + selectedCombination['unit_price'];
            $('#unit_price_display').text(formatCurrency(newUnitPrice, currencyFormat, currencySign, currencyBlank));
        }

        // Ecotax
        ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax'];
        $('#ecotax_price_display').text(formatCurrency(ecotaxAmount, currencyFormat, currencySign, currencyBlank));
    }
}

//update display of the large image
function displayImage(domAAroundImgThumb, no_animation)
{
    if (typeof(no_animation) == 'undefined')
        no_animation = false;
    if (domAAroundImgThumb.prop('href'))
    {
        var new_src = domAAroundImgThumb.prop('href').replace('thickbox', 'large');
        var new_title = domAAroundImgThumb.prop('title');
        var new_href = domAAroundImgThumb.prop('href');
        if ($('#bigpic').prop('src') != new_src)
        {
            $('#bigpic').prop({
                'src' : new_src,
                'alt' : new_title,
                'title' : new_title
            }).load(function(){
                if (typeof(jqZoomEnabled) != 'undefined' && jqZoomEnabled)
                    $(this).prop('rel', new_href);
            });
        }
        $('#views_block li a').removeClass('shown');
        $(domAAroundImgThumb).addClass('shown');
    }
}

//update display of the discounts table
function displayDiscounts(combination)
{
    $('#quantityDiscount tbody tr').each(function() {
        if (($(this).attr('id') != 'quantityDiscount_0') &&
            ($(this).attr('id') != 'quantityDiscount_' + combination) &&
            ($(this).attr('id') != 'noQuantityDiscount'))
            $(this).fadeOut('slow');
     });

    if ($('#quantityDiscount_' + combination+',.quantityDiscount_' + combination).length != 0)
    {
        $('#quantityDiscount_' + combination+',.quantityDiscount_' + combination).show();
        $('#noQuantityDiscount').hide();
    }
    else
        $('#noQuantityDiscount').show();
}

// Serialscroll exclude option bug ?
function serialScrollFixLock(event, targeted, scrolled, items, position)
{
    serialScrollNbImages = $('#thumbs_list li:visible').length;
    serialScrollNbImagesDisplayed = 3;

    var leftArrow = position == 0 ? true : false;
    var rightArrow = position + serialScrollNbImagesDisplayed >= serialScrollNbImages ? true : false;

    $('#view_scroll_left').css('cursor', leftArrow ? 'default' : 'pointer').css('display', leftArrow ? 'none' : 'block').fadeTo(0, leftArrow ? 0 : 1);
    $('#view_scroll_right').css('cursor', rightArrow ? 'default' : 'pointer').fadeTo(0, rightArrow ? 0 : 1).css('display', rightArrow ? 'none' : 'block');
    return true;
}

// Change the current product images regarding the combination selected
function refreshProductImages(id_product_attribute)
{
    $('#thumbs_list_frame').scrollTo('li:eq(0)', 700, {axis:'x'});

    id_product_attribute = parseInt(id_product_attribute);

    if (id_product_attribute > 0 && typeof(combinationImages) != 'undefined' && typeof(combinationImages[id_product_attribute]) != 'undefined')
    {
        $('#thumbs_list li').hide();
        $('#thumbs_list').trigger('goto', 0);
        for (var i = 0; i < combinationImages[id_product_attribute].length; i++)
            $('#thumbnail_' + parseInt(combinationImages[id_product_attribute])).show();
        if (parseInt($('#thumbs_list_frame >li:visible').length) < parseInt($('#thumbs_list_frame >li').length))
            $('#wrapResetImages').show('slow');
        else
            $('#wrapResetImages').hide('slow');
    }
    else
    {
        $('#thumbs_list li').show();
        if (parseInt($('#thumbs_list_frame >li').length) == parseInt($('#thumbs_list_frame >li:visible').length))
            $('#wrapResetImages').hide('slow');
    }

    var thumb_width = $('#thumbs_list_frame >li').width() + parseInt($('#thumbs_list_frame >li').css('marginRight'));
    $('#thumbs_list_frame').width((parseInt((thumb_width) * $('#thumbs_list_frame >li').length)) + 'px');
    $('#thumbs_list').trigger('goto', 0);
    serialScrollFixLock('', '', '', '', 0);// SerialScroll Bug on goto 0 ?
}

//To do after loading HTML
$(document).ready(function()
{
    //init the serialScroll for thumbs
    $('#thumbs_list').serialScroll({
        items:'li:visible',
        prev:'#view_scroll_left',
        next:'#view_scroll_right',
        axis:'x',
        offset:0,
        start:0,
        stop:true,
        onBefore:serialScrollFixLock,
        duration:700,
        step: 2,
        lazy: true,
        lock: false,
        force:false,
        cycle:false
    });

    $('#thumbs_list').trigger('goto', 1);// SerialScroll Bug on goto 0 ?
    $('#thumbs_list').trigger('goto', 0);

    //hover 'other views' images management
    $('#views_block li a').hover(
        function(){displayImage($(this));},
        function(){}
    );

    //set jqZoom parameters if needed
    if (typeof(jqZoomEnabled) != 'undefined' && jqZoomEnabled)
    {
        $('#bigpic').attr('rel', $('#bigpic').attr('src').replace('large', 'thickbox'));
        $('img.jqzoom').jqueryzoom({
            xzoom: 200, //zooming div default width(default width value is 200)
            yzoom: 200, //zooming div default width(default height value is 200)
            offset: 21 //zooming div default offset(default offset value is 10)
            //position: "right" //zooming div position(default position value is "right")
        });
    }
    //add a link on the span 'view full size' and on the big image
    $('#view_full_size, #image-block img').click(function(){
        $('#views_block .shown').click();
    });

    //catch the click on the "more infos" button at the top of the page
    $('#short_description_block .button').click(function(){
        $('#more_info_tab_more_info').click();
        $.scrollTo( '#more_info_tabs', 1200 );
    });

    // Hide the customization submit button and display some message
    $('#customizedDatas input').click(function() {
        $('#customizedDatas input').hide();
        $('#ajax-loader').fadeIn();
        $('#customizedDatas').append(uploading_in_progress);
    });

    original_url = window.location + '';
    first_url_check = true;
    checkUrl();
    initLocationChange();

    //init the price in relation of the selected attributes
    if (typeof productHasAttributes != 'undefined' && productHasAttributes)
        findCombination(true);
    else if (typeof productHasAttributes != 'undefined' && !productHasAttributes)
        refreshProductImages(0);

    $('#resetImages').click(function() {
        refreshProductImages(0);
    });

    $('.thickbox').fancybox({
        'hideOnContentClick': true,
        'transitionIn'    : 'elastic',
        'transitionOut'    : 'elastic'
    });
});

function saveCustomization()
{
    $('#quantityBackup').val($('#quantity_wanted').val());
    customAction = $('#customizationForm').attr('action');
    $('body select[id^=group_]').each(function() {
        customAction = customAction.replace(new RegExp(this.id + '=\\d+'), this.id +'=' + this.value);
    });
    $('#customizationForm').attr('action', customAction);
    $('#customizationForm').submit();
}

function submitPublishProduct(url, redirect, token)
{
    var id_product = $('#admin-action-product-id').val();

    $.ajaxSetup({async: false});
    $.post(url + '/index.php', {
        action:'publishProduct',
        id_product: id_product,
        status: 1,
        redirect: redirect,
        ajax: 1,
        tab: 'AdminProducts',
        token: token
        },
        function(data)
        {
            if (data.indexOf('error') === -1)
            document.location.href = data;
        }
    );
    return true;
}

function checkMinimalQuantity(minimal_quantity)
{
    if ($('#quantity_wanted').val() < minimal_quantity)
    {
        $('#quantity_wanted').css('border', '1px solid red');
        $('#minimal_quantity_wanted_p').css('color', 'red');
    }
    else
    {
        $('#quantity_wanted').css('border', '1px solid #BDC2C9');
        $('#minimal_quantity_wanted_p').css('color', '#374853');
    }
}

function colorPickerClick(elt)
{
    id_attribute = $(elt).attr('id').replace('color_', '');
    $(elt).parent().parent().children().removeClass('selected');
    $(elt).fadeTo('fast', 1, function(){
                                $(this).fadeTo('fast', 0, function(){
                                    $(this).fadeTo('fast', 1, function(){
                                        $(this).parent().addClass('selected');
                                        });
                                    });
                                });
    $(elt).parent().parent().parent().children('.color_pick_hidden,#color_pick_hidden').val(id_attribute);
    findCombination(false);
}


function getProductAttribute()
{
    // get product attribute id
    product_attribute_id = $('#idCombination').val();
    product_id = $('#product_page_product_id').val();

    // get every attributes values
    request = '';
    //create a temporary 'tab_attributes' array containing the choices of the customer
    var tab_attributes = [];
    $('#attributes select, #attributes input[type=hidden], #attributes input[type=radio]:checked').each(function(){
        tab_attributes.push($(this).val());
    });

    // build new request
    for (var i in attributesCombinations)
        for (var a in tab_attributes)
            if (attributesCombinations['id_attribute'] === tab_attributes[a])
                request += '/'+attributesCombinations['group'] + '-' + attributesCombinations['attribute'];
    request = request.replace(request.substring(0, 1), '#/');
    url = window.location + '';

    // redirection
    if (url.indexOf('#') != -1)
        url = url.substring(0, url.indexOf('#'));

    // set ipa to the customization form
    $('#customizationForm').attr('action', $('#customizationForm').attr('action') + request);
    window.location = url + request;
}

function initLocationChange(time)
{
    if(!time) time = 500;
        setInterval(checkUrl, time);
}

function checkUrl()
{
    if (original_url != window.location || first_url_check)
    {
        first_url_check = false;
        url = window.location + '';
        // if we need to load a specific combination
        if (url.indexOf('#/') != -1)
        {
            // get the params to fill from a "normal" url
            params = url.substring(url.indexOf('#') + 1, url.length);
            tabParams = params.split('/');
            tabValues = [];
            if (tabParams[0] == '')
                tabParams.shift();
            for (var i in tabParams)
                tabValues.push(tabParams.split('-'));
            product_id = $('#product_page_product_id').val();
            // fill html with values
            $('.color_pick').removeClass('selected');
            $('.color_pick').parent().parent().children().removeClass('selected');
            count = 0;
            for (var z in tabValues)
                for (var a in attributesCombinations)
                    if (attributesCombinations[a]['group'] === decodeURIComponent(tabValues[z][0])
                        && attributesCombinations[a]['attribute'] === tabValues[z][1])
                    {
                        count++;
                        // add class 'selected' to the selected color
                        $('#color_' + attributesCombinations[a]['id_attribute']).addClass('selected');
                        $('#color_' + attributesCombinations[a]['id_attribute']).parent().addClass('selected');
                        $('input:radio[value=' + attributesCombinations[a]['id_attribute'] + ']').attr('checked', true);
                        $('input:hidden[name=group_' + attributesCombinations[a]['id_attribute_group'] + ']').val(attributesCombinations[a]['id_attribute']);
                        $('select[name=group_' + attributesCombinations[a]['id_attribute_group'] + ']').val(attributesCombinations[a]['id_attribute']);
                    }
            // find combination
            if (count >= 0)
            {
                findCombination(false);
                original_url = url;
            }
            // no combination found = removing attributes from url
            else
                window.location = url.substring(0, url.indexOf('#'));
        }
    }
}

Link to comment
Share on other sites

I compared your product.tpl to the one in PrestaShop v1.5.6.3 and they are different, so it seems you're not using the latest version of the theme. You can download PrestaShop v1.5.6.3 here and copy the default theme files from there.

 

I don't think it's a good idea to use the default PrestaShop v1.5 theme in PrestaShop v1.6 though, since it wasn't designed to work with it. You may encounter more issues like this in other areas.

Link to comment
Share on other sites

 

I compared your product.tpl to the one in PrestaShop v1.5.6.3 and they are different, so it seems you're not using the latest version of the theme. You can download PrestaShop v1.5.6.3 here and copy the default theme files from there.
 
I don't think it's a good idea to use the default PrestaShop v1.5 theme in PrestaShop v1.6 though, since it wasn't designed to work with it. You may encounter more issues like this in other areas.

 

Hi Rocky,

Many thanks for all your assistance. I decided to use the bootstrap files and that has fixed the problem. Whilst the site now looks different, I quite like the change.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...