X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FMyAccount.pm;h=ca5c82ea8fc502f566d1b07a3d12b5e1ee4cc662;hp=279acb25647a4584972be8281d12021a79d89513;hb=9049947bceb63fd795aab13ee5a17b17f180a4aa;hpb=425a87cceee1042973ef0b58755496eadb8caab1 diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 279acb256..ca5c82ea8 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -46,6 +46,7 @@ use FS::payby; use FS::acct_rt_transaction; use FS::msg_template; use FS::contact; +use FS::cust_location; $DEBUG = 1; $me = '[FS::ClientAPI::MyAccount]'; @@ -2268,11 +2269,23 @@ sub order_pkg { or return { 'error' => "unknown custnum $custnum" }; my $status = $cust_main->status; + + my %order_pkg_options = ()); + if ( $p->{locationnum} > 0 ) { + $order_pkg_options{locationnum} = delete($p->{locationnum}); + } elsif ( $p->{address1} ) { + $order_pkg_options{'cust_location'} = new FS::cust_location { + map { $_ => $p->{$_} } + qw( address1 address2 city county state zip country ) + }; + } + #false laziness w/ClientAPI/Signup.pm my $cust_pkg = new FS::cust_pkg ( { - 'custnum' => $custnum, - 'pkgpart' => $p->{'pkgpart'}, + 'custnum' => $custnum, + 'pkgpart' => $p->{'pkgpart'}, + 'quantity' => $p->{'quantity'} || 1, } ); my $error = $cust_pkg->check; return { 'error' => $error } if $error; @@ -2331,11 +2344,12 @@ sub order_pkg { } - use Tie::RefHash; - tie my %hash, 'Tie::RefHash'; - %hash = ( $cust_pkg => \@svc ); - #msgcat - $error = $cust_main->order_pkgs( \%hash, 'noexport' => 1 ); + $error = $cust_main->order_pkg( + 'cust_pkg' => $cust_pkg, + 'svcs' => \@svc, + 'noexport' => 1, + %order_pkg_options, + ); return { 'error' => $error } if $error; my $conf = new FS::Conf;