use BSE::TB::Orders;
use BSE::TB::OrderItems;
use BSE::Util::Tags qw(tag_error_img tag_hash tag_article);
-use Products;
+use BSE::TB::Products;
use BSE::TB::Seminars;
use DevHelp::Validate qw(dh_validate dh_validate_hash);
use Digest::MD5 'md5_hex';
use BSE::Util::Secure qw(make_secret);
use BSE::Template;
-our $VERSION = "1.045";
+our $VERSION = "1.051";
=head1 NAME
# my %custom_state = %{$req->session->{custom}};
# $cust_class->enter_cart(\@cart, \@cart_prods, \%custom_state, $req->cfg);
- $msg = '' unless defined $msg;
- $msg = escape_html($msg);
-
- $msg ||= $req->message;
+ $msg = $req->message($msg);
my %acts;
%acts =
my @items = @{$cart->items};
if ($cart->need_logon) {
- my ($msg, $id) = $cart->need_logon_reason;
+ my ($msg, $id) = $cart->need_logon_message;
return $class->_refresh_logon($req, $msg, $id);
}
my @cart = @{$req->session->{cart}};
if ($index >= 0 && $index < @cart) {
my ($item) = splice(@cart, $index, 1);
- my $product = Products->getByPkey($item->{productId});
+ my $product = BSE::TB::Products->getByPkey($item->{productId});
$req->flash_notice("msg:bse/shop/cart/remove", [ $product ]);
}
$req->session->{cart} = \@cart;
my $order = BSE::TB::Orders->getByPkey($id)
or return $class->req_cart($req);
my @items = $order->items;
- my @products = map { Products->getByPkey($_->{productId}) } @items;
+ my @products = map { BSE::TB::Products->getByPkey($_->{productId}) } @items;
my @item_cols = BSE::TB::OrderItem->columns;
- my %copy_cols = map { $_ => 1 } Product->columns;
+ my %copy_cols = map { $_ => 1 } BSE::TB::Product->columns;
delete @copy_cols{@item_cols};
my @copy_cols = keys %copy_cols;
my @showitems;
if ($msgid) {
$msg = $req->cfg->entry('messages', $msgid, $msg);
}
- $parms{message} = $msg if $msg;
+ $parms{m} = $msg if $msg;
$parms{mid} = $msgid if $msgid;
$url .= "?" . join("&", map "$_=".escape_uri($parms{$_}), keys %parms);
my @cart = @{$req->session->{cart}}
or return;
my @items;
- my @prodcols = Product->columns;
+ my @prodcols = BSE::TB::Product->columns;
my @newcart;
my $today = now_sqldate();
for my $item ($cart->items) {
for my $col (@prodcols) {
$work{$col} = $product->$col() unless exists $work{$col};
}
- $work{price} = $product->price(user => scalar $req->siteuser);
- $work{extended_retailPrice} = $work{units} * $work{price};
- $work{extended_gst} = $work{units} * $work{gst};
- $work{extended_wholesale} = $work{units} * $work{wholesalePrice};
+ my ($price, $tier) = $product->price(user => scalar $req->siteuser);
+ $work{price} = $item->price;
+ $work{tier_id} = $item->tier_id;
+ $work{extended_retailPrice} = $item->extended_retailPrice;
+ $work{extended_gst} = $item->extended_gst;
+ $work{extended_wholesale} = $item->extended_wholesale;
+ if ($cart->coupon_active) {
+ $work{product_discount} = $item->product_discount;
+ $work{product_discount_units} = $item->product_discount_units;
+ }
+ else {
+ $work{product_discount} = 0;
+ $work{product_discount_units} = 0;
+ }
push @newcart, \%work;
}
}
if ($cart->coupon_active) {
$values->{coupon_id} = $cart->coupon->id;
+ $values->{coupon_description} = $cart->coupon_description;
+ $values->{coupon_cart_wide} = $cart->coupon_cart_wide;
}
else {
$values->{coupon_id} = undef;
+ $values->{coupon_description} = "";
+ $values->{coupon_cart_wide} = 0;
}
$cart->set_shipping_cost($values->{shipping_cost});
$cart->set_shipping_method($values->{shipping_method});
$cart->set_delivery_in($values->{delivery_in});
$values->{coupon_code_discount_pc} = $cart->coupon_code_discount_pc;
+ $values->{product_cost_discount} = $cart->product_cost_discount;
$values->{total} = $cart->total;
my $cust_class = custom_class($cfg);
my $product;
if ($addid) {
$product = BSE::TB::Seminars->getByPkey($addid);
- $product ||= Products->getByPkey($addid);
+ $product ||= BSE::TB::Products->getByPkey($addid);
}
unless ($product) {
$$error = "Cannot find product $addid";
my $product;
if (defined $code) {
$product = BSE::TB::Seminars->getBy(product_code => $code);
- $product ||= Products->getBy(product_code => $code);
+ $product ||= BSE::TB::Products->getBy(product_code => $code);
}
unless ($product) {
$$error = "Cannot find product code $code";
for my $item (@$cart) {
if (!$item->{user} || $item->{user} != $user->id) {
- my $product = Products->getByPkey($item->{productId})
+ my $product = BSE::TB::Products->getByPkey($item->{productId})
or next;
my ($price, $tier) = $product->price(user => $user);
$item->{price} = $price;