Jump to content

[SOLVED] How to - Replace quantity text with an editable text box and update button on cart summary


wireaudio

Recommended Posts

Hello everyone,

the idea i had was to add a quantity text field so customers can change the quantity in the shopping cart - something that i believe 1.4 already has integrated, but i'm too scared to switch until it's final :)

I searched everywhere and all i could find was how to add a box that increases quantity by the quantity in the box... and that's not quite what i needed.

What does this do?

Replaces the quantity listed in the shopping cart summary with a editable text box where number can be changed to whatever customer wants, and adds a button under the text box named "Update" to change the quantity.

(see attachments for pictures)

This has only been tested on products without any customization quantities or non-quantitative products. (In other words, it's tested only on regular products). I will not do any more testing do to the lack of need for it.

Note: Each product has its own update button. I might consider changing this in the future, but for now, it will be like this.

PLEASE MAKE SURE TO BACKUP classes/Cart.php and themes/prestashop/shopping-cart-product-line.tpl before you begin!!!

The changes are quite simple and require editing of just two files, adding some code in one and replacing some code on the other:

Step 1:

First edit classes/Cart.php



Find:

               elseif ($operator == 'down')
               {
                   $qty = '`quantity` - '.intval($quantity);
                   $newQty = $result['quantity'] - intval($quantity);
               }




Add immedialy after:

               elseif ($operator == 'setto')
               {
                   $result2 = Db::getInstance()->getRow('
                       SELECT '.($id_product_attribute ? 'pa' : 'p').'.`quantity`, p.`out_of_stock`
                       FROM `'._DB_PREFIX_.'product` p
                       '.($id_product_attribute ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON p.`id_product` = pa.`id_product`' : '').'
                       WHERE p.`id_product` = '.intval($id_product).
                       ($id_product_attribute != NULL ? ' AND `id_product_attribute` = '.intval($id_product_attribute) : ''));
                   $productQty = intval($result2['quantity']);
                   $newQty = intval($quantity);
                   $qty = intval($quantity);

                   if (!Product::isAvailableWhenOutOfStock(intval($result2['out_of_stock'])))
                       if (intval($newQty) > $productQty)
                           return false;
               }





It should look like this:


.
.
.
               elseif ($operator == 'down')
               {
                   $qty = '`quantity` - '.intval($quantity);
                   $newQty = $result['quantity'] - intval($quantity);
               }
               elseif ($operator == 'setto')
               {
                   $result2 = Db::getInstance()->getRow('
                       SELECT '.($id_product_attribute ? 'pa' : 'p').'.`quantity`, p.`out_of_stock`
                       FROM `'._DB_PREFIX_.'product` p
                       '.($id_product_attribute ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON p.`id_product` = pa.`id_product`' : '').'
                       WHERE p.`id_product` = '.intval($id_product).
                       ($id_product_attribute != NULL ? ' AND `id_product_attribute` = '.intval($id_product_attribute) : ''));
                   $productQty = intval($result2['quantity']);
                   $newQty = intval($quantity);
                   $qty = intval($quantity);

                   if (!Product::isAvailableWhenOutOfStock(intval($result2['out_of_stock'])))
                       if (intval($newQty) > $productQty)
                           return false;
               }
               else
                   return false;
.
.
.




Step 2:

Open themes/prestashop/shopping-cart-product-line.tpl


Find:


{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}





Replace with:

           <form action="{$base_dir}cart.php" method="post">    
               <input type="hidden" name="token" value="{$token_cart}" />
               <input type="hidden" name="id_product" value="{$product.id_product|intval}" />
               <input type="hidden" name="add" value="1" />
               <input type="hidden" name="ipa" value="{$product.id_product_attribute|intval}" />
                  <input type="hidden" name="op" value="setto" />
               <input align="left" type="text" name="qty" class="text" value="{$product.cart_quantity-$quantityDisplayed}" size="3" maxlength="5" /><br />

<input type="submit" name="Submit" value="{l s='Update'}" /></p>
           </form>

40172_BY8lqD3jPuq1mYco0V09_t

40173_GApE3kmXUfOSTuJDzdG2_t

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Hello, and thanks for this precious tip which I used, and it worked perfectly on a local host.
BUT, once on a remote server, it caused some bug when trying to change product quantities and returned this error : "you already have the maximum quantity available for this product" even if there is enough products in stock.

Hope it will help to improve the original code.
May be useful for people who still use an old version of Prestashop, but as said before, it certainly has to be done without a hack with the 1.4 new release...

Link to comment
Share on other sites

  • 1 month later...

Hello, thank you very much for share this code, it's really good.

I use this code and I made some modification, nothing big, but I got a problem, all works fine except the first element of the product list, I mean, If I have 4 different product on my cart, I can change the quantities for the 2nd, the 3rd and 4th, but never I can do for the first one, when I make click on update on the first element then it submits all form and not only the update quantity, it's very rarely, because as I write before all other elements make the update good.
Finally, I can add that I put all code like you show on this post, and the same error for the first element is shown, please if you have any idea of that let me know, I try to change so many thing but I can't make that this first element works fine.

In advance thank you very much.

PS: I forgot, I try with different product like the first of the list, and with all makes same, the problem is always with the first element of the list.

Link to comment
Share on other sites

Hello Joa,

I am testing the box on my servers, and they all seem to act fine.
Feel free to see if it does it on my site as well, maybe i'm not duplicating it right. You can go to www.powerprolighting.com or www.exitretrofit.com, they both use the same code as listed above.

Let me know.

Link to comment
Share on other sites

Thank you very much for your fast answer !!

Well, I try to check those websites but I can´t see the one page checkout on them, maybe you disable this option.

I try all day to check all code but I can´t make it works fine, I mean, all works fine except the first element of the list, and if the cart has only one element or product then it does not works fine, it´s like if the first product in the cart when I click UPDATE then the cart page is summited to the next step, but always the first product only.

Well, I´ll try to fix that, if I have any update I will post here.

Thank you very much !!

Link to comment
Share on other sites

Ok, i will re-enable the 1 page checkout once i have some time and i'll try to figure out the bug, however i'm leaving town until monday. Please post back here to remind me sometime next week if you don't hear from me.

Take care.

Link to comment
Share on other sites

  • 7 months later...

Hello, this is really great and very interesting and useful BUT regretably I can´t make it to work :(

 

Using Prestashop 1.4.5 and the Glossy Template 1.4 and I am not using the one page checkout, using 5 steps.

 

I think that probably I am relacing or making the change wrongly, also there seems to be some missing text in the above post where there is two empty squares that have more text content but it invisble.

 

 

Please could anyone tell what is the right way to do it and if there is something wrong?

 

Thanks very much

 

Here below is my final cart.php after making the change

 

/* Update quantity if product already exist */
  if ($result)
  {
if ($operator == 'up')
{
 $result2 = Db::getInstance()->getRow('
  SELECT '.(!empty($id_product_attribute) ? 'pa' : 'p').'.`quantity`, p.`out_of_stock`
  FROM `'._DB_PREFIX_.'product` p
  '.(!empty($id_product_attribute) ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON p.`id_product` = pa.`id_product`' : '').'
  WHERE p.`id_product` = '.(int)($id_product).
  (!empty($id_product_attribute) ? ' AND `id_product_attribute` = '.(int)$id_product_attribute : ''));
 $productQty = (int)$result2['quantity'];
 $newQty = (int)$result['quantity'] + (int)$quantity;
 $qty = '+ '.(int)$quantity;
 if (!Product::isAvailableWhenOutOfStock((int)$result2['out_of_stock']))
  if ($newQty > $productQty)
   return false;
}
elseif ($operator == 'down')
			{
				$qty = '`quantity` - '.intval($quantity);
				$newQty = $result['quantity'] - intval($quantity);
			}
*____________________________________this here is the new part added__________________________________
			elseif ($operator == 'setto')
			{
				$result2 = Db::getInstance()->getRow('
					SELECT '.($id_product_attribute ? 'pa' : 'p').'.`quantity`, p.`out_of_stock`
					FROM `'._DB_PREFIX_.'product` p
					'.($id_product_attribute ? 'LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON p.`id_product` = pa.`id_product`' : '').'
					WHERE p.`id_product` = '.intval($id_product).
					($id_product_attribute != NULL ? ' AND `id_product_attribute` = '.intval($id_product_attribute) : ''));
				$productQty = intval($result2['quantity']);
				$newQty = intval($quantity);
				$qty = intval($quantity);
				if (!Product::isAvailableWhenOutOfStock(intval($result2['out_of_stock'])))
					if (intval($newQty) > $productQty)
						return false;
			}
*______________________________this is the end of the part added_______________________________
			else
				return false;
 if ($newQty < $minimalQuantity AND $minimalQuantity > 1)
  return -1;
}
else
 return false;
/* Delete product from cart */

 

AND THEN ALSO THE - shopping-cart-product-line.tpl with the added and replaced form

 

<a class="cart_quantity_down" style="opacity: 0.3;" href="#" id="cart_quantity_down_{$product.id_product}_{$product.id_product_attribute}" title="{l s='You must purchase a minimum of '}{$product.minimal_quantity}{l s=' of this product.'}">
<img src="{$img_dir}icon/quantity_down.gif" width="14" height="9" alt="{l s='Subtract'}" />
  </a>
  {/if}
  </div>
  <input type="hidden" value="<form action="{$base_dir}cart.php" method="post">  
			<input type="hidden" name="token" value="{$token_cart}" />
			<input type="hidden" name="id_product" value="{$product.id_product|intval}" />
			<input type="hidden" name="add" value="1" />
			<input type="hidden" name="ipa" value="{$product.id_product_attribute|intval}" />
			   <input type="hidden" name="op" value="setto" />
			<input align="left" type="text" name="qty" class="text" value="{$product.cart_quantity-$quantityDisplayed}" size="3" maxlength="5" /><br />

<input type="submit" name="Submit" value="{l s='Update'}" /></p>
		</form>" />
  <input size="2" type="text" class="cart_quantity_input" value="{<form action="{$base_dir}cart.php" method="post">  
			<input type="hidden" name="token" value="{$token_cart}" />
			<input type="hidden" name="id_product" value="{$product.id_product|intval}" />
			<input type="hidden" name="add" value="1" />
			<input type="hidden" name="ipa" value="{$product.id_product_attribute|intval}" />
			   <input type="hidden" name="op" value="setto" />
			<input align="left" type="text" name="qty" class="text" value="{$product.cart_quantity-$quantityDisplayed}" size="3" maxlength="5" /><br />

<input type="submit" name="Submit" value="{l s='Update'}" /></p>
		</form>" />

 {/if}
</td>
<td class="cart_total">
 <span class="price" id="total_product_price_{$product.id_product}_{$product.id_product_attribute}">

Link to comment
Share on other sites

  • 2 weeks later...

Please, anyone else have already changed the + - buttons and have replaced them with an update button as shown here ?

 

It is very interesting to add a new update button in the prestashop cart instead of the + - buttons but regretably I have followed the instructions but it does not work for me. It seems that there is MORE code than what is shown in the post.

 

Please, could anyone be so kind to tell me how to do it, and what is needed to change?.

 

Thanks very much. Kindest regards.

Link to comment
Share on other sites

  • 8 months later...

I have worked on this because I found one bug and display problem.

I have also corrected a bug from Prestashop, the available/not avavailable icon that was not working.

 

Find attached the file you need to have it works.

This works on Prestashop 1.4.8.2

 

1) Put the Cart.php in the YourShopRoot/override/classes

2) Save the file YourShopRoot/themes/YourTheme/shopping-cart-product-line.tpl under a new name (shopping-cart-product-line.tpl.orig for example)

3) Copy the attached shopping-cart-product-line.tpl in the same folder

4) Copy refresh.gif and delete.gif in the YourSitesRoot/themes/YourTheme/img/icon folder

5) In global.css look for .cart_quantity_input, delete this line and copy :

.cart_quantity_input { float: left; margin: 5px 1px 0 0; }

.cart_quantity_udate { float: left; margin: 5px 10px 0 2px; border-width: 0px;}

 

 

Enjoy

 

Patrice

Cart.zip

Edited by PatriceVigier (see edit history)
  • Like 2
Link to comment
Share on other sites

Cart.php code :

 

<?php
/*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 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/osl-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: 14001 $
*  @license	http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
class Cart extends CartCore {
/**
 * Update product quantity
 *
 * @param integer $quantity Quantity to add (or substract)
 * @param integer $id_product Product ID
 * @param integer $id_product_attribute Attribute ID if needed
 * @param string $operator Indicate if quantity must be increased or decreased
 */
public function updateQty($quantity, $id_product, $id_product_attribute = NULL, $id_customization = false, $operator = 'up') {
	$product = new Product((int) $id_product, false, (int) Configuration::get('PS_LANG_DEFAULT'));
	/* If we have a product combination, the minimal quantity is set with the one of this combination */
	if (!empty($id_product_attribute))
		$minimalQuantity = (int) Attribute::getAttributeMinimalQty((int) $id_product_attribute);
	else
		$minimalQuantity = (int) $product->minimal_quantity;
	if (!Validate::isLoadedObject($product))
		die(Tools::displayError());
	if (isset(self::$_nbProducts[$this->id]))
		unset(self::$_nbProducts[$this->id]);
	if (isset(self::$_totalWeight[$this->id]))
		unset(self::$_totalWeight[$this->id]);
	if ((int) $quantity <= 0)
		return $this->deleteProduct((int) $id_product, (int) $id_product_attribute, (int) $id_customization);
	else if (!$product->available_for_order OR Configuration::get('PS_CATALOG_MODE'))
		return false;
	else {
		/* Check if the product is already in the cart */
		$result = $this->containsProduct((int) $id_product, (int) $id_product_attribute, (int) $id_customization);
		/* Update quantity if product already exist */
		if ($result) {
			if ($operator == 'up') {
				$result2 = Db::getInstance()->getRow('
  SELECT ' . (!empty($id_product_attribute) ? 'pa' : 'p') . '.`quantity`, p.`out_of_stock`
  FROM `' . _DB_PREFIX_ . 'product` p
  ' . (!empty($id_product_attribute) ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON p.`id_product` = pa.`id_product`' : '') . '
  WHERE p.`id_product` = ' . (int) ($id_product) .
						(!empty($id_product_attribute) ? ' AND `id_product_attribute` = ' . (int) $id_product_attribute : ''));
				$productQty = (int) $result2['quantity'];
				$newQty = (int) $result['quantity'] + (int) $quantity;
				$qty = '+ ' . (int) $quantity;
				if (!Product::isAvailableWhenOutOfStock((int) $result2['out_of_stock']))
					if ($newQty > $productQty)
						return false;
			}

			elseif ($operator == 'down') {
				$qty = '- ' . (int) $quantity;
				$newQty = (int) $result['quantity'] - (int) $quantity;
				if ($newQty < $minimalQuantity AND $minimalQuantity > 1)
					return -1;
			}

//Ajout Patrice				
			elseif ($operator == 'setto') {
				$result2 = Db::getInstance()->getRow('
					SELECT ' . ($id_product_attribute ? 'pa' : 'p') . '.`quantity`, p.`out_of_stock`
					FROM `' . _DB_PREFIX_ . 'product` p
					' . ($id_product_attribute ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON p.`id_product` = pa.`id_product`' : '') . '
					WHERE p.`id_product` = ' . intval($id_product) .
						($id_product_attribute != NULL ? ' AND `id_product_attribute` = ' . intval($id_product_attribute) : ''));
				$productQty = intval($result2['quantity']);
				$newQty = intval($quantity);
				$qty = intval($quantity);
				if (!Product::isAvailableWhenOutOfStock(intval($result2['out_of_stock'])))
					if (intval($newQty) > $productQty)
						return false;
			}
//Fin ajout Patrice
			else
				return false;
			/* Delete product from cart */
			if ($newQty <= 0)
				return $this->deleteProduct((int) $id_product, (int) $id_product_attribute, (int) $id_customization);
			else if ($newQty < $minimalQuantity)
				return -1;
			else
				Db::getInstance()->Execute('
 UPDATE `' . _DB_PREFIX_ . 'cart_product`
 SET `quantity` = ' . $qty . ', `date_add` = NOW()
 WHERE `id_product` = ' . (int) $id_product .
						(!empty($id_product_attribute) ? ' AND `id_product_attribute` = ' . (int) $id_product_attribute : '') . '
 AND `id_cart` = ' . (int) $this->id . '
 LIMIT 1');
		}
		/* Add product to the cart */
		else {
			$result2 = Db::getInstance()->getRow('
SELECT ' . (!empty($id_product_attribute) ? 'pa' : 'p') . '.`quantity`, p.`out_of_stock`
FROM `' . _DB_PREFIX_ . 'product` p
' . (!empty($id_product_attribute) ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON p.`id_product` = pa.`id_product`' : '') . '
WHERE p.`id_product` = ' . (int) $id_product .
					(!empty($id_product_attribute) ? ' AND `id_product_attribute` = ' . (int) $id_product_attribute : ''));
			if (!Product::isAvailableWhenOutOfStock((int) $result2['out_of_stock']))
				if ((int) $quantity > $result2['quantity'])
					return false;
			if ((int) $quantity < $minimalQuantity)
				return -1;
			if (!Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'cart_product', array('id_product' => (int) $id_product,
						'id_product_attribute' => (int) $id_product_attribute, 'id_cart' => (int) $this->id,
						'quantity' => (int) $quantity, 'date_add' => date('Y-m-d H:i:s')), 'INSERT'))
				return false;
		}
	}
	// refresh cache of self::_products
	$this->_products = $this->getProducts(true);
	$this->update(true);
	if ($product->customizable)
		return $this->_updateCustomizationQuantity((int) $quantity, (int) $id_customization, (int) $id_product, (int) $id_product_attribute, $operator);
	else
		return true;
}
}

 

shopping-cart-product-line.tpl code

 

{*
* 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: 14008 $
*  @license	http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
<script type='text/javascript' charset='utf-8'>
{literal}
function required()
{
var len = document.getElementsByName('qty').length;
var txtValue = document.getElementsByName('qty');
var i = 0;
while (i<len || txtValue[i].value >0)
{
if((txtValue[i].value == 0) || (txtValue[i].value == "0") || (txtValue[i].value == ""))
	{
	   //alert("{/literal} {l s=' Quantity zero is not allowed, to delete the product, \n click on delete function located on the right of the line.'} {literal}");
	   alert("La quantité à zéro n\'est pas autorisée, \n pour supprimer l\'article, \n cliquez sur la fonction supprimer, à droite de la ligne.");			  
	txtValue[i].focus();
	return false;
	break;
	}
i++
}
}
{/literal}
</script>
<tr id="product_{$product.id_product}_{$product.id_product_attribute}" class="{if $smarty.foreach.productLoop.last}last_item{elseif $smarty.foreach.productLoop.first}first_item{/if}{if isset($customizedDatas.$productId.$productAttributeId) AND $quantityDisplayed == 0}alternate_item{/if} cart_item">
<td class="cart_product">
 <a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'small')}" alt="{$product.name|escape:'htmlall':'UTF-8'}" {if isset($smallSize)}width="{$smallSize.width}" height="{$smallSize.height}" {/if} /></a>
</td>
<td class="cart_description">
 <h5><a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'}</a></h5>
 {if isset($product.attributes) && $product.attributes}<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.attributes|escape:'htmlall':'UTF-8'}</a>{/if}
</td>
<td class="cart_ref">{if $product.reference}{$product.reference|escape:'htmlall':'UTF-8'}{else}--{/if}</td>
<td class="cart_availability">
{if $product.active AND $product.quantity <= $product.stock_quantity AND $product.available_for_order AND !$PS_CATALOG_MODE}
  <img src="{$img_dir}icon/available.gif" alt="{l s='Available'}" width="14" height="14" />
 {else}
  <img src="{$img_dir}icon/unavailable.gif" alt="{l s='Out of stock'}" width="14" height="14" />
 {/if}
	</td>
<td class="cart_unit">
 <span class="price" id="product_price_{$product.id_product}_{$product.id_product_attribute}">
  {if !$priceDisplay}{convertPrice price=$product.price_wt}{else}{convertPrice price=$product.price}{/if}
 </span>
</td>
<td class="cart_quantity"{if isset($customizedDatas.$productId.$productAttributeId) AND $quantityDisplayed == 0} style="text-align: center;"{/if}>
 {if isset($customizedDatas.$productId.$productAttributeId) AND $quantityDisplayed == 0}<span id="cart_quantity_custom_{$product.id_product}_{$product.id_product_attribute}" >{$product.customizationQuantityTotal}</span>{/if}
 {if !isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0}
		   <form name = "form1"  onsubmit="return required(document.form1.qty)" action="{$base_dir}cart.php" method="post" >
			<input type="hidden" name="token" value="{$token_cart}" />
			<input type="hidden" name="id_product" value="{$product.id_product|intval}" />
			<input type="hidden" name="add" value="1" />
			<input type="hidden" name="ipa" value="{$product.id_product_attribute|intval}" />
			<input type="hidden" name="op" value="setto" />
			<input align="left" type="text" name="qty" class="cart_quantity_input" value="{$product.cart_quantity-$quantityDisplayed}" size="1" maxlength="4" onblur="required(document.form1.qty)"/>
			<input class="cart_quantity_udate" type="image" title="{l s='Update quantity'}" src="{$img_dir}icon/refresh.gif" alt="{l s='Update'}" width="16" height="16" />
		</form>
 {/if}
</td>
<td class="cart_total">
 <span class="price" id="total_product_price_{$product.id_product}_{$product.id_product_attribute}">
  {if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}
{if !$priceDisplay}{displayPrice price=$product.total_customization_wt}{else}{displayPrice price=$product.total_customization}{/if}
  {else}
{if !$priceDisplay}{displayPrice price=$product.total_wt}{else}{displayPrice price=$product.total}{/if}
  {/if}
											<a rel="nofollow" class="cart_quantity_delete" id="{$product.id_product}_{$product.id_product_attribute}" href="{$link->getPageLink('cart.php', true)}?delete&id_product={$product.id_product|intval}&ipa={$product.id_product_attribute|intval}&token={$token_cart}" title="{l s='Delete'}"><img src="{$img_dir}icon/delete.gif" alt="{l s='Delete'}" class="icon" width="14" height="14" /></a>
{*Patrice -fin*}
			</span>
	</td>
</tr>

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Hi my mistake I replaced the cart.php in YourShopRoot/classes instead of YourShopRoot/override/classes

I now replaced the cart.php in the override/classes folder.

 

But now i get a new error when i checkout or add to cart

 

You already have the maximum quantity available for this product." even when i enough products in stock.

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

  • 2 months later...
  • 2 weeks later...
  • 1 month later...

Hi my mistake I replaced the cart.php in YourShopRoot/classes instead of YourShopRoot/override/classes

I now replaced the cart.php in the override/classes folder.

 

But now i get a new error when i checkout or add to cart

 

You already have the maximum quantity available for this product." even when i enough products in stock.

 

same problem here

Link to comment
Share on other sites

  • 10 months later...
  • 4 months later...

Well, I find error.

 

So it's for ps 1.5.6.2, and I let you test for other versions.

 

First : copy code of PatriceVigier to modify Cart.php and shopping-cart-product-line.tpl (with picture if you want)

 

Secondly : in Cart.php, change $productQty to $product_qty and $newQty to $new_qty (because it's for ps 1.4)

 

and Thirdly : always in Cart.php, find 

/* Delete product from cart */
if ($new_qty <= 0)
	return $this->deleteProduct((int)$id_product, (int)$id_product_attribute, (int)$id_customization);
else if ($new_qty < $minimal_quantity)
	return -1;
else
	Db::getInstance()->execute('
		UPDATE `'._DB_PREFIX_.'cart_product`
		SET `quantity` = '.$qty.', `date_add` = NOW()
		WHERE `id_product` = '.(int)$id_product.
		(!empty($id_product_attribute) ? ' AND `id_product_attribute` = '.(int)$id_product_attribute : '').'
		AND `id_cart` = '.(int)$this->id.(Configuration::get('PS_ALLOW_MULTISHIPPING') && $this->isMultiAddressDelivery() ? ' AND `id_address_delivery` = '.(int)$id_address_delivery : '').'
		LIMIT 1'
	);

Change this line 

SET `quantity` = `quantity` '.$qty.', `date_add` = NOW()

by

SET `quantity` = '.$qty.', `date_add` = NOW()

I declare this post is twice resolved.

 

Thank you very much to PatriceVigier.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hello,

 

Sorry I don't know :( 

I stayed in the version 1.5.6.2 and I don't know if there is a lot of difference between them.

You can try but think of copy to protect the original files.

 

If that works, thank you for letting it know, that will interest certainly somebody.  ;)

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