Author Topic: Add delete button and action for address list in checkout page  (Read 111 times)

florihana

  • Beginner
  • *
  • Posts: 21
  • A beginner
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
Code: [Select]
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
Code: [Select]
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

  • Beginner
  • *
  • Posts: 21
  • A beginner
Re: Add delete button and action for address list in checkout page
« Reply #1 on: September 01, 2017, 11:55:24 am »
Hi,

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

here add:
Code: [Select]
'</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
Code: [Select]
$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)
Code: [Select]
$this->setRedirect( JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE)  );