X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2FClientAPI%2FMyAccount.pm;h=a0546fc6a99df00cef7fb4bc88b2ac53e1c3786e;hb=6da8d320d8792e6b70ec5cf1a40088f87f4762e5;hp=86c7ac324e1068b5e4c92af85530f403add47ff7;hpb=ec7e8155fce544f19f2b6734476ed6db8c200aa9;p=freeside.git diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 86c7ac324..a0546fc6a 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -47,6 +47,7 @@ use FS::acct_rt_transaction; use FS::msg_template; use FS::contact; use FS::cust_contact; +use FS::cust_location; $DEBUG = 1; $me = '[FS::ClientAPI::MyAccount]'; @@ -2302,11 +2303,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; @@ -2365,11 +2378,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;