steveosoule
6/3/2015 - 8:14 PM

Miva - Shop as Customer with mvt:do

Miva - Shop as Customer with mvt:do

<h2>Customer_Load_Login</h2>
	<mvt:do file="'/mm5/5.00/features/cus/cus_db.mvc'" name="g.result" value="Customer_Load_Login('ssoule', l.settings:customer)" />
	Result: &mvt:global:result;<br>
	<mvt:eval expr="decodeattribute(glosub(miva_array_serialize(l.settings:customer), ',', '<br>'))" />

<h2>Basket_Create_Customer</h2>
	<mvt:do file="'/mm5/5.00/modules/util/shopascustomer.mvc'" name="g.result" value="Basket_Create_Customer( l.settings:customer:id, l.settings:basket )" />
	Result: &mvt:global:result;<br>
	<h3>Customer</h3>
	<mvt:eval expr="decodeattribute(glosub(miva_array_serialize(l.settings:customer), ',', '<br>'))" />
	<h3>Basket</h3>
	<mvt:eval expr="decodeattribute(glosub(miva_array_serialize(l.settings:basket), ',', '<br>'))" />


<h2>Shop As Customer</h2>
	<mvt:assign name="l.session_id" value="l.settings:basket:session_id"/>
	<mvt:assign name="l.cussess_id" value="l.settings:basket:cussess_id"/>

	<mvt:if expr="g.Domain:mmcexp">
		<mvt:assign name="l.expires" value="s.dyn_time_t + ( g.Domain:mmcexp * 60 )"/>
	<mvt:else>
		<mvt:assign name="l.expires" value="''"/>
	</mvt:if>

	<mvt:if expr="g.Domain:mmcsexp">
		<mvt:assign name="l.secure_expires" value="s.dyn_time_t + ( g.Domain:mmcsexp * 60 )"/>
	<mvt:else>
		<mvt:assign name="l.secure_expires" value="''"/>
	</mvt:if>

	<mvt:do file="g.Module_Library_Utilities" name="l.store_code_alpha_numeric"	value="AlphaNumericOnly( g.Store:code )"/>
	<mvt:assign name="l.cookie_prefix" value="'mm5-' $ l.store_code_alpha_numeric $ '-'"/>

	<mvt:do file="g.Module_Library_Utilities" name="l.null" value="SetRuntimePaths()"/>
	<mvt:do file="g.Module_Library_Utilities" name="l.null" value="SetCookie( g.Output_Cookies, l.cookie_prefix $ 'basket-id', l.session_id, g.cookiedomain, l.expires, g.cookiepath, 0 )"/>
	<mvt:do file="g.Module_Library_Utilities" name="l.null" value="SetCookie( g.Output_Cookies, l.cookie_prefix $ 'customer-session', l.cussess_id, g.cookiedomain, l.secure_expires, g.cookiepath, ( len( g.Domain:mm_surl ) NE 0 ) )"/>

	<mvt:do file="g.Module_Library_Utilities" name="l.null" value="OutputCookies( g.Output_Cookies )"/>
	<mvt:assign name="l.null" value="miva_output_header( 'Status', '302 Found' )"/>
	<mvt:assign name="l.null" value="miva_output_header( 'Location', g.Domain:mm_url $ 'Screen=PLST&Store_Code=' $ encodeattribute( g.Store:code ) $ '&Session_ID=' $ encodeattribute( l.session_id ) )"/>