Revision 399

Date:
2013/11/22 20:35:46
Author:
ahitrov
Revision Log:
Функции корзины
Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/plugins/webshop/lib/webshop/Keeper.pm

     
    27 27 }
    28 28 my @items = $keeper->get_documents (
    29 29 class => 'webshop::Basket',
    30 status => [0,1],
    30 status => 1,
    31 31 order_id=> 0,
    32 32 %opts,
    33 33 );
     
    36 36 my $found = 0;
    37 37 if ( @items ) {
    38 38 foreach my $item ( @items ) {
    39 if ( $object->item_id == $item->item_id && $object->color_id == $item->color_id && $object->size_id == $item->size_id ) {
    40 $item->number($item->number + $object->number);
    41 $item->status(1);
    39 if ( $object->item_id == $item->item_id && $object->color_id == $item->color_id &&
    40 ((!$object->size_id && !$object->size) || ($object->size_id && $object->size_id == $item->size_id) || ($object->size && $object->size eq $item->size)) ) {
    41 $item->number( $item->number + $object->number );
    42 $item->price( $object->price );
    42 43 $item->store;
    43 44 $found = 1;
    44 45 }
     
    86 87 my $found = 0;
    87 88 if ( @items ) {
    88 89 foreach my $item ( @items ) {
    89 if ( $object->item_id == $item->item_id && $object->color_id == $item->color_id && ($object->size_id == $item->size_id || $object->size eq $item->size) ) {
    90 if ( $object->item_id == $item->item_id && $object->color_id == $item->color_id &&
    91 ((!$object->size_id && !$object->size) || ($object->size_id && $object->size_id == $item->size_id) || ($object->size && $object->size eq $item->size)) ) {
    90 92 $item->number($item->number + $object->number);
    91 93 $item->store;
    92 94 $found = 1;
     
    174 176 $sum += $item->number * $item->price;
    175 177 }
    176 178 }
    177 my @plugins = split (/[\ |\t]+/, $state->{plugins});
    178 if ( grep { $_ eq 'session' } @plugins && ref $session ) {
    179 $session->set ( basket_total => $total, basket_sum => $sum );
    180 }
    181 179 return \@items;
    182 180 }
    183 181
     
    199 197 }
    200 198
    201 199
    200 sub wishlist_count {
    201 my $self = shift;
    202 my $basket = shift;
    203 return (0,0) unless ref $basket eq 'ARRAY' && @$basket;
    204
    205 my $total = 0;
    206 my $sum = 0;
    207 foreach my $item ( @$basket ) {
    208 if ( $item->status == 0 ) {
    209 $total += $item->number;
    210 $sum += $item->number * $item->price;
    211 }
    212 }
    213 return ($total, $sum);
    214 }
    215
    216
    202 217 sub clear_basket {
    203 218 my $self = shift;
    204 219 my (%opts) = @_;
  • utf8/plugins/webshop/lib/webshop/SQL/Basket.pm

     
    129 129 'attr' => 'color_id',
    130 130 'type' => 'integer',
    131 131 'rusname' => 'ID цвета',
    132 'hidden' => 1,
    133 132 'db_field' => 'color_id',
    134 133 'db_type' => 'integer',
    135 134 },