News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Delete additional shipment addresses

Started by WebSoft, July 01, 2012, 22:20:56 PM

Previous topic - Next topic

WebSoft

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)

Chifu

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.

Milbo

It would be great, when you write it :-)

We just did not had the time.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Chifu

#3
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 :)

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

WebSoft

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