Revision 363

Date:
2013/06/18 12:29:19
Author:
ahitrov
Revision Log:
Coupon basket recount bug
New session object used in webshop operations
Files:

Legend:

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

     
    119 119 if ( ref $items eq 'ARRAY' && @$items ) {
    120 120 my $found_sum = 0;
    121 121 foreach my $bi ( @$basket ) {
    122 warn "BASKET: Item id [".$bi->item_id."]\n";
    122 warn "BASKET: Item id [".$bi->item_id."]\n" if $DEBUG;
    123 123 next unless $bi->special_price;
    124 124 foreach ( @$items) {
    125 warn "BASKET: Item [".$_->name."] id [".$_->id."]\n";
    126 125 if ( $bi->item_id == $_->id ) {
    126 warn "BASKET: Item [".$_->name."] id [".$_->id."]\n" if $DEBUG;
    127 127 $found_sum += $bi->number * $bi->price;
    128 128 last;
    129 129 }
    130 130 }
    131 131 }
    132 warn "Sum found: [$found_sum]\n";
    132 warn "Sum found: [$found_sum]\n" if $DEBUG;
    133 133 return $self->can_discount( $found_sum );
    134 134 } elsif ( $self->groups ) {
    135 135 return 0;
    136 } else {
    137 my $found_sum = 0;
    138 foreach my $bi ( @$basket ) {
    139 warn "BASKET: Item id [".$bi->item_id."]\n" if $DEBUG;
    140 next unless $bi->special_price;
    141 $found_sum += $bi->number * $bi->price;
    142 }
    143 warn "Sum found: [$found_sum]\n" if $DEBUG;
    144 return $self->can_discount( $found_sum );
    136 145 }
    137
    138 return $self->can_discount( $sum_total );
    146 return 0;
    139 147 }
    140 148
    141 149
  • utf8/plugins/webshop/lib/webshop/Keeper.pm

     
    53 53 $object->store;
    54 54 }
    55 55 my @plugins = split (/[\ |\t]+/, $state->{plugins});
    56 if ( grep { $_ eq 'session' } @plugins ) {
    57 $keeper->{session}->store_value ( basket_total => $total, basket_sum => $sum );
    56 if ( grep { $_ eq 'session' } @plugins && ref $session ) {
    57 $session->set ( basket_total => $total, basket_sum => $sum );
    58 58 }
    59 59 return ($total, $sum);
    60 60 }
     
    92 92 $sum += $item->number * $item->price;
    93 93 }
    94 94 my @plugins = split (/[\ |\t]+/, $state->{plugins});
    95 if ( grep { $_ eq 'session' } @plugins ) {
    96 $keeper->{session}->store_value ( basket_total => $total, basket_sum => $sum );
    95 if ( grep { $_ eq 'session' } @plugins && ref $session ) {
    96 $session->set ( basket_total => $total, basket_sum => $sum );
    97 97 }
    98 98 warn "Merge end\n" if $DEBUG;
    99 99 return ($total, $sum);
     
    107 107 return unless $opts{uid} || $opts{session} || $opts{order_id};
    108 108
    109 109 my $uid = delete $opts{uid};
    110 my $session = delete $opts{session};
    110 my $session_id = delete $opts{session};
    111 111 unless ( exists $opts{order_id} && $opts{order_id} ) {
    112 112 $opts{order_id} = 0;
    113 113 if ( $uid ) {
    114 114 $opts{uid} = $uid;
    115 } elsif ( $session ) {
    116 $opts{session} = $session;
    115 } elsif ( $session_id ) {
    116 $opts{session} = $session_id;
    117 117 }
    118 118 }
    119 119 $opts{status} = 1 unless exists $opts{status} && defined $opts{status};
     
    130 130 }
    131 131 }
    132 132 my @plugins = split (/[\ |\t]+/, $state->{plugins});
    133 if ( grep { $_ eq 'session' } @plugins ) {
    134 $keeper->{session}->store_value ( basket_total => $total, basket_sum => $sum );
    133 if ( grep { $_ eq 'session' } @plugins && ref $session ) {
    134 $session->set ( basket_total => $total, basket_sum => $sum );
    135 135 }
    136 136 return \@items;
    137 137 }
     
    177 177 $statement->finish;
    178 178
    179 179 my @plugins = split (/[\ |\t]+/, $state->{plugins});
    180 if ( grep { $_ eq 'session' } @plugins ) {
    181 $keeper->{session}->store_value ( basket_total => 0, basket_sum => 0 );
    180 if ( grep { $_ eq 'session' } @plugins && ref $session ) {
    181 $session->set ( basket_total => 0, basket_sum => 0 );
    182 182 }
    183 183 }
    184 184
     
    258 258 }
    259 259 }
    260 260 my @plugins = split (/[\ |\t]+/, $state->{plugins});
    261 if ( !$session_no_store && grep { $_ eq 'session' } @plugins ) {
    262 $keeper->{session}->store_value ( basket_total => $total, basket_sum => $sum );
    261 if ( !$session_no_store && grep { $_ eq 'session' } @plugins && ref $session ) {
    262 $session->set ( basket_total => $total, basket_sum => $sum );
    263 263 }
    264 264 return ($total, $sum, \@new_basket);
    265 265 }