Add delete button and action for address list in checkout page

Started by florihana, August 31, 2017, 15:15:01 PM

Previous topic - Next topic

florihana

Hi Experts:

Joomla: 3.6
VirtueMart 3.0.18

I need to add delete button in checkout page, see picture
In this page we could add serveral delivery address, but there is no delete delivery address function
so I would like to ask experts if someone had done this or any way to make it more easier clean code

I guess the delete controller is in this file: /components/com_virtuemart/controllers/user.php

line 272
function removeAddressST(){

$virtuemart_userinfo_id = vRequest::getInt('virtuemart_userinfo_id');
$virtuemart_user_id = vRequest::getInt('virtuemart_user_id');

//Lets do it dirty for now
$userModel = VmModel::getModel('user');
vmdebug('removeAddressST',$virtuemart_user_id,$virtuemart_userinfo_id);
$userModel->setId($virtuemart_user_id[0]);
$userModel->removeAddress($virtuemart_userinfo_id);

$layout = vRequest::getCmd('layout','edit');
$this->setRedirect( JRoute::_('index.php?option=com_virtuemart&view=user&task=edit&virtuemart_user_id[]='.$virtuemart_user_id[0], $this->useXHTML,$this->useSSL) );
}


And for showing this add delivery address list layout view is in this file: components/com_virtuemart/views/cart/tmpl/defaut_address.php
line 80
if($this->cart->user->virtuemart_user_id==0){

echo vmText::_ ('COM_VIRTUEMART_USER_FORM_ST_SAME_AS_BT');
echo VmHtml::checkbox ('STsameAsBT', $this->cart->STsameAsBT,1,0,'id="STsameAsBTjs" data-dynamic-update=1') . '<br />';
} else if(!empty($this->cart->lists['shipTo'])){
echo $this->cart->lists['shipTo'];
}



so how do I binding this controller: removeAddressST to view part ?

thank you so much

florihana

Hi,

find out the solution, it has to add delet action in components/com_virtuemart/views/cart/view.html.php
renderCompleteAddressList()

here add:
'</a>&nbsp;&nbsp;<a href="'.JRoute::_ ('index.php?option=com_virtuemart&view=user&task=removeAddressST&virtuemart_user_id[]=' . $_addressList[$_i]->virtuemart_user_id . '&virtuemart_userinfo_id=' . $address->virtuemart_userinfo_id, $useXHTTML, $useSSL ). '" >'.'<i class="icon-delete"></i>'.vmText::_('COM_VIRTUEMART_USER_DELETE_ST').'</a></br>';

then go to: components/com_virtuemart/controllers/user.php

comment out
$this->setRedirect( JRoute::_('index.php?option=com_virtuemart&view=user&task=edit&virtuemart_user_id[]='.$virtuemart_user_id[0], $this->useXHTML,$this->useSSL) );

add this instead ( to avoid redirect to edit my account page)
$this->setRedirect( JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE)  );