[ic] Item Discount Persists when clearing ALL_ITEMS

Mike Heins mike at perusion.com
Wed Feb 2 00:48:12 UTC 2011


Quoting IC (ic at tvcables.co.uk):
> Hi Folks,
> 
> I am using some code that assigns a discount in a usertag:-
> 
> $Tag->discount(  { code => $partcode1}, "\$s - $discount"  );
> 
> This works fine.
> 
> However when I try to clear all item discounts the item discount in the
> session persists, I have tried:-
> 
> $Session->{discount} = ();
> $Tag->discount(  { code => 'ALL_ITEMS'}, "\$s * 1"  );
> [discount ALL_ITEMS][/discount]
> [discount code="ALL_ITEMS"][/discount]
> [discount ALL_ITEMS]$s * 1[/discount]
> 
> The only way I can clear it is with the specific item code:-
> 
> [discount code="itemsku"][/discount]
> 
> What would stop ALL_ITEMS from clearing the item discount?
> 

ALL_ITEMS is different from individual SKU discounts.

You can do

	%{$Session->{discount}} = ();

if you don't want to preserve the special ENTIRE_ORDER
and ALL_ITEMS discounts. If you do, then you could run:

	my @keys = keys %{$Session->{discount}};
	@keys = grep $_ !~ /^(ALL_ITEMS|ENTIRE_ORDER)$/, @keys;

	for(@keys) {
	    delete $Session->{discount}->{$_};
	}

That is one of many ways to do it, selected for clarity.

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.328.4479  <mike at perusion.com>

Software axiom: Lack of speed kills.



More information about the interchange-users mailing list