PDA

View Full Version : Version 5 shipping module - scripting


Adam - FMM
03-07-07, 04:33 AM
Well, finally jumping into custom scripting for V5. First project is a custom shipping module that has to do the following (actually it does more than this but this is the part I have not figured out):

Loop through the basket and make 2 totals. The first is the weight total for all products with the string 'steel' in the description. The second is for everything else.

In V4 I know what to do but I'm having trouble coming up with the right functions and so forth for version 5 (and it is a Mivasql store).

The shipping modules in the lsk I have looked through just get the weight of the basket all at once like this:

MvASSIGN NAME="l.weight" VALUE = "{ [ g.Module_Library_DB ].Basket_Weight( g.Basket:basket_id ) }">

Instead of like in V4 where it loops using the Find_First / Find_Next while loop.

In version 4 I would also back check in mid loop to see if the product description had the word steel in it using the Product_Find_Code function. I cannot get this function to work anymore in V5.

Has anyone yet compiled a list of the available functions of these types in the lib file for V5 yet? Or any kind of shove in the right direction would be great. I've had my V5 scripting blinders on a little too long.

Adam - FMM
03-07-07, 05:41 AM
Stream of consciousness updates.

After a lot of searching it look spretty simple if I build my own queries. The following appears to work correctly for gathering up the weight of all products in the basket who's description contains the string 'steel'. Is this how it ought to be done?

<MvOPENVIEW NAME = "Merchant"
VIEW = "Basketitems"
QUERY = "{ 'SELECT * FROM ' $ g.Store_Table_Prefix $ 'basketitems' }">
<MvWHILE EXPR = "{ NOT Basketitems.d.EOF }">
<MvIF EXPR = "{ Basketitems.d.basket_id EQ g.Basket:basket_id }">
<MvOPENVIEW NAME = "Merchant"
VIEW = "BasketProd"
QUERY = "{ 'SELECT * FROM ' $ g.Store_Table_Prefix $ 'products' }">
<MvWHILE EXPR = "{ NOT BasketProd.d.EOF }">
<MvIF EXPR = "{ Basketitems.d.code EQ BasketProd.d.code AND 'steel' CIN BasketProd.d.DESCRIP }">
<MvASSIGN NAME = "l.steelweight" VALUE = "{ l.steelweight + (Basketitems.d.weight * Basketitems.d.quantity) }">
</MvIF>
<MvSKIP NAME = "Merchant" VIEW = "BasketProd" ROWS = 1>
</MvWHILE>
<MvCLOSEVIEW NAME = "Merchant" VIEW = "BasketProd">
</MvIF>
<MvSKIP NAME = "Merchant" VIEW = "Basketitems" ROWS = 1>
</MvWHILE>
<MvCLOSEVIEW NAME = "Merchant" VIEW = "Basketitems">