xml Miva - 变异篮子项目替换多变量部分

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml Miva - 变异篮子项目替换多变量部分相关的知识,希望对你有一定的参考价值。

<mvt:comment>
	| ------------------------------------------------
	| Custom Variant Basket Item Replacement
	| ------------------------------------------------
	| This logic is to help aid in Synncronyzing with Quickbooks for products with multiple parts.
	| Our standard Variant Basket Item Replacement module does not work for variants with multiple parts.
</mvt:comment>
<mvt:foreach iterator="item" array="basket:items">

	<mvt:comment>
		| We only need to do this process for items with variant parts
	</mvt:comment>
		<mvt:if expr="miva_array_elements( l.settings:item:parts ) EQ 0 ">
			<mvt:foreachcontinue/>
		</mvt:if>

	<mvt:comment>
		| Lets prepare a concatenation of part codes
		| Also, we'll check if one of the products has been flagged as the one to use for replacement (and disregard the concatenation)
	</mvt:comment>
		<mvt:foreach iterator="part" array="item:parts">
			<mvt:assign name="l.index" value="miva_array_insert( l.settings:item:cf:part_codes, l.settings:part:code, -1 )" />
			<mvt:item name="customfields" param="Read_Product_ID(l.settings:part:id, 'use_as_variant_replacement_code', l.settings:part:cf:use_as_variant_replacement_code)" />
			<mvt:if expr="l.settings:part:cf:use_as_variant_replacement_code">
				<mvt:assign name="l.settings:item:cf:variant_replacement_code" value="l.settings:part:code" />
				<mvt:foreachstop/>
			</mvt:if>
		</mvt:foreach>
		<mvt:assign name="l.settings:item:cf:part_codes" value="glosub( l.settings:item:cf:part_codes, ',', '_' )" />

	<mvt:comment>
		| Use designated product for variant replacement,
		| or use concatenated product codes
	</mvt:comment>
		<mvt:if expr="l.settings:item:cf:variant_replacement_code">
			<mvt:assign name="l.settings:item:cf:update_code" value="l.settings:item:cf:variant_replacement_code" />
		<mvt:else>
			<mvt:assign name="l.settings:item:cf:update_code" value="l.settings:item:cf:part_codes" />
		</mvt:if>

	<mvt:comment>
		| Miva's product codes cant't be longer than 50 characters.
		| We'll md5 it if they are too long
	</mvt:comment>
		<mvt:if expr="len(l.settings:item:cf:part_codes) GT 50">
			<mvt:assign name="l.settings:item:cf:part_codes" value="crypto_md5( l.settings:item:cf:part_codes )" />
		</mvt:if>

	<mvt:comment>
		| Update the DB with our custom variant code logic
	</mvt:comment>
		<mvt:if expr="l.settings:item:code NE l.settings:item:cf:part_codes">
			<mvt:assign name="l.settings:query:query" value="'UPDATE ' $ g.store_table_prefix $ 'BasketItems SET code = ? WHERE line_id = ?'" />
			<mvt:assign name="l.settings:query:bind_parameters[1]" value="l.settings:item:cf:update_code" />
			<mvt:assign name="l.settings:query:bind_parameters[2]" value="l.settings:item:line_id" />
			<mvt:item name="sql" param="l.settings:query"/>
		</mvt:if>

</mvt:foreach>

以上是关于xml Miva - 变异篮子项目替换多变量部分的主要内容,如果未能解决你的问题,请参考以下文章

xml Miva - 变异篮子项目替换与自定义领域排除产品

xml Miva - 添加和删除篮子费用

xml Miva - 在另一个字符串出现后获取字符串的一部分

html 最近浏览的项目功能。所有自定义Miva代码,不由模块运行。它存储产品代码列表,最多显示12个

html Miva商人 - 替换特殊字符

html Miva商人 - 替换特殊字符