MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

RE: [mv] Order multiple items into multiple carts with one click



Ok, I think I solved my problem. Since I'm showing three carts on one page,
there needs to be some synchronization. To explain what's going on: The
customer can subscribe to a service, which then goes into the "subscription"
cart. But the service usually has a one-time set-up fee, which goes into the
"main" (purchase) cart. These fees can't be deleted from the "main" cart,
the delete option is only available in the "subscription" cart. For this to
work, I need the following code (is there a shorter or more elegant
solution?):
Oh yes, one more thing: offType comes from my product database and is the
offer type, 1 being a purchase product, 2 being a subscribed service.

[comment]
    Copy all valid items that have a one-time price and a quantity > 0 from
the
    subscription cart into the main purchase cart, if they're not there
already.
[/comment]
[item-list subscription]
    [item-next]
        [if-field ! price]
            1
        [else]
            [calc]
                [item-quantity] < 1
            [/calc]
        [/else]
        [/if-field]
    [/item-next]
    [if !ordered [item-code] main]
        [perl arg=carts interpolate=1]
            my $mainItems = '[nitems main]';
            my $code = '[item-code]';
            $Safe{'carts'}->{'main'}->[$mainItems]->{'code'} = $code;
            $Safe{'carts'}->{'main'}->[$mainItems]->{'quantity'} = 1;
            return;
        [/perl]
    [/if]
[/item-list]


[comment]
    Put all subscription items from the subscription cart into the scratch
    variable subscription_items, separated by '::'.
    Put all product items from the main cart into the scratch variable
    main_product_items, separated by '::'.
    Put all subscription items from the main cart into the scratch variable
    main_subscription_items, separated by '::'.
[/comment]    
[set subscription_items][/set]
[item-list subscription]
    [perl arg=scratch interpolate=1]
        $Safe{'scratch'}->{'subscription_items'} .= '[item-code]::';
        return;
    [/perl]
[/item-list]

[set main_product_items][/set]
[set main_subscription_items][/set]
[item-list main]
    [value name="offType" set="[item-field offType]" hide=1]
    [if value offType == 1]
        [perl arg=scratch interpolate=1]
            $Safe{'scratch'}->{'main_product_items'} .= '[item-code]::';
            return;
        [/perl]
    [/if]
    [if value offType == 2]
        [perl arg=scratch interpolate=1]
            $Safe{'scratch'}->{'main_subscription_items'} .=
'[item-code]::';
            return;
        [/perl]
    [/if]
[/item-list]


[comment]
    Search through the main cart and keep all the items that are either in
    main_product_items or subscription_items. I.e. delete the subscription
    items in the main cart that were left over when the user deleted a
    subscription from the subscription cart.
[/comment]
[perl arg=carts interpolate=1]
    my $main = $Safe{'carts'}->{'main'};
    my @newMain=();
    my $itemMain;

    foreach $itemMain (@$main) {
        if ("[scratch main_product_items]" =~ /$itemMain->{'code'}::/ or
        "[scratch subscription_items]" =~ /$itemMain->{'code'}::/) {
            if ($itemMain->{'quantity'} > 0) {
                @newMain = (@newMain, $itemMain);
            }
        }
    }
    @{$main} = @newMain;
    return;
[/perl]

> ----------
> From: 	Mr. Anthony R.J. Ball[SMTP:ant@maine.com]
> Sent: 	Mittwoch, 29. September 1999 14:57
> To: 	minivend-users@minivend.com
> Subject: 	Re: [mv] Order multiple items into multiple carts with one
> click
> 
> ******    message to minivend-users from "Mr. Anthony R.J. Ball"
> <ant@maine.com>     ******
> 
> > However, I need to order the same item into several carts, something
> like
> > 
> > [page form="
> >    mv_order_item=[item-code]
> >    mv_order_quantity=1
> >    mv_cartname=main
> > 
> >    mv_order_item=[item-code]
> >    mv_order_quantity=1
> >    mv_cartname=subscription
> > 
> >    mv_separate_items=1
> >    mv_todo=refresh"]
> >     Order multiple items
> > [/page]
> > 
> > mv_separate_items doesn't seem to make any difference. Anyway, it
> doesn't
> > work... How can I do this?
> 
>   I don't think mv_cartname is stackable... you could probably do this
> with 
> the perl tag calling the order tag as a function. Just pass the order item
> into the basket page and have your perl above the [item-loop]. 
> 
> -- 
> 
> Anthony Ball                                                ant@maine.com
> MaineStreet Communications, Inc        208 Portland Road, Gray, ME  04039
> tel:1.207.657.5078         fax:1.207.657.5048       http://www.maine.com/
> -
> To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
> email with 'UNSUBSCRIBE minivend-users' in the body to
> Majordomo@minivend.com.
> Archive of past messages: http://www.minivend.com/minivend/minivend-list
> 


Search for: Match: Format: Sort by: