Jump to content

Mettre quantité produits à 1 sans la possibilité d'en ajouter


Recommended Posts

Bonjour,

Sur notre site, nous vendons aussi qu'un seul produit à la fois. Pour ma part, je suis allée directement dans le template product.tpl et j'ai enlevé l'affichage de la quantité de produit.

Ces lignes-ci sur une version PS 1.6.0.8 :

<p id="quantity_wanted_p"{*if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || $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*}" />
							<a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down">
								<span><i class="icon-minus"></i></span>
							</a>
							<a href="#" data-field-qty="qty" class="btn btn-default button-plus product_quantity_up ">
								<span><i class="icon-plus"></i></span>
							</a>							</a>

							<span class="clearfix"></span>
						</p>

Ne vous inquiétez pas pour "$product->quantity <= 0", dans le même fichier plus bas, la quantité minimale est à 1. (:

Bon courage,

Cordialement,

 

Okar

Link to comment
Share on other sites

Je te remercie ! et du coup, quand le produit sera vendu, est-ce qu'il sera enlevé de la vente également? (Le site que je fais, vends des tableaux donc y en a qu'un seul à chaque fois)

 

edit : j'ai testé, après achat cela affiche "ce produit n'est plus en stock".

Cependant, quand finalement je supprime le produit de mon panier, il ne revient pas en stock. C'est normal?

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

Rebonjour,

De rien (:

 

Si vous avez activé le paiement en 5 étapes, il faudra modifier aussi le template order-payment.tpl comme suit  :

{*
* 2007-2014 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-2014 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{if !$opc}
	{addJsDef currencySign=$currencySign|html_entity_decode:2:"UTF-8"}
	{addJsDef currencyRate=$currencyRate|floatval}
	{addJsDef currencyFormat=$currencyFormat|intval}
	{addJsDef currencyBlank=$currencyBlank|intval}
	{addJsDefL name=txtProduct}{l s='product' js=1}{/addJsDefL}
	{addJsDefL name=txtProducts}{l s='products' js=1}{/addJsDefL}
	{capture name=path}{l s='Your payment method'}{/capture}
	<h1 class="page-heading">{l s='Please choose your payment method'}</h1>
{else}
	<h1 class="page-heading step-num"><span>3</span> {l s='Please choose your payment method'}</h1>
{/if}

{if !$opc}
	{assign var='current_step' value='payment'}
	{include file="$tpl_dir./order-steps.tpl"}
	{include file="$tpl_dir./errors.tpl"}
{else}
	<div id="opc_payment_methods" class="opc-main-block">
		<div id="opc_payment_methods-overlay" class="opc-overlay" style="display: none;"></div>
{/if}
		<div class="paiement_block">
			<div id="HOOK_TOP_PAYMENT">{$HOOK_TOP_PAYMENT}</div>
				{if $HOOK_PAYMENT}
					{if !$opc}
						<div id="order-detail-content" class="table_block table-responsive">
							<table id="cart_summary" class="table table-bordered">
								<thead>
									<tr>
										<th class="cart_product first_item">{l s='Product'}</th>
										<th class="cart_description item">{l s='Description'}</th>
										<th class="cart_availability item">{l s='Avail.'}</th>
										<th class="cart_unit item">{l s='Unit price'}</th>
										<!--<th class="cart_quantity item">{*l s='Qty'*}</th>-->
										<th class="cart_total last_item">{l s='Total'}</th>
									</tr>
								</thead>
								<tfoot>
									{if $use_taxes}
										{if $priceDisplay}
											<tr class="cart_total_price">
												<td colspan="4" class="text-right">{if $display_tax_label}{l s='Total products (tax excl.)'}{else}{l s='Total products'}{/if}</td>
												<td colspan="2" class="price" id="total_product">{displayPrice price=$total_products}</td>
											</tr>
										{else}
											<tr class="cart_total_price">
												<td colspan="4" class="text-right">{if $display_tax_label}{l s='Total products (tax incl.)'}{else}{l s='Total products'}{/if}</td>
												<td colspan="2" class="price" id="total_product">{displayPrice price=$total_products_wt}</td>
											</tr>
										{/if}
									{else}
										<tr class="cart_total_price">
											<td colspan="4" class="text-right">{l s='Total products'}</td>
											<td colspan="2" class="price" id="total_product">{displayPrice price=$total_products}</td>
										</tr>
									{/if}
									<tr class="cart_total_voucher" {if $total_wrapping == 0}style="display:none"{/if}>
										<td colspan="4" class="text-right">
											{if $use_taxes}
												{if $priceDisplay}
													{if $display_tax_label}{l s='Total gift wrapping (tax excl.):'}{else}{l s='Total gift wrapping cost:'}{/if}
												{else}
													{if $display_tax_label}{l s='Total gift wrapping (tax incl.)'}{else}{l s='Total gift wrapping cost:'}{/if}
												{/if}
											{else}
												{l s='Total gift wrapping cost:'}
											{/if}
										</td>
										<td colspan="2" class="price-discount price" id="total_wrapping">
											{if $use_taxes}
												{if $priceDisplay}
													{displayPrice price=$total_wrapping_tax_exc}
												{else}
													{displayPrice price=$total_wrapping}
												{/if}
											{else}
												{displayPrice price=$total_wrapping_tax_exc}
											{/if}
										</td>
									</tr>
									{if $total_shipping_tax_exc <= 0 && !isset($virtualCart)}
										<tr class="cart_total_delivery">
											<td colspan="4" class="text-right">{l s='Shipping:'}</td>
											<td colspan="2" class="price" id="total_shipping">{l s='Free Shipping!'}</td>
										</tr>
									{else}
										{if $use_taxes && $total_shipping_tax_exc != $total_shipping}
											{if $priceDisplay}
												<tr class="cart_total_delivery" {if $shippingCost <= 0} style="display:none"{/if}>
													<td colspan="4" class="text-right">{if $display_tax_label}{l s='Total shipping (tax excl.)'}{else}{l s='Total shipping'}{/if}</td>
													<td colspan="2" class="price" id="total_shipping">{displayPrice price=$shippingCostTaxExc}</td>
												</tr>
											{else}
												<tr class="cart_total_delivery"{if $shippingCost <= 0} style="display:none"{/if}>
													<td colspan="4" class="text-right">{if $display_tax_label}{l s='Total shipping (tax incl.)'}{else}{l s='Total shipping'}{/if}</td>
													<td colspan="2" class="price" id="total_shipping" >{displayPrice price=$shippingCost}</td>
												</tr>
											{/if}
										{else}
											<tr class="cart_total_delivery"{if $shippingCost <= 0} style="display:none"{/if}>
												<td colspan="4" class="text-right">{l s='Total shipping'}</td>
												<td colspan="2" class="price" id="total_shipping" >{displayPrice price=$shippingCostTaxExc}</td>
											</tr>
										{/if}
									{/if}
									<tr class="cart_total_voucher" {if $total_discounts == 0}style="display:none"{/if}>
										<td colspan="4" class="text-right">
											{if $use_taxes}
												{if $priceDisplay}
													{if $display_tax_label}{l s='Total vouchers (tax excl.)'}{else}{l s='Total vouchers'}{/if}
												{else}
													{if $display_tax_label}{l s='Total vouchers (tax incl.)'}{else}{l s='Total vouchers'}{/if}
												{/if}
											{else}
												{l s='Total vouchers'}
											{/if}
										</td>
										<td colspan="2" class="price-discount price" id="total_discount">
											{if $use_taxes}
												{if $priceDisplay}
													{displayPrice price=$total_discounts_tax_exc*-1}
												{else}
													{displayPrice price=$total_discounts*-1}
												{/if}
											{else}
												{displayPrice price=$total_discounts_tax_exc*-1}
											{/if}
										</td>
									</tr>
									{if $use_taxes}
										{if $priceDisplay && $total_tax != 0}
											<tr class="cart_total_tax">
												<td colspan="4" class="text-right">{l s='Total tax:'}</td>
												<td colspan="2" class="price" id="total_tax" >{displayPrice price=$total_tax}</td>
											</tr>
										{/if}
										<tr class="cart_total_price">
											<td colspan="4" class="total_price_container text-right"><span>{l s='Total'}</span></td>
											<td colspan="2" class="price" id="total_price_container">
												<span id="total_price">{displayPrice price=$total_price}</span>
											</td>
										</tr>
									{else}
									<tr class="cart_total_price">
										{if $voucherAllowed}
											<td colspan="2" id="cart_voucher" class="cart_voucher">
												<div id="cart_voucher" class="table_block">
													{if isset($errors_discount) && $errors_discount}
														<ul class="alert alert-danger">
														{foreach from=$errors_discount key=k item=error}
															<li>{$error|escape:'html':'UTF-8'}</li>
														{/foreach}
														</ul>
													{/if}
													{if $voucherAllowed}
														<form action="{if $opc}{$link->getPageLink('order-opc', true)}{else}{$link->getPageLink('order', true)}{/if}" method="post" id="voucher">
															<fieldset>
																<h4>{l s='Vouchers'}</h4>
																<input type="text" id="discount_name" class="form-control" name="discount_name" value="{if isset($discount_name) && $discount_name}{$discount_name}{/if}" />
																<input type="hidden" name="submitDiscount" />
																<button type="submit" name="submitAddDiscount" class="button btn btn-default button-small"><span>{l s='ok'}</span></button>
																{if $displayVouchers}
																	<p id="title" class="title_offers">{l s='Take advantage of our offers:'}</p>
																	<div id="display_cart_vouchers">
																	{foreach from=$displayVouchers item=voucher}
																		<span onclick="$('#discount_name').val('{$voucher.name}');return false;" class="voucher_name">{$voucher.name}</span> - {$voucher.description} <br />
																	{/foreach}
																	</div>
																{/if}
															</fieldset>
														</form>
													{/if}
												</div>
											</td>
										{/if}
										<td colspan="{if !$voucherAllowed}3{else}2{/if}" class="text-right total_price_container">
											<span>{l s='Total'}</span>
										</td>
										<td colspan="1" class="price total_price_container" id="total_price_container">
											<span id="total_price">{displayPrice price=$total_price_without_tax}</span>
										</td>
									</tr>
									{/if}
								</tfoot>

								<tbody>
									{foreach from=$products item=product name=productLoop}
										{assign var='productId' value=$product.id_product}
										{assign var='productAttributeId' value=$product.id_product_attribute}
										{*assign var='quantityDisplayed' value=0*}
										{assign var='cannotModify' value=1}
										{assign var='odd' value=$product@iteration%2}
										{assign var='noDeleteButton' value=1}

										{* Display the product line *}
										{include file="$tpl_dir./shopping-cart-product-line.tpl"}

										{* Then the customized datas ones*}
										{if isset($customizedDatas.$productId.$productAttributeId)}
											{foreach from=$customizedDatas.$productId.$productAttributeId[$product.id_address_delivery] key='id_customization' item='customization'}
												<tr id="product_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}" class="alternate_item cart_item">
													<td colspan="4">
														{foreach from=$customization.datas key='type' item='datas'}
															{if $type == $CUSTOMIZE_FILE}
																<div class="customizationUploaded">
																	<ul class="customizationUploaded">
																		{foreach from=$datas item='picture'}
																			<li>
																				<img src="{$pic_dir}{$picture.value}_small" alt="" class="customizationUploaded" />
																			</li>
																		{/foreach}
																	</ul>
																</div>
															{elseif $type == $CUSTOMIZE_TEXTFIELD}
																<ul class="typedText">
																	{foreach from=$datas item='textField' name='typedText'}
																		<li>
																			{if $textField.name}
																				{l s='%s:' sprintf=$textField.name}
																			{else}
																				{l s='Text #%s:' sprintf=$smarty.foreach.typedText.index+1}
																			{/if}
																			{$textField.value}
																		</li>
																	{/foreach}
																</ul>
															{/if}
														{/foreach}
													</td>
													<!--<td class="cart_quantity text-center">
														{*$customization.quantity*}
													</td>-->
													<td class="cart_total"></td>
												</tr>
												{*assign var='quantityDisplayed' value=$quantityDisplayed+$customization.quantity*}
											{/foreach}
											{* If it exists also some uncustomized products *}
											{*if $product.quantity-$quantityDisplayed > 0}{include file="$tpl_dir./shopping-cart-product-line.tpl"}{/if*}
										{/if}
									{/foreach}
									{assign var='last_was_odd' value=$product@iteration%2}
									{foreach $gift_products as $product}
										{assign var='productId' value=$product.id_product}
										{assign var='productAttributeId' value=$product.id_product_attribute}
										{*assign var='quantityDisplayed' value=0*}
										{assign var='odd' value=($product@iteration+$last_was_odd)%2}
										{assign var='ignoreProductLast' value=isset($customizedDatas.$productId.$productAttributeId)}
										{assign var='cannotModify' value=1}
										{* Display the gift product line *}
										{include file="./shopping-cart-product-line.tpl" productLast=$product@last productFirst=$product@first}
									{/foreach}
								</tbody>

								{if count($discounts)}
									<tbody>
										{foreach from=$discounts item=discount name=discountLoop}
											<tr class="cart_discount {if $smarty.foreach.discountLoop.last}last_item{elseif $smarty.foreach.discountLoop.first}first_item{else}item{/if}" id="cart_discount_{$discount.id_discount}">
												<td class="cart_discount_description" colspan="2">{$discount.description}</td>												
												<td class="cart_discount_name">{$discount.name}</td>
												<td class="cart_discount_price" colspan="2">
													<span class="price-discount">
														{if $discount.value_real > 0}
															{if !$priceDisplay}
																{displayPrice price=$discount.value_real*-1}
															{else}
																{displayPrice price=$discount.value_tax_exc*-1}
															{/if}
														{/if}
													</span>
												</td>
											</tr>
										{/foreach}
									</tbody>
								{/if}
							</table>
						</div> <!-- end order-detail-content -->
					{/if}
					{if $opc}<div id="opc_payment_methods-content">{/if}
					<div id="HOOK_PAYMENT">
						{$HOOK_PAYMENT}
					</div>
					{if $opc}</div> <!-- end opc_payment_methods-content -->{/if}
				{else}
					<p class="alert alert-warning">{l s='No payment modules have been installed.'}</p>
				{/if}
				{if !$opc}
					<p class="cart_navigation clearfix">
						<a href="{$link->getPageLink('order', true, NULL, "step=2")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default">
							<i class="icon-chevron-left"></i>
							{l s='Continue shopping'}
						</a>
					</p>
				{else}
					</div> <!-- end opc_payment_methods -->
				{/if}
			</div> <!-- end HOOK_TOP_PAYMENT -->

Cela n'affichera pas la quantité non plus dans la confirmation avant paiement et donc le client ne pourra pas modifier la quantité.

 

Hum, non il te faut une gestion des stocks avec 1 seul produit en stock pour chaque produit.

 

Bon courage,

 

Okar

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

Eh bien, une procédure normale de paiement :

une personne voit un tableau qui lui plait. Sur cette page, elle peut déjà choisir la quantité; (cela est supprimé via les lignes que j'ai modifié dans product.tpl, les premières lignes que j'ai copié-collé)

Elle clique sur "ajouter au panier"; A partir de là, elle peut être redirigée vers son panier ou non (on va supposer qu'elle l'est);

Elle arrive sur la page de commande (en fonction de ce que vous avez choisi : one page checkout, ou commande standard en 5 étapes, je vais supposer que vous utilisez la seconde);

Là, elle confirme son choix (ici, elle peut de nouveau choisir la quantité. Je vous ai copié-collé mon fichier order-payment.tpl ici, vous pouvez remplacer le vôtre par celui-ci, si vous avez la même version presta que moi ou au-dessus. Sauvegardez tout de même sur votre ordinateur votre propre fichier order-payment.tpl au cas où);

Elle passe ensuite à l'étape d'identification : si elle a déjà un compte, elle s'identifie, sinon elle en crée un;

Elle valide son adresse de livraison et de facturation;

Ensuite, elle choisit son moyen de livraison dans les différents moyens que vous lui proposez;

Enfin, elle paie en ligne si vous avez installé un module de paiement (ou si vous voulez qu'elle paie à la livraison, prenez le module  "paiement à la livraison").

 

J'espère avoir été claire, n'hésitez pas à poser des questions, si non !

Link to comment
Share on other sites

Toujours ? Hmm... Allez voir du côté du template shopping-cart-product-line.tpl, alors... Et changez les lignes de votre fichier par celles-ci :

<td class="cart_quantity text-center">1
		{*if isset($cannotModify) AND $cannotModify == 1}
			<span>
				{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}
					{$product.customizationQuantityTotal}
				{else}
					{$product.cart_quantity-$quantityDisplayed}
				{/if}
			</span>
		{else}
			{if isset($customizedDatas.$productId.$productAttributeId) AND $quantityDisplayed == 0}
				<span id="cart_quantity_custom_{$product.id_product}_{$product.id_product_attribute}_{$product.id_address_delivery|intval}" >{$product.customizationQuantityTotal}</span>
			{/if}
			{if !isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0}
				
				<input type="hidden" value="{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}" name="quantity_{$product.id_product}_{$product.id_product_attribute}_{if $quantityDisplayed > 0}nocustom{else}0{/if}_{$product.id_address_delivery|intval}_hidden" />
				<input size="2" type="text" autocomplete="off" class="cart_quantity_input form-control grey" value="{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}"  name="quantity_{$product.id_product}_{$product.id_product_attribute}_{if $quantityDisplayed > 0}nocustom{else}0{/if}_{$product.id_address_delivery|intval}" />
				<div class="cart_quantity_button clearfix">
				{if $product.minimal_quantity < ($product.cart_quantity-$quantityDisplayed) OR $product.minimal_quantity <= 1}
					<a rel="nofollow" class="cart_quantity_down btn btn-default button-minus" id="cart_quantity_down_{$product.id_product}_{$product.id_product_attribute}_{if $quantityDisplayed > 0}nocustom{else}0{/if}_{$product.id_address_delivery|intval}" href="{$link->getPageLink('cart', true, NULL, "add=1&id_product={$product.id_product|intval}&ipa={$product.id_product_attribute|intval}&id_address_delivery={$product.id_address_delivery|intval}&op=down&token={$token_cart}")|escape:'html':'UTF-8'}" title="{l s='Subtract'}">
				<span><i class="icon-minus"></i></span>
				</a>
				{else}
					<a class="cart_quantity_down btn btn-default button-minus disabled" href="#" id="cart_quantity_down_{$product.id_product}_{$product.id_product_attribute}_{if $quantityDisplayed > 0}nocustom{else}0{/if}_{$product.id_address_delivery|intval}" title="{l s='You must purchase a minimum of %d of this product.' sprintf=$product.minimal_quantity}">
					<span><i class="icon-minus"></i></span>
				</a>
				{/if}
                	<a rel="nofollow" class="cart_quantity_up btn btn-default button-plus" id="cart_quantity_up_{$product.id_product}_{$product.id_product_attribute}_{if $quantityDisplayed > 0}nocustom{else}0{/if}_{$product.id_address_delivery|intval}" href="{$link->getPageLink('cart', true, NULL, "add=1&id_product={$product.id_product|intval}&ipa={$product.id_product_attribute|intval}&id_address_delivery={$product.id_address_delivery|intval}&token={$token_cart}")|escape:'html':'UTF-8'}" title="{l s='Add'}"><span><i class="icon-plus"></i></span></a>
				</div>
			{/if}
		{/if*}
	</td>

Vous aurez un 1 d'affiché et rien d'autre.
Tenez-moi au courant. N'oubliez pas de vider votre navigateur et dans votre FTP, videz aussi /www/cache/smarty/compile/ de tous les dossiers (laissez uniquement le index.php qui traine).

 

Bon courage,

 

Okar

Link to comment
Share on other sites

Ah, votre gestion des stocks n'accepte peut-être pas 1 en tant que quantité minimale. Si vous savez que vous n'avez qu'un seul produit à chaque fois, de toute façon, il vous suffira de passer le produit en "sold out" (mais ce n'est pas optimisé, cela risque de vous prendre du temps, essayez quand même de voir si vous ne pouvez pas mettre 1 en quantité minimale dans vos stocks).

 

Bon courage pour la suite,

Cordialement,

Okar

Link to comment
Share on other sites

Par contre, quand je vais voir dans les détails du produit, mon menu disparait

 

Edit : non je sais, j'ai désinstaller me menu haut pour le réinstaller mais il me fait des erreurs de "maximum execution excedeed" !

 

post-898514-0-63490400-1421077215_thumb.png

 

re edit : J'ai redémarré mon serveur wamp, j'ai réussi à aller sur la page de configuration du module "blocktopmenu", mais cependant quand j'enregistre ce que j'ai fais, ça me remet l'erreur.

 

J'ai réussi à enfin enregistrer mais l'erreur persiste assez souvent :/

post-898514-0-96831500-1421076906_thumb.png

Edited by Bourdel (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...