VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: WebSoft on July 01, 2012, 22:20:56 PM

Title: Delete additional shipment addresses
Post by: WebSoft on July 01, 2012, 22:20:56 PM
Hi
Have a lot of B2B customers...
Users can add multiple shipment addresses on checkout - or multiple shipment can be added in Admin:
Anybody found where, how or a fix to delete a shipment address ???
- besides MySQL   8)
Title: Re: Delete additional shipment addresses
Post by: Chifu on July 02, 2012, 15:43:13 PM
The same problem. I dont know how to delete aditional shipto address from the frontend site (privat room, etc).

Maybe there is function for deleting, or i need write new function? Plz help me.
Title: Re: Delete additional shipment addresses
Post by: Milbo on July 03, 2012, 00:21:04 AM
It would be great, when you write it :-)

We just did not had the time.
Title: Re: Delete additional shipment addresses
Post by: Chifu on July 03, 2012, 00:43:39 AM
Well, i wrote this simple function in sitename/components/com_virtuemart/controllers/user.php

I'm a bad programmer in php, because I do frontend, and I do not know well Joomla API, so I do not know how this will affect the safety function and yes I am sure that it can be much more elegant written. But it works, until a better solution :)

Link for delete address in sitename/components/com_virtuemart/controllers/user.php
Quote
static function generateStAddressList ($view, $userModel, $task) {
...
$_shipTo[] = '<a href="index.php?option=com_virtuemart&view=user&task=deleteAddressST&virtuemart_user_id[]=' . $_addressList[$_i]->virtuemart_user_id . '&virtuemart_userinfo_id=' . $_addressList[$_i]->virtuemart_userinfo_id . '" class="icon_delete">Delete address</a>';
...
}


The function:
Quotefunction deleteAddressSt(){
      $db = JFactory::getDBO();
      $currentUser = JFactory::getUser();
      $virtuemart_userinfo_id = JRequest::getVar('virtuemart_userinfo_id');
      
      $msg = '';
      if ( isset($virtuemart_userinfo_id) && $currentUser->id != 0 ) {
         $q = 'DELETE FROM #__virtuemart_userinfos  WHERE virtuemart_user_id="'. $currentUser->id .'" AND virtuemart_userinfo_id="'. $virtuemart_userinfo_id .'"';
         $db->setQuery($q);
         $db->query();
         
         $msg = vmInfo('Address has been successfully deleted.');
      }
      $layout = JRequest::getWord('layout','edit');
      $this->setRedirect( JRoute::_('index.php?option=com_virtuemart&view=user&layout='.$layout), $msg );
   }

If someone can do this function better, it would be great :)
Title: Re: Delete additional shipment addresses
Post by: Milbo on July 03, 2012, 00:54:45 AM
Looks quite good. There is a method with model and table, but I think this makes more trouble in that case.

Thank you, we take it.
Title: Re: Delete additional shipment addresses
Post by: WebSoft on July 12, 2012, 12:37:52 PM
GREAT - Thx for sharing - awesome - you should do backend   8)

Maybe the wrong forum...: I can“t get a proper sitemap in Dreamweaver !
Would love to know what you and Milbo use for development  ;)
XDEBUG or something better  ???

Thx