[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ic] Assemblies -- Magic words


Quoting Eric Small (suppressed):
> Jeme wrote:
> >
> >Is that in the distribution?  It's not in the Debian package I have. 
> >Where can I get this demo?  More importantly (assuming you have a moment
> >to point it out and save me a day's rifling through code), what is
> >different in your demo that causes behavior?
> > 
> >
> I have done something very similar to what you're trying to do.  It is 
> possible :)  I used parts of the Mike demo to help me out.  I downloaded 
> my copy from http://www.interchange.rtfm.info/downloads/demos/
> 
> I don't recall that the Mike demo did have item grouping in the cart 
> with a single checkbox, but I might have missed it since I was taking 
> pieces of Mike and putting into Foundation.

It may just be in my local version. In any case, it is very
easy:

	[if-item-param !mv_si]
	<input type=checkbox name="quantity[item-param mv_ip]" value=0> Remove
	[/if-item-param]

> One problem I did run into was changing cart quantities.  The quantity 
> of the master item will change, but the child items won't change.  You 
> should be able to find my solution, which was created with much help 
> from Mike Heins, by searching the forums for munge_cart_quantity.  This 
> action will update the cart quantities to keep the same ratio between 
> the parent and child items in a group.  I'm not much of a Perl 
> programmer so my code probably isn't a "best solution", but it does work.

That is actually an possiblity for a standard feature; you could have a
"mv_slave_quantity" parameter that would automatically change the
quantity of sub_items when the master item changed.

In any case, it is pretty easy to put in a little bit of
embedded Perl code for the basket/checkout/final order profile:

    [calc]
        my %quantity;
        for my $it (@$Items) {
            next unless $it->{mv_mi};
            if($it->{mv_si}) {
		$it->{quantity} = $quantity{$it->{mv_mi}};
            }
            else {
		$quantity{$it->{mv_mi}} = $it->{quantity};
            }
        }
        return;
    [/calc]

Actually, now that I think about it that is a great place to put a
SpecialSub -- "post_cart_update" and "pre_cart_update".

Sub <<EOR
sub slave_quantity {
        my %quantity;
        for my $it (@$Items) {
            next unless $it->{mv_mi};
            if($it->{mv_si}) {
		$it->{quantity} = $quantity{$it->{mv_mi}};
            }
            else {
		$quantity{$it->{mv_mi}} = $it->{quantity};
            }
        }
        return;
}
EOR

SpecialSub post_cart_update slave_quantity

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <suppressed>

Being against torture ought to be sort of a bipartisan thing.
-- Karl Lehenbauer
_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.