Jump to content

[Solved] How To Delete A Free Gift From The Shopping-Cart With A Delete Button


Recommended Posts

I SOLVED it myself. Works fairly well, is not perfect, but does the job.

 

In this way I have done it :

 

Look in your theme folder and open  ” shopping-cart-product-line.tpl

 

look for:

 

{if (!isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0) && empty($product.gift)} 

 

and replace it with:

 

 

{if (!isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0)}{* && empty($product.gift) *}

 

--------------------------------------------------------------------------

 

 

In cart rules, I created different rules (actions> send a free gift) to give a free gift from a certain purchase amount, as a gift at 50 euro, or another gift at 100 euros etc ....

 

The customer can then choose a gift from the list under the vouchers block.

 

Now it would be useful if there is a delete button  ( like a normal product ) present if the customer selected a wrong gift to remove it in order to select another gift.

 

I've already looked at the file shopping-cart.tlp but did not immediately find something to fix it.

 

Does anyone have any experience with coding, believed to be a few lines in which tpl file is modified.

 

Best regards, Profoon

 

ps: I use version 1.6.1.1 prestashop

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

  • 1 month later...
  • 3 months later...

UP please, Is not working like this,

 

The issue is in the forge :

http://forge.prestashop.com/browse/PSCFV-10647

 

we need to put something maybe after {else} ??

<td class="cart_delete text-center" data-title="{l s='Delete'}">
		{if (!isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0) && empty($product.gift)}
			<div>
				<a rel="nofollow" title="{l s='Delete'}" class="cart_quantity_delete" id="{$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, "delete=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'}"><i class="icon-trash"></i></a>
			</div>
		{else}

		{/if}
		</td>
Edited by Deasy-Oak (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Solution (prestashop 1.6.1.10):

 

In Cart.php modify CartCore::getSummaryDetails by adding this line 

                        $gift_product['id_cart_rule_gift']= $cart_rule['id_cart_rule'];  

after

                        $gift_product = $product;

                        $gift_product['cart_quantity'] = 1;
                        $gift_product['price'] = 0;
                        $gift_product['price_wt'] = 0;
                        $gift_product['total_wt'] = 0;
                        $gift_product['total'] = 0;
                        $gift_product['gift'] = true;
 
In shopping-cart.tpl add this line:
                        {assign var='id_cart_rule_gift' value=$product.id_cart_rule_gift}
inside this foreach command:
                        {foreach $gift_products as $product}
                                   {assign var='productId' value=$product.id_product}
                                   {assign var='productAttributeId' value=$product.id_product_attribute}
                                   ...
                                   {include file="$tpl_dir./shopping-cart-product-line.tpl" productLast=$product@last productFirst=$product@first}
                        {/foreach}
 
In shopping-cart-product-line.tpl add:
                    {if !empty($product.gift)}                
                        {if strlen($product.id_cart_rule_gift)}
                            <a
                                href="{if $opc}{$link->getPageLink('order-opc', true)}{else}{$link->getPageLink('order', true)}{/if}?deleteDiscount={$product.id_cart_rule_gift}"
                                class="price_discount_delete"
                                title="{l s='Delete'}">
                                <i class="icon-trash"></i>
                            </a>
                        {/if}                
                    {/if} 
 
inside the else part of this conditional command:
 
           {if !isset($noDeleteButton) || !$noDeleteButton}
                   <td class="cart_delete text-center" data-title="{l s='Delete'}" ...
               {if (!isset($customizedDatas.$productId.$productAttributeId) OR $quantityDisplayed > 0) && empty($product.gift)}
                    <div>
                        ...
                   </div>
               {else}
 
                 ********************* add here ******************************
 
               {/if}
           </td>
         {/if}
  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...