Jump to content

Bouton ajouter au produit ficher produit disparu


Recommended Posts

Bonjour,

 

Il y a plusieurs années nous avons fait intervenir un prestataire (dont nous tairons le nom) pour ajouter une option sur nos champs texte de personnalisation des fiches produits. Depuis peu, nous proposons des produits sans ce champ texte de personnalisation et là surprise : le bouton "ajouter au panier" n’apparaît pas sur ces fiches produits !... J'ai réalisé un test, dès que j'ajoute le champ texte de personnalisation, le bouton ajouter au panier apparaît !

 

Je pense donc que l'absence du bouton "ajouter au panier" est liée à l'absence du champ texte de personnalisation.... Je suis allée dans le fichier product.tpl et j'ai trouvé l'endroit où il est question du champ de personnalisation et du bouton "add to cart" mais je ne sais pas ce qui pose problème.

Pourriez-vous m'aider ? j'ai essayé de relancé le prestataire mais il ne m'a pas encore répondu :( et suite à d'autres échanges que nous avions eu avec lui pour d'autres soucis qui n'ont jamais trouvé de solution, je ne compte pas trop sur lui :(:(

merci par avance.

voici le code où je pense que tout se joue !

 

<div class="clear"></div>
			{if $product->text_fields|intval}
			<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>
						{if $smarty.foreach.customizationFields.index == 0}
              <li class="customizationUploadLine">
                <div id="custom_message">
                </div>
              </li>
            {/if}
						{counter}
					{/if}
				{/foreach}
			</ul>
			{/if}
			<p style="clear: left;" id="customizedDatas">
				<input type="hidden" name="quantityBackup" id="quantityBackup" value="" />
				<input type="hidden" name="submitCustomizedDatas" value="1" />
				<input type="button" class="button" value="{l s='Add to cart'}" onclick="javascript:saveCustomization()" />
				<span id="ajax-loader" style="display:none"><img src="{$img_ps_dir}loader.gif" alt="loader" /></span>
			</p>
			<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>
		</form>
		<p class="clear required"><sup>*</sup> {l s='required fields'}</p>

 

 

merci

 

BBA

Link to comment
Share on other sites

Ouch ! 1.4 je ne connais pas du tout ^^

Mais s'il n'y a pas d'erreur et que le bouton ne s'affiche pas du tout, le souci doit venir d'une des conditions d'affichage sur cette ligne : 

<P{if (!$allow_oosp && $product->quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_county_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>

Essayez de vérifier chacune de ces conditions pour voir si les produits correspondent...

 

A.

Link to comment
Share on other sites

ok, ça ne peut pas être lié à la condition d'affichage du champ de personnalisation ?

parce que c'est ce qu'il se passe :

- fiche produit sans champ : bouton ajouter au panier absent

- ficher produit avec champ : bouton ajouter au panier présent

Link to comment
Share on other sites

comme cela ?

 

<!-- Customizable products -->
{if $product->customizable}

	<div class="customization_block">
		<form method="post" action="{$customizationFormTarget}" enctype="multipart/form-data" id="customizationForm">
			<p>
				{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}
			<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>
						{if $smarty.foreach.customizationFields.index == 0}
              <li class="customizationUploadLine">
                <div id="custom_message">
                </div>
              </li>
            {/if}
						{counter}
					{/if}
				{/foreach}
			</ul>
			{/if}
			<p style="clear: left;" id="customizedDatas">
				<input type="hidden" name="quantityBackup" id="quantityBackup" value="" />
				<input type="hidden" name="submitCustomizedDatas" value="1" />
				<input type="button" class="button" value="{l s='Add to cart'}" onclick="javascript:saveCustomization()" />
				<span id="ajax-loader" style="display:none"><img src="{$img_ps_dir}loader.gif" alt="loader" /></span>
			</p>
			<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>
		</form>
		<p class="clear required"><sup>*</sup> {l s='required fields'}</p>
	</div>
{/if}
</div>

{else}

<!-- l'affichage du bouton classique -->

{if}

 

Link to comment
Share on other sites

Yep

 

Et vous pouvez voir le tpl original ici: https://github.com/PrestaShop/PrestaShop-1.4/blob/master/themes/prestashop/product.tpl

Donc à priori, le code standard à mettre dans la boucle else:

 

<!-- 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', true)}" 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 !isset($priceDisplayPrecision)}
  {assign var='priceDisplayPrecision' value=2}
  {/if}
  {if !$priceDisplay || $priceDisplay == 2}
  {assign var='productPrice' value=$product->getPrice(true, $smarty.const.NULL, $priceDisplayPrecision)}
  {assign var='productPriceWithoutRedution' value=$product->getPriceWithoutReduct(false, $smarty.const.NULL)}
  {elseif $priceDisplay == 1}
  {assign var='productPrice' value=$product->getPrice(false, $smarty.const.NULL, $priceDisplayPrecision)}
  {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>&nbsp;{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" {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>
Link to comment
Share on other sites

  • 2 weeks later...

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...