Jump to content

Help! Effacer "ajouter au panier" aux visiteurs


Recommended Posts

Bonjour,

 

je créé un site dédié aux professionnels, pour cela le client doit demander un accès pour découvrir nos tarifs. Seulement, un visiteur peut découvrir ces tarifs, car le bouton "ajouter aux paniers" apparait sur la fiche produit, car nous proposons des variantes pour chaque article. Je suis parvennu à effecer les prix sur le fichier productlist.tpl mais n y parviens pas sur le fichier product.tpl.

Trouvez ci dessous le code et indiquez moi comment le corriger pour parvenir à cacher ce bouton aux visiteurs, mais qu il soit apparent aux connectés:

 

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

 

Merci d avance...

Link to comment
Share on other sites

Merci beaucoup, mais je dois mal m y prendre, car j'ai fait comme indiqué, mais cela ne change pas grand chose....

 

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

{if $cookie->isLogged()} <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>

{/if}

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

Link to comment
Share on other sites

Il faut recompiler le tpl apres chaque modification.

Ca se fait en activant la recompilation forcée de smarty dans les preferences -> performances

Ensuite tu recharges la page de la boutique avec ton navigateur.

Puis tu desactives la compilation forcee

Link to comment
Share on other sites

Apres avoir mis mon display error sur on, j ai ce message qui apparait:

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/homez.614/bijougro/www/themes/mystoretheme/product.tpl" on line 367 "<p{if {if $logged} AND(!$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>" unknown function "AND"' in /homez.614/bijougro/www/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:431 Stack trace: #0 /homez.614/bijougro/www/tools/smarty/sysplugins/smarty_internal_templateparser.php(2660): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown functio...') #1 /homez.614/bijougro/www/tools/smarty/sysplugins/smarty_internal_templateparser.php(2812): Smarty_Intern in /homez.614/bijougro/www/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 431

Link to comment
Share on other sites

Bonjour,

 

Je te confirme que c'est bien $cookie->isLogged() qu'il faut mettre.

Smarty est tout à fait capable d'exécuter ce type d'appels lorsque des objets lui sont passés.

 

Voici le code que tu devras utiliser :

 

[color=#a52a2a]<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}[/color]
[color=#a52a2a]{if $cookie->isLogged() == true}
<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>[/color]
[color=#a52a2a]{/if}
{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>[/color]

Link to comment
Share on other sites

  • 2 weeks later...

Super Nikoskos

 

 

Je suis désolé pour cette réponse tardive, mais j étais en déplacement.

 

Le bouton "ajouter au panier apparait toujours", par contre quand je clique dessus une pop up s'ouvre avec ce message: TECHNICAL ERROR: unable to add the product.

 

Details:

Error thrown: [object XMLHttpRequest]

Text status: parsererror

 

De plus, j'ai ce message qui apparait e haut de page à l ouverture:

Warning: mysql_query() [function.mysql-query]: Unable to save result set in /homez.614/bijougro/www/classes/MySQL.php on line 76

 

Warning: array_key_exists() expects parameter 2 to be array, boolean given in /homez.614/bijougro/www/classes/Product.php on line 1869

 

En tout cas,

 

merci beaucoup

Edited by TOTO76 (see edit history)
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...