Register

Author Topic: Remove item issues in Checkout Cart when changing to third party themes  (Read 4734 times)

Randem

  • Administrator
  • Hero Member
  • *****
  • Posts: 2686
Remove item issues in Checkout Cart when changing to third party themes
« Reply #1 on: January 29, 2016, 07:44:53 PM »
I have come across a few error in third party themes that claimed to be OpenCart v2.x compatible and basically work except when removing product from the checkout cart.
The files that I have found to have the answers are the following:

  • catalog\view\theme\default\template\common\cart.tpl      -   Line 25
  • catalog\view\theme\default\template\checkout\cart.tpl     -   Line 76 and 79

The problem with some third party themes involves the AJAX call onclick=cart.remove in the listed files. The problem connects with a key that was not changed in the theme. The voucher line is incorrect in the v2.1.0.1 theme.

$product['key'] is supposed to have been changed to  $product['cart_id']

I have noticed this in the zMaxcart themes for one but almost every other theme that I  have looked at has this issue also. This has been fixed in our VQMOD XML file with the following code:

Other Helpful Information

Code: [Select]
//=======================================================================================================================
// RJ - 20160127  - Fix Theme (cart.remove and voucher.remove) line 25
//=======================================================================================================================

<file name="catalog/view/theme/*/template/common/cart.tpl">
<operation error="ignore">
   <search position="replace"><![CDATA[<td class="text-center"><button type="button" onclick="cart.remove('<?php echo $product['key']; ?>');" title="<?php echo $button_remove?>" class="btn btn-danger btn-xs"><i class="fa fa-times"></i></button></td>]]></search>
<add><![CDATA[<td class="text-center"><button type="button" onclick="cart.remove('<?php echo $product['cart_id']; ?>');" title="<?php echo $button_remove?>" class="btn btn-danger btn-xs"><i class="fa fa-times"></i></button></td>]]></add>
</operation>
    </file>
 
//=======================================================================================================================
// RJ - 20160129  - Fix Theme (cart.remove and voucher.remove) lines  76 and 79
//=======================================================================================================================

<file name="catalog/view/theme/*/template/checkout/cart.tpl">
<operation error="ignore">
   <search position="replace"><![CDATA[<input type="text" name="quantity[<?php echo $product['key']; ?>]" value="<?php echo $product['quantity']; ?>" size="1" class="form-control" />]]></search>
<add><![CDATA[<input type="text" name="quantity[<?php echo $product['cart_id']; ?>]" value="<?php echo $product['quantity']; ?>" size="1" class="form-control" />]]></add>
</operation>


<operation error="ignore">
   <search position="replace"><![CDATA[<button type="button" data-toggle="tooltip" title="<?php echo $button_remove?>" class="btn btn-danger" onclick="cart.remove('<?php echo $product['key']; ?>');"><i class="fa fa-times-circle"></i></button></span></div></td>]]></search>
<add><![CDATA[<button type="button" data-toggle="tooltip" title="<?php echo $button_remove?>" class="btn btn-danger" onclick="cart.remove('<?php echo $product['cart_id']; ?>');"><i class="fa fa-times-circle"></i></button></span></div></td>]]></add>
</operation>
    </file>