[ic] Discounts and coupon tracking?

Jonathan Clark jonc at webmaint.com
Fri Jun 4 17:14:17 EDT 2004


Quoting Mike Heins:
> Quoting Jonathan Clark (jonc at webmaint.com):
> > What I can't do at the moment is apply conditions to a specific
> line in the
> > cart. Lets say I have an item which is available with multiple
> options - the
> > basic item (no options) I make virtually no money on and can't afford to
> > discount, but some options I can afford the discount. There is
> no way of me
> > doing an item discount through the discounts system to cover this. If my
> > item is 12345 and I set up an item discount, I have access only
> to quantity
> > and subtotal. It would be too complex to make a whole lot of
> other variables
> > available to the discount sub, but I think the way forward
> might be to have
> > a new type of discount:
> >
> > 'CART_ITEM_1' => 'return $s'
> > 'CART_ITEM_2' => 'return $s * 0.9'
> > etc.
> >
> > Obviously I would have to recreate this each time the cart
> changed though.
> > Maybe a better way would be to allow the discount sub to use or
> have access
> > to a modifier in the cart.
>
> Wouldn't the standard mv_discount for the item work here?
>
>
> [calc]
>
> 	for my $it (@$Items) {
> 		## Apply a discount randomly
> 		if(rand(2) < 1) {
> 			# Sorry bubba, no discount
> 			$it->{mv_discount_message} = "No discount!";
> 			delete $it->{mv_discount};
> 		}
> 		else {
> 			# You lucked out!
> 			$it->{mv_discount_message} = "You have a discount!";
> 			$it->{mv_discount} = q{$s * .75};
> 		}
> 	}
> 	return;
> [/calc]
>
> [item-list]
> 	[if-item-param mv_discount]
> 	    [item-code] -- [item-param mv_discount_message]
> 		-- Regular [item-subtotal]
> 		-- Discounted [item-discount-subtotal]<br>
> 	[else]
> 	    [item-code] -- [item-param mv_discount_message]
> 		-- Regular [item-subtotal]
> 	[/else]
> 	[/if-item-param]<br>
> [/item-list]
> <br><br>
> [total-cost]

Thanks Mike,

Fantastic! Every day's a school day :-) This will do the job nicely.

Kevin Walsh has also pointed out to me that I can use
$item->{whatever_modifier} in the discount code to get access to things in
the cart.


Jonathan.


--
Jonathan Clark
Webmaint.com - Building Clever Websites        http://www.webmaint.com/
Webmaint.net - Business Web Hosting            http://www.webmaint.net/
WireTel      - Internet Connectivity Solutions http://www.wiretel.net/




More information about the interchange-users mailing list