diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 5749fef83..72f0ca304 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -8,6 +8,7 @@ - fixed #11348: Typ-o in debug notice SQLReport - fixed #11350: Story Topic asset missing description... - fixed #11351: Double submits on ITransact checkout + - fixed #11353: shop - sales - error 7.8.9 - fixed #11235: wiki search diff --git a/docs/upgrades/packages-7.8.10/root_import_account_shop_shop-account-layout.wgpkg b/docs/upgrades/packages-7.8.10/root_import_account_shop_shop-account-layout.wgpkg new file mode 100644 index 000000000..eb1173c51 Binary files /dev/null and b/docs/upgrades/packages-7.8.10/root_import_account_shop_shop-account-layout.wgpkg differ diff --git a/lib/WebGUI/Account/Shop.pm b/lib/WebGUI/Account/Shop.pm index 135f3bb73..35c745bf9 100644 --- a/lib/WebGUI/Account/Shop.pm +++ b/lib/WebGUI/Account/Shop.pm @@ -6,6 +6,7 @@ use WebGUI::Exception; use WebGUI::International; use WebGUI::Pluggable; use WebGUI::Utility; +use WebGUI::Shop::Vendor; use JSON qw{ from_json }; use base qw/WebGUI::Account/; @@ -58,6 +59,10 @@ sub appendCommonVars { $var->{ 'manage_tax_url' } = $self->getUrl( 'module=shop;do=manageTaxData' ); $var->{ 'manageTaxIsActive' } = $method eq 'manageTaxData'; + + eval { WebGUI::Shop::Vendor->newByUserId($session, $session->user->userId); }; + $var->{ 'userIsVendor' } = ! Exception::Class->caught(); + $session->log->warn($@); } #------------------------------------------------------------------- @@ -253,32 +258,35 @@ Page that show your earnings if you are a vendor. sub www_viewSales { my $self = shift; my $session = $self->session; - my $vendor = WebGUI::Shop::Vendor->newByUserId( $session, $session->user->userId ); - - my $var = $vendor->getPayoutTotals; - my $totalSales = 0; + my $vendor = eval { WebGUI::Shop::Vendor->newByUserId( $session, $session->user->userId ); }; my @products; + my $totalSales = 0; + my $var = {}; + if (! Exception::Class->caught()) { - my $sth = $session->db->read( - q{ SELECT t1.*, sum(t1.quantity) as quantity, sum(t1.vendorPayoutAmount) as payoutAmount } - . q{ FROM transactionItem as t1, transaction as t2 } - . q{ WHERE t1.transactionId=t2.transactionId AND t2.isSuccessful <> 0 } - . q{ AND vendorId=? } - . q{ group by assetId order by quantity desc }, - [ $vendor->getId ] - ); - while (my $row = $sth->hashRef) { - my $data = $row; + $var = $vendor->getPayoutTotals; - # Add asset properties to tmpl_vars. - my $asset = WebGUI::Asset->newByDynamicClass( $session, $row->{ assetId } ); - $row = { %{ $row }, %{ $asset->get } } if $asset; - - push @products, $row; + my $sth = $session->db->read( + q{ SELECT t1.*, sum(t1.quantity) as quantity, sum(t1.vendorPayoutAmount) as payoutAmount } + . q{ FROM transactionItem as t1, transaction as t2 } + . q{ WHERE t1.transactionId=t2.transactionId AND t2.isSuccessful <> 0 } + . q{ AND vendorId=? } + . q{ group by assetId order by quantity desc }, + [ $vendor->getId ] + ); + while (my $row = $sth->hashRef) { + my $data = $row; - $totalSales += $row->{quantity}; + # Add asset properties to tmpl_vars. + my $asset = WebGUI::Asset->newByDynamicClass( $session, $row->{ assetId } ); + $row = { %{ $row }, %{ $asset->get } } if $asset; + + push @products, $row; + + $totalSales += $row->{quantity}; + } + $sth->finish; } - $sth->finish; $var->{ product_loop } = \@products; $var->{ total_products } = scalar @products; diff --git a/lib/WebGUI/Help/Account_Shop.pm b/lib/WebGUI/Help/Account_Shop.pm index 130f8f21a..b8b0d669a 100644 --- a/lib/WebGUI/Help/Account_Shop.pm +++ b/lib/WebGUI/Help/Account_Shop.pm @@ -18,6 +18,7 @@ our $HELP = { variables => [ { name => "manage_purchases_url", }, { name => "managePurchasesIsActive", }, + { name => "userIsVendor", }, ], related => [ ], }, diff --git a/lib/WebGUI/i18n/English/Account_Shop.pm b/lib/WebGUI/i18n/English/Account_Shop.pm index 98e7f5e55..690f18ffc 100644 --- a/lib/WebGUI/i18n/English/Account_Shop.pm +++ b/lib/WebGUI/i18n/English/Account_Shop.pm @@ -44,6 +44,11 @@ our $I18N = { lastUpdated => 1119068809, }, + 'userIsVendor' => { + message => q{A boolean that is true if the current user is a vendor.}, + lastUpdated => 1263833421, + }, + 'common account variables' => { message => q{Common Account, Shop Plugin, Template Variables.}, lastUpdated => 1230867169,