html 使用客户的实际Miva定价更新SearchSpring结果

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 使用客户的实际Miva定价更新SearchSpring结果相关的知识,希望对你有一定的参考价值。

/*
 	Update SearchSpring Results with the Customer's actual Miva-Pricing

	1.) When the SearchSpring's afterResultsChange fires
	2.) Get all of the product codes that SearchSpring Loaded
	3.) Send those product codes to a Miva page
	4.) On the Miva page, calculate their Runtime/Sale-Pricing
	5.) Return the sale pricing as JSON
	6.) Update the price of each product in the SearchSpring Results
*/
 
var update_searchspring_prices = function(){
	var product_codes = $('.category-product').map(function(){
		return $(this).attr('data-product-code');
	}).toArray();

	$.ajax({
		url: '/searchspring-prices.html',
		type: 'GET',
		dataType: 'json',
		data: {
			Product_Codes: product_codes
		}
	})
	.done(function(products) {
		products.forEach(function(product){
			var $product = $('.category-product[data-product-code="' + product.code + '"]');

			$product.find('.category-product-price').text(product.formatted_price);
		});
	});
};

SearchSpring.Catalog.init({
	// other store-specific options go here...
	afterResultsChange: function(){
		update_searchspring_prices();
	}
});
<mvt:comment>
	<!--
	g.Product_Codes is a comma separated list of product codes being sent as a query-string parameter
	-->
</mvt:comment>
<mvt:assign name="l.settings:product_codes" value="miva_array_deserialize(g.Product_Codes)" />

<mvt:foreach iterator="code" array="product_codes">
	<mvt:do name="l.result" file="g.Module_Library_DB" value="Product_Load_Code( l.settings:code, l.settings:product )" />
	<mvt:do file="g.Module_Feature_TUI_UT" name="l.result" value="CommonComponentFields_Initialize_Product_Runtime( l.settings:product )" />
	<mvt:assign name="l.index" value="miva_array_insert( l.settings:products, l.settings:product, -1 )" />
</mvt:foreach>

<mvt:do file="g.Module_Feature_TUI_UT" name="l.result"  value="CommonComponentFields_Initialize_Product_Discounts_Runtime(l.settings:products, miva_array_elements(l.settings:products) )" />

<mvt:assign name="l.result" value="miva_output_header( 'Content-Type', 'application/json' )" />
<mvt:do file="g.Module_JSON" name="l.success" value="JSON_Output( l.settings:products )" />

以上是关于html 使用客户的实际Miva定价更新SearchSpring结果的主要内容,如果未能解决你的问题,请参考以下文章

xml Miva - 产品批量定价供应XML

html Miva - 禁用客户端维度刷新

html Miva - 强制客户登录

html Miva客户注册负载

html Miva - 批量报告 - 获取客户登录

html 在Checkout中保存Miva客户字段