steveosoule
12/13/2016 - 9:26 PM

Miva - Add & Remove Basket Charges

Miva - Add & Remove Basket Charges

<mvt:if expr="g.Delete_Charge">
	<h2>Delete Charge</h2>
	<mvt:do file="g.Module_Library_DB" name="l.gone" value="BasketCharge_Delete_All_Type(g.Basket:basket_id, 'CUSTOM_CHARGE')" />
</mvt:if>


<mvt:if expr="g.Add_Charge">
	<mvt:assign name="l.basket_charge:basket_id" value="g.Basket:basket_id" />
	<mvt:assign name="l.basket_charge:module_id" value="0" />
	<mvt:assign name="l.basket_charge:type" value="'CUSTOM_CHARGE'" />
	<mvt:assign name="l.basket_charge:descrip" value="'Custom Charge'" />
	<mvt:assign name="l.basket_charge:amount" value="-20" />
	<mvt:assign name="l.basket_charge:disp_amt" value="'-20.00'" />
	<mvt:assign name="l.basket_charge:tax_exempt" value="0" />
	<mvt:comment>insert charge</mvt:comment>
	<mvt:do file="g.Module_Library_DB" name="l.chargecount" value="BasketCharge_Insert( l.basket_charge )" />
</mvt:if>

<mvt:if expr="g.Delete_Charge OR g.Add_Charge">
	<mvt:comment>
		| Reload Charges List
	</mvt:comment>
	<mvt:do file="g.Module_Library_DB" name="l.success" value="BasketChargeList_Load_Basket( g.Basket:basket_id, l.settings:charges )" /><mvt:comment>For some reason, using `l.settings:basket:charges` would never "refresh" the charges on the page, so we'll need to reassign it</mvt:comment>
	<mvt:assign name="l.settings:basket:charges" value="l.settings:charges" />

	<mvt:comment>
		| Regenerate Currency Formatted Charges
	</mvt:comment>
	<mvt:foreach iterator="charge" array="basket:charges">
		<mvt:do file="g.Module_Store_Module_Currency" name="l.settings:charge:formatted_disp_amt" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:charge:amount )" />
	</mvt:foreach>

	<mvt:comment>
		| Reload Basket Totals
	</mvt:comment>
	<mvt:do file="g.Module_Library_DB" name="l.settings:basket:total" value="Basket_Total( g.Basket:basket_id )" />
	<mvt:do file="g.Module_Store_Module_Currency" name="l.settings:basket:formatted_total" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:basket:total )" />
	Total: &mvt:basket:formatted_total;<br>

	<mvt:do file="g.Module_Library_DB" name="l.settings:basket:sub_total" value="Basket_SubTotal( g.Basket:basket_id )" />
	<mvt:do file="g.Module_Store_Module_Currency" name="l.settings:basket:formatted_sub_total" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:basket:sub_total )" />
	Sub Total: &mvt:basket:formatted_sub_total;<br>

	<mvt:do file="g.Module_Library_DB" name="l.settings:basket:item_total" value="BasketItem_Total( g.Basket:basket_id )" />
	<mvt:do file="g.Module_Store_Module_Currency" name="l.settings:basket:formatted_item_total" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:basket:item_total )" />
	Item Total: &mvt:basket:formatted_item_total;<br>
</mvt:if>