News:

Support the VirtueMart project and become a member

Main Menu

Creating 'Delete' button in VirtueMart 2+ Cart Module

Started by DATURA, December 25, 2012, 14:36:52 PM

Previous topic - Next topic

DATURA

Hello!


I'm trying to modify VirtueMart cart module and add "delete" button to the list of items





But nothing can do with it, besause i'm just a PHP programmer  :-[


Trying as shown there http://forum.virtuemart.net/index.php?topic=99141.0
but after activating "plg_system_vm2_cart_j25" stops working "add to cart" button,
and got
"http://xxxxxxxxxx.ru/index.php?option=com_virtuemart&nosef=1&view=cart&task=viewJS&format=json&_=1356442163804 500 (Internal Server Error)"
in java console.


May be somebody already do it? May be there is any way to write it?


Please help with it..  :(


Joomla! 2.5.8,
VirtueMart 2.0.16

DATURA


May be use some AJAX/Java request which remove product from cart by product SKU?


For example write product list in cart module by code:

<div class="vm_cart_products">
<div class="container">
<?php foreach ($data->products as $product)
{
if ($show_price) { ?>

<div class="del_<?php echo  $product['product_sku'?>" style="float: right;">
<span class="del-button"><input type="submit" class="del-button" value="" /></span>
</div>
  <div class="prices" style="float: right;">
<?php echo  $product['prices'?></div>
<?php ?>
<div class="product_row">
<span class="product_name"><?php echo  $product['product_name'?></span>&nbsp;&nbsp;&nbsp;<span class="quantity"><?php echo  $product['quantity'?></span>&nbsp;шт.
</div>

<div class="horizontal-separator"></div>
<?php 
}
?>

</div>
</div>


???

DATURA

#2
From cart order page items removing by code


<a class="vmicon vm2-remove_from_cart"
title="<?php echo JText::('COM_VIRTUEMART_CART_DELETE'?>" align="middle"
href="<?php echo JRoute::('index.php?option=com_virtuemart&view=cart&task=delete&cart_virtuemart_product_id=' $prow->cart_item_id?>">
</a>



but how to convert product_sku to cart_virtuemart_product_id???  :o :-\

DATURA

#3
OK, if we disable SEO in virtualmart and got link like
/magazin/view/productdetails/virtuemart_product_id/4/virtuemart_category_id/1.html

in $product[product_name], so...


<?php // Cut product id from product link "/magazin/view/cart/task/delete/cart_virtuemart_product_id/4.html"
$id_pos = stripos($product[product_name],'product_id/')+11;
$cat_pos = stripos($product[product_name],'/virtuemart_category_id');
$prod_id = substr ($product[product_name], $id_pos, $cat_pos - $id_pos);
?>



and we now may delete the product with

<a
class="vmicon vm2-remove_from_cart"
title="<?php echo JText::('COM_VIRTUEMART_CART_DELETE'?>"
align="middle"
href="<?php echo JRoute::('index.php?option=com_virtuemart&view=cart&task=delete&cart_virtuemart_product_id=' .$prod_id?>">
</a>



BUT we got redirecting to "main cart"... with working cart module... brrrrrrrrrr  :-X :-\