Categories
Extensions OpenCart

OpenCart Move To Wishlist Module

This module allowed customer move the product into their wishlist on the cart page. It’s better than remove the item from cart. This module will move the item into wishlist then remove the item from the customer’s cart.

The module just modified 2 file in OpenCart included Controller/Cart and Template/Cart.

1. catalog/controller/checkout/cart.php
Find these line:

$data['products'][] = array(

Add these before line found:

'product_id' => $product['product_id'],

2. catalog/view/theme/*/template/checkout/cart.tpl
Find these line:

<?php if ($product['recurring']) { ?>

Add these before line found:

<br />
<button data-toggle="tooltip" onclick="moveToWishList(‘<?php echo $product[‘product_id’]; ?>’,'<?php echo $product[‘cart_id’]; ?>’);" title="Move To Wishlist" class="btn btn-default"><i class="fa fa-heart"></i> Move To Wishlist</button>

Find these line:

<?php echo $footer; ?>

Add these before line found:

<script type=”text/javascript”>
<!–
function moveToWishList(product_id,key) {
$.ajax({
url: ‘index.php?route=account/wishlist/add’,
type: ‘post’,
data: ‘product_id=’ + product_id,
dataType: ‘json’,
success: function(json) {
$(‘.alert’).remove();

cart.remove(key);

$(‘#wishlist-total span’).html(json[‘total’]);
$(‘#wishlist-total’).attr(‘title’, json[‘total’]);

$(‘html, body’).animate({ scrollTop: 0 }, ‘slow’);

if (json[‘success’]) {
$(‘#content’).parent().before(‘<div class=”alert alert-success”><i class=”fa fa-check-circle”></i> ‘ + json[‘success’] + ‘ <button type=”button” class=”close” data-dismiss=”alert”>×</button></div>’);
}
if (getURLVar(‘route’) == ‘checkout/cart’ || getURLVar(‘route’) == ‘checkout/checkout’) {
location = ‘index.php?route=checkout/cart’;
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + “\r\n” + xhr.statusText + “\r\n” + xhr.responseText);
}
});
}
//–></script>

Here are OCMod available for easy install(Included 2x & 3x OC version): Download here

Please feel free donate a cup of coffee for the module. Thank you.

Donate